@descope/outbound-applications-widget 0.5.12 → 0.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +2 -2
- package/dist/index.d.ts +72 -71
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* @descope/outbound-applications-widget v0.5.
|
|
3
|
+
* @descope/outbound-applications-widget v0.5.14
|
|
4
4
|
*/
|
|
5
|
-
this["descope-outbound-applications-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.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={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),(e=>"string"==typeof e?e:(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},l=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 o=e(n);return o[t]=!0,o}};var c,d,u,h;function p(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!p(r,s))return!1}else if(r!==s)return!1}return!0}let f=class{constructor(e={},{forceUpdate:t=!1}={}){c.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,c,"f")):e,n=Object.assign(Object.assign({},o(this,c,"f")),t);if(o(this,h,"f")||!p(o(this,c,"f"),n)){const e=o(this,c,"f");i(this,c,n,"f"),Object.freeze(o(this,c,"f")),setTimeout((()=>{Object.values(o(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,c,e,"f"),i(this,h,t,"f")}get current(){return Object.assign({},o(this,c,"f"))}subscribe(e){return i(this,u,o(this,u,"f")+1,"f"),o(this,d,"f")[o(this,u,"f")]=e,o(this,u,"f").toString()}unsubscribe(e){const t=!!o(this,d,"f")[e];return t&&delete o(this,d,"f")[e],t}unsubscribeAll(){return i(this,d,{},"f"),!0}};function g(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:""}}c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap;const v=["error","warn","info","debug"],m={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},b=l((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,m))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e||m),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return v.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),w="undefined"!=typeof localStorage,y="https://static.descope.com/pages",k="https://static2.descope.com/pages",S=w&&localStorage.getItem("base.content.url")||"",I=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,C=l((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)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),O=l((e=>{var t,n;const i=r(b,C)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const i=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(i,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})),A=e=>t=>{var n,i,s;const a=r(b,C,O)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,o(this,n,"m",i).bind(this))}async init(){var e;l.forEach((e=>o(this,n,"m",i).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,i=function(t,n){const o=e[t],i="function"==typeof o?o(t,n):o;i&&this.logger.error(i)},s};A.missingAttrValidator=I;const x=l((e=>{const t=r(A({"project-id":I}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),j=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),E="Trying the next fallback URL...",R=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(o){return null==n||n.debug(`Network error fetching URL ${e} [${o.message}], retrying...`),fetch(e,t)}};const T=l((e=>{var t,n,s,a,l,c,d;const u=r(b,x,j)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const r=o(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];i(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;o(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o}={})=>{const i=Array.isArray(e)?e:[e];for(let e=0;e<i.length;e++){const r=i[e],s=e===i.length-1;try{const i=await R(r.toString(),t,{logger:n});if(i.ok)return null==o||o(e),null==n||n.debug(`Successfully fetched URL ${r}`),i;const a=`Error fetching URL ${r} [${i.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${E}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${E}`)}}})(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=S||this.baseStaticUrl;if(r)return o(this,t,"m",c).call(this,e,r);o(this,n,"f")!==this.baseUrl&&(i(this,n,this.baseUrl,"f"),i(this,s,void 0,"f"),o(this,a,"f").clear());const l=[];if(o(this,s,"f"))l.push(o(this,t,"m",c).call(this,e,o(this,s,"f"))),o(this,s,"f")===y&&l.push(o(this,t,"m",c).call(this,e,k));else{const n=this.baseUrl+"/pages";this.baseUrl&&!o(this,a,"f").has(n)&&l.push(o(this,t,"m",c).call(this,e,n)),o(this,a,"f").has(y)||l.push(o(this,t,"m",c).call(this,e,y)),l.push(o(this,t,"m",c).call(this,e,k))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o=y}){const i=new URL(o);return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.baseUrl=o,i}({projectId:this.projectId,filename:e,baseUrl:t})},d})),$=l((e=>{var t,n;const i=r(A({"project-id":I}))(e);return n=class extends i{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return o(this,t,"f").set(e,n),()=>{o(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(o(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=o(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),_=l((e=>{var t,n,s,a,l;const c=r(T,$,C)(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",o(this,t,"m",n).bind(this))}get config(){return o(this,s,"f")||i(this,s,o(this,a,"f").call(this),"f"),o(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){i(this,s,void 0,"f")},l})),U=l((e=>{var t,n,s,a,l,c,d;return d=class extends(r(C,b)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),"debug"===e&&o(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&o(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)),o(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),i(this,n,null,"f")},a=async function(){i(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return ma})),document.body.appendChild(o(this,n,"f"))},l=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},c=function(e,t){var i;e&&(null===(i=o(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},d})),P=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],L=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()}`},M=(e,t,n)=>new Promise(((o,i)=>{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"),i(e)},r.onload=()=>{r.setAttribute("status","loaded"),o(r)},r.src=t.toString(),document.body.appendChild(r)})),W=(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)}))}))},N=l((e=>{const t=r(b)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",o=[],i){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${i?" with SRI integrity check":""}`),(async(e,t)=>{for(const o of e){const{id:e,url:i,integrity:r}=o,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await W(s,r),o}catch(e){t(o,!0)}else try{return await M(e,i,r),o}catch(e){t(o,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,o="",i)=>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}/${o}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${L(a)}`};return i&&(l.integrity=i),[...e,l]}),[]))([...o,this.baseCdnUrl,...P],e,t,n,i),((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}"`)}))}}})),D="base.ui.components.url",F=w&&localStorage.getItem(D),q=l((e=>{var t,n,s,a,l,c,d;const u=r(b,_,N)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return o(this,a,"f")||i(this,a,o(this,t,"m",c).call(this),"f"),o(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=>o(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 o(this,t,"m",n).call(this),i=F?void 0:await o(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[F],i),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),z=l((e=>{var t,n,i;const s=r(C,O)(e);return i=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",o(this,t,"m",n).bind(this)),o(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},i}));class V{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const H=l((e=>{const t=r(z)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new V(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const o=[...e.adoptedStyleSheets||[]];o[t?"unshift":"push"](n),e.adoptedStyleSheets=o}}return n}}})),K="content-root",J="root",B=l((e=>{const t=r(H)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${J}">\n <div id="${K}"></div>\n </div>\n `,this.injectStyle(`\n #${J}, #${K} {\n height: 100%;\n }\n #${J} {\n position: relative;\n height: fit-content;\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(J)}}})),G="descope-modal";var X;let Y=class{constructor(e,t){X.set(this,void 0),this.nodeName="",i(this,X,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,X,"f"))}get ele(){var e,t;const n="function"==typeof o(this,X,"f")?o(this,X,"f").call(this):o(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 Z=class extends Y{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}set theme(e){var t,n;e?null===(n=this.ele)||void 0===n||n.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}};var Q,ee,te,ne;let oe=class extends Y{constructor(...e){super(...e),Q.add(this),ee.set(this,void 0),te.set(this,void 0),this.nodeName="descope-modal",o(this,Q,"m",ne).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)),o(this,Q,"m",ne).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,ee,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,ee,"f").content.cloneNode(!0)))}setContent(e){i(this,ee,e,"f"),this.reset()}remove(){var e,t;null===(e=o(this,te,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};ee=new WeakMap,te=new WeakMap,Q=new WeakSet,ne=function(){if(o(this,te,"f"))return;const e=this.ele;e&&(i(this,te,new MutationObserver((t=>{t.forEach(((n,o)=>{var i;const r="true"===n.oldValue,s=t[o+1]?t[o+1].oldValue:e.getAttribute("opened");r&&"true"!==s&&(null===(i=this.afterClose)||void 0===i||i.call(this))}))})),"f"),o(this,te,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};let ie=class extends Y{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}},re=class extends Y{constructor(){super(...arguments),this.nodeName="descope-outbound-apps"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}get connectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("connect-flow-id"))||""}get disconnectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("disconnect-flow-id"))||""}onConnectClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("connect-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("connect-clicked",n)}}onDisconnectClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("disconnect-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("disconnect-clicked",n)}}};const se=l((e=>{var t,n;const i=r(C,B,q)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends oe{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(G);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([G]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),ae="descope-notification";l((e=>{var t,n;const i=r(C,B,q)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ie{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ae);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(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([ae])}},t=new WeakMap,n}));const le="theme",ce=(e,t,n="")=>Object.entries(e).reduce(((e,[o,i])=>{if(!/^[a-zA-Z0-9-]+$/.test(o))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${o}`:o;if("object"==typeof i&&null!==i)return e+ce(i,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(i);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),"");function de(e,t){const n=Object.assign({},e);for(const[e,o]of Object.entries(t||{}))if(null!=o)if("object"==typeof o){if(0===Object.keys(o).length)continue;n[e]=de(n[e]||{},o)}else n[e]="string"==typeof o?(n[e]||"")+o:o;return n}const ue=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",he=l((e=>{const t=r(A({tenant:ue}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),pe=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',fe=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,b,w,y,k,S,I,x,j;const E=r(A({theme:pe}),he,T,C,q,_,B,O,H)(e);return j=class extends E{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,(()=>{o(this,t,"m",I).call(this),o(this,x,"f").call(this,"os"===this.getAttribute("theme"))})),x.set(this,(e=>{var n,i,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[s])||void 0===r||r.call(i,"change",(()=>o(this,t,"m",I).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||le}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)),o(this,S,"f").call(this),await Promise.all([o(this,t,"m",p).call(this),o(this,t,"m",v).call(this),o(this,t,"m",b).call(this)]),o(this,t,"m",m).call(this),this.observeAttributes(["theme"],o(this,S,"f")),this.observeAttributes(["theme-override"],(()=>o(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{i(this,d,null,"f"),o(this,t,"m",v).call(this),o(this,t,"m",b).call(this)})),this.observeAttributes(["style-id"],(()=>{i(this,c,null,"f"),o(this,t,"m",y).call(this),o(this,t,"m",p).call(this),o(this,t,"m",b).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,S=new WeakMap,x=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,o,i,r,s,a;const l=null===(i=null===(o=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===o?void 0:o.colors)||void 0===i?void 0:i.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}"]{${ce({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(D))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(D),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 o(this,c,"f")||(i(this,c,o(this,t,"m",u).call(this),"f"),o(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,c,"f")},p=async function(){var e,r;const s=await o(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)||"");o(this,n,"f")?o(this,n,"f").replaceSync(a):i(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 o(this,d,"f")||i(this,d,o(this,t,"m",f).call(this),"f"),o(this,d,"f")},v=async function(){var e,n,r,a;if(!this.tenantId)return void(null===(e=o(this,s,"f"))||void 0===e||e.replaceSync(""));const l=await o(this,t,"a",g);if(!l)return void(null===(n=o(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)||"");o(this,s,"f")?o(this,s,"f").replaceSync(c):i(this,s,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=o(this,a,"f"))||void 0===e||e.replaceSync(""));const n=o(this,t,"m",l).call(this);o(this,a,"f")?o(this,a,"f").replaceSync(n):i(this,a,this.injectStyle(n),"f")},b=async function(){var e,n,i,r;const s=await o(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await o(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===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.components)||{},(null===(r=null==l?void 0:l.dark)||void 0===r?void 0:r.components)||{})}},w=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},y=async function(){const e=await o(this,t,"m",w).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},k=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},I=function(){o(this,t,"m",y).call(this),o(this,t,"m",k).call(this)},j}));var ge=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),ve=()=>Math.random().toString(36).substring(7).split("").join("."),me={INIT:`@@redux/INIT${ve()}`,REPLACE:`@@redux/REPLACE${ve()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ve()}`};function be(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 we(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 ye(e){let t=typeof e;return t=we(e),t}function ke(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${ye(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: '${ye(n)}'`);return n(ke)(e,t)}let o=e,i=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 i}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${ye(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(!be(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${ye(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: '${ye(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,i=o(i,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:me.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: '${ye(e)}`);o=e,h({type:me.REPLACE})},[ge]: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: '${ye(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[ge](){return this}}}}}function Se(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Ie(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const i=t[o];void 0===e[i]&&Se(`No reducer provided for key "${i}"`),"function"==typeof e[i]&&(n[i]=e[i])}const o=Object.keys(n);let i,r;i={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:me.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:me.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 '${me.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 o=function(e,t,n,o){const i=Object.keys(t),r=n&&n.type===me.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===i.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!be(e))return`The ${r} has unexpected type of "${ye(e)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===me.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: "${i.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,i);o&&Se(o)}let s=!1;const a={};for(let i=0;i<o.length;i++){const r=o[i],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||o.length!==Object.keys(e).length,s?a:e}}function Ce(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Oe(e){return be(e)&&"type"in e&&"string"==typeof e.type}var Ae=Symbol.for("immer-nothing"),xe=Symbol.for("immer-draftable"),je=Symbol.for("immer-state"),Ee=[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 Re(e,...t){{const n=Ee[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var Te=Object.getPrototypeOf;function $e(e){return!!e&&!!e[je]}function _e(e){return!!e&&(Pe(e)||Array.isArray(e)||!!e[xe]||!!e.constructor?.[xe]||De(e)||Fe(e))}var Ue=Object.prototype.constructor.toString();function Pe(e){if(!e||"object"!=typeof e)return!1;const t=Te(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)===Ue}function Le(e,t){0===Me(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Me(e){const t=e[je];return t?t.type_:Array.isArray(e)?1:De(e)?2:Fe(e)?3:0}function We(e,t){return 2===Me(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ne(e,t,n){const o=Me(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function De(e){return e instanceof Map}function Fe(e){return e instanceof Set}function qe(e){return e.copy_||e.base_}function ze(e,t){if(De(e))return new Map(e);if(Fe(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Pe(e)){if(!Te(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[je];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const i=o[t],r=n[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[i]})}return Object.create(Te(e),n)}function Ve(e,t=!1){return Ke(e)||$e(e)||!_e(e)||(Me(e)>1&&(e.set=e.add=e.clear=e.delete=He),Object.freeze(e),t&&Le(e,((e,t)=>Ve(t,!0)))),e}function He(){Re(2)}function Ke(e){return Object.isFrozen(e)}var Je,Be={};function Ge(e){const t=Be[e];return t||Re(0,e),t}function Xe(){return Je}function Ye(e,t){t&&(Ge("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ze(e){Qe(e),e.drafts_.forEach(tt),e.drafts_=null}function Qe(e){e===Je&&(Je=e.parent_)}function et(e){return Je={drafts_:[],parent_:Je,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function tt(e){const t=e[je];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function nt(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[je].modified_&&(Ze(t),Re(4)),_e(e)&&(e=ot(t,e),t.parent_||rt(t,e)),t.patches_&&Ge("Patches").generateReplacementPatches_(n[je].base_,e,t.patches_,t.inversePatches_)):e=ot(t,n,[]),Ze(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ae?e:void 0}function ot(e,t,n){if(Ke(t))return t;const o=t[je];if(!o)return Le(t,((i,r)=>it(e,o,t,i,r,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return rt(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let i=t,r=!1;3===o.type_&&(i=new Set(t),t.clear(),r=!0),Le(i,((i,s)=>it(e,o,t,i,s,n,r))),rt(e,t,!1),n&&e.patches_&&Ge("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function it(e,t,n,o,i,r,s){if(i===n&&Re(5),$e(i)){const s=ot(e,i,r&&t&&3!==t.type_&&!We(t.assigned_,o)?r.concat(o):void 0);if(Ne(n,o,s),!$e(s))return;e.canAutoFreeze_=!1}else s&&n.add(i);if(_e(i)&&!Ke(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ot(e,i),t&&t.scope_.parent_||rt(e,i)}}function rt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ve(t,n)}var st={get(e,t){if(t===je)return e;const n=qe(e);if(!We(n,t))return function(e,t,n){const o=ct(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!_e(o)?o:o===lt(e.base_,t)?(ut(e),e.copy_[t]=ht(o,e)):o},has:(e,t)=>t in qe(e),ownKeys:e=>Reflect.ownKeys(qe(e)),set(e,t,n){const o=ct(qe(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=lt(qe(e),t),i=o?.[je];if(i&&i.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,o)&&(void 0!==n||We(e.base_,t)))return!0;ut(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!==lt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,ut(e),dt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=qe(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Re(11)},getPrototypeOf:e=>Te(e.base_),setPrototypeOf(){Re(12)}},at={};function lt(e,t){const n=e[je];return(n?qe(n):e)[t]}function ct(e,t){if(!(t in e))return;let n=Te(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Te(n)}}function dt(e){e.modified_||(e.modified_=!0,e.parent_&&dt(e.parent_))}function ut(e){e.copy_||(e.copy_=ze(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Le(st,((e,t)=>{at[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),at.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Re(13),at.set.call(this,e,t,void 0)},at.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Re(14),st.set.call(this,e[0],t,n,e[0])};function ht(e,t){const n=De(e)?Ge("MapSet").proxyMap_(e,t):Fe(e)?Ge("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Xe(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=o,r=st;n&&(i=[o],r=at);const{revoke:s,proxy:a}=Proxy.revocable(i,r);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:Xe()).drafts_.push(n),n}function pt(e){return $e(e)||Re(10,e),ft(e)}function ft(e){if(!_e(e)||Ke(e))return e;const t=e[je];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=ze(e,t.scope_.immer_.useStrictShallowCopy_)}else n=ze(e,!0);return Le(n,((e,t)=>{Ne(n,e,ft(t))})),t&&(t.finalized_=!1),n}var gt=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 o=this;return function(e=n,...i){return o.produce(e,(e=>t.call(this,e,...i)))}}let o;if("function"!=typeof t&&Re(6),void 0!==n&&"function"!=typeof n&&Re(7),_e(e)){const i=et(this),r=ht(e,void 0);let s=!0;try{o=t(r),s=!1}finally{s?Ze(i):Qe(i)}return Ye(i,n),nt(o,i)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===Ae&&(o=void 0),this.autoFreeze_&&Ve(o,!0),n){const t=[],i=[];Ge("Patches").generateReplacementPatches_(e,o,t,i),n(t,i)}return o}Re(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const i=this.produce(e,t,((e,t)=>{n=e,o=t}));return[i,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){_e(e)||Re(8),$e(e)&&(e=pt(e));const t=et(this),n=ht(e,void 0);return n[je].isManual_=!0,Qe(t),n}finishDraft(e,t){const n=e&&e[je];n&&n.isManual_||Re(9);const{scope_:o}=n;return Ye(o,t),nt(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Ge("Patches").applyPatches_;return $e(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},vt=gt.produce;gt.produceWithPatches.bind(gt),gt.setAutoFreeze.bind(gt),gt.setUseStrictShallowCopy.bind(gt),gt.applyPatches.bind(gt),gt.createDraft.bind(gt),gt.finishDraft.bind(gt);var mt=(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})}}},bt=(e,t,n)=>{const{memoize:o,memoizeOptions:i}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...i);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})}},wt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var yt=e=>Array.isArray(e)?e:[e];function kt(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 St(e,t){const n=[],{length:o}=e;for(let i=0;i<o;i++)n.push(e[i].apply(null,t));return n}var It="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Ct=0,Ot=1;function At(){return{s:Ct,v:void 0,o:null,p:null}}function xt(e,t={}){let n=At();const{resultEqualityCheck:o}=t;let i,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 o=e.get(n);void 0===o?(t=At(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=At(),e.set(n,t)):t=o}}const a=t;let l;if(t.s===Ot)l=t.v;else if(l=e.apply(null,arguments),r++,o){const e=i?.deref?.()??i;null!=e&&o(e,l)&&(l=e,0!==r&&r--);i="object"==typeof l&&null!==l||"function"==typeof l?new It(l):l}return a.s=Ot,a.v=l,l}return s.clearCache=()=>{n=At(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function jt(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,i=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=xt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=yt(c),f=yt(u),g=kt(e),v=l((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const b=d((function(){i++;const e=St(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...wt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:mt},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:bt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=St(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(b,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:l,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Et=jt(xt),Rt=Object.assign(((e,t=Et)=>{!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),o=t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,o)=>(e[n[o]]=t,e)),{})));return o}),{withTypes:()=>Rt});function Tt(e){return({dispatch:t,getState:n})=>o=>i=>"function"==typeof i?i(t,n,e):o(i)}var $t=Tt(),_t=Tt;((...e)=>{const t=jt(...e)})(xt);var Ut="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Ce:Ce.apply(null,arguments)},Pt=e=>e&&"function"==typeof e.match;function Lt(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Oe(t)&&t.type===e,n}function Mt(e){return"function"==typeof e&&"type"in e&&Pt(e)}function Wt(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 Nt=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 Dt(e){return _e(e)?vt(e,(()=>{})):e}function Ft(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function qt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function zt(e,t,n){const o=Vt(e,t,n);return{detectMutations:()=>Ht(e,t,o,n)}}function Vt(e,t=[],n,o="",i=new Set){const r={value:n};if(!e(n)&&!i.has(n)){i.add(n),r.children={};for(const i in n){const s=o?o+"."+i:i;t.length&&-1!==t.indexOf(s)||(r.children[i]=Vt(e,t,n[i],s))}}return r}function Ht(e,t=[],n,o,i=!1,r=""){const s=n?n.value:void 0,a=s===o;if(i&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:r};if(e(s)||e(o))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in o)l[e]=!0;const c=t.length>0;for(let i in l){const s=r?r+"."+i:i;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Ht(e,t,n.children[i],o[i],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Kt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||be(e)}function Jt(e,t="",n=Kt,o,i=[],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!=o?o(e):Object.entries(e),l=i.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(i.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=Jt(c,a,n,o,i,r),s))return s}return r&&Bt(e)&&r.add(e),!1}function Bt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Bt(t))return!1;return!0}function Gt(e){return"boolean"==typeof e}var Xt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=e??{};let r=new Nt;if(t&&(Gt(t)?r.push($t):r.push(_t(t.extraArgument))),n){let e={};Gt(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,o,i){return JSON.stringify(e,n(t,i),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(i,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,i):o.push(i),~n.indexOf(r)&&(r=t.call(this,i,r))}else n.push(r);return null==e?r:e.call(this,i,r)}},{isImmutable:o=qt,ignoredPaths:i,warnAfter:r=32}=e;const s=zt.bind(null,o,i);return({getState:e})=>{let n,o=e(),i=s(o);return a=>l=>{const c=Wt(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),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(o=e(),n=i.detectMutations(),i=s(o),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(o){let e={};Gt(o)||(e=o),r.push(function(e={}){{const{isSerializable:t=Kt,getEntries:n,ignoredActions:o=[],ignoredActionPaths:i=["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(!Oe(u))return c(u);const h=c(u),p=Wt(s,"SerializableStateInvariantMiddleware");return l||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=Jt(u,"",t,n,i,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 o=Jt(e.getState(),"",t,n,r,d);if(o){const{keyPath:e,value:t}=o;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(i){let e={};Gt(i)||(e=i),r.unshift(function(e={}){const{isActionCreator:t=Mt}=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},Yt=e=>t=>{setTimeout(t,e)},Zt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Yt(10),Qt=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new Nt(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let i=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?Zt:"callback"===e.type?e.queueNotification:Yt(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>i&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return i=!e?.meta?.RTK_autoBatch,r=!i,r&&(s||(s=!0,l(c))),o.dispatch(e)}finally{i=!0}}})})("object"==typeof n?n:void 0)),o};function en(e){const t=Xt(),{reducer:n,middleware:o,devTools:i=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!be(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=Ie(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(l=o(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=Ce;i&&(c=Ut({trace:!0,..."object"==typeof i&&i}));const d=function(...e){return t=>(n,o)=>{const i=t(n,o);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:i.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=Ce(...a)(i.dispatch),{...i,dispatch:r}}}(...l),u=Qt(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 ke(a,r,c(...h))}function tn(e){const t={},n=[];let o;const i={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)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,i},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,i}};return e(i),[t,n,o]}function nn(...e){return t=>e.some((e=>((e,t)=>Pt(e)?e.match(t):e(t))(e,t)))}var on=["name","message","stack","code"],rn=class{constructor(e,t){this.payload=e,this.meta=t}_type},sn=class{constructor(e,t){this.payload=e,this.meta=t}_type},an=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of on)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},ln=(()=>{function e(e,t,n){const o=Lt(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=Lt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Lt(e+"/rejected",((e,t,o,i,r)=>({payload:i,error:(n&&n.serializeError||an)(e||"Rejected"),meta:{...r||{},arg:o,requestId:t,rejectedWithValue:!!i,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(i(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 rn(e,t),fulfillWithValue:(e,t)=>new sn(e,t)})).then((t=>{if(t instanceof rn)throw t;return t instanceof sn?o(t.payload,c,e,t.meta):o(t,c,e)}))])}catch(t){p=t instanceof rn?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(cn)})}}),{pending:i,rejected:r,fulfilled:o,settled:nn(r,o),typePrefix:e})}return e.withTypes=()=>e,e})();function cn(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 un(e,t){return`${e}/${t}`}function hn(e,t,n,o){function i(i,...r){let s=n.call(e,i);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return i.unwrapped=t,i}var pn=function({creators:e}={}){const t=e?.asyncThunk?.[dn];return function(e){const{name:n,reducerPath:o=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 i=("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(i),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=[],o]="function"==typeof e.extraReducers?tn(e.extraReducers):[e.extraReducers],i={...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,[o,i,r]=tn(t);if(function(e){return"function"==typeof e}(e))n=()=>Dt(e());else{const t=Dt(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...i.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($e(e)){const o=n(e,t);return void 0===o?e:o}if(_e(e))return vt(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in i)e.addCase(t,i[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}r.forEach((o=>{const r=i[o],s={reducerName:o,type:un(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},o,i){let r,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=o.reducer,s=o.prepare}else r=o;i.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Lt(e,s):Lt(e))}(s,r,a):function({type:e,reducerName:t},n,o,i){if(!i)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=i(e,r,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);l&&o.addCase(u.rejected,l);c&&o.addMatcher(u.settled,c);o.exposeCaseReducer(t,{fulfilled:s||fn,pending:a||fn,rejected:l||fn,settled:c||fn})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,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=Ft(d,this,{insert:()=>new WeakMap});return Ft(n,t,{insert:()=>{const n={};for(const[o,i]of Object.entries(e.selectors??{}))n[o]=hn(this,i,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 o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function fn(){}var gn="listenerMiddleware";Lt(`${gn}/add`),Lt(`${gn}/removeAll`),Lt(`${gn}/remove`);const vn=e=>l((t=>{const n=pn(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(b)(t)){constructor(...e){super(...e);const t=en({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),i=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{cn(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},r=Object.keys(o).reduce(((e,t)=>(e[t]=i(o[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(b(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}}));const mn=l((e=>{const t=r(A({"widget-id":I}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),bn=l((e=>{const t=r(_,mn)(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]}}})),wn=l((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=g(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:""}})),yn=e=>l((t=>{var n,i,s;const a=r(T,mn,bn,wn)(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 o(this,n,"m",i).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,i=async function(t){var n;const o=await this.getWidgetConfig(),i=this.firstAvailableLocale(null!==(n=null==o?void 0:o.targetLocales)&&void 0!==n?n:[]);if(!i)return;const r=".html",s=t.endsWith(r)?t.slice(0,-5):t;try{const t=await this.fetchStaticResource(`${e}/${this.widgetId}/${s}-${i}${r}`,"text");return null==t?void 0:t.body}catch(e){return}},s})),kn=l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),Sn=l((e=>{var n,i,r;return r=class extends(fe(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:l}=e,c=t(e,["flowId","client","form"]);return a(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:o(this,n,"m",i).call(this,l),client:Object.assign(Object.assign({},this.clientInput),s)},c))}},n=new WeakSet,i=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},r}));function In(e){return new URLSearchParams(window.location.search).get(e)}const Cn=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)}))}))},On=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}}),An=ln("outboundApps/load",((e,{extra:{api:t}})=>t.outboundApps.getAllOutboundApps())),xn=Cn(An)({onFulfilled:(e,t)=>{var n;e.outboundAppsList.data=null===(n=t.payload)||void 0===n?void 0:n.apps}},On((e=>e.outboundAppsList))),jn={action:An,reducer:xn},En=ln("outboundApps/getConnectedOutboundApps",((e,{extra:{api:t}})=>t.outboundApps.getConnectedOutboundApps(e))),Rn=Cn(En)({onFulfilled:(e,t)=>{var n;e.connectedOutboundAppsIds.data=null===(n=t.payload)||void 0===n?void 0:n.appIds}},On((e=>e.connectedOutboundAppsIds))),Tn={action:En,reducer:Rn},$n={outboundAppsList:{data:[],loading:!1,error:null},connectedOutboundAppsIds:{data:[],loading:!1,error:null},allowedAppsIds:{data:void 0},me:{loading:!1,error:null,data:{}}};class _n extends Error{}function Un(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 Pn(e,t){if("string"!=typeof e)throw new _n("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,o=e.split(".")[n];if("string"!=typeof o)throw new _n(`Invalid token specified: missing part #${n+1}`);let i;try{i=Un(o)}catch(e){throw new _n(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new _n(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}_n.prototype.name="InvalidTokenError";var Ln={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},sso:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const Mn="<region>",Wn=`https://api.${Mn}descope.com`,Nn=6e5,Dn="dct",Fn=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},qn=[503,520,521,522,524,530],zn=[100,5e3,5e3],Vn=e=>new Promise((t=>setTimeout(t,e))),Hn=e=>async function(...t){let n=await e(...t),o=0;for(;qn.includes(n.status)&&o<zn.length;)await Vn(zn[o]),n=await e(...t),o++;o>0&&(n.retries=o);const i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n};let Kn;const Jn=()=>{if(Kn)return Kn;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 Kn=`${t}-${n}`,Kn};var Bn;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(Bn||(Bn={}));const Gn=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(Mn,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{r=`${r}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return r},Xn=(...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)),{})),Yn={"Content-Type":"application/json"},Zn=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Qn=(e,t)=>{const n={"x-descope-sdk-session-id":Jn(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.67.1","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},eo=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var to=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||Wn,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=>Fn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await Hn(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return Fn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:Hn(n)})(i,a),d=async e=>{var i;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:Xn(Zn(t,g),Qn(t,o),(null==n?void 0:n.baseHeaders)||{},eo(v)?Yn:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const b=await c(Gn({path:d,baseUrl:l,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==b?void 0:b.clone()),null==r?void 0:r.transformResponse){const e=await b.json(),t=(w=(null===(i=b.headers)||void 0===i?void 0:i.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function o(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function i(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;o();)if(","===e.charAt(n)){for(s=n,n+=1,o(),a=n;n<e.length&&i();)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}(w).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.assign({},b),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}var w;return b};return{get:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Bn.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Bn.post,token:i}),patch:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Bn.patch,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Bn.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Bn.delete,token:o}),hooks:r,buildUrl:(e,n)=>Gn({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.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}}))},no=429;function oo(e,t,n){var o;let i=io(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[Dn])===t)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function io(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Pn(e)}function ro(e){const{exp:t}=io(e);return(new Date).getTime()/1e3>t}function so(e){let t=io(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function ao(e,t){return oo(e,t,"permissions")}function lo(e,t){return oo(e,t,"roles")}const co=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function uo(e,t){var n;const o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=r:(i.error=r,o.status===no&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}function ho(e){var t;return(null===(t=io(e))||void 0===t?void 0:t[Dn])||""}const po=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),fo=(e,t)=>(n=t)=>t=>{const o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.join(" OR "))},go=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),vo=e=>t=>e.test(t),mo=vo(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),bo=vo(/^\+[1-9]{1}[0-9]{3,14}$/),wo=po(mo,'"{val}" is not a valid email'),yo=po(bo,'"{val}" is not a valid phone number'),ko=po((e=>e.length>=1),"Minimum length is 1");const So=po((e=>"string"==typeof e),"Input is not a string"),Io=po((e=>Array.isArray(e)),"Input is not an array"),Co=po((e=>"boolean"==typeof e),"Input is not a boolean"),Oo=po((e=>void 0===e),"Input is defined"),Ao=fo([So(),Oo()],"Input is not a string or undefined"),xo=fo([Io(),Co()],"Input is not an array or boolean"),jo=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>go(...e).validate(n[t]))),t(...n)),Eo=e=>[So(`"${e}" must be a string`)],Ro=e=>[Ao(`"${e}" must be string or undefined`)],To=e=>[So(`"${e}" must be a string`),ko(`"${e}" must not be empty`)],$o=e=>[So(`"${e}" must be a string`),wo()],_o=e=>[So(`"${e}" must be a string`),yo()],Uo=jo(To("accessKey")),Po=e=>({exchange:Uo(((t,n)=>uo(e.post(Ln.accessKey.exchange,{loginOptions:n},{token:t}))))}),Lo=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e),Mo=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Nn,Nn)});var Wo,No;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Wo||(Wo={})),function(e){e.email="email"}(No||(No={}));const Do=Object.assign(Object.assign({},Wo),No);var Fo;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Fo||(Fo={}));const qo=To("loginId"),zo=jo(To("token")),Vo=jo(qo),Ho=jo(To("pendingRef")),Ko=jo(qo,$o("email")),Jo=e=>({verify:zo((t=>uo(e.post(Ln.enchantedLink.verify,{token:t})))),signIn:Vo(((n,o,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return uo(e.post(co(Ln.enchantedLink.signIn,Do.email),{loginId:n,URI:o,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:Vo(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return uo(e.post(co(Ln.enchantedLink.signUpOrIn,Do.email),{loginId:n,URI:o,loginOptions:s,providerId:r}))})),signUp:Vo(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return uo(e.post(co(Ln.enchantedLink.signUp,Do.email),{loginId:n,URI:o,user:i,loginOptions:a,providerId:s}))})),waitForSession:Ho(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Mo(n);let s;const a=setInterval((async()=>{const n=await e.post(Ln.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(uo(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Ko(((t,n,o,i,r)=>uo(e.post(Ln.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),Bo=jo(To("flowId")),Go=jo(To("executionId"),To("stepId"),To("interactionId")),Xo=e=>({start:Bo(((t,n,o,i,r,s,a,l=!1)=>uo(e.post(Ln.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:Go(((t,n,o,i,r,s,a=!1)=>uo(e.post(Ln.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s,isCustomScreen:a}))))}),Yo=To("loginId"),Zo=jo(To("token")),Qo=jo(Yo),ei=jo(Yo,_o("phone")),ti=jo(Yo,$o("email")),ni=Object.keys(Do).filter((e=>e!==Wo.voice&&e!==Wo.im)),oi=e=>({verify:Zo((t=>uo(e.post(Ln.magicLink.verify,{token:t})))),signIn:ni.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Qo(((n,i,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return uo(e.post(co(Ln.magicLink.signIn,o),{loginId:n,URI:i,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:ni.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Qo(((n,i,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return uo(e.post(co(Ln.magicLink.signUp,o),{loginId:n,URI:i,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:ni.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Qo(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return uo(e.post(co(Ln.magicLink.signUpOrIn,o),{loginId:n,URI:i,loginOptions:a,providerId:s}))}))})),{}),update:{email:ti(((t,n,o,i,r)=>uo(e.post(Ln.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(Wo).filter((e=>e!==Wo.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ei(((t,o,i,r,s)=>uo(e.post(co(Ln.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var ii;!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"}(ii||(ii={}));const ri=jo(To("code")),si=e=>({start:Object.assign(((t,n,o,i,r)=>uo(e.post(Ln.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:i}))),Object.keys(ii).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i,r)=>uo(e.post(Ln.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:i}))})),{})),exchange:ri((t=>uo(e.post(Ln.oauth.exchange,{code:t})))),startNative:(t,n,o)=>uo(e.post(Ln.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>uo(e.post(Ln.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>uo(e.get(Ln.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>uo(e.post(Ln.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>uo(e.post(Ln.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),ai=To("appId"),li=jo(ai),ci=e=>({connect:li(((t,n,o)=>{const i=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,uo(e.post(Ln.outbound.connect,{appId:t,tenantId:i,tenantLevel:r,options:n},{token:o}))}))}),di=To("loginId"),ui=jo(di,To("code")),hi=jo(di),pi=jo(di,_o("phone")),fi=jo(di,$o("email")),gi=e=>({verify:Object.keys(Do).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ui(((t,o)=>uo(e.post(co(Ln.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Do).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:hi(((n,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return uo(e.post(co(Ln.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Do).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:hi(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return uo(e.post(co(Ln.otp.signUp,o),{loginId:n,user:i,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Do).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:hi(((n,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return uo(e.post(co(Ln.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:fi(((t,n,o,i)=>uo(e.post(Ln.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(Wo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pi(((t,o,i,r)=>uo(e.post(co(Ln.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),vi=jo(To("tenant")),mi=jo(To("code")),bi=e=>({start:vi(((t,n,o,i,r,s,a,l)=>uo(e.post(Ln.sso.start,o||{},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})},i&&{token:i}))))),exchange:mi((t=>uo(e.post(Ln.sso.exchange,{code:t}))))}),wi=To("loginId"),yi=jo(wi,To("code")),ki=jo(wi),Si=jo(wi),Ii=e=>({signUp:ki(((t,n)=>uo(e.post(Ln.totp.signUp,{loginId:t,user:n})))),verify:yi(((t,n,o,i)=>uo(e.post(Ln.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),update:Si(((t,n)=>uo(e.post(Ln.totp.update,{loginId:t},{token:n}))))}),Ci=To("loginId"),Oi=To("newPassword"),Ai=jo(Ci,To("password")),xi=jo(Ci),ji=jo(Ci,Oi),Ei=jo(Ci,To("oldPassword"),Oi),Ri=e=>({signUp:Ai(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return uo(e.post(Ln.password.signUp,{loginId:n,password:o,user:i,loginOptions:a,providerId:s}))})),signIn:Ai(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return uo(e.post(Ln.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:r}))})),sendReset:xi(((t,n,o)=>uo(e.post(Ln.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:ji(((t,n,o)=>uo(e.post(Ln.password.update,{loginId:t,newPassword:n},{token:o})))),replace:Ei(((t,n,o)=>uo(e.post(Ln.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>uo(e.get(Ln.password.policy))}),Ti=Eo("loginId"),$i=To("loginId"),_i=Eo("origin"),Ui=jo($i,_i,To("name")),Pi=jo($i,_i),Li=jo(Ti,_i),Mi=jo($i,_i,Ro("token")),Wi=jo(To("transactionId"),To("response")),Ni=e=>({signUp:{start:Ui(((t,n,o,i,r)=>uo(e.post(Ln.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,loginOptions:r,passkeyOptions:i})))),finish:Wi(((t,n)=>uo(e.post(Ln.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Li(((t,n,o,i,r)=>uo(e.post(Ln.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:Wi(((t,n)=>uo(e.post(Ln.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Pi(((t,n,o,i)=>uo(e.post(Ln.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:o}))))},update:{start:Mi(((t,n,o,i,r)=>uo(e.post(Ln.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i,mfa:r},{token:o})))),finish:Wi(((t,n)=>uo(e.post(Ln.webauthn.update.finish,{transactionId:t,response:n}))))}}),Di=Eo("loginId"),Fi=jo(Di),qi=jo(To("pendingRef")),zi=e=>({signUpOrIn:Fi(((n,o={})=>{var{providerId:i}=o,r=t(o,["providerId"]);return uo(e.post(Ln.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:i}))})),signUp:Fi(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return uo(e.post(Ln.notp.signUp,{loginId:n,user:o,providerId:r,loginOptions:s}))})),signIn:Fi(((n,o={},i)=>{var{providerId:r}=o,s=t(o,["providerId"]);return uo(e.post(Ln.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:i}))})),waitForSession:qi(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Mo(n);let s;const a=setInterval((async()=>{const n=await e.post(Ln.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(uo(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Vi=jo(To("token")),Hi=jo(Ro("token"));var Ki,Ji=jo([(Ki=To("projectId"),po(((e,t)=>n=>go(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let i=0,r=e===Object(e)?e:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,e)))("projectId",Ki))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=to({baseUrl:o,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:i,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:Po(l),otp:gi(l),magicLink:oi(l),enchantedLink:Jo(l),oauth:si(l),outbound:ci(l),sso:bi(l),saml:bi(l),totp:Ii(l),notp:zi(l),webauthn:Ni(l),password:Ri(l),flow:Xo(l),refresh:Hi(((e,t,n,o)=>{const i={};n&&(i.externalToken=n);const r=o?Ln.tryRefresh:Ln.refresh;return uo(l.post(r,i,{token:e,queryParams:t}))})),selectTenant:jo([So("tenantId")],[Ao('"token" must be string or undefined')])(((e,t)=>uo(l.post(Ln.selectTenant,{tenant:e},{token:t})))),logout:Hi((e=>uo(l.post(Ln.logout,{},{token:e})))),logoutAll:Hi((e=>uo(l.post(Ln.logoutAll,{},{token:e})))),me:Hi((e=>uo(l.get(Ln.me,{token:e})))),myTenants:jo([xo('"tenants" must a string array or a boolean')],[Ao('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,uo(l.post(Ln.myTenants,n,{token:t}))})),history:Hi((e=>uo(l.get(Ln.history,{token:e})))),isJwtExpired:Vi(ro),getTenants:Vi(so),getJwtPermissions:Vi(ao),getJwtRoles:Vi(lo),getCurrentTenant:Vi(ho),httpClient:l};var l})),Bi=Object.assign(Ji,{DeliveryMethods:Do});
|
|
6
|
-
/*! js-cookie v3.0.8 | MIT */function Gi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)"__proto__"!==o&&(e[o]=n[o])}return e}var Xi=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=Gi({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in o||(o[a]=t.read(s,a)),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",Gi({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Gi({},this.attributes,t))},withConverter:function(t){return e(Gi({},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 Yi={default:"endpoint"},Zi="Blocked by CSP",Qi="The endpoint parameter is not a valid URL",er="Failed to load the JS script of the agent",tr="9319";function nr(e,t){var n,o,i,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||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,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Zi||s===Qi)n.exclude(),r=0;else if(s===tr)n.exclude();else if(s===er){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!i.has(l)&&(i.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+o()-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,o=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,i=t[0],r=t[1];return(o=r,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(i)}))}))};return u(c).then((function(e){return[e,a]}))}var or="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",ir=or;function rr(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:or,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(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 nr(e,sr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===tr?new Error(er):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function sr(e){return function(e,t,n){var o,i=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),i=t.blockedURI;i!==n.href&&i!==n.protocol.slice(0,-1)&&i!==n.origin||(o=t,a())};i.addEventListener(r,s);var a=function(){return i.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(),o)return n(o);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(Qi);var o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(er))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(Zi)})).then(ar)}function ar(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(tr);return n}const lr="3.2.0",cr="undefined"!=typeof window,dr=Math.pow(2,31)-1,ur=`https://descopecdn.com/npm/oidc-client-ts@${lr}/dist/browser/oidc-client-ts.min.js`,hr=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${lr}/dist/browser/oidc-client-ts.min.js`,pr=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let fr;const gr=e=>{try{return Pn(e).exp}catch(e){return null}},vr=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:gr(n)},mr=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?gr(o):void 0)},br=e=>{const{access_token:n,id_token:o,refresh_token:i,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:o,refreshJwt:e.refreshJwt||i,sessionExpiration:e.sessionExpiration||mr(e),cookieExpiration:e.cookieExpiration||vr(e)},s)},wr=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},yr=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 br(n)},kr=()=>cr&&!!window.descopeBridge,Sr=(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 pr.includes(n)},Ir=void 0!==fr||cr&&void 0!==window.localStorage,Cr=(e,t)=>{var n,o;return null===(o=null===(n=fr||cr&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},Or=e=>{var t,n;return null===(n=null===(t=fr||cr&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},Ar=e=>{var t,n;return null===(n=null===(t=fr||cr&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},xr=e=>{var t,n,o,i,r;return null!==(r=null!==(n=null===(t=null==fr?void 0:fr.key)||void 0===t?void 0:t.call(fr,e))&&void 0!==n?n:cr&&(null===(i=null===(o=window.localStorage)||void 0===o?void 0:o.key)||void 0===i?void 0:i.call(o,e)))&&void 0!==r?r:null},jr=e=>{var t,n;return cr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},Er=e=>{var t,n;try{cr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},Rr=(...e)=>{console.debug(...e)},Tr=(...e)=>{console.warn(...e)},$r="DS",_r="DSR",Ur="DSI",Pr="DSRCN";function Lr(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=Mr(o);Xi.set(e,t,{path:i,domain:c?o:void 0,expires:l,sameSite:r,secure:a})}}function Mr(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 Wr=e=>(null==e?void 0:e.cookieName)||$r,Nr=e=>(null==e?void 0:e.cookieName)||_r;function Dr(e="",t){return Xi.get(Nr(t))||Or(`${e}${_r}`)||""}function Fr(e="",t){return Xi.get(Wr(t))||Or(`${e}${$r}`)||""}function qr(e=""){return Or(`${e}${Ur}`)||""}function zr(e="",t,n,o){Ar(`${e}${_r}`),Ar(`${e}${$r}`),Ar(`${e}${Ur}`),Ar(`${e}${Pr}`);const i=Wr(t);Xi.remove(i,null==o?void 0:o.session);const r=Nr(n);Xi.remove(r,null==o?void 0:o.refresh)}const Vr=(e,t,n)=>o=>{const i=Object.assign(o,{token:o.token||Dr(e,t)});if(!n){const t=function(e=""){return Or(`${e}${Pr}`)}(e);t&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return Or(`${e}DTD`)||""}(e);return r&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-trusted-device-token":r})),i},Hr=cr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Kr="vsid",Jr="vrid",Br="fp",Gr=(e=!1)=>{const t=Or(Br);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Xr=async(e,t=Hr)=>{try{if(Gr())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=rr({apiKey:e,endpoint:[o.toString(),Yi],scriptUrlPattern:[r,ir]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Kr]:e,[Jr]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};Cr(Br,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Yr=e=>{const t=Gr(!0);return t&&e.body&&(e.body.fpData=t),e},Zr="descopeFlowNonce",Qr="X-Descope-Flow-Nonce",es="/v1/flow/start",ts="/v1/flow/next",ns=(e,t=Zr)=>`${t}${e}`,os=(e,t=Zr)=>{try{const n=ns(e,t),o=Or(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(is(e,t),null):{value:i.value,seq:i.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},is=(e,t=Zr)=>{try{const n=ns(e,t);Ar(n)}catch(e){console.error("Error removing flow nonce:",e)}},rs=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},ss=e=>{var t;return e.path===ts&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?rs(e.body.executionId):null},as="dls_last_user_login_id",ls="dls_last_user_display_name",cs=e=>Cr(as,e),ds=()=>Or(as),us=()=>Or(ls),hs=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=ds(),r=us();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)},ps="DSLI",fs=e=>async(...t)=>{const n=await e(...t);return Er(ps),n};function gs(){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 vs(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Is(n.publicKey.challenge),n.publicKey.user.id=Is(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Is(e.id)})),n}(e);try{return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Cs(n.rawId),type:n.type,response:{attestationObject:Cs(n.response.attestationObject),clientDataJSON:Cs(n.response.clientDataJSON)}})}catch(e){throw await ws(e,t,!0)}var n}async function ms(e){const t=ks(e);try{return Ss(await navigator.credentials.get(t))}catch(e){throw await ws(e,t,!1)}}async function bs(e,t){const n=ks(e);n.signal=t.signal,n.mediation="conditional";try{return Ss(await navigator.credentials.get(n))}catch(e){throw await ws(e,n,!1)}}async function ws(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var o,i;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 ys())return"webauthn_unsupported";const s="platform"===(null===(i=null===(o=null==t?void 0:t.publicKey)||void 0===o?void 0:o.authenticatorSelection)||void 0===i?void 0:i.authenticatorAttachment);return n&&s&&!await ys(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function ys(e=!1){var t,n;if(!cr)return Promise.resolve(!1);if(kr()){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 o=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return o&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():o}function ks(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Is(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Is(e.id)})),n}function Ss(e){return JSON.stringify({id:e.id,rawId:Cs(e.rawId),type:e.type,response:{authenticatorData:Cs(e.response.authenticatorData),clientDataJSON:Cs(e.response.clientDataJSON),signature:Cs(e.response.signature),userHandle:e.response.userHandle?Cs(e.response.userHandle):void 0}})}function Is(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Cs(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Os,As=(Os=e=>({async signUp(t,n,o){const i=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await vs(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await ms(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(t,n){var o;const i=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const t=await vs(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await ms(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,t)}},async update(t,n,o){const i=await e.webauthn.update.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await vs(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:vs,get:ms,isSupported:ys,conditional:bs}}),(...e)=>{const t=Os(...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 xs="/fedcm/config",js=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function Es(e,t){var n;try{await Rs(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Rs(e,t){var n,o;const i=await async function(e,t="google",n,o,i){const r=js(),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(i&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==i||i(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!i.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+i.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+i.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}var Ts=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await ys(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});let $s;const _s=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const i=t();if(i)return n(i);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",(()=>{_s(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Us=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{$s||($s=(async()=>{try{return require("oidc-client-ts")}catch(e){return _s([ur,hr],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await $s;if(!o)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 i({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new o(d),stateUserKey:l}})(e,t,n)),{client:o,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await o(),s=await i.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)))),Cr(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 i;const{client:r}=await o(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await o(),s=(e=>{const t=Or(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 i.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:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||qr(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return Ar(i),t||window.location.replace(s),r}}},Ps=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,fr=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return cr?(o&&i&&Xr(o).catch((()=>null)),e(wr(r,{beforeRequest:Yr}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.51.4"},t.baseHeaders)}))),(e=>t=>{const n=gs(),o=gs(),i=gs(),r=gs(),s=e(wr(t,{afterRequest:async(e,t)=>{if(Sr(e,t))Rr("Session invalidated, notifying subscribers with empty values"),o.pub(null),i.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await yr(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&i.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await yr(t);s&&o.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=Lo(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return o.pub(null),i.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:o.sub,onUserChange:i.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var o;const{enableFlowNonce:i=!0,nonceStoragePrefix:r=Zr}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return e(s);((e=Zr)=>{try{if(!Ir)return;for(let i=0;i<(void 0,n=void 0,void 0,null!==(o=null!==(t=null==fr?void 0:fr.length)&&void 0!==t?t:cr&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);i++){const t=xr(i);if(t&&t.startsWith(e)){const n=Or(t);if(n)try{JSON.parse(n).expiry<Date.now()&&Ar(t)}catch(e){Ar(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(r);const a=e(wr(s,{afterRequest:async(e,t)=>{var n;if(e.path!==es&&e.path!==ts)return;const{nonce:o,seq:i,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(Qr),o=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 o=Number(n);return Number.isSafeInteger(o)?o:void 0})(n);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=ss(e)),{nonce:n,seq:o,executionId:rs(i)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!o||!s)return;const a=e.path===es,l=null===(n=os(s,r))||void 0===n?void 0:n.seq;!a&&void 0!==i&&void 0!==l&&i<=l||((e,t,n,o=Zr,i)=>{try{const r=ns(e,o),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:i};Cr(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,o,a,r,null!=i?i:a?void 0:l)},beforeRequest:e=>{if(e.path===ts){const t=ss(e);if(t){const n=((e,t=Zr)=>{var n,o;return null!==(o=null===(n=os(e,t))||void 0===n?void 0:n.value)&&void 0!==o?o:null})(t,r);n&&(e.headers=e.headers||{},e.headers[Qr]=n)}}return e}}));if(null===(o=a.flow)||void 0===o?void 0:o.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const o=e;let i;e=new Promise((e=>{i=e})),await o;try{return await t(...n)}finally{i()}}}return a}),(e=>t=>{const n=e(wr(t,{afterRequest:async(e,t)=>{if(Sr(e,t))return void Er(ps);const n=await yr(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,o;try{cr&&(null===(o=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o||o.call(n,e,t))}catch(e){}})(ps,String(n.sessionExpiration))}}));return Lo(n,["logout","logoutAll","oidc.logout"],fs)}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);const r=!!o,s="object"==typeof o&&(null==o?void 0:o.customActivityTracking);if(!r||kr())return Object.assign(e(i),{markUserActive:()=>{Tr("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&&(Rr("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),cr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(Rr("Expiration time passed, refreshing session"),f.refresh(Dr()||d))}));const f=e(wr(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i,nextRefreshSeconds:r}=await yr(t);if(Sr(e,t))Rr("Session invalidated, canceling all timers"),a();else if(n||i){if(c=((e,t)=>{if(t)return new Date(1e3*t);Rr("Could not extract expiration time from session token, trying to decode the token");try{const t=Pn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!c)return void Rr("Could not extract expiration time from session token");d=o,h=r>0;const e=((e,t)=>{let n;var o;return t>0?(n=1e3*t,Rr(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>dr&&(Rr(`Timeout is too large (${n}ms), setting it to ${dr}ms`),n=dr),n})(c,r);if(a(),e<=2e4)return void Rr("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Rr(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(cr&&"hidden"===document.visibilityState)Rr("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return Rr("Skipping refresh due to timer - user is idle"),void(p=!0);Rr("Refreshing session due to timer"),f.refresh(Dr()||o)}}),e)}}}));return Object.assign(Lo(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Rr("Clearing all timers"),a(),n})),{markUserActive:u?()=>{Rr("markUserActive() called"),h||Rr("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(Rr("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(Dr()||d))}:()=>{Tr("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(r),{getLastUserLoginId:ds,getLastUserDisplayName:us});const s=e(wr(r,{afterRequest:async(e,t)=>{var n;const{userInfo:o,lastAuth:i}=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=br((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==o?void 0:o.loginIds)||void 0===n?void 0:n[0],s=null==o?void 0:o.name;r?(cs(r),(e=>{Cr(ls,e)})(s)):(null==i?void 0:i.loginId)&&cs(i.loginId)}}));let a=Lo(s,["flow.start"],hs);return a=Lo(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(Ar(as),Ar(ls)),o})(i)),Object.assign(a,{getLastUserLoginId:ds,getLastUserDisplayName:us})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!o||!cr)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(wr(Object.assign({refreshCookieName:a},l),{beforeRequest:Vr(s,r,a),afterRequest:async(e,t)=>{if(Sr(e,t))Rr("Session invalidated, clearing persisted tokens"),zr(s,i,r,c);else{const e=await yr(t);e.cookieName?Cr(`${s||""}${Pr}`,e.cookieName):e.refreshJwt&&Ar(`${s||""}${Pr}`);const n=((e={},t=!1,n="",o=!1)=>{var i,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d}=e;let u;if(c)if(o){Ar(`${n}${_r}`);const t=o.sameSite||"Strict",s=null===(i=o.secure)||void 0===i||i,a=null!==(r=o.domain)&&void 0!==r?r:e.cookieDomain,l=Nr(o);s&&"https:"!==window.location.protocol&&Tr("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});Lr(l,c,d);const h=Mr(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=Nr(o);Xi.remove(e),Cr(`${n}${_r}`,c)}if(l)if(t){const n=t.sameSite||"Strict",o=null===(s=t.secure)||void 0===s||s,i=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=Wr(t);o&&"https:"!==window.location.protocol&&Tr("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:o,cookieDomain:i});Lr(r,l,c);const d=Mr(i);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?i:void 0}})}else Cr(`${n}${$r}`,l);return e.idToken&&Cr(`${n}${Ur}`,e.idToken),d&&Cr(`${n}DTD`,d),u})(e,i,s,r);n&&(c=n)}}})),u=Lo(d,["logout","logoutAll","oidc.logout"],((e,t,n,o)=>i=>async(...r)=>{const s=await i(...r);return zr(e,t,n,null==o?void 0:o()),s})(s,i,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Dr(s,r),getSessionToken:()=>Fr(s,i),getIdToken:()=>qr(s)})}))((e=>{const t=Bi(e),n=Us(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,i)=>{var r;if(kr())return Rr(`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(o),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(i&&cr&&void 0!==window.localStorage&&!jr(ps)&&!Or(as)&&!jr("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Fr(),a=Dr();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){Rr("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:s?"t":"f",dcr:a?"t":"f"},l,i)},logout:async o=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:o}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(o)},flow:Ts(t),webauthn:As(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){Es(o,e)},requestAuthentication(e){Es(o,e)}},async oneTap(e,t,n,i,r){await Rs(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:i,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(i+xs),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>cr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+xs);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var o,i})),Ls={allOutboundApps:"/v1/mgmt/outbound/apps",connectedOutboundApps:"/v1/mgmt/outbound/apps-with-user-token"},Ms={me:"/v1/auth/me"},Ws=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)})),Ns=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"appId1",name:"Application 1",description:"Description"},{id:"appId2",name:"Application 2",description:"Description"},{id:"appId3",name:"Application 3",description:"Description"}]})}))})),Ds=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:["outboundApp3"]})}))})),Fs=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({userId:"user-1"})}))})),qs=({httpClient:e,mock:t})=>({getAllOutboundApps:()=>n(void 0,void 0,void 0,(function*(){if(t)return Ns();const n=yield e.get(Ls.allOutboundApps);return yield Ws(n),n.json()})),getConnectedOutboundApps:o=>n(void 0,[o],void 0,(function*({userId:n,tenantId:o}){if(t)return Ds();const i=yield e.get(Ls.connectedOutboundApps,{queryParams:o?{userId:n,tenantId:o}:{userId:n}});return yield Ws(i),i.json()}))}),zs=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return Fs();const n=yield e.get(Ms.me);return yield Ws(n),n.json()}))}),Vs=l((e=>{var t,s,a,l;const c=r(x,O,b,kn,j)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||le}get api(){return o(this,s,"f")||o(this,t,"m",a).call(this),o(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"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,s,((e,t,n)=>{const o=Ps(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.5.12"}}));return{outboundApps:qs({httpClient:o.httpClient,mock:t}),user:Object.assign({},zs({httpClient:o.httpClient,mock:t}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},l})),Hs=ln("users/me",((e,{extra:{api:t}})=>t.user.me())),Ks={action:Hs,reducer:Cn(Hs)({onFulfilled:(e,t)=>{e.me.data=t.payload}},On((e=>e.me)))},Js=l((e=>{const t=r(vn({name:"widget",initialState:$n,reducers:{setAllowedAppsIds:(e,{payload:t})=>{e.allowedAppsIds.data=t}},extraReducers:e=>{Ks.reducer(e),Tn.reducer(e),jn.reducer(e)},asyncActions:{getMe:Ks.action,getOutboundApps:jn.action,getConnectedOutboundApps:Tn.action}}),C,b,Vs)(e);return class extends t{constructor(...e){super(...e),this.state=$n,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Bs="widget-flow",Gs=l((e=>{var t,i,s;return s=class extends(r(wn,C,se,Js,kn,b,fe,Sn)(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=In(Bs);r&&(!function(e){if(window.history.replaceState&&In(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())}}(Bs),o(this,t,"m",i).call(this,r))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e}));new Z((()=>{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})),Xs=Et((e=>e.outboundAppsList.data),(e=>e.connectedOutboundAppsIds.data),(e=>e.allowedAppsIds.data),((e,t,n)=>e.filter((e=>void 0===n||n.includes(e.id))).map((e=>{const n=(null==t?void 0:t.includes(e.id))||!1;return Object.assign(Object.assign({},e),{appId:e.id,isConnected:n})})).sort(((e,t)=>e.name.localeCompare(t.name))))),Ys=Et((e=>e.me.data),(e=>e.userId)),Zs=l((e=>{var t,i,a,l,c;return c=class extends(r(b,C,q,B,yn("outbound-applications-widget"),Js)(e)){constructor(){super(...arguments),t.add(this)}static get observedAttributes(){return["allowed-outbound-apps-ids"]}attributeChangedCallback(e,n,i){"allowed-outbound-apps-ids"===e&&n!==i&&this.actions.setAllowedAppsIds(o(this,t,"a",l))}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield this.actions.getMe(),yield this.actions.setAllowedAppsIds(o(this,t,"a",l)),yield Promise.all([this.actions.getOutboundApps(),this.actions.getConnectedOutboundApps({userId:Ys(this.state),tenantId:this.tenantId})]);const r=yield o(this,t,"m",i).call(this);o(this,t,"m",a).call(this,r),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(e),e}))},a=function(e){this.contentRootElement.append(e.content.cloneNode(!0))},l=function(){var e;if(!this.hasAttribute("allowed-outbound-apps-ids"))return;const t=null===(e=this.getAttribute("allowed-outbound-apps-ids"))||void 0===e?void 0:e.trim();return t?t.split(",").map((e=>e.trim())).filter(Boolean):[]},c})),Qs=l((e=>class extends(r(fe,O)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),ea=l((e=>{var t,s,a,l,c,d,u,h,p,f,g,v,m,w,y,k,S;return S=class extends(r(wn,Qs,Js,b,Zs,se,Sn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),u.set(this,null),h.set(this,null),k.set(this,(e=>{let t,n;return(...o)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,o)||(t=o,n=e(...o)),n)})((e=>{o(this,s,"f").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),o(this,t,"m",y).call(this,Xs(this.state)),o(this,t,"m",p).call(this),o(this,t,"m",v).call(this),this.subscribe(o(this,k,"f").bind(this),Xs)}))}},s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,k=new WeakMap,t=new WeakSet,p=function(){o(this,s,"f").connectFlowId&&(i(this,a,this.createModal({"data-id":"outbound-apps-connect"}),"f"),o(this,a,"f").afterClose=()=>{var e;if(o(this,u,"f")){const t=null===(e=o(this,a,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",o(this,u,"f")),i(this,u,null,"f")}},i(this,c,new Z((()=>{var e;return null===(e=o(this,a,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(o(this,c,"f")))},f=function(e,t,n){e.open(),t.removeEventListener("page-updated",n)},g=function(e,n){var i;const r=null===(i=e.ele)||void 0===i?void 0:i.querySelector("descope-wc"),s=()=>o(this,t,"m",f).call(this,e,r,s);n=s,null==r||r.addEventListener("page-updated",n)},v=function(){i(this,l,this.createModal({"data-id":"outbound-apps-disconnect"}),"f"),i(this,d,new Z((()=>{var e;return null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,l,"f").afterClose=()=>{var e;if(o(this,h,"f")){const t=null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",o(this,h,"f")),i(this,h,null,"f")}},this.syncFlowTheme(o(this,d,"f"))},m=function(e){o(this,a,"f").setContent(this.createFlowTemplate({flowId:o(this,s,"f").connectFlowId,outboundAppId:e})),o(this,t,"m",g).call(this,o(this,a,"f"),o(this,u,"f")),o(this,c,"f").onSuccess((()=>{o(this,a,"f").close(),this.actions.getConnectedOutboundApps({userId:Ys(this.state),tenantId:this.tenantId})}))},w=function(e){o(this,l,"f").setContent(this.createFlowTemplate({flowId:o(this,s,"f").disconnectFlowId,outboundAppId:e})),o(this,t,"m",g).call(this,o(this,l,"f"),o(this,h,"f")),o(this,d,"f").onSuccess((()=>{o(this,l,"f").close(),this.actions.getConnectedOutboundApps({userId:Ys(this.state)})}))},y=function(e){i(this,s,new re((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-outbound-apps")}),{logger:this.logger}),"f"),o(this,s,"f").onConnectClick((({id:e})=>{o(this,t,"m",m).call(this,e)})),o(this,s,"f").onDisconnectClick((({id:e})=>{o(this,t,"m",w).call(this,e)})),o(this,s,"f").data=e},S})),ta=l((e=>class extends(r(U,fe,Gs,ea)(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)}))}})),na=r((e=>class extends(ta(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Nd})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.5.12"}}}))}}))(HTMLElement);customElements.define("descope-outbound-applications-widget",na);const oa=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var ia,ra,sa,aa,la,ca,da,ua,ha,pa;const fa=document.createElement("template");fa.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 ga=r(H)(HTMLElement);class va extends ga{constructor(){var e;super(),ia.add(this),ra.set(this,new f({messages:[]})),sa.set(this,void 0),aa.set(this,void 0),la.set(this,void 0),ca.set(this,{resize:o(this,ia,"m",pa).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(fa.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'),i(this,sa,this.shadowRoot.querySelector(".debugger"),"f"),o(this,sa,"f").style.top="32px",o(this,sa,"f").style.left=window.innerWidth-300-32+"px",i(this,aa,o(this,sa,"f").querySelector(".content"),"f"),i(this,la,o(this,sa,"f").querySelector(".header"),"f")}updateData(e){o(this,ra,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=oa(e,e.offsetLeft-o,e.offsetTop-i,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})(o(this,sa,"f"),o(this,la,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,ca,"f").resize),(e=o(this,sa,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,sa,"f").onresize=o(this,ia,"m",ha).bind(this),o(this,ra,"f").subscribe(o(this,ia,"m",da).bind(this))}disconnectedCallback(){o(this,ra,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,ca,"f").resize)}}ra=new WeakMap,sa=new WeakMap,aa=new WeakMap,la=new WeakMap,ca=new WeakMap,ia=new WeakSet,da=function(e){o(this,ia,"m",ua).call(this,e),o(this,ia,"m",ha).call(this)},ua=function(e){o(this,aa,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},ha=function(){o(this,aa,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;o||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},pa=function(){const[e,t]=oa(o(this,sa,"f"),Number.parseInt(o(this,sa,"f").style.left,10),Number.parseInt(o(this,sa,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,sa,"f").style.top=`${t}px`,o(this,sa,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",va);var ma=Object.freeze({__proto__:null,default:va});const ba="undefined"!=typeof localStorage,wa="J151000",ya="E103205",ka="E108201",Sa=ba&&localStorage.getItem("base.content.url")||"",Ia="base.ui.components.url";ba&&localStorage.getItem(Ia),ba&&localStorage.getItem(Ia);const Ca="descope-login-flow",Oa="code",Aa="redirect_mode",xa="err",ja="data-exclude-field",Ea="data-exclude-next",Ra="dls_last_auth",Ta="dls_last_submitted_login_id",$a="state_id",_a="saml_idp_state_id",Ua="wsfed_idp_state_id",Pa="saml_idp_username",La="descope_idp_initiated",Ma="sso_app_id",Wa="custom_app_id",Na="third_party_app_id",Da="third_party_app_state_id",Fa="oidc_login_hint",qa="oidc_prompt",za="oidc_resource",Va="oidc_error_redirect_uri",Ha="application_scopes",Ka="data-type",Ja="redirect",Ba="poll",Ga="webauthnCreate",Xa="webauthnGet",Ya="nativeBridge",Za="loadForm",Qa="submit",el="polling",tl=["descope-multi-select-combo-box","descope-text-area"],nl="dls_last_auth_in_flight",ol=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts","data","totp","notp","sentTo","sso","selfProvisionDomains"];var il;!function(e){e.backward="backward",e.forward="forward"}(il||(il={}));const rl=["descope-enriched-text"];function sl(e){return new URLSearchParams(window.location.search).get(e)}function al(e){if(window.history.replaceState&&sl(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 ll(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?il.forward:n<o?il.backward:void 0}const cl=e=>{let[t="",n=""]=(sl(Ca)||"").split("_");const o=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||o&&o!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:o}};function dl(){al(Ca)}const ul=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),hl=(e,t)=>{const{executionId:n,stepId:o,executionFlowId:i}=cl(e);if(i&&e!==i)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&dl();const r=sl("t")||void 0;r&&al("t");const s=sl(Oa)||void 0;s&&al(Oa);const a="popup"===sl(Aa);a&&al(Aa);const l=sl(xa)||void 0;l&&al(xa);const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:sl("ra-challenge"),redirectAuthCallbackUrl:sl("ra-callback"),redirectAuthBackupCallbackUri:sl("ra-backup-callback"),redirectAuthInitiator:sl("ra-initiator")},p=sl($a);p&&al($a);const f=sl(_a);f&&al(_a);const g=sl(Ua);g&&al(Ua);const v=sl(Pa);f&&al(Pa);const m=sl(La);m&&al(La);const b=sl(Ma);b&&al(Ma);const w=sl(Wa);w&&al(Wa);const y=sl(Na);y&&al(Na);const k=sl(Da);k&&al(Da);const S=sl(Ha);S&&al(Ha);const I=sl(Fa);I&&al(Fa);const C=sl(qa);C&&al(qa);const O=sl(Va);O&&al(Va);const A=sl(za);return A&&al(za),{executionId:n,stepId:o,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:f,wsfedIdpStateId:g,samlIdpUsername:v,descopeIdpInitiated:"true"===m,ssoAppId:b,customAppId:w,oidcLoginHint:I,oidcPrompt:C,oidcErrorRedirectUri:O,oidcResource:A,thirdPartyAppId:y,thirdPartyAppStateId:k,applicationScopes:S}}},pl=e=>{let t,n;return Object.assign(((...o)=>{return t&&(r=o,(i=t).length===r.length&&i.every(((e,t)=>e===r[t])))||(t=o,n=e(...o)),n;var i,r}),{reset:()=>{t=void 0,n=void 0}})},fl=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])');setTimeout((()=>{null==t||t.focus()}))}};function gl(e,t,n){return new Promise(((o,i)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?o(n):i(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),o(e))})).catch((e=>{r||(clearTimeout(s),i(e))}))}))}const vl=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:o,samlIdpUsername:i,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||o||i||r||s||a||l||c||d||u||h||p),ml=e=>null==e?void 0:e.submit(),bl=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},wl=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},yl={minLength:"data-password-policy-value-minlength",strength:"data-password-policy-value-passwordstrength",disallowedChars:"data-password-policy-value-disallowedchars",email:"data-password-policy-value-email",activePolicies:"active-policies",availablePolicies:"available-policies"},kl=(e,t)=>{var n;const o=null==e?void 0:e.componentsDynamicAttrs;if(!o)return;const i=Object.entries(o).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==i?void 0:i[1])||void 0===n?void 0:n.attributes},Sl=[{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(yl).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=kl(e,"recoveryCodes");if(t)return Array.isArray(t.data)?t.data.map((e=>e.value)):[]})(e.componentsConfig)},{key:"outboundApp",from:e=>(e=>{const t=kl(e,"outboundApp");if(t)return{label:t.label,iconSrc:t["icon-src"],appId:t["data-descope-outbound-oauth-app-id"]}})(e.componentsConfig)}],Il=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Cl(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Ol,Al,xl,jl;function El(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!El(r,s))return!1}else if(r!==s)return!1}return!0}let Rl=class{constructor(e={},{forceUpdate:t=!1}={}){Ol.set(this,void 0),Al.set(this,{}),xl.set(this,0),jl.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,Ol,"f")):e,n=Object.assign(Object.assign({},o(this,Ol,"f")),t),r=o(this,Ol,"f");i(this,Ol,n,"f"),Object.freeze(o(this,Ol,"f")),setTimeout((()=>{Object.values(o(this,Al,"f")).forEach((({cb:e,selector:t,forceUpdate:i})=>{const s=t(r),a=t(n);(o(this,jl,"f")||i||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!El(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},i(this,Ol,e,"f"),i(this,jl,t,"f")}get current(){return Object.assign({},o(this,Ol,"f"))}set forceUpdate(e){i(this,jl,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return i(this,xl,o(this,xl,"f")+1,"f"),o(this,Al,"f")[o(this,xl,"f")]={cb:e,selector:t,forceUpdate:n},o(this,xl,"f").toString()}unsubscribe(e){const t=!!o(this,Al,"f")[e];return t&&delete o(this,Al,"f")[e],t}unsubscribeAll(){return i(this,Al,{},"f"),!0}};Ol=new WeakMap,Al=new WeakMap,xl=new WeakMap,jl=new WeakMap;const Tl=["*","#","/","(",")","[","]","_","<",">","`"],$l=e=>"string"!=typeof e?e:e.replace((e=>{const t=Tl.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),_l=["disabled"],Ul=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${ja}])`)).forEach((e=>{e.value=n}))}))},Pl=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),Ll=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,o)=>n?$l(Pl(t,o)):Pl(t,o))),Ml=(e,t,n)=>{e.querySelectorAll(`[${Ka}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Wl=(e,t,n)=>{var o,i;const r=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==e?void 0:e.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},Nl=(e,n,o,i)=>{var r,s;Ml(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),Ml(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=>rl.includes(e))(e.localName);e.textContent=Ll(e.textContent,t,n);const o=e.getAttribute("href");o&&e.setAttribute("href",Ll(o,t))}))})(e,n),((e,n,o)=>{if(!n)return;const{componentsDynamicAttrs:i}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});i&&Object.keys(i).forEach((e=>{const t=i[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 i=n[t];if("string"!=typeof i)try{i=JSON.stringify(i)}catch(e){o.error(`Could not stringify value "${i}" for "${t}"`,e.message),i=""}e.setAttribute(t,i)}))}))}))})(e,null==n?void 0:n.componentsConfig,i),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=Ll(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])=>{_l.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)},Dl=pl((()=>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)))),o=(()=>{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 gl(100,n,o)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let Fl;const ql=(e,t)=>{Fl?Fl.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},zl=e=>Fl?Fl.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,Vl="dls_ab_testing_id",Hl={"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,o]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=o?o:0)},"not-in-range":(e,t)=>{const[n,o]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==o&&!Number.isNaN(n)&&!Number.isNaN(o))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>o},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function Kl(e,t){const n={};try{Object.assign(n,JSON.parse(zl(Ra)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function Jl(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||ql(Ra,JSON.stringify(e)))}function Bl(){try{return JSON.parse(zl(nl)||"{}")}catch(e){return{}}}function Gl(e){try{(e=>{Fl?Fl.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(nl)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const Xl=(e,t="")=>Object.keys(e).reduce(((n,o)=>{var i;if(Array.isArray(e[o]))return Object.assign(Object.assign({},n),{[o]:{value:e[o].map((e=>"object"==typeof e&&null!==e?Xl(e):e))}});if("object"==typeof e[o]&&null!==e[o]&&!(null===(i=e[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),Xl(e[o],`${t+o}.`));const r="object"==typeof e[o]?e[o]:{value:e[o]},s=Object.assign(Object.assign({},n),{[t+o]:r,[`form.${t}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),Yl=l((e=>{var t,n,i,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;o(this,t,"m",n).call(this)&&o(this,t,"m",i).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)},i=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})),Zl=["input","change"];function Ql(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 ec(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 tc(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 nc(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function oc(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const ic=new Map,rc={equal:(e,t)=>e===t||ec(e)===ec(t),"not-equal":(e,t)=>e!==t&&ec(e)!==ec(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(ec(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(ec(t)),"greater-than":(e,t)=>{const n=Ql(e),o=Ql(t);return n.ok&&o.ok&&n.value>o.value},"greater-than-or-equal":(e,t)=>{const n=Ql(e),o=Ql(t);return n.ok&&o.ok&&n.value>=o.value},"less-than":(e,t)=>{const n=Ql(e),o=Ql(t);return n.ok&&o.ok&&n.value<o.value},"less-than-or-equal":(e,t)=>{const n=Ql(e),o=Ql(t);return n.ok&&o.ok&&n.value<=o.value},empty:e=>oc(e),"not-empty":e=>!oc(e),"is-true":e=>{const t=tc(e);return t.ok&&t.value},"is-false":e=>{const t=tc(e);return t.ok&&!t.value},in:(e,t)=>{const n=nc(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=nc(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(ic.has(e))return null!==(t=ic.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return ic.set(e,n),n}(ec(t));return null!==n&&n.test(e)}};function sc(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=>sc(e,t))):e.value}function ac(e,t){const n=rc[e.operator];return!!n&&n(sc(e.target,t),sc(e.predicate,t))}function lc(e,t){const n={};return(null!=e?e:[]).forEach((e=>{var o;(function(e,t){var n;return(null!==(n=e.rules)&&void 0!==n?n:[]).some((e=>function(e,t){var n;const o=null!==(n=e.atomicConditions)&&void 0!==n?n:[];return!!o.length&&(e.logicalOr?o.some((e=>ac(e,t))):o.every((e=>ac(e,t))))}(e,t)))})(e,t)&&(null!==(o=e.componentIds)&&void 0!==o?o:[]).forEach((t=>{n[t]=e.action}))})),n}const cc=["hide","disable","read-only"];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,n){return Object.keys(t).forEach((o=>{const i=t[o];n[o]!==i&&hc(e,o).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove("hidden");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,i)))})),Object.keys(n).forEach((o=>{const i=n[o],r=t[o];i!==r&&hc(e,o).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add("hidden");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,i)))})),Object.assign({},n)}const fc="component-conditions:";function gc(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 vc(e,t){const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((n=>e[n]===t[n]))}function mc(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function bc(e,t,n){const o={};return n.forEach((n=>{e[n]?o[n]=e[n]:t[n]&&(o[n]=t[n])})),o}const wc=l((e=>{var t,n,s,a,l,c;const d=r(b)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,mc())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{cc.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${cc.map((e=>`"${e}"`)).join(", ")}`)})),pc(e,{},t))}initRealtimeConditions(e,r){var a,c,d,u;o(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(`${fc} no real-time rules to apply on this screen`);this.logger.info(`${fc} 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 o;e&&("form"===e.kind&&e.form?t.add(e.form):"list"===e.kind&&(null!==(o=e.items)&&void 0!==o?o:[]).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 o=gc(n);void 0!==o&&(p[t]=o)}));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},b=bc(lc(h,p),g,f);vc(v,b)||(m.applied=pc(e,v,b)),m.inputHandler=e=>o(this,t,"m",s).call(this,e),Zl.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${fc} listening for "${Zl.join('" and "')}" events on form fields; ${Object.keys(v).length} component(s) start hidden / disabled / read-only by these rules`);const w=this.nextRequestStatus;if(null==w?void 0:w.subscribe){const e=({isLoading:e})=>{m.paused=e,e&&m.debounceTimer&&(clearTimeout(m.debounceTimer),m.debounceTimer=null)},t=w.subscribe(e);m.unsubscribePauseListener=()=>{var e;null!=t&&(null===(e=w.unsubscribe)||void 0===e||e.call(w,t))}}i(this,n,m,"f")}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),o(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(e){var i,r;const s=o(this,n,"f");if(!s.root||s.paused)return;const l=e.target;if(!l)return;if(null===(i=l.hasAttribute)||void 0===i?void 0:i.call(l,ja))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]=gc(l),s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout((()=>{s.debounceTimer=null,o(this,t,"m",a).call(this)}),50)},a=function(){const e=o(this,n,"f");if(!e.root)return;let t;try{t=bc(lc(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${fc} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const i=e.applied;vc(i,t)||(this.logger.debug(`${fc} form changed — updating components: was ${JSON.stringify(i)}, now ${JSON.stringify(t)}`),e.applied=pc(e.root,i,t))},l=function(){const e=o(this,n,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&(Object.keys(e.applied).length>0&&e.root.isConnected&&pc(e.root,e.applied,{}),Zl.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)}))),i(this,n,mc(),"f")},c})),yc="project-id",kc="flow-id",Sc=e=>{const t=(e=>{const t=e.getAttribute(yc),n=e.getAttribute(kc);return t&&n?Array.from(e.ownerDocument.querySelectorAll("descope-wc")).filter((e=>e.getAttribute(yc)===t&&e.getAttribute(kc)===n)):[]})(e);return t.length>1&&t[0]!==e},Ic=l((e=>{var t,n,s,a;const l=r(b)(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),o(this,t,"m",s).call(this)}attributeChangedCallback(e,n,i){var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),n===i||e!==yc&&e!==kc||o(this,t,"m",s).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){queueMicrotask((()=>{if(!this.isConnected)return;const e=this.getAttribute(yc),t=this.getAttribute(kc),r=`${e}|${t}`;o(this,n,"f")!==r&&Sc(this)&&(i(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})),Cc=["externalId","email","phone"],Oc=["newPassword","password"],Ac="data-username-anchor",xc=e=>{var t;if(!e)return"";try{const n=null===(t=window.sessionStorage)||void 0===t?void 0:t.getItem(Ta);if(!n)return"";const o=JSON.parse(n);return o.executionId===e&&o.loginId||""}catch(e){return""}},jc=l((e=>{var t,n,s,a,l;const c=r(b)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}updateScreenUser(e){var r,l,c;i(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:[xc(o(this,t,"a",a))||(null===(c=null===(l=o(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(`[${Ac}="true"]`).forEach((e=>e.remove())),((e,t,n,o)=>{var i;const r=(null==n?void 0:n.email)||(null===(i=null==n?void 0:n.loginIds)||void 0===i?void 0:i[0]);(e=>e.querySelector("descope-new-password")||e.querySelector("descope-password"))(t)?r?(e=>{const t=['input[autocomplete="username"]',...Cc.map((e=>`[name="${e}"]`))].join(", ");return e.some((e=>e.querySelector(t)))})([e,t])?o.debug("Username anchor: screen already has an identifier field"):(o.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(ja,"true"),t.setAttribute(Ac,"true"),t.setAttribute("value",e),t.value=e,Object.assign(t.style,{position:"absolute",opacity:"0",pointerEvents:"none",height:"0",border:"0"}),t})(r))):o.debug("Username anchor: no user identifier available"):o.debug("Username anchor: no password component on screen")})(this,o(this,t,"a",s).contentRootElement,o(this,n,"f"),this.logger)}captureLastSubmittedLoginId(e={},n){const i=bl(e,Cc);i&&((e,t)=>{var n;if(e&&t)try{null===(n=window.sessionStorage)||void 0===n||n.setItem(Ta,JSON.stringify({executionId:t,loginId:e}))}catch(e){}})(i,n||o(this,t,"a",a))}storeCredentials(e={}){var t,i,r,s,a,l;const c=bl(e,Cc)||(null===(t=o(this,n,"f"))||void 0===t?void 0:t.email)||(null===(r=null===(i=o(this,n,"f"))||void 0===i?void 0:i.loginIds)||void 0===r?void 0:r[0]),d=bl(e,Oc);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.error("Could not store credentials",null==e?void 0:e.message)}))}catch(e){this.logger.error("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=o(this,t,"a",s).flowState)||void 0===e?void 0:e.current)||void 0===n?void 0:n.executionId)||""},l}));var Ec,Rc,Tc,$c,_c,Uc,Pc,Lc,Mc,Wc,Nc,Dc,Fc,qc,zc,Vc,Hc,Kc,Jc,Bc,Gc,Xc;const Yc=r(fe,T,Yl,wc,Ic,jc,H)(HTMLElement);class Zc extends Yc{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),Ec.add(this),Tc.set(this,!1),$c.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,Ec,"m",Xc).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)}},_c.set(this,new Rl),Uc.set(this,new Rl),Pc.set(this,{}),this.getComponentsContext=()=>o(this,Pc,"f"),this.nextRequestStatus=new Rl({isLoading:!1}),Lc.set(this,void 0),Mc.set(this,{popstate:o(this,Ec,"m",qc).bind(this),componentsContext:o(this,Ec,"m",Jc).bind(this)}),Wc.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,Wc,e,"f"),o(this,Ec,"m",Dc).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return Xl(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 o(this,$c,"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");i(this,$c,e,"f"),(e=>{Fl=e})(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}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,o;const i=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=tl.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==e.key||i||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),o(this,Uc,"f").subscribe(o(this,Ec,"m",Gc).bind(this)),o(this,Uc,"f").update({isDebug:this.debug}),o(this,Ec,"m",Fc).call(this),yield o(this,Ec,"m",Hc).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}=hl(this.flowId,this.loggerWrapper);window.addEventListener("popstate",o(this,Mc,"f").popstate),window.addEventListener("components-context",o(this,Mc,"f").componentsContext),o(this,_c,"f").subscribe(o(this,Ec,"m",Vc).bind(this)),o(this,_c,"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)),i(this,Tc,!0,"f")}))}disconnectedCallback(){var e;o(this,_c,"f").unsubscribeAll(),o(this,Uc,"f").unsubscribeAll(),o(this,Ec,"m",Bc).call(this),window.removeEventListener("popstate",o(this,Mc,"f").popstate),window.removeEventListener("components-context",o(this,Mc,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,n){var i;if(null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,t,n),this.shadowRoot.isConnected&&o(this,Tc,"f")&&t!==n&&Rc.observedAttributes.includes(e)){o(this,Ec,"m",Fc).call(this);const i=null===t;o(this,_c,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,dl()),{[ul(e)]:n,stepId:r,executionId:s}})),o(this,Uc,"f").update({isDebug:this.debug})}}}var Qc,ed,td,nd,od,id,rd,sd,ad,ld,cd,dd,ud,hd,pd,fd,gd,vd,md,bd,wd,yd,kd,Sd,Id,Cd,Od,Ad,xd,jd,Ed,Rd,Td,$d,_d,Ud,Pd,Ld,Md;Rc=Zc,Tc=new WeakMap,$c=new WeakMap,_c=new WeakMap,Uc=new WeakMap,Pc=new WeakMap,Lc=new WeakMap,Mc=new WeakMap,Wc=new WeakMap,Ec=new WeakSet,Nc=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 ")},Dc=function(){o(this,Ec,"m",Nc).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Fc=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes","theme-override"];Rc.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[ul(t)])throw Error(`${t} cannot be empty`)}))},qc=function(){const{stepId:e,executionId:t}=cl(this.flowId);o(this,_c,"f").update({stepId:e,executionId:t})},zc=function(e,t){Ps&&"function"==typeof Ps||this.logger.error("SDK was not loaded properly",Ps,JSON.stringify(Ps));const i=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},Rc.sdkConfigOverrides),{projectId:e,baseUrl:t});o(this,$c,"f")&&(i.customStorage=o(this,$c,"f")),this.sdk=Ps(i),["start","next"].forEach((e=>{const t=function(e,t,o){return(...i)=>n(this,void 0,void 0,(function*(){let n;const r=o+1;for(let s=0;s<r;s++)try{return yield e(...i)}catch(e){n=e,s<o&&(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*(){try{return yield t(...o)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:wa,errorDescription:t.toString()}}}}))}))},Vc=function(e,t,i){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;o(this,Ec,"m",zc).call(this,t,n)}o(this,Wc,"f").call(this,e)}))},Hc=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield o(this,Ec,"m",Kc).call(this))}))},Kc=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(Sa||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.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}}))},Jc=function(e){i(this,Pc,Object.assign(Object.assign({},o(this,Pc,"f")),e.detail),"f")},Bc=function(){var e;null===(e=o(this,Lc,"f"))||void 0===e||e.remove(),i(this,Lc,null,"f")},Gc=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,Lc,document.createElement("descope-debugger"),"f"),Object.assign(o(this,Lc,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return nu})),document.body.appendChild(o(this,Lc,"f"))):o(this,Ec,"m",Bc).call(this)}))},Xc=function(e,t){var n;e&&this.debug&&(null===(n=o(this,Lc,"f"))||void 0===n||n.updateData({title:e,description:t}))},Zc.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.0.2"}};class Wd extends Zc{static set sdkConfigOverrides(e){Zc.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Zc.sdkConfigOverrides}constructor(){const e=new Rl({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),Qc.add(this),this.stepState=new Rl({}),ed.set(this,void 0),td.set(this,null),nd.set(this,null),od.set(this,{visibilitychange:o(this,Qc,"m",id).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},hd.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},fd.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()?o(this,Qc,"m",gd).call(this,t):t()})),vd.set(this,((e,t,r,s,a=!1)=>{const l=[ya,"E103202",ka];if(this.flowState.current.action===Ba){if(o(this,bd,"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;i(this,ed,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,i;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,el,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 gl(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,vd,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===wa)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,vd,"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===(i=null==p?void 0:p.error)||void 0===i?void 0:i.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):o(this,vd,"f").call(this,e,t,r,s),o(this,wd,"f").call(this,p)}))),d),"f")}})),md.set(this,(()=>{clearTimeout(o(this,ed,"f")),i(this,ed,null,"f")})),bd.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),wd.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 i=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}`;o(this,Qc,"m",Ld).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:i}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||i,(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!==ya&&d!==ka||!this.isRestartOnError||o(this,Qc,"m",ud).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:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,o):this.loggerWrapper.info(n,o)}));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:b,lastAuth:w,action:y,openInNewTabUrl:k}=e.data;if(y!==Ba&&o(this,md,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&Jl(Object.assign(Object.assign({},w),{lastUsedPerScreen:Bl()})),Gl(this.loggerWrapper);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void o(this,Qc,"m",Ld).call(this,"success",t)}this.storeLastAuthenticatedUser&&Jl(w,!0),k&&window.open(k,"_blank");const{executionId:S,stepId:I,stepName:C,screen:O,redirect:A,webauthn:x,error:j,samlIdpResponse:E,wsFedIdpResponse:R,nativeResponse:T}=e.data,$=Date.now();y!==Ba?(this.loggerWrapper.info(`Step "${C||`#${I}`}" is ${m}`,"",{screen:O,status:m,stepId:I,stepName:C,action:y,error:j}),(null===(g=O.state)||void 0===g?void 0:g.clientScripts)&&i(this,nd,this.loadSdkScripts(O.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==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==x?void 0:x.transactionId,webauthnOptions:null==x?void 0:x.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.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:$})):this.flowState.update({action:y,reqTimestamp:$})})),yd.set(this,pl((()=>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)}}))))),Ad.set(this,null),Rd.set(this,wl(((e,t,i)=>n(this,void 0,void 0,(function*(){var n,r;if("true"===e.getAttribute("formnovalidate")||o(this,Qc,"m",Cd).call(this)){const s=null==e?void 0:e.getAttribute("id");o(this,Qc,"m",_d).call(this,e,s,i),o(this,Qc,"m",xd).call(this,e);const a=yield o(this,Qc,"m",Od).call(this),l=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const c=Object.assign(Object.assign(Object.assign({},l),a),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin}),d=yield t(s,c);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(a,null===(r=null==d?void 0:d.data)||void 0===r?void 0:r.executionId),this.storeCredentials(a)}}))))),this.flowState=e}nativeResume(e,t){var n,i,r,s,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const o=new URL(c.url);t=null===(n=o.searchParams)||void 0===n?void 0:n.get(Oa),e=(null===(i=o.searchParams)||void 0===i?void 0:i.get(xa))||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(Ca).split("_").pop();o(this,md,"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:{[Cl(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 o=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,o,i;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===(o=globalThis.descope)||void 0===o?void 0:o[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.17",`dist/${e.id}.js`));const s=null===(i=globalThis.descope)||void 0===i?void 0:i[e.id];return new Promise(((n,o)=>{try{const o=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(o){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=o,this.shadowRoot.appendChild(t);const n=this.nextRequestStatus.subscribe((()=>{var i;this.loggerWrapper.debug("Stopping script",e.id),(null===(i=o.stop)||void 0===i?void 0:i.call(o))&&(this.nextRequestStatus.unsubscribe(n),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}))}}catch(e){o(e)}}))}))))),i=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([o,i])}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),o(this,Qc,"m",cd).call(this),window.addEventListener("visibilitychange",o(this,od,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),o(this,md,"f").call(this),null===(e=o(this,td,"f"))||void 0===e||e.abort(),i(this,td,null,"f"),window.removeEventListener("visibilitychange",o(this,od,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const o=g(e),i=yield this.getTargetLocales();return i.includes(o.locale)?n=`${t}-${o.locale}.html`:i.includes(o.fallback)&&(n=`${t}-${o.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:v,screenState:m,redirectTo:b,redirectIsPopup:w,redirectUrl:y,token:k,code:S,isPopup:I,exchangeError:C,webauthnTransactionId:O,webauthnOptions:A,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:E,redirectAuthInitiator:R,locale:T,samlIdpResponseUrl:$,samlIdpResponseSamlResponse:_,samlIdpResponseRelayState:U,wsFedIdpResponseUrl:P,wsFedIdpResponseWresult:L,wsFedIdpResponseWctx:M,nativeResponseType:W,nativePayload:N,reqTimestamp:D}=e,F=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let q,z,V;const H=(()=>{const e=zl(Vl);if(!e){const e=Math.floor(100*Math.random()+1);return ql(Vl,e.toString()),e}return Number(e)})(),{outboundAppId:K}=this,{outboundAppScopes:J}=this,B=this.sdk.getLastUserLoginId(),G=yield this.getFlowConfig(),X=yield this.getProjectConfig(),Y=Object.entries(X.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Z=j&&x?{callbackUrl:j,codeChallenge:x,backupCallbackUri:E}: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){Gl(this.loggerWrapper);const e=[...G.clientScripts||[],...G.sdkScripts||[]];if(G.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:o})=>{var i;if("ELSE"===t)return!0;const r=null===(i=Hl[t])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(e,o))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:B,code:S,token:k,abTestingKey:H,lastAuth:Kl(B,this.loggerWrapper)},G.conditions)),e.push(...t||[])}else G.condition?({startScreenId:q,conditionInteractionId:V}=((e,t)=>{var n;const o=null===(n=Hl[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const i=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==i?void 0:i.screenId,startScreenName:null==i?void 0:i.screenName,conditionInteractionId:null==i?void 0:i.interactionId}})(G.condition,{loginId:B,code:S,token:k,abTestingKey:H,lastAuth:Kl(B,this.loggerWrapper)})):(z=G.startScreenName,q=G.startScreenId);if(i(this,nd,this.loadSdkScripts(e),"f"),G.fingerprintEnabled&&G.fingerprintKey?yield Xr(G.fingerprintKey,this.baseUrl):Ar(Br),!vl(q,F)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Z},F),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:Kl(B,this.loggerWrapper),abTestingKey:H,locale:g(T).locale,nativeOptions:Q,outboundAppId:K,outboundAppScopes:J}),V,"",X.componentsVersion,Y,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),S?{exchangeCode:S,idpInitiated:!0}:{}),F.descopeIdpInitiated&&{idpInitiated:!0}),k?{token:k}:{}),F.oidcLoginHint?{externalId:F.oidcLoginHint}:{}));return o(this,wd,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:I,code:S,exchangeError:C,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),I&&(s("code")&&S||s("exchangeError")&&C))return void o(this,Qc,"m",Md).call(this,p,S,C);if(p&&(s("token")&&k||s("code")&&S||s("exchangeError")&&C)){const e=yield this.sdk.flow.next(p,h,Qa,G.version,X.componentsVersion,{token:k,exchangeCode:S,exchangeError:C});return o(this,wd,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Za&&$&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!_)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=e,i.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(i),o(i)})($,_,U||"",ml)}if(f===Za&&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,o)=>{const i=document.createElement("form");i.method="POST",i.action=e;const r=(e,t)=>{const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n};i.appendChild(r("wa","wsignin1.0")),i.appendChild(r("wresult",t)),i.appendChild(r("wctx",n));const s=document.createElement("input");s.type="submit",s.id="WSFedSubmitButton",s.value="Continue",s.style.display="none",i.appendChild(s),document.body.appendChild(i),o(i)})(P,L,M||"",ml)}if(f===Ja&&(s("redirectTo")||s("deferredRedirect"))){if(!b)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===b)return;if("android"===R&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${w}`),w){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,o)=>{const i=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+i,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-o)/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=${o},top=${a},left=${s},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c})(b,"?",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 i=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const o=t?this.popupOrigin:window.location.origin;if(e.origin!==o)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${o}"`);const{action:i,data:r}=e.data||{};"code"===i&&(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),o(this,Qc,"m",Ld).call(this,"popupclosed",{abandoned:!n}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==r||r())}),1e3);if(t)window.addEventListener("message",i),r=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",i)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=i,r=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(b),this.flowState.update({redirectTo:"no-op"}),o(this,Qc,"m",Ld).call(this,"popupclosed",{});return}if(f===Ga||f===Xa){if(!O||!A)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t,n,r;null===(l=o(this,td,"f"))||void 0===l||l.abort(),i(this,td,null,"f");try{e=f===Ga?yield this.sdk.webauthn.helpers.create(A):yield this.sdk.webauthn.helpers.get(A)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name,n=e.reason,r=e.message}const s=yield this.sdk.flow.next(p,h,Qa,G.version,X.componentsVersion,{transactionId:O,response:e,failure:t,failureReason:n,failureMessage:r});o(this,wd,"f").call(this,s)}if(f===Ya)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,Qa,G.version,X.componentsVersion,e);o(this,wd,"f").call(this,t)})),o(this,Qc,"m",ad).call(this,W,N),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&o(this,vd,"f").call(this,p,h,G.version,X.componentsVersion),!v&&!q)return void this.loggerWrapper.warn("No screen was found to show");const te=q||v,ne=yield this.getHtmlFilenameWithLocale(T,te),{oidcLoginHint:oe,oidcPrompt:ie,oidcErrorRedirectUri:re,oidcResource:se,samlIdpUsername:ae}=F,le={direction:ll(h,r.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:B,name:this.sdk.getLastUserDisplayName()||B},componentsConfig:Object.assign(Object.assign(Object.assign({},G.componentsConfig),ee),null==m?void 0:m.componentsConfig)}),htmlFilename:`${te}.html`,htmlLocaleFilename:ne,screenId:te,stepName:e.stepName||z,samlIdpUsername:ae,oidcLoginHint:oe,oidcPrompt:ie,oidcErrorRedirectUri:re,oidcResource:se,action:f,locale:g(T).locale},ce=Kl(B,this.loggerWrapper);vl(q,F)?le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==G?void 0:G.clientScripts)||[];yield o(this,Qc,"m",Td).call(this,n);const i=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Z},F),{lastAuth:ce,preview:this.preview,abTestingKey:H,client:this.client}),y&&{redirectUrl:y}),{locale:g(T).locale,nativeOptions:Q,outboundAppId:K,outboundAppScopes:J}),V,e,X.componentsVersion,Y,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),Il(t)),S&&{exchangeCode:S,idpInitiated:!0}),F.descopeIdpInitiated&&{idpInitiated:!0}),k&&{token:k}),le.next.isCustomScreen);return o(this,wd,"f").call(this,i),i})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==m?void 0:m.clientScripts)||[];yield o(this,Qc,"m",Td).call(this,n);const i=yield this.sdk.flow.next(p,h,e,G.version,X.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),Il(t)),le.next.isCustomScreen);return o(this,wd,"f").call(this,i),i}))),this.loggerWrapper.debug("Got a screen with id",le.screenId),yield o(this,Qc,"m",pd).call(this,le),this.stepState.update(le)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var i,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 o(this,Qc,"m",Sd).call(this,f,d):(e=>{e.querySelectorAll(`descope-button[${Ka}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(f),!e.samlIdpUsername||(null===(i=u.form)||void 0===i?void 0:i.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),Nl(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,o])=>{Array.from(e.querySelectorAll(`[${n}="${o}"]`)).forEach((e=>{e.setAttribute(n,t||o)}))}))})(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,o])=>{Array.from(e.querySelectorAll(`[${t}="${o}"]`)).forEach((e=>{e.setAttribute(t,n||o)}))}))})(f,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,i;yield g;const r=this.contentRootElement;((e,t)=>{Wl(e,"descope-totp-image",t)})(r,null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image),((e,t)=>{Wl(e,"descope-notp-image",t)})(r,null===(i=null==u?void 0:u.notp)||void 0===i?void 0:i.image),((e,t,n,o)=>{n&&Object.keys(n).forEach((i=>{if(!t.querySelector(i))return void o.debug(`Skipping css vars for component "${i}"`,`Got css vars for component ${i} but Could not find it on next page`);const r=customElements.get(i);r?Object.keys(n[i]).forEach((t=>{var s;const a=n[i],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void o.info(`Could not find css variable name for ${t} in ${i}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):o.debug(`Could not find component class for ${i}`,"Check if the component is registered")}))})(r,f,u.cssVars,this.loggerWrapper),r.replaceChildren(f);const s=!t.htmlFilename;setTimeout((()=>{o(this,Qc,"m",jd).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const o=()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))};if("true"===t.getAttribute("invalid")||(null===(n=t.value)||void 0===n?void 0:n.length))return void o();const i={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(i.timer),i.timer=void 0)};i.timer=setTimeout((()=>{e.removeEventListener("click",r),o(),i.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(r),((e,t)=>{Ul(e,null==t?void 0:t.inputs),Ul(e,null==t?void 0:t.form)})(r,u),this.initRealtimeConditions(r,u),o(this,Qc,"m",Id).call(this,{isFirstScreen:s,isCustomScreen:!1,stepName:e.stepName}),fl(r,this.autoFocus,s),o(this,Qc,"m",Ud).call(this,h)})),o(this,Qc,"m",Pd).call(this,d,h),r.querySelector(`[${Ka}="polling"]`)&&d(el,{})}));c?o(this,Qc,"m",gd).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${ja}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}ed=new WeakMap,td=new WeakMap,nd=new WeakMap,od=new WeakMap,hd=new WeakMap,fd=new WeakMap,vd=new WeakMap,md=new WeakMap,bd=new WeakMap,wd=new WeakMap,yd=new WeakMap,Ad=new WeakMap,Rd=new WeakMap,Qc=new WeakSet,id=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},rd=function(e,t,i){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=i,this.nativeCallbacks.screenResolve=n,o(this,Qc,"m",ad).call(this,"beforeScreen",{screen:e,context:t})}))}))},sd=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&o(this,Qc,"m",ad).call(this,"afterScreen",{screen:e})},ad=function(e,t){o(this,Qc,"m",Ld).call(this,"bridge",{type:e,payload:t})},ld=function({errorText:e,errorType:t}){const n=()=>{var n;let o=e;try{o=(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(`[${Ka}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",o)};this.addEventListener("screen-updated",n,{once:!0}),n()},cd=function(){var e,n,i;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,o=t(void 0===n?{}:n,["errorText","errorType"]),i=t(e,["screenState"]);return Object.assign(Object.assign({},i),{screenState:o})})),null===(n=this.stepState)||void 0===n||n.subscribe(o(this,Qc,"m",ld).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===(i=this.stepState)||void 0===i||i.subscribe(o(this,Qc,"m",dd).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})},dd=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=""}))})),fl(this.contentRootElement,this.autoFocus,!1))},ud=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")}))},pd=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,o=(e,t)=>ol.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!o(0,e)))));var n,o;const{screenState:{errorText:i,errorType:r}}=e;(i||r)&&(t.error={text:i,type:r}),e.action&&(t.action=e.action);const s=(e=>{if(!e)return;const t={};return Sl.forEach((({key:n,from:o})=>{const i=o(e);void 0!==i&&(t[n]=i)})),Object.keys(t).length?t:void 0})(e.screenState);return s&&(t.data=s),t})(t(r,["next","stepName"]));let c=yield o(this,Qc,"m",rd).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(o(this,fd,"f").call(this,c),s&&(s.isCustomScreen=c),o(this,hd,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),i(this,hd,c,"f"),c?this.stepState.unsubscribeAll():o(this,Qc,"m",cd).call(this)}c?(this.loggerWrapper.debug("Showing a custom screen"),o(this,Qc,"m",Id).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=c}))},gd=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")},kd=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)}))}},Sd=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,td,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Dl())){const{options:e,transactionId:r}=(yield o(this,yd,"f").call(this))||{};e&&r&&(o(this,Qc,"m",kd).call(this,s),i(this,td,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,o(this,td,"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)})))}}))},Id=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&o(this,Qc,"m",Ld).call(this,"ready",{}),t||o(this,Qc,"m",sd).call(this,n),o(this,Qc,"m",Ld).call(this,"page-updated",{screenName:n}),o(this,Qc,"m",Ld).call(this,"screen-updated",{screenName:n})},Cd=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,o;"slot"===t.localName||t.classList.contains("hidden")||(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},Od=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})),{})}))},xd=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)||[],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 i(this,nd,(()=>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 o=yield this.getFlowConfig(),r=[...o.clientScripts||[],...o.sdkScripts||[]];this.loadSdkScripts(r)})),d=()=>{var e;window.removeEventListener("pageshow",o(this,Ad,"f")),i(this,Ad,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),c())}),"f"),window.addEventListener("pageshow",o(this,Ad,"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:t})=>{t?(this.addEventListener("popupclosed",c,{once:!0}),e.setAttribute("loading","true"),s.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(u),"success"===this.flowStatus?(this.removeEventListener("popupclosed",c),l()):d())}))},jd=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>o(this,Qc,"m",Ed).call(this,e)))},Ed=function(e){e&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),o=`input-${e.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),e.appendChild(i),t.setAttribute("slot",o),this.appendChild(t)}))},Td=function(e){return n(this,void 0,void 0,(function*(){if(o(this,nd,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield o(this,nd,"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 i=[];for(const e of t)"function"==typeof e.refresh&&i.push(e.refresh());if(i.length>0)try{yield gl(5e3,Promise.all(i),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},$d=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var i;(null===(i=n.checkValidity)||void 0===i?void 0:i.call(n))&&o(this,Rd,"f").call(this,n,e,t)}))}))},_d=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=Bl();n[e]=t,ql(nl,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},Ud=function(e){var t;const n=null===(t=Kl(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const o=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),i=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);o&&i&&(i.replaceWith(o),o.appendChild(i))},Pd=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${Ea}]), [data-type="button"]:not([${Ea}]`).forEach((n=>{n.onclick=()=>{o(this,Rd,"f").call(this,n,e,t)}})),o(this,Qc,"m",$d).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${ja}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Ld=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Md=function(e,t,n){var o;const[i,r]=(null===(o=window.name)||void 0===o?void 0:o.split("|"))||[],s={data:{code:t,exchangeError:n},action:"code"};if("descope-wc"===i&&r){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",r);try{window.opener.postMessage(s,r)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(s),t.close()}try{window.close()}catch(e){}},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Wd);var Nd=Object.freeze({__proto__:null,default:Wd});const Dd=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},Fd=(e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Dd(e,e.offsetLeft-o,e.offsetTop-i,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 qd,zd,Vd,Hd,Kd,Jd,Bd,Gd,Xd,Yd,Zd;const Qd=document.createElement("template");Qd.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 eu=r(H)(HTMLElement);class tu extends eu{constructor(){super(),qd.add(this),zd.set(this,new Rl({messages:[]})),Vd.set(this,void 0),Hd.set(this,void 0),Kd.set(this,void 0),Jd.set(this,{resize:o(this,qd,"m",Zd).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Qd.content.cloneNode(!0)),i(this,Vd,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Hd,o(this,Vd,"f").querySelector(".content"),"f"),i(this,Kd,o(this,Vd,"f").querySelector(".header"),"f"),o(this,qd,"m",Bd).call(this)}updateData(e){o(this,zd,"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),Fd(o(this,Vd,"f"),o(this,Kd,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Jd,"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}})(o(this,Vd,"f")),o(this,Vd,"f").onresize=o(this,qd,"m",Yd).bind(this),o(this,zd,"f").subscribe(o(this,qd,"m",Gd).bind(this))}))}disconnectedCallback(){o(this,zd,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Jd,"f").resize)}}zd=new WeakMap,Vd=new WeakMap,Hd=new WeakMap,Kd=new WeakMap,Jd=new WeakMap,qd=new WeakSet,Bd=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'),o(this,Vd,"f").style.top="32px",o(this,Vd,"f").style.left=window.innerWidth-300-32+"px"},Gd=function(e){o(this,qd,"m",Xd).call(this,e),o(this,qd,"m",Yd).call(this)},Xd=function(e){o(this,Hd,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Yd=function(){o(this,Hd,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Zd=function(){const[e,t]=Dd(o(this,Vd,"f"),Number.parseInt(o(this,Vd,"f").style.left,10),Number.parseInt(o(this,Vd,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Vd,"f").style.top=`${t}px`,o(this,Vd,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",tu);var nu=Object.freeze({__proto__:null,default:tu});return na}();
|
|
5
|
+
this["descope-outbound-applications-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.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={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),(e=>"string"==typeof e?e:(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},l=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 o=e(n);return o[t]=!0,o}};var c,d,u,h;function p(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!p(r,s))return!1}else if(r!==s)return!1}return!0}let f=class{constructor(e={},{forceUpdate:t=!1}={}){c.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,c,"f")):e,n=Object.assign(Object.assign({},o(this,c,"f")),t);if(o(this,h,"f")||!p(o(this,c,"f"),n)){const e=o(this,c,"f");i(this,c,n,"f"),Object.freeze(o(this,c,"f")),setTimeout((()=>{Object.values(o(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,c,e,"f"),i(this,h,t,"f")}get current(){return Object.assign({},o(this,c,"f"))}subscribe(e){return i(this,u,o(this,u,"f")+1,"f"),o(this,d,"f")[o(this,u,"f")]=e,o(this,u,"f").toString()}unsubscribe(e){const t=!!o(this,d,"f")[e];return t&&delete o(this,d,"f")[e],t}unsubscribeAll(){return i(this,d,{},"f"),!0}};function g(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:""}}c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap;const v=["error","warn","info","debug"],m={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},b=l((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,m))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e||m),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return v.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),w="undefined"!=typeof localStorage,y="https://static.descope.com/pages",k="https://static2.descope.com/pages",I=w&&localStorage.getItem("base.content.url")||"",S=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,C=l((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)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),O=l((e=>{var t,n;const i=r(b,C)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const i=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(i,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})),E=e=>t=>{var n,i,s;const a=r(b,C,O)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,o(this,n,"m",i).bind(this))}async init(){var e;l.forEach((e=>o(this,n,"m",i).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,i=function(t,n){const o=e[t],i="function"==typeof o?o(t,n):o;i&&this.logger.error(i)},s};E.missingAttrValidator=S;const x=l((e=>{const t=r(E({"project-id":S}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),A=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),j="Trying the next fallback URL...",T=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(o){return null==n||n.debug(`Network error fetching URL ${e} [${o.message}], retrying...`),fetch(e,t)}};const R=l((e=>{var t,n,s,a,l,c,d;const u=r(b,x,A)(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=o(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];i(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;o(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o}={})=>{const i=Array.isArray(e)?e:[e];for(let e=0;e<i.length;e++){const r=i[e],s=e===i.length-1;try{const i=await T(r.toString(),t,{logger:n});if(i.ok)return null==o||o(e),null==n||n.debug(`Successfully fetched URL ${r}`),i;const a=`Error fetching URL ${r} [${i.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${j}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${j}`)}}})(r,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const r=I||this.baseStaticUrl;if(r)return o(this,t,"m",c).call(this,e,r);o(this,n,"f")!==this.baseUrl&&(i(this,n,this.baseUrl,"f"),i(this,s,void 0,"f"),o(this,a,"f").clear());const l=[];if(o(this,s,"f"))l.push(o(this,t,"m",c).call(this,e,o(this,s,"f"))),o(this,s,"f")===y&&l.push(o(this,t,"m",c).call(this,e,k));else{const n=this.baseUrl+"/pages";this.baseUrl&&!o(this,a,"f").has(n)&&l.push(o(this,t,"m",c).call(this,e,n)),o(this,a,"f").has(y)||l.push(o(this,t,"m",c).call(this,e,y)),l.push(o(this,t,"m",c).call(this,e,k))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o=y}){const i=new URL(o);return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.baseUrl=o,i}({projectId:this.projectId,filename:e,baseUrl:t})},d})),_=l((e=>{var t,n;const i=r(E({"project-id":S}))(e);return n=class extends i{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return o(this,t,"f").set(e,n),()=>{o(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(o(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=o(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),$=l((e=>{var t,n,s,a,l;const c=r(R,_,C)(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",o(this,t,"m",n).bind(this))}get config(){return o(this,s,"f")||i(this,s,o(this,a,"f").call(this),"f"),o(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){i(this,s,void 0,"f")},l})),P=l((e=>{var t,n,s,a,l,c,d;return d=class extends(r(C,b)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),"debug"===e&&o(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&o(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)),o(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),i(this,n,null,"f")},a=async function(){i(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return wa})),document.body.appendChild(o(this,n,"f"))},l=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},c=function(e,t){var i;e&&(null===(i=o(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},d})),U=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],L=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()}`},M=(e,t,n)=>new Promise(((o,i)=>{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"),i(e)},r.onload=()=>{r.setAttribute("status","loaded"),o(r)},r.src=t.toString(),document.body.appendChild(r)})),N=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},W=l((e=>{const t=r(b)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",o=[],i){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${i?" with SRI integrity check":""}`),(async(e,t)=>{for(const o of e){const{id:e,url:i,integrity:r}=o,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await N(s,r),o}catch(e){t(o,!0)}else try{return await M(e,i,r),o}catch(e){t(o,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,o="",i)=>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}/${o}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${L(a)}`};return i&&(l.integrity=i),[...e,l]}),[]))([...o,this.baseCdnUrl,...U],e,t,n,i),((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}"`)}))}}})),D="base.ui.components.url",F=w&&localStorage.getItem(D),q=l((e=>{var t,n,s,a,l,c,d;const u=r(b,$,W)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return o(this,a,"f")||i(this,a,o(this,t,"m",c).call(this),"f"),o(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=>o(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 o(this,t,"m",n).call(this),i=F?void 0:await o(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[F],i),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),z=l((e=>{var t,n,i;const s=r(C,O)(e);return i=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",o(this,t,"m",n).bind(this)),o(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},i}));class V{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const H=l((e=>{const t=r(z)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new V(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const o=[...e.adoptedStyleSheets||[]];o[t?"unshift":"push"](n),e.adoptedStyleSheets=o}}return n}}})),K="content-root",J="root",B=l((e=>{const t=r(H)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${J}">\n <div id="${K}"></div>\n </div>\n `,this.injectStyle(`\n #${J}, #${K} {\n height: 100%;\n }\n #${J} {\n position: relative;\n height: fit-content;\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(J)}}})),Y="descope-modal";var G;let X=class{constructor(e,t){G.set(this,void 0),this.nodeName="",i(this,G,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,G,"f"))}get ele(){var e,t;const n="function"==typeof o(this,G,"f")?o(this,G,"f").call(this):o(this,G,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};G=new WeakMap;let Z=class extends X{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}set theme(e){var t,n;e?null===(n=this.ele)||void 0===n||n.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}};var Q,ee,te,ne;let oe=class extends X{constructor(...e){super(...e),Q.add(this),ee.set(this,void 0),te.set(this,void 0),this.nodeName="descope-modal",o(this,Q,"m",ne).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)),o(this,Q,"m",ne).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,ee,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,ee,"f").content.cloneNode(!0)))}setContent(e){i(this,ee,e,"f"),this.reset()}remove(){var e,t;null===(e=o(this,te,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};ee=new WeakMap,te=new WeakMap,Q=new WeakSet,ne=function(){if(o(this,te,"f"))return;const e=this.ele;e&&(i(this,te,new MutationObserver((t=>{t.forEach(((n,o)=>{var i;const r="true"===n.oldValue,s=t[o+1]?t[o+1].oldValue:e.getAttribute("opened");r&&"true"!==s&&(null===(i=this.afterClose)||void 0===i||i.call(this))}))})),"f"),o(this,te,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};let ie=class extends X{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()}},re=class extends X{constructor(){super(...arguments),this.nodeName="descope-outbound-apps"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}get connectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("connect-flow-id"))||""}get disconnectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("disconnect-flow-id"))||""}onConnectClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("connect-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("connect-clicked",n)}}onDisconnectClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("disconnect-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("disconnect-clicked",n)}}};const se=l((e=>{var t,n;const i=r(C,B,q)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends oe{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(Y);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Y]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),ae="descope-notification";l((e=>{var t,n;const i=r(C,B,q)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ie{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ae);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(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([ae])}},t=new WeakMap,n}));const le="theme",ce=(e,t,n="")=>Object.entries(e).reduce(((e,[o,i])=>{if(!/^[a-zA-Z0-9-]+$/.test(o))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${o}`:o;if("object"==typeof i&&null!==i)return e+ce(i,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(i);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),"");function de(e,t){const n=Object.assign({},e);for(const[e,o]of Object.entries(t||{}))if(null!=o)if("object"==typeof o){if(0===Object.keys(o).length)continue;n[e]=de(n[e]||{},o)}else n[e]="string"==typeof o?(n[e]||"")+o:o;return n}const ue=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",he=l((e=>{const t=r(E({tenant:ue}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),pe=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',fe=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,b,w,y,k,I,S,x,A;const j=r(E({theme:pe}),he,R,C,q,$,B,O,H)(e);return A=class extends j{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),c.set(this,void 0),d.set(this,void 0),I.set(this,(()=>{o(this,t,"m",S).call(this),o(this,x,"f").call(this,"os"===this.getAttribute("theme"))})),x.set(this,(e=>{var n,i,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[s])||void 0===r||r.call(i,"change",(()=>o(this,t,"m",S).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")||le}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)),o(this,I,"f").call(this),await Promise.all([o(this,t,"m",p).call(this),o(this,t,"m",v).call(this),o(this,t,"m",b).call(this)]),o(this,t,"m",m).call(this),this.observeAttributes(["theme"],o(this,I,"f")),this.observeAttributes(["theme-override"],(()=>o(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{i(this,d,null,"f"),o(this,t,"m",v).call(this),o(this,t,"m",b).call(this)})),this.observeAttributes(["style-id"],(()=>{i(this,c,null,"f"),o(this,t,"m",y).call(this),o(this,t,"m",p).call(this),o(this,t,"m",b).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,I=new WeakMap,x=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,o,i,r,s,a;const l=null===(i=null===(o=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===o?void 0:o.colors)||void 0===i?void 0:i.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}"]{${ce({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(D))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(D),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 o(this,c,"f")||(i(this,c,o(this,t,"m",u).call(this),"f"),o(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,c,"f")},p=async function(){var e,r;const s=await o(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)||"");o(this,n,"f")?o(this,n,"f").replaceSync(a):i(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 o(this,d,"f")||i(this,d,o(this,t,"m",f).call(this),"f"),o(this,d,"f")},v=async function(){var e,n,r,a;if(!this.tenantId)return void(null===(e=o(this,s,"f"))||void 0===e||e.replaceSync(""));const l=await o(this,t,"a",g);if(!l)return void(null===(n=o(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)||"");o(this,s,"f")?o(this,s,"f").replaceSync(c):i(this,s,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=o(this,a,"f"))||void 0===e||e.replaceSync(""));const n=o(this,t,"m",l).call(this);o(this,a,"f")?o(this,a,"f").replaceSync(n):i(this,a,this.injectStyle(n),"f")},b=async function(){var e,n,i,r;const s=await o(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await o(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===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.components)||{},(null===(r=null==l?void 0:l.dark)||void 0===r?void 0:r.components)||{})}},w=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},y=async function(){const e=await o(this,t,"m",w).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},k=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},S=function(){o(this,t,"m",y).call(this),o(this,t,"m",k).call(this)},A}));var ge=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),ve=()=>Math.random().toString(36).substring(7).split("").join("."),me={INIT:`@@redux/INIT${ve()}`,REPLACE:`@@redux/REPLACE${ve()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ve()}`};function be(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 we(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 ye(e){let t=typeof e;return t=we(e),t}function ke(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${ye(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: '${ye(n)}'`);return n(ke)(e,t)}let o=e,i=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 i}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${ye(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(!be(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${ye(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: '${ye(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,i=o(i,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:me.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: '${ye(e)}`);o=e,h({type:me.REPLACE})},[ge]: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: '${ye(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[ge](){return this}}}}}function Ie(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Se(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const i=t[o];void 0===e[i]&&Ie(`No reducer provided for key "${i}"`),"function"==typeof e[i]&&(n[i]=e[i])}const o=Object.keys(n);let i,r;i={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:me.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:me.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 '${me.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 o=function(e,t,n,o){const i=Object.keys(t),r=n&&n.type===me.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===i.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!be(e))return`The ${r} has unexpected type of "${ye(e)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===me.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: "${i.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,i);o&&Ie(o)}let s=!1;const a={};for(let i=0;i<o.length;i++){const r=o[i],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||o.length!==Object.keys(e).length,s?a:e}}function Ce(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Oe(e){return be(e)&&"type"in e&&"string"==typeof e.type}var Ee=Symbol.for("immer-nothing"),xe=Symbol.for("immer-draftable"),Ae=Symbol.for("immer-state"),je=[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 Te(e,...t){{const n=je[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var Re=Object.getPrototypeOf;function _e(e){return!!e&&!!e[Ae]}function $e(e){return!!e&&(Ue(e)||Array.isArray(e)||!!e[xe]||!!e.constructor?.[xe]||De(e)||Fe(e))}var Pe=Object.prototype.constructor.toString();function Ue(e){if(!e||"object"!=typeof e)return!1;const t=Re(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)===Pe}function Le(e,t){0===Me(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Me(e){const t=e[Ae];return t?t.type_:Array.isArray(e)?1:De(e)?2:Fe(e)?3:0}function Ne(e,t){return 2===Me(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function We(e,t,n){const o=Me(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function De(e){return e instanceof Map}function Fe(e){return e instanceof Set}function qe(e){return e.copy_||e.base_}function ze(e,t){if(De(e))return new Map(e);if(Fe(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Ue(e)){if(!Re(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Ae];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const i=o[t],r=n[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[i]})}return Object.create(Re(e),n)}function Ve(e,t=!1){return Ke(e)||_e(e)||!$e(e)||(Me(e)>1&&(e.set=e.add=e.clear=e.delete=He),Object.freeze(e),t&&Le(e,((e,t)=>Ve(t,!0)))),e}function He(){Te(2)}function Ke(e){return Object.isFrozen(e)}var Je,Be={};function Ye(e){const t=Be[e];return t||Te(0,e),t}function Ge(){return Je}function Xe(e,t){t&&(Ye("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ze(e){Qe(e),e.drafts_.forEach(tt),e.drafts_=null}function Qe(e){e===Je&&(Je=e.parent_)}function et(e){return Je={drafts_:[],parent_:Je,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function tt(e){const t=e[Ae];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function nt(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Ae].modified_&&(Ze(t),Te(4)),$e(e)&&(e=ot(t,e),t.parent_||rt(t,e)),t.patches_&&Ye("Patches").generateReplacementPatches_(n[Ae].base_,e,t.patches_,t.inversePatches_)):e=ot(t,n,[]),Ze(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ee?e:void 0}function ot(e,t,n){if(Ke(t))return t;const o=t[Ae];if(!o)return Le(t,((i,r)=>it(e,o,t,i,r,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return rt(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let i=t,r=!1;3===o.type_&&(i=new Set(t),t.clear(),r=!0),Le(i,((i,s)=>it(e,o,t,i,s,n,r))),rt(e,t,!1),n&&e.patches_&&Ye("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function it(e,t,n,o,i,r,s){if(i===n&&Te(5),_e(i)){const s=ot(e,i,r&&t&&3!==t.type_&&!Ne(t.assigned_,o)?r.concat(o):void 0);if(We(n,o,s),!_e(s))return;e.canAutoFreeze_=!1}else s&&n.add(i);if($e(i)&&!Ke(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ot(e,i),t&&t.scope_.parent_||rt(e,i)}}function rt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ve(t,n)}var st={get(e,t){if(t===Ae)return e;const n=qe(e);if(!Ne(n,t))return function(e,t,n){const o=ct(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!$e(o)?o:o===lt(e.base_,t)?(ut(e),e.copy_[t]=ht(o,e)):o},has:(e,t)=>t in qe(e),ownKeys:e=>Reflect.ownKeys(qe(e)),set(e,t,n){const o=ct(qe(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=lt(qe(e),t),i=o?.[Ae];if(i&&i.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,o)&&(void 0!==n||Ne(e.base_,t)))return!0;ut(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!==lt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,ut(e),dt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=qe(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Te(11)},getPrototypeOf:e=>Re(e.base_),setPrototypeOf(){Te(12)}},at={};function lt(e,t){const n=e[Ae];return(n?qe(n):e)[t]}function ct(e,t){if(!(t in e))return;let n=Re(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Re(n)}}function dt(e){e.modified_||(e.modified_=!0,e.parent_&&dt(e.parent_))}function ut(e){e.copy_||(e.copy_=ze(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Le(st,((e,t)=>{at[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),at.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Te(13),at.set.call(this,e,t,void 0)},at.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Te(14),st.set.call(this,e[0],t,n,e[0])};function ht(e,t){const n=De(e)?Ye("MapSet").proxyMap_(e,t):Fe(e)?Ye("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Ge(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=o,r=st;n&&(i=[o],r=at);const{revoke:s,proxy:a}=Proxy.revocable(i,r);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:Ge()).drafts_.push(n),n}function pt(e){return _e(e)||Te(10,e),ft(e)}function ft(e){if(!$e(e)||Ke(e))return e;const t=e[Ae];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=ze(e,t.scope_.immer_.useStrictShallowCopy_)}else n=ze(e,!0);return Le(n,((e,t)=>{We(n,e,ft(t))})),t&&(t.finalized_=!1),n}var gt=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 o=this;return function(e=n,...i){return o.produce(e,(e=>t.call(this,e,...i)))}}let o;if("function"!=typeof t&&Te(6),void 0!==n&&"function"!=typeof n&&Te(7),$e(e)){const i=et(this),r=ht(e,void 0);let s=!0;try{o=t(r),s=!1}finally{s?Ze(i):Qe(i)}return Xe(i,n),nt(o,i)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===Ee&&(o=void 0),this.autoFreeze_&&Ve(o,!0),n){const t=[],i=[];Ye("Patches").generateReplacementPatches_(e,o,t,i),n(t,i)}return o}Te(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const i=this.produce(e,t,((e,t)=>{n=e,o=t}));return[i,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){$e(e)||Te(8),_e(e)&&(e=pt(e));const t=et(this),n=ht(e,void 0);return n[Ae].isManual_=!0,Qe(t),n}finishDraft(e,t){const n=e&&e[Ae];n&&n.isManual_||Te(9);const{scope_:o}=n;return Xe(o,t),nt(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Ye("Patches").applyPatches_;return _e(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},vt=gt.produce;gt.produceWithPatches.bind(gt),gt.setAutoFreeze.bind(gt),gt.setUseStrictShallowCopy.bind(gt),gt.applyPatches.bind(gt),gt.createDraft.bind(gt),gt.finishDraft.bind(gt);var mt=(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})}}},bt=(e,t,n)=>{const{memoize:o,memoizeOptions:i}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...i);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})}},wt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var yt=e=>Array.isArray(e)?e:[e];function kt(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 It(e,t){const n=[],{length:o}=e;for(let i=0;i<o;i++)n.push(e[i].apply(null,t));return n}var St="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Ct=0,Ot=1;function Et(){return{s:Ct,v:void 0,o:null,p:null}}function xt(e,t={}){let n=Et();const{resultEqualityCheck:o}=t;let i,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 o=e.get(n);void 0===o?(t=Et(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=Et(),e.set(n,t)):t=o}}const a=t;let l;if(t.s===Ot)l=t.v;else if(l=e.apply(null,arguments),r++,o){const e=i?.deref?.()??i;null!=e&&o(e,l)&&(l=e,0!==r&&r--);i="object"==typeof l&&null!==l||"function"==typeof l?new St(l):l}return a.s=Ot,a.v=l,l}return s.clearCache=()=>{n=Et(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function At(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,i=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=xt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=yt(c),f=yt(u),g=kt(e),v=l((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const b=d((function(){i++;const e=It(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...wt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:mt},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:bt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=It(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(b,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:l,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var jt=At(xt),Tt=Object.assign(((e,t=jt)=>{!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),o=t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,o)=>(e[n[o]]=t,e)),{})));return o}),{withTypes:()=>Tt});function Rt(e){return({dispatch:t,getState:n})=>o=>i=>"function"==typeof i?i(t,n,e):o(i)}var _t=Rt(),$t=Rt;((...e)=>{const t=At(...e)})(xt);var Pt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Ce:Ce.apply(null,arguments)},Ut=e=>e&&"function"==typeof e.match;function Lt(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Oe(t)&&t.type===e,n}function Mt(e){return"function"==typeof e&&"type"in e&&Ut(e)}function Nt(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 Wt=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 Dt(e){return $e(e)?vt(e,(()=>{})):e}function Ft(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function qt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function zt(e,t,n){const o=Vt(e,t,n);return{detectMutations:()=>Ht(e,t,o,n)}}function Vt(e,t=[],n,o="",i=new Set){const r={value:n};if(!e(n)&&!i.has(n)){i.add(n),r.children={};for(const i in n){const s=o?o+"."+i:i;t.length&&-1!==t.indexOf(s)||(r.children[i]=Vt(e,t,n[i],s))}}return r}function Ht(e,t=[],n,o,i=!1,r=""){const s=n?n.value:void 0,a=s===o;if(i&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:r};if(e(s)||e(o))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in o)l[e]=!0;const c=t.length>0;for(let i in l){const s=r?r+"."+i:i;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Ht(e,t,n.children[i],o[i],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Kt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||be(e)}function Jt(e,t="",n=Kt,o,i=[],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!=o?o(e):Object.entries(e),l=i.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(i.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=Jt(c,a,n,o,i,r),s))return s}return r&&Bt(e)&&r.add(e),!1}function Bt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Bt(t))return!1;return!0}function Yt(e){return"boolean"==typeof e}var Gt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=e??{};let r=new Wt;if(t&&(Yt(t)?r.push(_t):r.push($t(t.extraArgument))),n){let e={};Yt(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,o,i){return JSON.stringify(e,n(t,i),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(i,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,i):o.push(i),~n.indexOf(r)&&(r=t.call(this,i,r))}else n.push(r);return null==e?r:e.call(this,i,r)}},{isImmutable:o=qt,ignoredPaths:i,warnAfter:r=32}=e;const s=zt.bind(null,o,i);return({getState:e})=>{let n,o=e(),i=s(o);return a=>l=>{const c=Nt(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),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(o=e(),n=i.detectMutations(),i=s(o),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(o){let e={};Yt(o)||(e=o),r.push(function(e={}){{const{isSerializable:t=Kt,getEntries:n,ignoredActions:o=[],ignoredActionPaths:i=["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(!Oe(u))return c(u);const h=c(u),p=Nt(s,"SerializableStateInvariantMiddleware");return l||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=Jt(u,"",t,n,i,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 o=Jt(e.getState(),"",t,n,r,d);if(o){const{keyPath:e,value:t}=o;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(i){let e={};Yt(i)||(e=i),r.unshift(function(e={}){const{isActionCreator:t=Mt}=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},Xt=e=>t=>{setTimeout(t,e)},Zt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Xt(10),Qt=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new Wt(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let i=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?Zt:"callback"===e.type?e.queueNotification:Xt(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>i&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return i=!e?.meta?.RTK_autoBatch,r=!i,r&&(s||(s=!0,l(c))),o.dispatch(e)}finally{i=!0}}})})("object"==typeof n?n:void 0)),o};function en(e){const t=Gt(),{reducer:n,middleware:o,devTools:i=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!be(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=Se(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(l=o(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=Ce;i&&(c=Pt({trace:!0,..."object"==typeof i&&i}));const d=function(...e){return t=>(n,o)=>{const i=t(n,o);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:i.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=Ce(...a)(i.dispatch),{...i,dispatch:r}}}(...l),u=Qt(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 ke(a,r,c(...h))}function tn(e){const t={},n=[];let o;const i={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)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,i},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,i}};return e(i),[t,n,o]}function nn(...e){return t=>e.some((e=>((e,t)=>Ut(e)?e.match(t):e(t))(e,t)))}var on=["name","message","stack","code"],rn=class{constructor(e,t){this.payload=e,this.meta=t}_type},sn=class{constructor(e,t){this.payload=e,this.meta=t}_type},an=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of on)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},ln=(()=>{function e(e,t,n){const o=Lt(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=Lt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Lt(e+"/rejected",((e,t,o,i,r)=>({payload:i,error:(n&&n.serializeError||an)(e||"Rejected"),meta:{...r||{},arg:o,requestId:t,rejectedWithValue:!!i,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(i(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 rn(e,t),fulfillWithValue:(e,t)=>new sn(e,t)})).then((t=>{if(t instanceof rn)throw t;return t instanceof sn?o(t.payload,c,e,t.meta):o(t,c,e)}))])}catch(t){p=t instanceof rn?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(cn)})}}),{pending:i,rejected:r,fulfilled:o,settled:nn(r,o),typePrefix:e})}return e.withTypes=()=>e,e})();function cn(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 un(e,t){return`${e}/${t}`}function hn(e,t,n,o){function i(i,...r){let s=n.call(e,i);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return i.unwrapped=t,i}var pn=function({creators:e}={}){const t=e?.asyncThunk?.[dn];return function(e){const{name:n,reducerPath:o=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 i=("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(i),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=[],o]="function"==typeof e.extraReducers?tn(e.extraReducers):[e.extraReducers],i={...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,[o,i,r]=tn(t);if(function(e){return"function"==typeof e}(e))n=()=>Dt(e());else{const t=Dt(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...i.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(_e(e)){const o=n(e,t);return void 0===o?e:o}if($e(e))return vt(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in i)e.addCase(t,i[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}r.forEach((o=>{const r=i[o],s={reducerName:o,type:un(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},o,i){let r,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=o.reducer,s=o.prepare}else r=o;i.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Lt(e,s):Lt(e))}(s,r,a):function({type:e,reducerName:t},n,o,i){if(!i)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=i(e,r,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);l&&o.addCase(u.rejected,l);c&&o.addMatcher(u.settled,c);o.exposeCaseReducer(t,{fulfilled:s||fn,pending:a||fn,rejected:l||fn,settled:c||fn})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,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=Ft(d,this,{insert:()=>new WeakMap});return Ft(n,t,{insert:()=>{const n={};for(const[o,i]of Object.entries(e.selectors??{}))n[o]=hn(this,i,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 o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function fn(){}var gn="listenerMiddleware";Lt(`${gn}/add`),Lt(`${gn}/removeAll`),Lt(`${gn}/remove`);const vn=e=>l((t=>{const n=pn(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(b)(t)){constructor(...e){super(...e);const t=en({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),i=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{cn(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},r=Object.keys(o).reduce(((e,t)=>(e[t]=i(o[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(b(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}}));const mn=l((e=>{const t=r(E({"widget-id":S}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),bn=l((e=>{const t=r($,mn)(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]}}})),wn=l((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=g(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:""}})),yn=e=>l((t=>{var n,i,s;const a=r(R,mn,bn,wn)(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 o(this,n,"m",i).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,i=async function(t){var n;const o=await this.getWidgetConfig(),i=this.firstAvailableLocale(null!==(n=null==o?void 0:o.targetLocales)&&void 0!==n?n:[]);if(!i)return;const r=".html",s=t.endsWith(r)?t.slice(0,-5):t;try{const t=await this.fetchStaticResource(`${e}/${this.widgetId}/${s}-${i}${r}`,"text");return null==t?void 0:t.body}catch(e){return}},s})),kn=l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),In=w&&localStorage.getItem("base.debug.logs.url"),Sn=l((e=>{const t=r(E({"flow-id":S}))(e);return class extends t{get flowId(){return this.getAttribute("flow-id")}}}));function Cn(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 o=Math.floor(n/60);return o<24?`${o} hours`:`${Math.floor(o/24)} days`}const On=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g;const v=r(W,b,C,$,x,Sn)(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 o(this,n,"f")}updateTelemetryContext(e){if(o(this,n,"f"))try{o(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";i(this,f,o(this,t,"m",h).call(this).then((e=>o(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=o(this,f,"f"))&&void 0!==e?e:Promise.resolve()}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),o(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(o(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",[In]);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(i(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"),!o(this,n,"f").isReady())return this.logger.error("Telemetry manager failed to initialize (RUM client not ready)"),void i(this,n,null,"f");i(this,s,!0,"f"),this.logger.info("Telemetry initialized successfully"),e.expiration&&o(this,t,"m",c).call(this,e.expiration)}catch(e){this.logger.error("Failed to initialize telemetry:",e),i(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 o(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 (${Cn(n)}). Setting to maximum.`),this.logger.info(`Telemetry will expire at ${new Date(e).toISOString()} (in ${Cn(s)})`),i(this,a,setTimeout((()=>{this.logger.info("Telemetry expiration time reached, shutting down"),o(this,t,"m",d).call(this)}),s),"f")},d=function(){if(o(this,a,"f")&&(clearTimeout(o(this,a,"f")),i(this,a,null,"f")),o(this,n,"f"))try{this.logger.debug("Shutting down telemetry..."),o(this,n,"f").shutdown(),i(this,n,null,"f"),i(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,i=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.telemetry,r=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(r)&&r>0?r:1},process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN&&{guestRoleArn:process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN})},a=Object.assign(Object.assign(Object.assign({},s),i),{rumConfig:Object.assign(Object.assign({},s.rumConfig),null==i?void 0:i.rumConfig),capture:o(this,t,"m",p).call(this,null==i?void 0:i.capture)});return a.enabled&&!o(this,t,"m",u).call(this,a.rumConfig)&&(this.logger.warn("Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization."),a.enabled=!1),i||(a.expiration=Date.now()+3e5,this.logger.debug("No backend telemetry config present; applying a 5-minute safety cap on the session.")),a},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})),En=l((e=>{var n,i,r;return r=class extends(fe(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:l}=e,c=t(e,["flowId","client","form"]);return a(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:o(this,n,"m",i).call(this,l),client:Object.assign(Object.assign({},this.clientInput),s)},c))}},n=new WeakSet,i=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},r}));function xn(e){return new URLSearchParams(window.location.search).get(e)}const An=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)}))}))},jn=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}}),Tn=ln("outboundApps/load",((e,{extra:{api:t}})=>t.outboundApps.getAllOutboundApps())),Rn=An(Tn)({onFulfilled:(e,t)=>{var n;e.outboundAppsList.data=null===(n=t.payload)||void 0===n?void 0:n.apps}},jn((e=>e.outboundAppsList))),_n={action:Tn,reducer:Rn},$n=ln("outboundApps/getConnectedOutboundApps",((e,{extra:{api:t}})=>t.outboundApps.getConnectedOutboundApps(e))),Pn=An($n)({onFulfilled:(e,t)=>{var n;e.connectedOutboundAppsIds.data=null===(n=t.payload)||void 0===n?void 0:n.appIds}},jn((e=>e.connectedOutboundAppsIds))),Un={action:$n,reducer:Pn},Ln={outboundAppsList:{data:[],loading:!1,error:null},connectedOutboundAppsIds:{data:[],loading:!1,error:null},allowedAppsIds:{data:void 0},me:{loading:!1,error:null,data:{}}};class Mn extends Error{}function Nn(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 Wn(e,t){if("string"!=typeof e)throw new Mn("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,o=e.split(".")[n];if("string"!=typeof o)throw new Mn(`Invalid token specified: missing part #${n+1}`);let i;try{i=Nn(o)}catch(e){throw new Mn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new Mn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Mn.prototype.name="InvalidTokenError";var Dn={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},sso:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const Fn="<region>",qn=`https://api.${Fn}descope.com`,zn=6e5,Vn=()=>{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")}},Hn=[503,520,521,522,524,530],Kn=[100,5e3,5e3],Jn=e=>new Promise((t=>setTimeout(t,e))),Bn=e=>async function(...t){let n=await e(...t),o=0;for(;Hn.includes(n.status)&&o<Kn.length;)await Jn(Kn[o]),n=await e(...t),o++;o>0&&(n.retries=o);const i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n};let Yn;const Gn=()=>{if(Yn)return Yn;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 Yn=`${t}-${n}`,Yn};var Xn;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(Xn||(Xn={}));const Zn=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(Fn,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{r=`${r}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return r},Qn=(...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)),{})),eo={"Content-Type":"application/json"},to=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},no=(e,t)=>{const n={"x-descope-sdk-session-id":Gn(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.69.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},oo=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var io=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||qn,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=>Vn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await Bn(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return Vn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:Bn(n)})(i,a),d=async e=>{var i;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:Qn(to(t,g),no(t,o),(null==n?void 0:n.baseHeaders)||{},oo(v)?eo:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const b=await c(Zn({path:d,baseUrl:l,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==b?void 0:b.clone()),null==r?void 0:r.transformResponse){const e=await b.json(),t=(w=(null===(i=b.headers)||void 0===i?void 0:i.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function o(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function i(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;o();)if(","===e.charAt(n)){for(s=n,n+=1,o(),a=n;n<e.length&&i();)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}(w).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.assign({},b),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}var w;return b};return{get:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Xn.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Xn.post,token:i}),patch:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Xn.patch,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Xn.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Xn.delete,token:o}),hooks:r,buildUrl:(e,n)=>Zn({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.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}}))},ro=429;function so(e,t,n){var o;let i=ao(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i.dct)===t)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function ao(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Wn(e)}function lo(e){const{exp:t}=ao(e);return(new Date).getTime()/1e3>t}function co(e){let t=ao(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function uo(e,t){return so(e,t,"permissions")}function ho(e,t){return so(e,t,"roles")}const po=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function fo(e,t){var n;const o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=r:(i.error=r,o.status===ro&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}function go(e){var t;return(null===(t=ao(e))||void 0===t?void 0:t.dct)||""}const vo=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),mo=(e,t)=>(n=t)=>t=>{const o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.join(" OR "))},bo=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),wo=e=>t=>e.test(t),yo=wo(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),ko=wo(/^\+[1-9]{1}[0-9]{3,14}$/),Io=vo(yo,'"{val}" is not a valid email'),So=vo(ko,'"{val}" is not a valid phone number'),Co=vo((e=>e.length>=1),"Minimum length is 1");const Oo=vo((e=>"string"==typeof e),"Input is not a string"),Eo=vo((e=>Array.isArray(e)),"Input is not an array"),xo=vo((e=>"boolean"==typeof e),"Input is not a boolean"),Ao=vo((e=>void 0===e),"Input is defined"),jo=mo([Oo(),Ao()],"Input is not a string or undefined"),To=mo([Eo(),xo()],"Input is not an array or boolean"),Ro=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>bo(...e).validate(n[t]))),t(...n)),_o=e=>[Oo(`"${e}" must be a string`)],$o=e=>[jo(`"${e}" must be string or undefined`)],Po=e=>[Oo(`"${e}" must be a string`),Co(`"${e}" must not be empty`)],Uo=e=>[Oo(`"${e}" must be a string`),Io()],Lo=e=>[Oo(`"${e}" must be a string`),So()],Mo=Ro(Po("accessKey")),No=e=>({exchange:Mo(((t,n)=>fo(e.post(Dn.accessKey.exchange,{loginOptions:n},{token:t}))))}),Wo=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e),Do=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||zn,zn)});var Fo,qo;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Fo||(Fo={})),function(e){e.email="email"}(qo||(qo={}));const zo=Object.assign(Object.assign({},Fo),qo);var Vo;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Vo||(Vo={}));const Ho=Po("loginId"),Ko=Ro(Po("token")),Jo=Ro(Ho),Bo=Ro(Po("pendingRef")),Yo=Ro(Ho,Uo("email")),Go=e=>({verify:Ko((t=>fo(e.post(Dn.enchantedLink.verify,{token:t})))),signIn:Jo(((n,o,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return fo(e.post(po(Dn.enchantedLink.signIn,zo.email),{loginId:n,URI:o,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:Jo(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return fo(e.post(po(Dn.enchantedLink.signUpOrIn,zo.email),{loginId:n,URI:o,loginOptions:s,providerId:r}))})),signUp:Jo(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return fo(e.post(po(Dn.enchantedLink.signUp,zo.email),{loginId:n,URI:o,user:i,loginOptions:a,providerId:s}))})),waitForSession:Bo(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Do(n);let s;const a=setInterval((async()=>{const n=await e.post(Dn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(fo(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Yo(((t,n,o,i,r)=>fo(e.post(Dn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),Xo=Ro(Po("flowId")),Zo=Ro(Po("executionId"),Po("stepId"),Po("interactionId")),Qo=e=>({start:Xo(((t,n,o,i,r,s,a,l=!1)=>fo(e.post(Dn.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:Zo(((t,n,o,i,r,s,a=!1)=>fo(e.post(Dn.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s,isCustomScreen:a}))))}),ei=Po("loginId"),ti=Ro(Po("token")),ni=Ro(ei),oi=Ro(ei,Lo("phone")),ii=Ro(ei,Uo("email")),ri=Object.keys(zo).filter((e=>e!==Fo.voice&&e!==Fo.im)),si=e=>({verify:ti((t=>fo(e.post(Dn.magicLink.verify,{token:t})))),signIn:ri.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:ni(((n,i,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return fo(e.post(po(Dn.magicLink.signIn,o),{loginId:n,URI:i,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:ri.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:ni(((n,i,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return fo(e.post(po(Dn.magicLink.signUp,o),{loginId:n,URI:i,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:ri.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:ni(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return fo(e.post(po(Dn.magicLink.signUpOrIn,o),{loginId:n,URI:i,loginOptions:a,providerId:s}))}))})),{}),update:{email:ii(((t,n,o,i,r)=>fo(e.post(Dn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(Fo).filter((e=>e!==Fo.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:oi(((t,o,i,r,s)=>fo(e.post(po(Dn.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var ai;!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"}(ai||(ai={}));const li=Ro(Po("code")),ci=e=>({start:Object.assign(((t,n,o,i,r)=>fo(e.post(Dn.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:i}))),Object.keys(ai).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i,r)=>fo(e.post(Dn.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:i}))})),{})),exchange:li((t=>fo(e.post(Dn.oauth.exchange,{code:t})))),startNative:(t,n,o)=>fo(e.post(Dn.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>fo(e.post(Dn.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>fo(e.get(Dn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>fo(e.post(Dn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>fo(e.post(Dn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),di=Po("appId"),ui=Ro(di),hi=e=>({connect:ui(((t,n,o)=>{const i=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,fo(e.post(Dn.outbound.connect,{appId:t,tenantId:i,tenantLevel:r,options:n},{token:o}))}))}),pi=Po("loginId"),fi=Ro(pi,Po("code")),gi=Ro(pi),vi=Ro(pi,Lo("phone")),mi=Ro(pi,Uo("email")),bi=e=>({verify:Object.keys(zo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:fi(((t,o)=>fo(e.post(po(Dn.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(zo).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:gi(((n,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return fo(e.post(po(Dn.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(zo).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:gi(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return fo(e.post(po(Dn.otp.signUp,o),{loginId:n,user:i,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(zo).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:gi(((n,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return fo(e.post(po(Dn.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:mi(((t,n,o,i)=>fo(e.post(Dn.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(Fo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vi(((t,o,i,r)=>fo(e.post(po(Dn.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),wi=Ro(Po("tenant")),yi=Ro(Po("code")),ki=e=>({start:wi(((t,n,o,i,r,s,a,l)=>fo(e.post(Dn.sso.start,o||{},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})},i&&{token:i}))))),exchange:yi((t=>fo(e.post(Dn.sso.exchange,{code:t}))))}),Ii=Po("loginId"),Si=Ro(Ii,Po("code")),Ci=Ro(Ii),Oi=Ro(Ii),Ei=e=>({signUp:Ci(((t,n)=>fo(e.post(Dn.totp.signUp,{loginId:t,user:n})))),verify:Si(((t,n,o,i)=>fo(e.post(Dn.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),update:Oi(((t,n)=>fo(e.post(Dn.totp.update,{loginId:t},{token:n}))))}),xi=Po("loginId"),Ai=Po("newPassword"),ji=Ro(xi,Po("password")),Ti=Ro(xi),Ri=Ro(xi,Ai),_i=Ro(xi,Po("oldPassword"),Ai),$i=e=>({signUp:ji(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return fo(e.post(Dn.password.signUp,{loginId:n,password:o,user:i,loginOptions:a,providerId:s}))})),signIn:ji(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return fo(e.post(Dn.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:r}))})),sendReset:Ti(((t,n,o)=>fo(e.post(Dn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Ri(((t,n,o)=>fo(e.post(Dn.password.update,{loginId:t,newPassword:n},{token:o})))),replace:_i(((t,n,o)=>fo(e.post(Dn.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>fo(e.get(Dn.password.policy))}),Pi=_o("loginId"),Ui=Po("loginId"),Li=_o("origin"),Mi=Ro(Ui,Li,Po("name")),Ni=Ro(Ui,Li),Wi=Ro(Pi,Li),Di=Ro(Ui,Li,$o("token")),Fi=Ro(Po("transactionId"),Po("response")),qi=e=>({signUp:{start:Mi(((t,n,o,i,r)=>fo(e.post(Dn.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,loginOptions:r,passkeyOptions:i})))),finish:Fi(((t,n)=>fo(e.post(Dn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Wi(((t,n,o,i,r)=>fo(e.post(Dn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:Fi(((t,n)=>fo(e.post(Dn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ni(((t,n,o,i)=>fo(e.post(Dn.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:o}))))},update:{start:Di(((t,n,o,i,r)=>fo(e.post(Dn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i,mfa:r},{token:o})))),finish:Fi(((t,n)=>fo(e.post(Dn.webauthn.update.finish,{transactionId:t,response:n}))))}}),zi=_o("loginId"),Vi=Ro(zi),Hi=Ro(Po("pendingRef")),Ki=e=>({signUpOrIn:Vi(((n,o={})=>{var{providerId:i}=o,r=t(o,["providerId"]);return fo(e.post(Dn.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:i}))})),signUp:Vi(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return fo(e.post(Dn.notp.signUp,{loginId:n,user:o,providerId:r,loginOptions:s}))})),signIn:Vi(((n,o={},i)=>{var{providerId:r}=o,s=t(o,["providerId"]);return fo(e.post(Dn.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:i}))})),waitForSession:Hi(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Do(n);let s;const a=setInterval((async()=>{const n=await e.post(Dn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(fo(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Ji=Ro(Po("token")),Bi=Ro($o("token"));var Yi,Gi=Ro([(Yi=Po("projectId"),vo(((e,t)=>n=>bo(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let i=0,r=e===Object(e)?e:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,e)))("projectId",Yi))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=io({baseUrl:o,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:i,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:No(l),otp:bi(l),magicLink:si(l),enchantedLink:Go(l),oauth:ci(l),outbound:hi(l),sso:ki(l),saml:ki(l),totp:Ei(l),notp:Ki(l),webauthn:qi(l),password:$i(l),flow:Qo(l),refresh:Bi(((e,t,n,o)=>{const i={};n&&(i.externalToken=n);const r=o?Dn.tryRefresh:Dn.refresh;return fo(l.post(r,i,{token:e,queryParams:t}))})),selectTenant:Ro([Oo("tenantId")],[jo('"token" must be string or undefined')])(((e,t)=>fo(l.post(Dn.selectTenant,{tenant:e},{token:t})))),logout:Bi((e=>fo(l.post(Dn.logout,{},{token:e})))),logoutAll:Bi((e=>fo(l.post(Dn.logoutAll,{},{token:e})))),me:Bi((e=>fo(l.get(Dn.me,{token:e})))),myTenants:Ro([To('"tenants" must a string array or a boolean')],[jo('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,fo(l.post(Dn.myTenants,n,{token:t}))})),history:Bi((e=>fo(l.get(Dn.history,{token:e})))),isJwtExpired:Ji(lo),getTenants:Ji(co),getJwtPermissions:Ji(uo),getJwtRoles:Ji(ho),getCurrentTenant:Ji(go),httpClient:l};var l})),Xi=Object.assign(Gi,{DeliveryMethods:zo});
|
|
6
|
+
/*! js-cookie v3.0.8 | MIT */function Zi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)"__proto__"!==o&&(e[o]=n[o])}return e}var Qi=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=Zi({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in o||(o[a]=t.read(s,a)),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",Zi({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Zi({},this.attributes,t))},withConverter:function(t){return e(Zi({},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 er={default:"endpoint"},tr="Blocked by CSP",nr="The endpoint parameter is not a valid URL",or="Failed to load the JS script of the agent",ir="9319";function rr(e,t){var n,o,i,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||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,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===tr||s===nr)n.exclude(),r=0;else if(s===ir)n.exclude();else if(s===or){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!i.has(l)&&(i.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+o()-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,o=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,i=t[0],r=t[1];return(o=r,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(i)}))}))};return u(c).then((function(e){return[e,a]}))}var sr="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",ar=sr;function lr(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:sr,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(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 rr(e,cr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===ir?new Error(or):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function cr(e){return function(e,t,n){var o,i=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),i=t.blockedURI;i!==n.href&&i!==n.protocol.slice(0,-1)&&i!==n.origin||(o=t,a())};i.addEventListener(r,s);var a=function(){return i.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(),o)return n(o);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(nr);var o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(or))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(tr)})).then(dr)}function dr(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(ir);return n}const ur="3.2.0",hr="undefined"!=typeof window,pr=Math.pow(2,31)-1,fr=`https://descopecdn.com/npm/oidc-client-ts@${ur}/dist/browser/oidc-client-ts.min.js`,gr=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${ur}/dist/browser/oidc-client-ts.min.js`,vr=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let mr;const br=e=>{try{return Wn(e).exp}catch(e){return null}},wr=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:br(n)},yr=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?br(o):void 0)},kr=e=>{const{access_token:n,id_token:o,refresh_token:i,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:o,refreshJwt:e.refreshJwt||i,sessionExpiration:e.sessionExpiration||yr(e),cookieExpiration:e.cookieExpiration||wr(e)},s)},Ir=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Sr=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 kr(n)},Cr=()=>hr&&!!window.descopeBridge,Or=(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 vr.includes(n)},Er=void 0!==mr||hr&&void 0!==window.localStorage,xr=(e,t)=>{var n,o;return null===(o=null===(n=mr||hr&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},Ar=e=>{var t,n;return null===(n=null===(t=mr||hr&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},jr=e=>{var t,n;return null===(n=null===(t=mr||hr&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},Tr=e=>{var t,n,o,i,r;return null!==(r=null!==(n=null===(t=null==mr?void 0:mr.key)||void 0===t?void 0:t.call(mr,e))&&void 0!==n?n:hr&&(null===(i=null===(o=window.localStorage)||void 0===o?void 0:o.key)||void 0===i?void 0:i.call(o,e)))&&void 0!==r?r:null},Rr=e=>{var t,n;return hr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},_r=e=>{var t,n;try{hr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},$r=(...e)=>{console.debug(...e)},Pr=(...e)=>{console.warn(...e)},Ur="DS",Lr="DSR",Mr="DSI",Nr="DSRCN";function Wr(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=Dr(o);Qi.set(e,t,{path:i,domain:c?o:void 0,expires:l,sameSite:r,secure:a})}}function Dr(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 Fr=e=>(null==e?void 0:e.cookieName)||Ur,qr=e=>(null==e?void 0:e.cookieName)||Lr;function zr(e="",t){return Qi.get(qr(t))||Ar(`${e}${Lr}`)||""}function Vr(e="",t){return Qi.get(Fr(t))||Ar(`${e}${Ur}`)||""}function Hr(e=""){return Ar(`${e}${Mr}`)||""}function Kr(e="",t,n,o){jr(`${e}${Lr}`),jr(`${e}${Ur}`),jr(`${e}${Mr}`),jr(`${e}${Nr}`);const i=Fr(t);Qi.remove(i,null==o?void 0:o.session);const r=qr(n);Qi.remove(r,null==o?void 0:o.refresh)}const Jr=(e,t,n)=>o=>{const i=Object.assign(o,{token:o.token||zr(e,t)});if(!n){const t=function(e=""){return Ar(`${e}${Nr}`)}(e);t&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return Ar(`${e}DTD`)||""}(e);return r&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-trusted-device-token":r})),i},Br=hr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Yr="vsid",Gr="vrid",Xr="fp",Zr=(e=!1)=>{const t=Ar(Xr);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Qr=async(e,t=Br)=>{try{if(Zr())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=lr({apiKey:e,endpoint:[o.toString(),er],scriptUrlPattern:[r,ar]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Yr]:e,[Gr]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};xr(Xr,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},es=e=>{const t=Zr(!0);return t&&e.body&&(e.body.fpData=t),e},ts="descopeFlowNonce",ns="X-Descope-Flow-Nonce",os="/v1/flow/start",is="/v1/flow/next",rs=(e,t=ts)=>`${t}${e}`,ss=(e,t=ts)=>{try{const n=rs(e,t),o=Ar(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(as(e,t),null):{value:i.value,seq:i.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},as=(e,t=ts)=>{try{const n=rs(e,t);jr(n)}catch(e){console.error("Error removing flow nonce:",e)}},ls=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},cs=e=>{var t;return e.path===is&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?ls(e.body.executionId):null},ds="dls_last_user_login_id",us="dls_last_user_display_name",hs=e=>xr(ds,e),ps=()=>Ar(ds),fs=()=>Ar(us),gs=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=ps(),r=fs();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)},vs="DSLI",ms=e=>async(...t)=>{const n=await e(...t);return _r(vs),n};function bs(){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 ws(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Es(n.publicKey.challenge),n.publicKey.user.id=Es(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Es(e.id)})),n}(e);try{return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:xs(n.rawId),type:n.type,response:{attestationObject:xs(n.response.attestationObject),clientDataJSON:xs(n.response.clientDataJSON)}})}catch(e){throw await Is(e,t,!0)}var n}async function ys(e){const t=Cs(e);try{return Os(await navigator.credentials.get(t))}catch(e){throw await Is(e,t,!1)}}async function ks(e,t){const n=Cs(e);n.signal=t.signal,n.mediation="conditional";try{return Os(await navigator.credentials.get(n))}catch(e){throw await Is(e,n,!1)}}async function Is(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var o,i;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 Ss())return"webauthn_unsupported";const s="platform"===(null===(i=null===(o=null==t?void 0:t.publicKey)||void 0===o?void 0:o.authenticatorSelection)||void 0===i?void 0:i.authenticatorAttachment);return n&&s&&!await Ss(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function Ss(e=!1){var t,n;if(!hr)return Promise.resolve(!1);if(Cr()){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 o=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return o&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():o}function Cs(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Es(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Es(e.id)})),n}function Os(e){return JSON.stringify({id:e.id,rawId:xs(e.rawId),type:e.type,response:{authenticatorData:xs(e.response.authenticatorData),clientDataJSON:xs(e.response.clientDataJSON),signature:xs(e.response.signature),userHandle:e.response.userHandle?xs(e.response.userHandle):void 0}})}function Es(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function xs(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var As,js=(As=e=>({async signUp(t,n,o){const i=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await ws(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await ys(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(t,n){var o;const i=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const t=await ws(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await ys(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,t)}},async update(t,n,o){const i=await e.webauthn.update.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await ws(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:ws,get:ys,isSupported:Ss,conditional:ks}}),(...e)=>{const t=As(...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 Ts="/fedcm/config";async function Rs(e,t){var n;try{await _s(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function _s(e,t){var n,o;const i=await async function(e,t="google",n,o,i){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(i&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==i||i(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!i.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+i.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+i.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}var $s=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Ss(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});let Ps;const Us=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const i=t();if(i)return n(i);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",(()=>{Us(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Ls=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{Ps||(Ps=(async()=>{try{return require("oidc-client-ts")}catch(e){return Us([fr,gr],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await Ps;if(!o)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 i({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new o(d),stateUserKey:l}})(e,t,n)),{client:o,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await o(),s=await i.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)))),xr(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 i;const{client:r}=await o(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await o(),s=(e=>{const t=Ar(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 i.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:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||Hr(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return jr(i),t||window.location.replace(s),r}}},Ms=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,mr=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return hr?(o&&i&&Qr(o).catch((()=>null)),e(Ir(r,{beforeRequest:es}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.51.6"},t.baseHeaders)}))),(e=>t=>{const n=bs(),o=bs(),i=bs(),r=bs(),s=e(Ir(t,{afterRequest:async(e,t)=>{if(Or(e,t))$r("Session invalidated, notifying subscribers with empty values"),o.pub(null),i.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await Sr(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&i.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await Sr(t);s&&o.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=Wo(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return o.pub(null),i.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:o.sub,onUserChange:i.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var o;const{enableFlowNonce:i=!0,nonceStoragePrefix:r=ts}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return e(s);((e=ts)=>{try{if(!Er)return;for(let i=0;i<(void 0,n=void 0,void 0,null!==(o=null!==(t=null==mr?void 0:mr.length)&&void 0!==t?t:hr&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);i++){const t=Tr(i);if(t&&t.startsWith(e)){const n=Ar(t);if(n)try{JSON.parse(n).expiry<Date.now()&&jr(t)}catch(e){jr(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(r);const a=e(Ir(s,{afterRequest:async(e,t)=>{var n;if(e.path!==os&&e.path!==is)return;const{nonce:o,seq:i,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(ns),o=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 o=Number(n);return Number.isSafeInteger(o)?o:void 0})(n);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=cs(e)),{nonce:n,seq:o,executionId:ls(i)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!o||!s)return;const a=e.path===os,l=null===(n=ss(s,r))||void 0===n?void 0:n.seq;!a&&void 0!==i&&void 0!==l&&i<=l||((e,t,n,o=ts,i)=>{try{const r=rs(e,o),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:i};xr(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,o,a,r,null!=i?i:a?void 0:l)},beforeRequest:e=>{if(e.path===is){const t=cs(e);if(t){const n=((e,t=ts)=>{var n,o;return null!==(o=null===(n=ss(e,t))||void 0===n?void 0:n.value)&&void 0!==o?o:null})(t,r);n&&(e.headers=e.headers||{},e.headers[ns]=n)}}return e}}));if(null===(o=a.flow)||void 0===o?void 0:o.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const o=e;let i;e=new Promise((e=>{i=e})),await o;try{return await t(...n)}finally{i()}}}return a}),(e=>t=>{const n=e(Ir(t,{afterRequest:async(e,t)=>{if(Or(e,t))return void _r(vs);const n=await Sr(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,o;try{hr&&(null===(o=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o||o.call(n,e,t))}catch(e){}})(vs,String(n.sessionExpiration))}}));return Wo(n,["logout","logoutAll","oidc.logout"],ms)}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);const r=!!o,s="object"==typeof o&&(null==o?void 0:o.customActivityTracking);if(!r||Cr())return Object.assign(e(i),{markUserActive:()=>{Pr("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&&($r("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),hr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&($r("Expiration time passed, refreshing session"),f.refresh(zr()||d))}));const f=e(Ir(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i,nextRefreshSeconds:r}=await Sr(t);if(Or(e,t))$r("Session invalidated, canceling all timers"),a();else if(n||i){if(c=((e,t)=>{if(t)return new Date(1e3*t);$r("Could not extract expiration time from session token, trying to decode the token");try{const t=Wn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!c)return void $r("Could not extract expiration time from session token");d=o,h=r>0;const e=((e,t)=>{let n;var o;return t>0?(n=1e3*t,$r(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>pr&&($r(`Timeout is too large (${n}ms), setting it to ${pr}ms`),n=pr),n})(c,r);if(a(),e<=2e4)return void $r("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});$r(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(hr&&"hidden"===document.visibilityState)$r("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return $r("Skipping refresh due to timer - user is idle"),void(p=!0);$r("Refreshing session due to timer"),f.refresh(zr()||o)}}),e)}}}));return Object.assign(Wo(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return $r("Clearing all timers"),a(),n})),{markUserActive:u?()=>{$r("markUserActive() called"),h||$r("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&($r("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(zr()||d))}:()=>{Pr("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(r),{getLastUserLoginId:ps,getLastUserDisplayName:fs});const s=e(Ir(r,{afterRequest:async(e,t)=>{var n;const{userInfo:o,lastAuth:i}=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=kr((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==o?void 0:o.loginIds)||void 0===n?void 0:n[0],s=null==o?void 0:o.name;r?(hs(r),(e=>{xr(us,e)})(s)):(null==i?void 0:i.loginId)&&hs(i.loginId)}}));let a=Wo(s,["flow.start"],gs);return a=Wo(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(jr(ds),jr(us)),o})(i)),Object.assign(a,{getLastUserLoginId:ps,getLastUserDisplayName:fs})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!o||!hr)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(Ir(Object.assign({refreshCookieName:a},l),{beforeRequest:Jr(s,r,a),afterRequest:async(e,t)=>{if(Or(e,t))$r("Session invalidated, clearing persisted tokens"),Kr(s,i,r,c);else{const e=await Sr(t);e.cookieName?xr(`${s||""}${Nr}`,e.cookieName):e.refreshJwt&&jr(`${s||""}${Nr}`);const n=((e={},t=!1,n="",o=!1)=>{var i,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d}=e;let u;if(c)if(o){jr(`${n}${Lr}`);const t=o.sameSite||"Strict",s=null===(i=o.secure)||void 0===i||i,a=null!==(r=o.domain)&&void 0!==r?r:e.cookieDomain,l=qr(o);s&&"https:"!==window.location.protocol&&Pr("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});Wr(l,c,d);const h=Dr(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=qr(o);Qi.remove(e),xr(`${n}${Lr}`,c)}if(l)if(t){const n=t.sameSite||"Strict",o=null===(s=t.secure)||void 0===s||s,i=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=Fr(t);o&&"https:"!==window.location.protocol&&Pr("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:o,cookieDomain:i});Wr(r,l,c);const d=Dr(i);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?i:void 0}})}else xr(`${n}${Ur}`,l);return e.idToken&&xr(`${n}${Mr}`,e.idToken),d&&xr(`${n}DTD`,d),u})(e,i,s,r);n&&(c=n)}}})),u=Wo(d,["logout","logoutAll","oidc.logout"],((e,t,n,o)=>i=>async(...r)=>{const s=await i(...r);return Kr(e,t,n,null==o?void 0:o()),s})(s,i,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>zr(s,r),getSessionToken:()=>Vr(s,i),getIdToken:()=>Hr(s)})}))((e=>{const t=Xi(e),n=Ls(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,i)=>{var r;if(Cr())return $r(`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(o),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(i&&hr&&void 0!==window.localStorage&&!Rr(vs)&&!Ar(ds)&&!Rr("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Vr(),a=zr();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){$r("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:s?"t":"f",dcr:a?"t":"f"},l,i)},logout:async o=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:o}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(o)},flow:$s(t),webauthn:js(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){Rs(o,e)},requestAuthentication(e){Rs(o,e)}},async oneTap(e,t,n,i,r){await _s(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:i,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(i+Ts),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>hr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+Ts);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var o,i})),Ns={allOutboundApps:"/v1/mgmt/outbound/apps",connectedOutboundApps:"/v1/mgmt/outbound/apps-with-user-token"},Ws={me:"/v1/auth/me"},Ds=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)})),Fs=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"appId1",name:"Application 1",description:"Description"},{id:"appId2",name:"Application 2",description:"Description"},{id:"appId3",name:"Application 3",description:"Description"}]})}))})),qs=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:["outboundApp3"]})}))})),zs=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({userId:"user-1"})}))})),Vs=({httpClient:e,mock:t})=>({getAllOutboundApps:()=>n(void 0,void 0,void 0,(function*(){if(t)return Fs();const n=yield e.get(Ns.allOutboundApps);return yield Ds(n),n.json()})),getConnectedOutboundApps:o=>n(void 0,[o],void 0,(function*({userId:n,tenantId:o}){if(t)return qs();const i=yield e.get(Ns.connectedOutboundApps,{queryParams:o?{userId:n,tenantId:o}:{userId:n}});return yield Ds(i),i.json()}))}),Hs=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return zs();const n=yield e.get(Ws.me);return yield Ds(n),n.json()}))}),Ks=l((e=>{var t,s,a,l;const c=r(x,O,b,kn,A)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||le}get api(){return o(this,s,"f")||o(this,t,"m",a).call(this),o(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"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,s,((e,t,n)=>{const o=Ms(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.5.14"}}));return{outboundApps:Vs({httpClient:o.httpClient,mock:t}),user:Object.assign({},Hs({httpClient:o.httpClient,mock:t}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},l})),Js=ln("users/me",((e,{extra:{api:t}})=>t.user.me())),Bs={action:Js,reducer:An(Js)({onFulfilled:(e,t)=>{e.me.data=t.payload}},jn((e=>e.me)))},Ys=l((e=>{const t=r(vn({name:"widget",initialState:Ln,reducers:{setAllowedAppsIds:(e,{payload:t})=>{e.allowedAppsIds.data=t}},extraReducers:e=>{Bs.reducer(e),Un.reducer(e),_n.reducer(e)},asyncActions:{getMe:Bs.action,getOutboundApps:_n.action,getConnectedOutboundApps:Un.action}}),C,b,Ks)(e);return class extends t{constructor(...e){super(...e),this.state=Ln,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Gs="widget-flow",Xs=l((e=>{var t,i,s;return s=class extends(r(wn,C,se,Ys,kn,b,fe,En)(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=xn(Gs);r&&(!function(e){if(window.history.replaceState&&xn(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())}}(Gs),o(this,t,"m",i).call(this,r))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e}));new Z((()=>{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})),Zs=jt((e=>e.outboundAppsList.data),(e=>e.connectedOutboundAppsIds.data),(e=>e.allowedAppsIds.data),((e,t,n)=>e.filter((e=>void 0===n||n.includes(e.id))).map((e=>{const n=(null==t?void 0:t.includes(e.id))||!1;return Object.assign(Object.assign({},e),{appId:e.id,isConnected:n})})).sort(((e,t)=>e.name.localeCompare(t.name))))),Qs=jt((e=>e.me.data),(e=>e.userId)),ea=l((e=>{var t,i,a,l,c;return c=class extends(r(b,C,q,B,yn("outbound-applications-widget"),Ys)(e)){constructor(){super(...arguments),t.add(this)}static get observedAttributes(){return["allowed-outbound-apps-ids"]}attributeChangedCallback(e,n,i){"allowed-outbound-apps-ids"===e&&n!==i&&this.actions.setAllowedAppsIds(o(this,t,"a",l))}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield this.actions.getMe(),yield this.actions.setAllowedAppsIds(o(this,t,"a",l)),yield Promise.all([this.actions.getOutboundApps(),this.actions.getConnectedOutboundApps({userId:Qs(this.state),tenantId:this.tenantId})]);const r=yield o(this,t,"m",i).call(this);o(this,t,"m",a).call(this,r),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(e),e}))},a=function(e){this.contentRootElement.append(e.content.cloneNode(!0))},l=function(){var e;if(!this.hasAttribute("allowed-outbound-apps-ids"))return;const t=null===(e=this.getAttribute("allowed-outbound-apps-ids"))||void 0===e?void 0:e.trim();return t?t.split(",").map((e=>e.trim())).filter(Boolean):[]},c})),ta=l((e=>class extends(r(fe,O)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),na=l((e=>{var t,s,a,l,c,d,u,h,p,f,g,v,m,w,y,k,I;return I=class extends(r(wn,ta,Ys,b,ea,se,En)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),u.set(this,null),h.set(this,null),k.set(this,(e=>{let t,n;return(...o)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,o)||(t=o,n=e(...o)),n)})((e=>{o(this,s,"f").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),o(this,t,"m",y).call(this,Zs(this.state)),o(this,t,"m",p).call(this),o(this,t,"m",v).call(this),this.subscribe(o(this,k,"f").bind(this),Zs)}))}},s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,k=new WeakMap,t=new WeakSet,p=function(){o(this,s,"f").connectFlowId&&(i(this,a,this.createModal({"data-id":"outbound-apps-connect"}),"f"),o(this,a,"f").afterClose=()=>{var e;if(o(this,u,"f")){const t=null===(e=o(this,a,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",o(this,u,"f")),i(this,u,null,"f")}},i(this,c,new Z((()=>{var e;return null===(e=o(this,a,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(o(this,c,"f")))},f=function(e,t,n){e.open(),t.removeEventListener("page-updated",n)},g=function(e,n){var i;const r=null===(i=e.ele)||void 0===i?void 0:i.querySelector("descope-wc"),s=()=>o(this,t,"m",f).call(this,e,r,s);n=s,null==r||r.addEventListener("page-updated",n)},v=function(){i(this,l,this.createModal({"data-id":"outbound-apps-disconnect"}),"f"),i(this,d,new Z((()=>{var e;return null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,l,"f").afterClose=()=>{var e;if(o(this,h,"f")){const t=null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",o(this,h,"f")),i(this,h,null,"f")}},this.syncFlowTheme(o(this,d,"f"))},m=function(e){o(this,a,"f").setContent(this.createFlowTemplate({flowId:o(this,s,"f").connectFlowId,outboundAppId:e})),o(this,t,"m",g).call(this,o(this,a,"f"),o(this,u,"f")),o(this,c,"f").onSuccess((()=>{o(this,a,"f").close(),this.actions.getConnectedOutboundApps({userId:Qs(this.state),tenantId:this.tenantId})}))},w=function(e){o(this,l,"f").setContent(this.createFlowTemplate({flowId:o(this,s,"f").disconnectFlowId,outboundAppId:e})),o(this,t,"m",g).call(this,o(this,l,"f"),o(this,h,"f")),o(this,d,"f").onSuccess((()=>{o(this,l,"f").close(),this.actions.getConnectedOutboundApps({userId:Qs(this.state)})}))},y=function(e){i(this,s,new re((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-outbound-apps")}),{logger:this.logger}),"f"),o(this,s,"f").onConnectClick((({id:e})=>{o(this,t,"m",m).call(this,e)})),o(this,s,"f").onDisconnectClick((({id:e})=>{o(this,t,"m",w).call(this,e)})),o(this,s,"f").data=e},I})),oa=l((e=>class extends(r(P,fe,Xs,na)(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)}))}})),ia=r((e=>class extends(oa(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return qd})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.5.14"}}}))}}))(HTMLElement);customElements.define("descope-outbound-applications-widget",ia);const ra=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var sa,aa,la,ca,da,ua,ha,pa,fa,ga;const va=document.createElement("template");va.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 ma=r(H)(HTMLElement);class ba extends ma{constructor(){var e;super(),sa.add(this),aa.set(this,new f({messages:[]})),la.set(this,void 0),ca.set(this,void 0),da.set(this,void 0),ua.set(this,{resize:o(this,sa,"m",ga).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(va.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'),i(this,la,this.shadowRoot.querySelector(".debugger"),"f"),o(this,la,"f").style.top="32px",o(this,la,"f").style.left=window.innerWidth-300-32+"px",i(this,ca,o(this,la,"f").querySelector(".content"),"f"),i(this,da,o(this,la,"f").querySelector(".header"),"f")}updateData(e){o(this,aa,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=ra(e,e.offsetLeft-o,e.offsetTop-i,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})(o(this,la,"f"),o(this,da,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,ua,"f").resize),(e=o(this,la,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,la,"f").onresize=o(this,sa,"m",fa).bind(this),o(this,aa,"f").subscribe(o(this,sa,"m",ha).bind(this))}disconnectedCallback(){o(this,aa,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,ua,"f").resize)}}aa=new WeakMap,la=new WeakMap,ca=new WeakMap,da=new WeakMap,ua=new WeakMap,sa=new WeakSet,ha=function(e){o(this,sa,"m",pa).call(this,e),o(this,sa,"m",fa).call(this)},pa=function(e){o(this,ca,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},fa=function(){o(this,ca,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;o||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},ga=function(){const[e,t]=ra(o(this,la,"f"),Number.parseInt(o(this,la,"f").style.left,10),Number.parseInt(o(this,la,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,la,"f").style.top=`${t}px`,o(this,la,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",ba);var wa=Object.freeze({__proto__:null,default:ba});const ya="undefined"!=typeof localStorage,ka="J151000",Ia="E103205",Sa="E108201",Ca=ya&&localStorage.getItem("base.content.url")||"",Oa="base.ui.components.url";ya&&localStorage.getItem(Oa),ya&&localStorage.getItem(Oa);const Ea="descope-login-flow",xa="code",Aa="redirect_mode",ja="err",Ta="data-exclude-field",Ra="data-exclude-next",_a="dls_last_auth",$a="dls_last_submitted_login_id",Pa="state_id",Ua="saml_idp_state_id",La="wsfed_idp_state_id",Ma="saml_idp_username",Na="descope_idp_initiated",Wa="sso_app_id",Da="custom_app_id",Fa="third_party_app_id",qa="third_party_app_state_id",za="oidc_login_hint",Va="oidc_prompt",Ha="oidc_resource",Ka="oidc_error_redirect_uri",Ja="application_scopes",Ba="data-type",Ya="redirect",Ga="poll",Xa="webauthnCreate",Za="webauthnGet",Qa="nativeBridge",el="loadForm",tl="submit",nl="polling",ol=["descope-multi-select-combo-box","descope-text-area"],il="dls_last_auth_in_flight",rl=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts","data","totp","notp","sentTo","sso","selfProvisionDomains"];var sl;!function(e){e.backward="backward",e.forward="forward"}(sl||(sl={}));const al=["descope-enriched-text"];function ll(e){return new URLSearchParams(window.location.search).get(e)}function cl(e){if(window.history.replaceState&&ll(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 dl(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?sl.forward:n<o?sl.backward:void 0}const ul=e=>{let[t="",n=""]=(ll(Ea)||"").split("_");const o=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||o&&o!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:o}};function hl(){cl(Ea)}const pl=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),fl=(e,t)=>{const{executionId:n,stepId:o,executionFlowId:i}=ul(e);if(i&&e!==i)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&hl();const r=ll("t")||void 0;r&&cl("t");const s=ll(xa)||void 0;s&&cl(xa);const a="popup"===ll(Aa);a&&cl(Aa);const l=ll(ja)||void 0;l&&cl(ja);const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:ll("ra-challenge"),redirectAuthCallbackUrl:ll("ra-callback"),redirectAuthBackupCallbackUri:ll("ra-backup-callback"),redirectAuthInitiator:ll("ra-initiator")},p=ll(Pa);p&&cl(Pa);const f=ll(Ua);f&&cl(Ua);const g=ll(La);g&&cl(La);const v=ll(Ma);f&&cl(Ma);const m=ll(Na);m&&cl(Na);const b=ll(Wa);b&&cl(Wa);const w=ll(Da);w&&cl(Da);const y=ll(Fa);y&&cl(Fa);const k=ll(qa);k&&cl(qa);const I=ll(Ja);I&&cl(Ja);const S=ll(za);S&&cl(za);const C=ll(Va);C&&cl(Va);const O=ll(Ka);O&&cl(Ka);const E=ll(Ha);return E&&cl(Ha),{executionId:n,stepId:o,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:f,wsfedIdpStateId:g,samlIdpUsername:v,descopeIdpInitiated:"true"===m,ssoAppId:b,customAppId:w,oidcLoginHint:S,oidcPrompt:C,oidcErrorRedirectUri:O,oidcResource:E,thirdPartyAppId:y,thirdPartyAppStateId:k,applicationScopes:I}}},gl=e=>{let t,n;return Object.assign(((...o)=>{return t&&(r=o,(i=t).length===r.length&&i.every(((e,t)=>e===r[t])))||(t=o,n=e(...o)),n;var i,r}),{reset:()=>{t=void 0,n=void 0}})},vl=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])');setTimeout((()=>{null==t||t.focus()}))}};function ml(e,t,n){return new Promise(((o,i)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?o(n):i(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),o(e))})).catch((e=>{r||(clearTimeout(s),i(e))}))}))}const bl=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:o,samlIdpUsername:i,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||o||i||r||s||a||l||c||d||u||h||p),wl=e=>null==e?void 0:e.submit(),yl=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},kl=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},Il={minLength:"data-password-policy-value-minlength",strength:"data-password-policy-value-passwordstrength",disallowedChars:"data-password-policy-value-disallowedchars",email:"data-password-policy-value-email",activePolicies:"active-policies",availablePolicies:"available-policies"},Sl=(e,t)=>{var n;const o=null==e?void 0:e.componentsDynamicAttrs;if(!o)return;const i=Object.entries(o).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==i?void 0:i[1])||void 0===n?void 0:n.attributes},Cl=[{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(Il).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=Sl(e,"recoveryCodes");if(t)return Array.isArray(t.data)?t.data.map((e=>e.value)):[]})(e.componentsConfig)},{key:"outboundApp",from:e=>(e=>{const t=Sl(e,"outboundApp");if(t)return{label:t.label,iconSrc:t["icon-src"],appId:t["data-descope-outbound-oauth-app-id"]}})(e.componentsConfig)}],Ol=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function El(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var xl,Al,jl,Tl;function Rl(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Rl(r,s))return!1}else if(r!==s)return!1}return!0}let _l=class{constructor(e={},{forceUpdate:t=!1}={}){xl.set(this,void 0),Al.set(this,{}),jl.set(this,0),Tl.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,xl,"f")):e,n=Object.assign(Object.assign({},o(this,xl,"f")),t),r=o(this,xl,"f");i(this,xl,n,"f"),Object.freeze(o(this,xl,"f")),setTimeout((()=>{Object.values(o(this,Al,"f")).forEach((({cb:e,selector:t,forceUpdate:i})=>{const s=t(r),a=t(n);(o(this,Tl,"f")||i||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!Rl(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},i(this,xl,e,"f"),i(this,Tl,t,"f")}get current(){return Object.assign({},o(this,xl,"f"))}set forceUpdate(e){i(this,Tl,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return i(this,jl,o(this,jl,"f")+1,"f"),o(this,Al,"f")[o(this,jl,"f")]={cb:e,selector:t,forceUpdate:n},o(this,jl,"f").toString()}unsubscribe(e){const t=!!o(this,Al,"f")[e];return t&&delete o(this,Al,"f")[e],t}unsubscribeAll(){return i(this,Al,{},"f"),!0}};xl=new WeakMap,Al=new WeakMap,jl=new WeakMap,Tl=new WeakMap;const $l=["*","#","/","(",")","[","]","_","<",">","`"],Pl=e=>"string"!=typeof e?e:e.replace((e=>{const t=$l.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),Ul=["disabled"],Ll=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Ta}])`)).forEach((e=>{e.value=n}))}))},Ml=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),Nl=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,o)=>n?Pl(Ml(t,o)):Ml(t,o))),Wl=(e,t,n)=>{e.querySelectorAll(`[${Ba}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Dl=(e,t,n)=>{var o,i;const r=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==e?void 0:e.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},Fl=(e,n,o,i)=>{var r,s;Wl(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),Wl(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=>al.includes(e))(e.localName);e.textContent=Nl(e.textContent,t,n);const o=e.getAttribute("href");o&&e.setAttribute("href",Nl(o,t))}))})(e,n),((e,n,o)=>{if(!n)return;const{componentsDynamicAttrs:i}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});i&&Object.keys(i).forEach((e=>{const t=i[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 i=n[t];if("string"!=typeof i)try{i=JSON.stringify(i)}catch(e){o.error(`Could not stringify value "${i}" for "${t}"`,e.message),i=""}e.setAttribute(t,i)}))}))}))})(e,null==n?void 0:n.componentsConfig,i),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=Nl(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])=>{Ul.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)},ql=gl((()=>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)))),o=(()=>{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 ml(100,n,o)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let zl;const Vl=(e,t)=>{zl?zl.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},Hl=e=>zl?zl.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,Kl="dls_ab_testing_id",Jl={"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,o]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=o?o:0)},"not-in-range":(e,t)=>{const[n,o]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==o&&!Number.isNaN(n)&&!Number.isNaN(o))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>o},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function Bl(e,t){const n={};try{Object.assign(n,JSON.parse(Hl(_a)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function Yl(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||Vl(_a,JSON.stringify(e)))}function Gl(){try{return JSON.parse(Hl(il)||"{}")}catch(e){return{}}}function Xl(e){try{(e=>{zl?zl.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(il)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const Zl=(e,t="")=>Object.keys(e).reduce(((n,o)=>{var i;if(Array.isArray(e[o]))return Object.assign(Object.assign({},n),{[o]:{value:e[o].map((e=>"object"==typeof e&&null!==e?Zl(e):e))}});if("object"==typeof e[o]&&null!==e[o]&&!(null===(i=e[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),Zl(e[o],`${t+o}.`));const r="object"==typeof e[o]?e[o]:{value:e[o]},s=Object.assign(Object.assign({},n),{[t+o]:r,[`form.${t}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),Ql=l((e=>{var t,n,i,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;o(this,t,"m",n).call(this)&&o(this,t,"m",i).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)},i=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})),ec=["input","change"];function tc(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 nc(e){return null==e?"":"string"==typeof e?e:"boolean"==typeof e?e?"true":"false":"number"==typeof e?Number.isFinite(e)?String(e):"":String(e)}function oc(e){if("boolean"==typeof e)return{value:e,ok:!0};if("string"==typeof e){if("true"===e)return{value:!0,ok:!0};if("false"===e)return{value:!1,ok:!0}}return"number"==typeof e?{value:0!==e,ok:!0}:{value:!1,ok:!1}}function ic(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function rc(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const sc=new Map,ac={equal:(e,t)=>e===t||nc(e)===nc(t),"not-equal":(e,t)=>e!==t&&nc(e)!==nc(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(nc(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(nc(t)),"greater-than":(e,t)=>{const n=tc(e),o=tc(t);return n.ok&&o.ok&&n.value>o.value},"greater-than-or-equal":(e,t)=>{const n=tc(e),o=tc(t);return n.ok&&o.ok&&n.value>=o.value},"less-than":(e,t)=>{const n=tc(e),o=tc(t);return n.ok&&o.ok&&n.value<o.value},"less-than-or-equal":(e,t)=>{const n=tc(e),o=tc(t);return n.ok&&o.ok&&n.value<=o.value},empty:e=>rc(e),"not-empty":e=>!rc(e),"is-true":e=>{const t=oc(e);return t.ok&&t.value},"is-false":e=>{const t=oc(e);return t.ok&&!t.value},in:(e,t)=>{const n=ic(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=ic(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(sc.has(e))return null!==(t=sc.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return sc.set(e,n),n}(nc(t));return null!==n&&n.test(e)}};function lc(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=>lc(e,t))):e.value}function cc(e,t){const n=ac[e.operator];return!!n&&n(lc(e.target,t),lc(e.predicate,t))}function dc(e,t){const n={};return(null!=e?e:[]).forEach((e=>{var o;(function(e,t){var n;return(null!==(n=e.rules)&&void 0!==n?n:[]).some((e=>function(e,t){var n;const o=null!==(n=e.atomicConditions)&&void 0!==n?n:[];return!!o.length&&(e.logicalOr?o.some((e=>cc(e,t))):o.every((e=>cc(e,t))))}(e,t)))})(e,t)&&(null!==(o=e.componentIds)&&void 0!==o?o:[]).forEach((t=>{n[t]=e.action}))})),n}const uc=["hide","disable","read-only"];const hc=/(["\\])/g;function pc(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(hc,"\\$1")}function fc(e,t){return Array.from(e.querySelectorAll(`[id="${pc(t)}"]`))}function gc(e,t,n){return Object.keys(t).forEach((o=>{const i=t[o];n[o]!==i&&fc(e,o).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove("hidden");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,i)))})),Object.keys(n).forEach((o=>{const i=n[o],r=t[o];i!==r&&fc(e,o).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add("hidden");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,i)))})),Object.assign({},n)}const vc="component-conditions:";function mc(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 bc(e,t){const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((n=>e[n]===t[n]))}function wc(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function yc(e,t,n){const o={};return n.forEach((n=>{e[n]?o[n]=e[n]:t[n]&&(o[n]=t[n])})),o}const kc=l((e=>{var t,n,s,a,l,c;const d=r(b)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,wc())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{uc.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${uc.map((e=>`"${e}"`)).join(", ")}`)})),gc(e,{},t))}initRealtimeConditions(e,r){var a,c,d,u;o(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(`${vc} no real-time rules to apply on this screen`);this.logger.info(`${vc} 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 o;e&&("form"===e.kind&&e.form?t.add(e.form):"list"===e.kind&&(null!==(o=e.items)&&void 0!==o?o:[]).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="${pc(t)}"]`)||e.querySelector(`[name="${pc(n)}"]`)}(e,t);if(!n)return;const o=mc(n);void 0!==o&&(p[t]=o)}));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},b=yc(dc(h,p),g,f);bc(v,b)||(m.applied=gc(e,v,b)),m.inputHandler=e=>o(this,t,"m",s).call(this,e),ec.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${vc} listening for "${ec.join('" and "')}" events on form fields; ${Object.keys(v).length} component(s) start hidden / disabled / read-only by these rules`);const w=this.nextRequestStatus;if(null==w?void 0:w.subscribe){const e=({isLoading:e})=>{m.paused=e,e&&m.debounceTimer&&(clearTimeout(m.debounceTimer),m.debounceTimer=null)},t=w.subscribe(e);m.unsubscribePauseListener=()=>{var e;null!=t&&(null===(e=w.unsubscribe)||void 0===e||e.call(w,t))}}i(this,n,m,"f")}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),o(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(e){var i,r;const s=o(this,n,"f");if(!s.root||s.paused)return;const l=e.target;if(!l)return;if(null===(i=l.hasAttribute)||void 0===i?void 0:i.call(l,Ta))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]=mc(l),s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout((()=>{s.debounceTimer=null,o(this,t,"m",a).call(this)}),50)},a=function(){const e=o(this,n,"f");if(!e.root)return;let t;try{t=yc(dc(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${vc} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const i=e.applied;bc(i,t)||(this.logger.debug(`${vc} form changed — updating components: was ${JSON.stringify(i)}, now ${JSON.stringify(t)}`),e.applied=gc(e.root,i,t))},l=function(){const e=o(this,n,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&(Object.keys(e.applied).length>0&&e.root.isConnected&&gc(e.root,e.applied,{}),ec.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)}))),i(this,n,wc(),"f")},c})),Ic="project-id",Sc="flow-id",Cc=e=>{const t=(e=>{const t=e.getAttribute(Ic),n=e.getAttribute(Sc);return t&&n?Array.from(e.ownerDocument.querySelectorAll("descope-wc")).filter((e=>e.getAttribute(Ic)===t&&e.getAttribute(Sc)===n)):[]})(e);return t.length>1&&t[0]!==e},Oc=l((e=>{var t,n,s,a;const l=r(b)(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),o(this,t,"m",s).call(this)}attributeChangedCallback(e,n,i){var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),n===i||e!==Ic&&e!==Sc||o(this,t,"m",s).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){queueMicrotask((()=>{if(!this.isConnected)return;const e=this.getAttribute(Ic),t=this.getAttribute(Sc),r=`${e}|${t}`;o(this,n,"f")!==r&&Cc(this)&&(i(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})),Ec=["externalId","email","phone"],xc=["newPassword","password"],Ac="data-username-anchor",jc=e=>{var t;if(!e)return"";try{const n=null===(t=window.sessionStorage)||void 0===t?void 0:t.getItem($a);if(!n)return"";const o=JSON.parse(n);return o.executionId===e&&o.loginId||""}catch(e){return""}},Tc=l((e=>{var t,n,s,a,l;const c=r(b)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}updateScreenUser(e){var r,l,c;i(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:[jc(o(this,t,"a",a))||(null===(c=null===(l=o(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(`[${Ac}="true"]`).forEach((e=>e.remove())),((e,t,n,o)=>{var i;const r=(null==n?void 0:n.email)||(null===(i=null==n?void 0:n.loginIds)||void 0===i?void 0:i[0]);(e=>e.querySelector("descope-new-password")||e.querySelector("descope-password"))(t)?r?(e=>{const t=['input[autocomplete="username"]',...Ec.map((e=>`[name="${e}"]`))].join(", ");return e.some((e=>e.querySelector(t)))})([e,t])?o.debug("Username anchor: screen already has an identifier field"):(o.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(Ta,"true"),t.setAttribute(Ac,"true"),t.setAttribute("value",e),t.value=e,Object.assign(t.style,{position:"absolute",opacity:"0",pointerEvents:"none",height:"0",border:"0"}),t})(r))):o.debug("Username anchor: no user identifier available"):o.debug("Username anchor: no password component on screen")})(this,o(this,t,"a",s).contentRootElement,o(this,n,"f"),this.logger)}captureLastSubmittedLoginId(e={},n){const i=yl(e,Ec);i&&((e,t)=>{var n;if(e&&t)try{null===(n=window.sessionStorage)||void 0===n||n.setItem($a,JSON.stringify({executionId:t,loginId:e}))}catch(e){}})(i,n||o(this,t,"a",a))}storeCredentials(e={}){var t,i,r,s,a,l;const c=yl(e,Ec)||(null===(t=o(this,n,"f"))||void 0===t?void 0:t.email)||(null===(r=null===(i=o(this,n,"f"))||void 0===i?void 0:i.loginIds)||void 0===r?void 0:r[0]),d=yl(e,xc);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.error("Could not store credentials",null==e?void 0:e.message)}))}catch(e){this.logger.error("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=o(this,t,"a",s).flowState)||void 0===e?void 0:e.current)||void 0===n?void 0:n.executionId)||""},l}));var Rc,_c,$c,Pc,Uc,Lc,Mc,Nc,Wc,Dc,Fc,qc,zc,Vc,Hc,Kc,Jc,Bc,Yc,Gc,Xc,Zc;const Qc=r(fe,R,Ql,kc,Oc,Tc,H,On)(HTMLElement);class ed extends Qc{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),Rc.add(this),this.sdkVersion="4.2.0",$c.set(this,!1),Pc.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,Rc,"m",Zc).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)}},Uc.set(this,new _l),Lc.set(this,new _l),Mc.set(this,{}),this.getComponentsContext=()=>o(this,Mc,"f"),this.nextRequestStatus=new _l({isLoading:!1}),Nc.set(this,void 0),Wc.set(this,{popstate:o(this,Rc,"m",Vc).bind(this),componentsContext:o(this,Rc,"m",Yc).bind(this)}),Dc.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,Dc,e,"f"),o(this,Rc,"m",qc).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 preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return Zl(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 o(this,Pc,"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");i(this,Pc,e,"f"),(e=>{zl=e})(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}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,o;const i=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=ol.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==e.key||i||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),o(this,Lc,"f").subscribe(o(this,Rc,"m",Xc).bind(this)),o(this,Lc,"f").update({isDebug:this.debug}),o(this,Rc,"m",zc).call(this),yield o(this,Rc,"m",Jc).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:r,stepId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f,ssoQueryParams:g}=fl(this.flowId,this.loggerWrapper);window.addEventListener("popstate",o(this,Wc,"f").popstate),window.addEventListener("components-context",o(this,Wc,"f").componentsContext),o(this,Uc,"f").subscribe(o(this,Rc,"m",Kc).bind(this)),o(this,Uc,"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)),i(this,$c,!0,"f")}))}disconnectedCallback(){var e;o(this,Uc,"f").unsubscribeAll(),o(this,Lc,"f").unsubscribeAll(),o(this,Rc,"m",Gc).call(this),window.removeEventListener("popstate",o(this,Wc,"f").popstate),window.removeEventListener("components-context",o(this,Wc,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,n){var i;if(null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,t,n),this.shadowRoot.isConnected&&o(this,$c,"f")&&t!==n&&_c.observedAttributes.includes(e)){o(this,Rc,"m",zc).call(this);const i=null===t;o(this,Uc,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,hl()),{[pl(e)]:n,stepId:r,executionId:s}})),o(this,Lc,"f").update({isDebug:this.debug})}}}var td,nd,od,id,rd,sd,ad,ld,cd,dd,ud,hd,pd,fd,gd,vd,md,bd,wd,yd,kd,Id,Sd,Cd,Od,Ed,xd,Ad,jd,Td,Rd,_d,$d,Pd,Ud,Ld,Md,Nd,Wd,Dd;_c=ed,$c=new WeakMap,Pc=new WeakMap,Uc=new WeakMap,Lc=new WeakMap,Mc=new WeakMap,Nc=new WeakMap,Wc=new WeakMap,Dc=new WeakMap,Rc=new WeakSet,Fc=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 ")},qc=function(){o(this,Rc,"m",Fc).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},zc=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes","theme-override"];_c.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[pl(t)])throw Error(`${t} cannot be empty`)}))},Vc=function(){const{stepId:e,executionId:t}=ul(this.flowId);o(this,Uc,"f").update({stepId:e,executionId:t})},Hc=function(e,t){Ms&&"function"==typeof Ms||this.logger.error("SDK was not loaded properly",Ms,JSON.stringify(Ms));const i=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},_c.sdkConfigOverrides),{projectId:e,baseUrl:t});o(this,Pc,"f")&&(i.customStorage=o(this,Pc,"f")),this.sdk=Ms(i),["start","next"].forEach((e=>{const t=function(e,t,o){return(...i)=>n(this,void 0,void 0,(function*(){let n;const r=o+1;for(let s=0;s<r;s++)try{return yield e(...i)}catch(e){n=e,s<o&&(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*(){try{return yield t(...o)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:ka,errorDescription:t.toString()}}}}))}))},Kc=function(e,t,i){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;o(this,Rc,"m",Hc).call(this,t,n)}o(this,Dc,"f").call(this,e)}))},Jc=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield o(this,Rc,"m",Bc).call(this))}))},Bc=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(Ca||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.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}}))},Yc=function(e){i(this,Mc,Object.assign(Object.assign({},o(this,Mc,"f")),e.detail),"f")},Gc=function(){var e;null===(e=o(this,Nc,"f"))||void 0===e||e.remove(),i(this,Nc,null,"f")},Xc=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,Nc,document.createElement("descope-debugger"),"f"),Object.assign(o(this,Nc,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return ru})),document.body.appendChild(o(this,Nc,"f"))):o(this,Rc,"m",Gc).call(this)}))},Zc=function(e,t){var n;e&&this.debug&&(null===(n=o(this,Nc,"f"))||void 0===n||n.updateData({title:e,description:t}))},ed.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.2.0"}};class Fd extends ed{static set sdkConfigOverrides(e){ed.sdkConfigOverrides=e}static get sdkConfigOverrides(){return ed.sdkConfigOverrides}constructor(){const e=new _l({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),td.add(this),this.stepState=new _l({}),nd.set(this,void 0),od.set(this,null),id.set(this,null),rd.set(this,{visibilitychange:o(this,td,"m",sd).bind(this)}),this.bridgeVersion=Fd.bridgeVersion,ad.set(this,void 0),this.nativeCallbacks={},gd.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},md.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()?o(this,td,"m",bd).call(this,t):t()})),wd.set(this,((e,t,r,s,a=!1)=>{const l=[Ia,"E103202",Sa];if(this.flowState.current.action===Ga){if(o(this,kd,"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;i(this,nd,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,i;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,nl,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 ml(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,wd,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===ka)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,wd,"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===(i=null==p?void 0:p.error)||void 0===i?void 0:i.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):o(this,wd,"f").call(this,e,t,r,s),o(this,Id,"f").call(this,p)}))),d),"f")}})),yd.set(this,(()=>{clearTimeout(o(this,nd,"f")),i(this,nd,null,"f")})),kd.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),Id.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 i=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}`;o(this,td,"m",Wd).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:i}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||i,(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!==Ia&&d!==Sa||!this.isRestartOnError||o(this,td,"m",fd).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:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,o):this.loggerWrapper.info(n,o)}));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:b,lastAuth:w,action:y,openInNewTabUrl:k}=e.data;if(y!==Ga&&o(this,yd,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&Yl(Object.assign(Object.assign({},w),{lastUsedPerScreen:Gl()})),Xl(this.loggerWrapper);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void o(this,td,"m",Wd).call(this,"success",t)}this.storeLastAuthenticatedUser&&Yl(w,!0),k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:C,screen:O,redirect:E,webauthn:x,error:A,samlIdpResponse:j,wsFedIdpResponse:T,nativeResponse:R}=e.data,_=Date.now();y!==Ga?(this.loggerWrapper.info(`Step "${C||`#${S}`}" is ${m}`,"",{screen:O,status:m,stepId:S,stepName:C,action:y,error:A}),(null===(g=O.state)||void 0===g?void 0:g.clientScripts)&&i(this,id,this.loadSdkScripts(O.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:C,executionId:I,action:y,redirectTo:null==E?void 0:E.url,redirectIsPopup:null==E?void 0:E.isPopup,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.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==T?void 0:T.url,wsFedIdpResponseWresult:null==T?void 0:T.wresult,wsFedIdpResponseWctx:null==T?void 0:T.wctx,nativeResponseType:null==R?void 0:R.type,nativePayload:null==R?void 0:R.payload,reqTimestamp:_})):this.flowState.update({action:y,reqTimestamp:_})})),Sd.set(this,gl((()=>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)}}))))),jd.set(this,null),$d.set(this,kl(((e,t,i)=>n(this,void 0,void 0,(function*(){var n,r;if("true"===e.getAttribute("formnovalidate")||o(this,td,"m",xd).call(this)){const s=null==e?void 0:e.getAttribute("id");o(this,td,"m",Ld).call(this,e,s,i),o(this,td,"m",Td).call(this,e);const a=yield o(this,td,"m",Ad).call(this),l=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const c=Object.assign(Object.assign(Object.assign({},l),a),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin}),d=yield t(s,c);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(a,null===(r=null==d?void 0:d.data)||void 0===r?void 0:r.executionId),this.storeCredentials(a)}}))))),this.flowState=e}nativeResume(e,t){var n,i,r,s,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const o=new URL(c.url);t=null===(n=o.searchParams)||void 0===n?void 0:n.get(xa),e=(null===(i=o.searchParams)||void 0===i?void 0:i.get(ja))||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(Ea).split("_").pop();o(this,yd,"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:{[El(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 o=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,o,i;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===(o=globalThis.descope)||void 0===o?void 0:o[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.17",`dist/${e.id}.js`));const s=null===(i=globalThis.descope)||void 0===i?void 0:i[e.id];return new Promise(((n,o)=>{try{const o=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(o){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=o,this.shadowRoot.appendChild(t);const n=this.nextRequestStatus.subscribe((()=>{var i;this.loggerWrapper.debug("Stopping script",e.id),(null===(i=o.stop)||void 0===i?void 0:i.call(o))&&(this.nextRequestStatus.unsubscribe(n),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}))}}catch(e){o(e)}}))}))))),i=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([o,i])}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,i(this,ad,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)),o(this,td,"m",hd).call(this),window.addEventListener("visibilitychange",o(this,rd,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e,t,n;super.disconnectedCallback(),o(this,ad,"f")&&(null===(t=null===(e=window.descopeBridge)||void 0===e?void 0:e.unregisterFlow)||void 0===t||t.call(e,o(this,ad,"f")),i(this,ad,void 0,"f")),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),o(this,yd,"f").call(this),null===(n=o(this,od,"f"))||void 0===n||n.abort(),i(this,od,null,"f"),window.removeEventListener("visibilitychange",o(this,rd,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const o=g(e),i=yield this.getTargetLocales();return i.includes(o.locale)?n=`${t}-${o.locale}.html`:i.includes(o.fallback)&&(n=`${t}-${o.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:v,screenState:m,redirectTo:b,redirectIsPopup:w,redirectUrl:y,token:k,code:I,isPopup:S,exchangeError:C,webauthnTransactionId:O,webauthnOptions:E,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:A,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:T,locale:R,samlIdpResponseUrl:_,samlIdpResponseSamlResponse:$,samlIdpResponseRelayState:P,wsFedIdpResponseUrl:U,wsFedIdpResponseWresult:L,wsFedIdpResponseWctx:M,nativeResponseType:N,nativePayload:W,reqTimestamp:D}=e,F=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let q,z,V;const H=(()=>{const e=Hl(Kl);if(!e){const e=Math.floor(100*Math.random()+1);return Vl(Kl,e.toString()),e}return Number(e)})(),{outboundAppId:K}=this,{outboundAppScopes:J}=this,B=this.sdk.getLastUserLoginId(),Y=yield this.getFlowConfig(),G=yield this.getProjectConfig(),X=Object.entries(G.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Z=A&&x?{callbackUrl:A,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){Xl(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:o})=>{var i;if("ELSE"===t)return!0;const r=null===(i=Jl[t])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(e,o))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:B,code:I,token:k,abTestingKey:H,lastAuth:Bl(B,this.loggerWrapper)},Y.conditions)),e.push(...t||[])}else Y.condition?({startScreenId:q,conditionInteractionId:V}=((e,t)=>{var n;const o=null===(n=Jl[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const i=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==i?void 0:i.screenId,startScreenName:null==i?void 0:i.screenName,conditionInteractionId:null==i?void 0:i.interactionId}})(Y.condition,{loginId:B,code:I,token:k,abTestingKey:H,lastAuth:Bl(B,this.loggerWrapper)})):(z=Y.startScreenName,q=Y.startScreenId);if(i(this,id,this.loadSdkScripts(e),"f"),Y.fingerprintEnabled&&Y.fingerprintKey?yield Qr(Y.fingerprintKey,this.baseUrl):jr(Xr),!bl(q,F)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Z},F),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:Bl(B,this.loggerWrapper),abTestingKey:H,locale:g(R).locale,nativeOptions:Q,outboundAppId:K,outboundAppScopes:J}),V,"",G.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),I?{exchangeCode:I,idpInitiated:!0}:{}),F.descopeIdpInitiated&&{idpInitiated:!0}),k?{token:k}:{}),F.oidcLoginHint?{externalId:F.oidcLoginHint}:{}));return o(this,Id,"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 o(this,td,"m",Dd).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,tl,Y.version,G.componentsVersion,{token:k,exchangeCode:I,exchangeError:C});return o(this,Id,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===el&&_&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!$)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=e,i.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(i),o(i)})(_,$,P||"",wl)}if(f===el&&U&&["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,o)=>{const i=document.createElement("form");i.method="POST",i.action=e;const r=(e,t)=>{const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n};i.appendChild(r("wa","wsignin1.0")),i.appendChild(r("wresult",t)),i.appendChild(r("wctx",n));const s=document.createElement("input");s.type="submit",s.id="WSFedSubmitButton",s.value="Continue",s.style.display="none",i.appendChild(s),document.body.appendChild(i),o(i)})(U,L,M||"",wl)}if(f===Ya&&(s("redirectTo")||s("deferredRedirect"))){if(!b)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===b)return;if("android"===T&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${w}`),w){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,o)=>{const i=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+i,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-o)/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=${o},top=${a},left=${s},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c})(b,"?",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 i=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const o=t?this.popupOrigin:window.location.origin;if(e.origin!==o)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${o}"`);const{action:i,data:r}=e.data||{};"code"===i&&(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),o(this,td,"m",Wd).call(this,"popupclosed",{abandoned:!n}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==r||r())}),1e3);if(t)window.addEventListener("message",i),r=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",i)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=i,r=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(b),this.flowState.update({redirectTo:"no-op"}),o(this,td,"m",Wd).call(this,"popupclosed",{});return}if(f===Xa||f===Za){if(!O||!E)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t,n,r;null===(l=o(this,od,"f"))||void 0===l||l.abort(),i(this,od,null,"f");try{e=f===Xa?yield this.sdk.webauthn.helpers.create(E):yield this.sdk.webauthn.helpers.get(E)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name,n=e.reason,r=e.message}const s=yield this.sdk.flow.next(p,h,tl,Y.version,G.componentsVersion,{transactionId:O,response:e,failure:t,failureReason:n,failureMessage:r});o(this,Id,"f").call(this,s)}if(f===Qa)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,tl,Y.version,G.componentsVersion,e);o(this,Id,"f").call(this,t)})),o(this,td,"m",dd).call(this,N,W),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&o(this,wd,"f").call(this,p,h,Y.version,G.componentsVersion),!v&&!q)return void this.loggerWrapper.warn("No screen was found to show");const te=q||v,ne=yield this.getHtmlFilenameWithLocale(R,te),{oidcLoginHint:oe,oidcPrompt:ie,oidcErrorRedirectUri:re,oidcResource:se,samlIdpUsername:ae}=F,le={direction:dl(h,r.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:B,name:this.sdk.getLastUserDisplayName()||B},componentsConfig:Object.assign(Object.assign(Object.assign({},Y.componentsConfig),ee),null==m?void 0:m.componentsConfig)}),htmlFilename:`${te}.html`,htmlLocaleFilename:ne,screenId:te,stepName:e.stepName||z,samlIdpUsername:ae,oidcLoginHint:oe,oidcPrompt:ie,oidcErrorRedirectUri:re,oidcResource:se,action:f,locale:g(R).locale},ce=Bl(B,this.loggerWrapper);bl(q,F)?le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==Y?void 0:Y.clientScripts)||[];yield o(this,td,"m",Pd).call(this,n);const i=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Z},F),{lastAuth:ce,preview:this.preview,abTestingKey:H,client:this.client}),y&&{redirectUrl:y}),{locale:g(R).locale,nativeOptions:Q,outboundAppId:K,outboundAppScopes:J}),V,e,G.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),Ol(t)),I&&{exchangeCode:I,idpInitiated:!0}),F.descopeIdpInitiated&&{idpInitiated:!0}),k&&{token:k}),le.next.isCustomScreen);return o(this,Id,"f").call(this,i),i})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==m?void 0:m.clientScripts)||[];yield o(this,td,"m",Pd).call(this,n);const i=yield this.sdk.flow.next(p,h,e,Y.version,G.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),Ol(t)),le.next.isCustomScreen);return o(this,Id,"f").call(this,i),i}))),this.loggerWrapper.debug("Got a screen with id",le.screenId),yield o(this,td,"m",vd).call(this,le),this.stepState.update(le)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var i,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 o(this,td,"m",Od).call(this,f,d):(e=>{e.querySelectorAll(`descope-button[${Ba}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(f),!e.samlIdpUsername||(null===(i=u.form)||void 0===i?void 0:i.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),Fl(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,o])=>{Array.from(e.querySelectorAll(`[${n}="${o}"]`)).forEach((e=>{e.setAttribute(n,t||o)}))}))})(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,o])=>{Array.from(e.querySelectorAll(`[${t}="${o}"]`)).forEach((e=>{e.setAttribute(t,n||o)}))}))})(f,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,i;yield g;const r=this.contentRootElement;((e,t)=>{Dl(e,"descope-totp-image",t)})(r,null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image),((e,t)=>{Dl(e,"descope-notp-image",t)})(r,null===(i=null==u?void 0:u.notp)||void 0===i?void 0:i.image),((e,t,n,o)=>{n&&Object.keys(n).forEach((i=>{if(!t.querySelector(i))return void o.debug(`Skipping css vars for component "${i}"`,`Got css vars for component ${i} but Could not find it on next page`);const r=customElements.get(i);r?Object.keys(n[i]).forEach((t=>{var s;const a=n[i],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void o.info(`Could not find css variable name for ${t} in ${i}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):o.debug(`Could not find component class for ${i}`,"Check if the component is registered")}))})(r,f,u.cssVars,this.loggerWrapper),r.replaceChildren(f);const s=!t.htmlFilename;setTimeout((()=>{o(this,td,"m",Rd).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const o=()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))};if("true"===t.getAttribute("invalid")||(null===(n=t.value)||void 0===n?void 0:n.length))return void o();const i={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(i.timer),i.timer=void 0)};i.timer=setTimeout((()=>{e.removeEventListener("click",r),o(),i.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(r),((e,t)=>{Ll(e,null==t?void 0:t.inputs),Ll(e,null==t?void 0:t.form)})(r,u),this.initRealtimeConditions(r,u),o(this,td,"m",Ed).call(this,{isFirstScreen:s,isCustomScreen:!1,stepName:e.stepName}),vl(r,this.autoFocus,s),o(this,td,"m",Md).call(this,h)})),o(this,td,"m",Nd).call(this,d,h),r.querySelector(`[${Ba}="polling"]`)&&d(nl,{})}));c?o(this,td,"m",bd).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${Ta}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}nd=new WeakMap,od=new WeakMap,id=new WeakMap,rd=new WeakMap,ad=new WeakMap,gd=new WeakMap,md=new WeakMap,wd=new WeakMap,yd=new WeakMap,kd=new WeakMap,Id=new WeakMap,Sd=new WeakMap,jd=new WeakMap,$d=new WeakMap,td=new WeakSet,sd=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},ld=function(e,t,i){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=i,this.nativeCallbacks.screenResolve=n,o(this,td,"m",dd).call(this,"beforeScreen",{screen:e,context:t})}))}))},cd=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&o(this,td,"m",dd).call(this,"afterScreen",{screen:e})},dd=function(e,t){o(this,td,"m",Wd).call(this,"bridge",{type:e,payload:t})},ud=function({errorText:e,errorType:t}){const n=()=>{var n;let o=e;try{o=(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(`[${Ba}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",o)};this.addEventListener("screen-updated",n,{once:!0}),n()},hd=function(){var e,n,i,r;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,o=t(void 0===n?{}:n,["errorText","errorType"]),i=t(e,["screenState"]);return Object.assign(Object.assign({},i),{screenState:o})})),null===(n=this.stepState)||void 0===n||n.subscribe(o(this,td,"m",ud).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===(i=this.stepState)||void 0===i||i.subscribe(o(this,td,"m",pd).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})))},pd=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=""}))})),vl(this.contentRootElement,this.autoFocus,!1))},fd=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")}))},vd=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,o=(e,t)=>rl.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!o(0,e)))));var n,o;const{screenState:{errorText:i,errorType:r}}=e;(i||r)&&(t.error={text:i,type:r}),e.action&&(t.action=e.action);const s=(e=>{if(!e)return;const t={};return Cl.forEach((({key:n,from:o})=>{const i=o(e);void 0!==i&&(t[n]=i)})),Object.keys(t).length?t:void 0})(e.screenState);return s&&(t.data=s),t})(t(r,["next","stepName"]));let c=yield o(this,td,"m",ld).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(o(this,md,"f").call(this,c),s&&(s.isCustomScreen=c),o(this,gd,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),i(this,gd,c,"f"),c?this.stepState.unsubscribeAll():o(this,td,"m",hd).call(this)}c?(this.loggerWrapper.debug("Showing a custom screen"),o(this,td,"m",Ed).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=c}))},bd=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")},Cd=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)}))}},Od=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,od,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield ql())){const{options:e,transactionId:r}=(yield o(this,Sd,"f").call(this))||{};e&&r&&(o(this,td,"m",Cd).call(this,s),i(this,od,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,o(this,od,"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)})))}}))},Ed=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&o(this,td,"m",Wd).call(this,"ready",{}),t||o(this,td,"m",cd).call(this,n),o(this,td,"m",Wd).call(this,"page-updated",{screenName:n}),o(this,td,"m",Wd).call(this,"screen-updated",{screenName:n})},xd=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,o;"slot"===t.localName||t.classList.contains("hidden")||(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},Ad=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})),{})}))},Td=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)||[],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 i(this,id,(()=>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 o=yield this.getFlowConfig(),r=[...o.clientScripts||[],...o.sdkScripts||[]];this.loadSdkScripts(r)})),d=()=>{var e;window.removeEventListener("pageshow",o(this,jd,"f")),i(this,jd,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),c())}),"f"),window.addEventListener("pageshow",o(this,jd,"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:t})=>{t?(this.addEventListener("popupclosed",c,{once:!0}),e.setAttribute("loading","true"),s.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(u),"success"===this.flowStatus?(this.removeEventListener("popupclosed",c),l()):d())}))},Rd=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>o(this,td,"m",_d).call(this,e)))},_d=function(e){e&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),o=`input-${e.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),e.appendChild(i),t.setAttribute("slot",o),this.appendChild(t)}))},Pd=function(e){return n(this,void 0,void 0,(function*(){if(o(this,id,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield o(this,id,"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 i=[];for(const e of t)"function"==typeof e.refresh&&i.push(e.refresh());if(i.length>0)try{yield ml(5e3,Promise.all(i),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Ud=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var i;(null===(i=n.checkValidity)||void 0===i?void 0:i.call(n))&&o(this,$d,"f").call(this,n,e,t)}))}))},Ld=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=Gl();n[e]=t,Vl(il,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},Md=function(e){var t;const n=null===(t=Bl(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const o=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),i=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);o&&i&&(i.replaceWith(o),o.appendChild(i))},Nd=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${Ra}]), [data-type="button"]:not([${Ra}]`).forEach((n=>{n.onclick=()=>{o(this,$d,"f").call(this,n,e,t)}})),o(this,td,"m",Ud).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Ta}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Wd=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Dd=function(e,t,n){var o;const[i,r]=(null===(o=window.name)||void 0===o?void 0:o.split("|"))||[],s={data:{code:t,exchangeError:n},action:"code"};if("descope-wc"===i&&r){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",r);try{window.opener.postMessage(s,r)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(s),t.close()}try{window.close()}catch(e){}},Fd.bridgeVersion=3,customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Fd);var qd=Object.freeze({__proto__:null,default:Fd});const zd=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},Vd=(e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=zd(e,e.offsetLeft-o,e.offsetTop-i,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 Hd,Kd,Jd,Bd,Yd,Gd,Xd,Zd,Qd,eu,tu;const nu=document.createElement("template");nu.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 ou=r(H)(HTMLElement);class iu extends ou{constructor(){super(),Hd.add(this),Kd.set(this,new _l({messages:[]})),Jd.set(this,void 0),Bd.set(this,void 0),Yd.set(this,void 0),Gd.set(this,{resize:o(this,Hd,"m",tu).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(nu.content.cloneNode(!0)),i(this,Jd,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Bd,o(this,Jd,"f").querySelector(".content"),"f"),i(this,Yd,o(this,Jd,"f").querySelector(".header"),"f"),o(this,Hd,"m",Xd).call(this)}updateData(e){o(this,Kd,"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),Vd(o(this,Jd,"f"),o(this,Yd,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Gd,"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}})(o(this,Jd,"f")),o(this,Jd,"f").onresize=o(this,Hd,"m",eu).bind(this),o(this,Kd,"f").subscribe(o(this,Hd,"m",Zd).bind(this))}))}disconnectedCallback(){o(this,Kd,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Gd,"f").resize)}}Kd=new WeakMap,Jd=new WeakMap,Bd=new WeakMap,Yd=new WeakMap,Gd=new WeakMap,Hd=new WeakSet,Xd=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'),o(this,Jd,"f").style.top="32px",o(this,Jd,"f").style.left=window.innerWidth-300-32+"px"},Zd=function(e){o(this,Hd,"m",Qd).call(this,e),o(this,Hd,"m",eu).call(this)},Qd=function(e){o(this,Bd,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},eu=function(){o(this,Bd,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},tu=function(){const[e,t]=zd(o(this,Jd,"f"),Number.parseInt(o(this,Jd,"f").style.left,10),Number.parseInt(o(this,Jd,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Jd,"f").style.top=`${t}px`,o(this,Jd,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",iu);var ru=Object.freeze({__proto__:null,default:iu});return ia}();
|
|
7
7
|
//# sourceMappingURL=index.js.map
|