@descope/web-component 3.70.7 → 4.0.1

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/README.md CHANGED
@@ -189,6 +189,12 @@ The function can be sync or async, and should return a boolean indicating whethe
189
189
  - `true`: Render a custom screen
190
190
  - `false`: Render the default flow screen
191
191
 
192
+ > **Breaking change (v4.0.0):** server-produced screen data that used to sit directly on
193
+ > `context` now lives under **`context.data`** — e.g. `context.totp` → `context.data.totp`,
194
+ > `context.inboundAppApproveScopes` → `context.data.inboundAppApproveScopes`. Status,
195
+ > `form`, and identity fields (`user` / `project` / `lastAuth`) stay at the top level.
196
+ > See [The `context` object](#the-context-object) below for the full list of `context.data` fields.
197
+
192
198
  This function allows rendering custom screens instead of the default flow screens.
193
199
  It can be useful for highly customized UIs or specific logic not covered by the default screens
194
200
 
@@ -275,7 +281,7 @@ by the flow). Their keys are the flow's own field names, so they don't fit the f
275
281
  above; they are omitted for now and reserved for a future `context.data.selects` map. This
276
282
  data was not available to custom screens before, so nothing changes for existing code.
277
283
 
278
- > **Breaking change (v-next):** screen-data fields that used to sit directly on `context`
284
+ > **Breaking change (v4.0.0):** screen-data fields that used to sit directly on `context`
279
285
  > now live under `context.data`. Migrate reads accordingly, e.g.
280
286
  > `context.inboundAppApproveScopes` → `context.data.inboundAppApproveScopes`,
281
287
  > `context.totp` → `context.data.totp`. Status, `form`, and identity fields
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),r=require("@descope/sdk-mixins/theme-mixin"),s=require("@descope/sdk-mixins/inject-style-mixin"),o=require("@descope/web-js-sdk"),n=require("../constants/index.js"),a=require("../helpers/helpers.js"),l=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var u,d,c,h,g,f,p,v,_,m,b,w,C,k,x,F,P,y,A,E,I,j,G=require("../helpers/storage.js"),S=require("../helpers/flowInputs.js"),M=require("../mixins/formMountMixin.js"),O=require("../mixins/componentConditionsMixin.js"),U=require("../mixins/duplicateFlowWarningMixin.js"),L=require("../mixins/passwordManagerMixin.js"),q=require("../constants/content.js"),R=require("../constants/general.js");function N(t){return Object.freeze({__proto__:null,default:t})}const W=e.compose(r.themeMixin,i.staticResourcesMixin,M.formMountMixin,O.componentConditionsMixin,U.duplicateFlowWarningMixin,L.passwordManagerMixin,s.injectStyleMixin)(HTMLElement);class D extends W{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(),u.add(this),c.set(this,!1),h.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,u,"m",j).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},g.set(this,new l),f.set(this,new l),p.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,p,"f"),this.nextRequestStatus=new l({isLoading:!1}),v.set(this,void 0),_.set(this,{popstate:t.__classPrivateFieldGet(this,u,"m",k).bind(this),componentsContext:t.__classPrivateFieldGet(this,u,"m",A).bind(this)}),m.set(this,void 0),this.getConfig=()=>t.__awaiter(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),t.__classPrivateFieldSet(this,m,e,"f"),t.__classPrivateFieldGet(this,u,"m",w).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){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 t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"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 S.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return S.extractNestedAttribute(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return t.__classPrivateFieldGet(this,h,"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");t.__classPrivateFieldSet(this,h,e,"f"),G.setCustomStorage(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return t.__awaiter(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=t=>{var e,i,r;const s=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),o=n.ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||s||o)return;t.preventDefault();const a=this.rootElement.querySelectorAll("descope-button");if(1===a.length&&"false"!==a[0].getAttribute("auto-submit"))return void a[0].click();const l=Array.from(a).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===l.length)return void l[0].click();const u=Array.from(a).filter((t=>"button"===t.getAttribute("data-type")));if(1===u.length)"false"!==u[0].getAttribute("auto-submit")&&u[0].click();else if(0===u.length){const t=Array.from(a).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return t.__awaiter(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return t.__awaiter(this,void 0,void 0,(function*(){var i;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(i=e.init)||void 0===i?void 0:i.call(this),t.__classPrivateFieldGet(this,f,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",I).bind(this)),t.__classPrivateFieldGet(this,f,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,u,"m",C).call(this),yield t.__classPrivateFieldGet(this,u,"m",P).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 r=yield this.getConfig();if("isMissingConfig"in r&&r.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:s,stepId:o,token:n,code:l,isPopup:d,exchangeError:h,redirectAuthCallbackUrl:p,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:m,redirectAuthInitiator:b,ssoQueryParams:w}=a.handleUrlParams(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t.__classPrivateFieldGet(this,_,"f").popstate),window.addEventListener("components-context",t.__classPrivateFieldGet(this,_,"f").componentsContext),t.__classPrivateFieldGet(this,g,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",F).bind(this)),t.__classPrivateFieldGet(this,g,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:s,token:n,code:l,isPopup:d,exchangeError:h,redirectAuthCallbackUrl:p,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:m,redirectAuthInitiator:b},w)),t.__classPrivateFieldSet(this,c,!0,"f")}))}disconnectedCallback(){var e;t.__classPrivateFieldGet(this,g,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,f,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,u,"m",E).call(this),window.removeEventListener("popstate",t.__classPrivateFieldGet(this,_,"f").popstate),window.removeEventListener("components-context",t.__classPrivateFieldGet(this,_,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,i,r){var s;if(null===(s=super.attributeChangedCallback)||void 0===s||s.call(this,e,i,r),this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,c,"f")&&i!==r&&d.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,u,"m",C).call(this);const s=null===i;t.__classPrivateFieldGet(this,g,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return s||(n=null,o=null,a.clearRunIdsFromUrl()),{[a.camelCase(e)]:r,stepId:o,executionId:n}})),t.__classPrivateFieldGet(this,f,"f").update({isDebug:this.debug})}}}d=D,c=new WeakMap,h=new WeakMap,g=new WeakMap,f=new WeakMap,p=new WeakMap,v=new WeakMap,_=new WeakMap,m=new WeakMap,u=new WeakSet,b=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 ")},w=function(){t.__classPrivateFieldGet(this,u,"m",b).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},C=function(){const t=["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"];d.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[a.camelCase(e)])throw Error(`${e} cannot be empty`)}))},k=function(){const{stepId:e,executionId:i}=a.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,g,"f").update({stepId:e,executionId:i})},x=function(e,i){o.createSdk&&"function"==typeof o.createSdk||this.logger.error("SDK was not loaded properly",o.createSdk,JSON.stringify(o.createSdk));const r=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},d.sdkConfigOverrides),{projectId:e,baseUrl:i});t.__classPrivateFieldGet(this,h,"f")&&(r.customStorage=t.__classPrivateFieldGet(this,h,"f")),this.sdk=o.createSdk(r),["start","next"].forEach((e=>{const i=this.sdk.flow[e],r=a.withRetry(i,1e3,3);this.sdk.flow[e]=(...i)=>t.__awaiter(this,void 0,void 0,(function*(){try{return yield r(...i)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:R.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}}))}))},F=function(e,i,r){return t.__awaiter(this,void 0,void 0,(function*(){const{projectId:i,baseUrl:s}=e;if(r("projectId")||r("baseUrl")){if(!i)return;t.__classPrivateFieldGet(this,u,"m",x).call(this,i,s)}t.__classPrivateFieldGet(this,m,"f").call(this,e)}))},P=function(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t.__classPrivateFieldGet(this,u,"m",y).call(this))}))},y=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=a.getContentUrl({projectId:this.projectId,filename:q.CONFIG_FILENAME,assetsFolder:q.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield a.fetchContent(t,"json"),!0}catch(t){return!1}}))},A=function(e){t.__classPrivateFieldSet(this,p,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,p,"f")),e.detail),"f")},E=function(){var e;null===(e=t.__classPrivateFieldGet(this,v,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,v,null,"f")},I=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,v,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,v,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return N(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,v,"f"))):t.__classPrivateFieldGet(this,u,"m",E).call(this)}))},j=function(e,i){var r;e&&this.debug&&(null===(r=t.__classPrivateFieldGet(this,v,"f"))||void 0===r||r.updateData({title:e,description:i}))},D.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.70.7"}},module.exports=D;
1
+ "use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),r=require("@descope/sdk-mixins/theme-mixin"),s=require("@descope/sdk-mixins/inject-style-mixin"),o=require("@descope/web-js-sdk"),n=require("../constants/index.js"),a=require("../helpers/helpers.js"),l=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var u,d,c,h,g,f,p,v,_,m,b,w,C,k,x,F,P,y,A,E,I,j,G=require("../helpers/storage.js"),S=require("../helpers/flowInputs.js"),M=require("../mixins/formMountMixin.js"),O=require("../mixins/componentConditionsMixin.js"),U=require("../mixins/duplicateFlowWarningMixin.js"),L=require("../mixins/passwordManagerMixin.js"),q=require("../constants/content.js"),R=require("../constants/general.js");function N(t){return Object.freeze({__proto__:null,default:t})}const W=e.compose(r.themeMixin,i.staticResourcesMixin,M.formMountMixin,O.componentConditionsMixin,U.duplicateFlowWarningMixin,L.passwordManagerMixin,s.injectStyleMixin)(HTMLElement);class D extends W{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(),u.add(this),c.set(this,!1),h.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,u,"m",j).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},g.set(this,new l),f.set(this,new l),p.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,p,"f"),this.nextRequestStatus=new l({isLoading:!1}),v.set(this,void 0),_.set(this,{popstate:t.__classPrivateFieldGet(this,u,"m",k).bind(this),componentsContext:t.__classPrivateFieldGet(this,u,"m",A).bind(this)}),m.set(this,void 0),this.getConfig=()=>t.__awaiter(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),t.__classPrivateFieldSet(this,m,e,"f"),t.__classPrivateFieldGet(this,u,"m",w).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){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 t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"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 S.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return S.extractNestedAttribute(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return t.__classPrivateFieldGet(this,h,"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");t.__classPrivateFieldSet(this,h,e,"f"),G.setCustomStorage(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return t.__awaiter(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=t=>{var e,i,r;const s=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),o=n.ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||s||o)return;t.preventDefault();const a=this.rootElement.querySelectorAll("descope-button");if(1===a.length&&"false"!==a[0].getAttribute("auto-submit"))return void a[0].click();const l=Array.from(a).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===l.length)return void l[0].click();const u=Array.from(a).filter((t=>"button"===t.getAttribute("data-type")));if(1===u.length)"false"!==u[0].getAttribute("auto-submit")&&u[0].click();else if(0===u.length){const t=Array.from(a).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return t.__awaiter(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return t.__awaiter(this,void 0,void 0,(function*(){var i;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(i=e.init)||void 0===i?void 0:i.call(this),t.__classPrivateFieldGet(this,f,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",I).bind(this)),t.__classPrivateFieldGet(this,f,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,u,"m",C).call(this),yield t.__classPrivateFieldGet(this,u,"m",P).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 r=yield this.getConfig();if("isMissingConfig"in r&&r.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:s,stepId:o,token:n,code:l,isPopup:d,exchangeError:h,redirectAuthCallbackUrl:p,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:m,redirectAuthInitiator:b,ssoQueryParams:w}=a.handleUrlParams(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t.__classPrivateFieldGet(this,_,"f").popstate),window.addEventListener("components-context",t.__classPrivateFieldGet(this,_,"f").componentsContext),t.__classPrivateFieldGet(this,g,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",F).bind(this)),t.__classPrivateFieldGet(this,g,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:s,token:n,code:l,isPopup:d,exchangeError:h,redirectAuthCallbackUrl:p,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:m,redirectAuthInitiator:b},w)),t.__classPrivateFieldSet(this,c,!0,"f")}))}disconnectedCallback(){var e;t.__classPrivateFieldGet(this,g,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,f,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,u,"m",E).call(this),window.removeEventListener("popstate",t.__classPrivateFieldGet(this,_,"f").popstate),window.removeEventListener("components-context",t.__classPrivateFieldGet(this,_,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,i,r){var s;if(null===(s=super.attributeChangedCallback)||void 0===s||s.call(this,e,i,r),this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,c,"f")&&i!==r&&d.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,u,"m",C).call(this);const s=null===i;t.__classPrivateFieldGet(this,g,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return s||(n=null,o=null,a.clearRunIdsFromUrl()),{[a.camelCase(e)]:r,stepId:o,executionId:n}})),t.__classPrivateFieldGet(this,f,"f").update({isDebug:this.debug})}}}d=D,c=new WeakMap,h=new WeakMap,g=new WeakMap,f=new WeakMap,p=new WeakMap,v=new WeakMap,_=new WeakMap,m=new WeakMap,u=new WeakSet,b=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 ")},w=function(){t.__classPrivateFieldGet(this,u,"m",b).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},C=function(){const t=["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"];d.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[a.camelCase(e)])throw Error(`${e} cannot be empty`)}))},k=function(){const{stepId:e,executionId:i}=a.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,g,"f").update({stepId:e,executionId:i})},x=function(e,i){o.createSdk&&"function"==typeof o.createSdk||this.logger.error("SDK was not loaded properly",o.createSdk,JSON.stringify(o.createSdk));const r=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},d.sdkConfigOverrides),{projectId:e,baseUrl:i});t.__classPrivateFieldGet(this,h,"f")&&(r.customStorage=t.__classPrivateFieldGet(this,h,"f")),this.sdk=o.createSdk(r),["start","next"].forEach((e=>{const i=this.sdk.flow[e],r=a.withRetry(i,1e3,3);this.sdk.flow[e]=(...i)=>t.__awaiter(this,void 0,void 0,(function*(){try{return yield r(...i)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:R.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}}))}))},F=function(e,i,r){return t.__awaiter(this,void 0,void 0,(function*(){const{projectId:i,baseUrl:s}=e;if(r("projectId")||r("baseUrl")){if(!i)return;t.__classPrivateFieldGet(this,u,"m",x).call(this,i,s)}t.__classPrivateFieldGet(this,m,"f").call(this,e)}))},P=function(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t.__classPrivateFieldGet(this,u,"m",y).call(this))}))},y=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=a.getContentUrl({projectId:this.projectId,filename:q.CONFIG_FILENAME,assetsFolder:q.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield a.fetchContent(t,"json"),!0}catch(t){return!1}}))},A=function(e){t.__classPrivateFieldSet(this,p,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,p,"f")),e.detail),"f")},E=function(){var e;null===(e=t.__classPrivateFieldGet(this,v,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,v,null,"f")},I=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,v,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,v,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return N(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,v,"f"))):t.__classPrivateFieldGet(this,u,"m",E).call(this)}))},j=function(e,i){var r;e&&this.debug&&(null===(r=t.__classPrivateFieldGet(this,v,"f"))||void 0===r||r.updateData({title:e,description:i}))},D.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.0.1"}},module.exports=D;
2
2
  //# sourceMappingURL=BaseDescopeWc.js.map
@@ -1,2 +1,2 @@
1
- import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as r}from"@descope/sdk-helpers";import{staticResourcesMixin as o}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as s}from"@descope/sdk-mixins/theme-mixin";import{injectStyleMixin as n}from"@descope/sdk-mixins/inject-style-mixin";import{createSdk as a}from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as u}from"../constants/index.js";import{handleUrlParams as l,clearRunIdsFromUrl as d,camelCase as c,getRunIdsFromUrl as h,getContentUrl as f,fetchContent as g,withRetry as p}from"../helpers/helpers.js";import m from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{setCustomStorage as b}from"../helpers/storage.js";import{transformFlowInputFormData as v,extractNestedAttribute as w}from"../helpers/flowInputs.js";import{formMountMixin as k}from"../mixins/formMountMixin.js";import{componentConditionsMixin as C}from"../mixins/componentConditionsMixin.js";import{duplicateFlowWarningMixin as y}from"../mixins/duplicateFlowWarningMixin.js";import{passwordManagerMixin as A}from"../mixins/passwordManagerMixin.js";import{CONFIG_FILENAME as x,PREV_VER_ASSETS_FOLDER as j}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as I}from"../constants/general.js";var E,M,L,S,U,O,W,D,P,N,F,K,R,T,B,H,J,V,q,$,z,Q;const G=r(s,o,k,C,y,A,n)(HTMLElement);class X extends G{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(r){super(),E.add(this),L.set(this,!1),S.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,E,"m",Q).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},U.set(this,new m),O.set(this,new m),W.set(this,{}),this.getComponentsContext=()=>t(this,W,"f"),this.nextRequestStatus=new m({isLoading:!1}),D.set(this,void 0),P.set(this,{popstate:t(this,E,"m",T).bind(this),componentsContext:t(this,E,"m",q).bind(this)}),N.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,N,r,"f"),t(this,E,"m",K).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){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 t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"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 v(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return w(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return t(this,S,"f")}set customStorage(t){if(t&&"function"!=typeof t.getItem)throw new Error("Custom storage must have a getItem method");if(t&&"function"!=typeof t.setItem)throw new Error("Custom storage must have a setItem method");if(t&&"function"!=typeof t.removeItem)throw new Error("Custom storage must have a removeItem method");i(this,S,t,"f"),b(t)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return e(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=t=>{var e,i,r;const o=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),s=u.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||o||s)return;t.preventDefault();const n=this.rootElement.querySelectorAll("descope-button");if(1===n.length&&"false"!==n[0].getAttribute("auto-submit"))return void n[0].click();const a=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(n).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(n).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return e(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const r=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=r.init)||void 0===e?void 0:e.call(this),t(this,O,"f").subscribe(t(this,E,"m",z).bind(this)),t(this,O,"f").update({isDebug:this.debug}),t(this,E,"m",R).call(this),yield t(this,E,"m",J).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 o=yield this.getConfig();if("isMissingConfig"in o&&o.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:s,stepId:n,token:a,code:u,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:g,redirectAuthInitiator:p,ssoQueryParams:m}=l(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t(this,P,"f").popstate),window.addEventListener("components-context",t(this,P,"f").componentsContext),t(this,U,"f").subscribe(t(this,E,"m",H).bind(this)),t(this,U,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:s,token:a,code:u,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:g,redirectAuthInitiator:p},m)),i(this,L,!0,"f")}))}disconnectedCallback(){var e;t(this,U,"f").unsubscribeAll(),t(this,O,"f").unsubscribeAll(),t(this,E,"m",$).call(this),window.removeEventListener("popstate",t(this,P,"f").popstate),window.removeEventListener("components-context",t(this,P,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,i,r){var o;if(null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,i,r),this.shadowRoot.isConnected&&t(this,L,"f")&&i!==r&&M.observedAttributes.includes(e)){t(this,E,"m",R).call(this);const o=null===i;t(this,U,"f").update((({stepId:t,executionId:i})=>{let s=t,n=i;return o||(n=null,s=null,d()),{[c(e)]:r,stepId:s,executionId:n}})),t(this,O,"f").update({isDebug:this.debug})}}}M=X,L=new WeakMap,S=new WeakMap,U=new WeakMap,O=new WeakMap,W=new WeakMap,D=new WeakMap,P=new WeakMap,N=new WeakMap,E=new WeakSet,F=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 ")},K=function(){t(this,E,"m",F).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},R=function(){const t=["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"];M.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[c(e)])throw Error(`${e} cannot be empty`)}))},T=function(){const{stepId:e,executionId:i}=h(this.flowId);t(this,U,"f").update({stepId:e,executionId:i})},B=function(i,r){a&&"function"==typeof a||this.logger.error("SDK was not loaded properly",a,JSON.stringify(a));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},M.sdkConfigOverrides),{projectId:i,baseUrl:r});t(this,S,"f")&&(o.customStorage=t(this,S,"f")),this.sdk=a(o),["start","next"].forEach((t=>{const i=this.sdk.flow[t],r=p(i,1e3,3);this.sdk.flow[t]=(...i)=>e(this,void 0,void 0,(function*(){try{return yield r(...i)}catch(e){return this.logger.error(`Error in sdk flow ${t} function`,e),{error:{errorCode:I,errorDescription:e.toString()}}}}))}))},H=function(i,r,o){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:r}=i;if(o("projectId")||o("baseUrl")){if(!e)return;t(this,E,"m",B).call(this,e,r)}t(this,N,"f").call(this,i)}))},J=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,E,"m",V).call(this))}))},V=function(){return e(this,void 0,void 0,(function*(){const t=f({projectId:this.projectId,filename:x,assetsFolder:j,baseUrl:this.baseStaticUrl});try{return yield g(t,"json"),!0}catch(t){return!1}}))},q=function(e){i(this,W,Object.assign(Object.assign({},t(this,W,"f")),e.detail),"f")},$=function(){var e;null===(e=t(this,D,"f"))||void 0===e||e.remove(),i(this,D,null,"f")},z=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,D,document.createElement("descope-debugger"),"f"),Object.assign(t(this,D,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("../debugger-wc.js"),document.body.appendChild(t(this,D,"f"))):t(this,E,"m",$).call(this)}))},Q=function(e,i){var r;e&&this.debug&&(null===(r=t(this,D,"f"))||void 0===r||r.updateData({title:e,description:i}))},X.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.70.7"}};export{X as default};
1
+ import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as r}from"@descope/sdk-helpers";import{staticResourcesMixin as o}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as s}from"@descope/sdk-mixins/theme-mixin";import{injectStyleMixin as n}from"@descope/sdk-mixins/inject-style-mixin";import{createSdk as a}from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as u}from"../constants/index.js";import{handleUrlParams as l,clearRunIdsFromUrl as d,camelCase as c,getRunIdsFromUrl as h,getContentUrl as f,fetchContent as g,withRetry as p}from"../helpers/helpers.js";import m from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{setCustomStorage as b}from"../helpers/storage.js";import{transformFlowInputFormData as v,extractNestedAttribute as w}from"../helpers/flowInputs.js";import{formMountMixin as k}from"../mixins/formMountMixin.js";import{componentConditionsMixin as C}from"../mixins/componentConditionsMixin.js";import{duplicateFlowWarningMixin as y}from"../mixins/duplicateFlowWarningMixin.js";import{passwordManagerMixin as A}from"../mixins/passwordManagerMixin.js";import{CONFIG_FILENAME as x,PREV_VER_ASSETS_FOLDER as j}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as I}from"../constants/general.js";var E,M,L,S,U,O,W,D,P,N,F,K,R,T,B,H,J,V,q,$,z,Q;const G=r(s,o,k,C,y,A,n)(HTMLElement);class X extends G{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(r){super(),E.add(this),L.set(this,!1),S.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,E,"m",Q).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},U.set(this,new m),O.set(this,new m),W.set(this,{}),this.getComponentsContext=()=>t(this,W,"f"),this.nextRequestStatus=new m({isLoading:!1}),D.set(this,void 0),P.set(this,{popstate:t(this,E,"m",T).bind(this),componentsContext:t(this,E,"m",q).bind(this)}),N.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,N,r,"f"),t(this,E,"m",K).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){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 t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"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 v(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return w(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return t(this,S,"f")}set customStorage(t){if(t&&"function"!=typeof t.getItem)throw new Error("Custom storage must have a getItem method");if(t&&"function"!=typeof t.setItem)throw new Error("Custom storage must have a setItem method");if(t&&"function"!=typeof t.removeItem)throw new Error("Custom storage must have a removeItem method");i(this,S,t,"f"),b(t)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return e(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=t=>{var e,i,r;const o=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),s=u.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||o||s)return;t.preventDefault();const n=this.rootElement.querySelectorAll("descope-button");if(1===n.length&&"false"!==n[0].getAttribute("auto-submit"))return void n[0].click();const a=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(n).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(n).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return e(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const r=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=r.init)||void 0===e?void 0:e.call(this),t(this,O,"f").subscribe(t(this,E,"m",z).bind(this)),t(this,O,"f").update({isDebug:this.debug}),t(this,E,"m",R).call(this),yield t(this,E,"m",J).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 o=yield this.getConfig();if("isMissingConfig"in o&&o.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:s,stepId:n,token:a,code:u,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:g,redirectAuthInitiator:p,ssoQueryParams:m}=l(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t(this,P,"f").popstate),window.addEventListener("components-context",t(this,P,"f").componentsContext),t(this,U,"f").subscribe(t(this,E,"m",H).bind(this)),t(this,U,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:s,token:a,code:u,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:g,redirectAuthInitiator:p},m)),i(this,L,!0,"f")}))}disconnectedCallback(){var e;t(this,U,"f").unsubscribeAll(),t(this,O,"f").unsubscribeAll(),t(this,E,"m",$).call(this),window.removeEventListener("popstate",t(this,P,"f").popstate),window.removeEventListener("components-context",t(this,P,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,i,r){var o;if(null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,i,r),this.shadowRoot.isConnected&&t(this,L,"f")&&i!==r&&M.observedAttributes.includes(e)){t(this,E,"m",R).call(this);const o=null===i;t(this,U,"f").update((({stepId:t,executionId:i})=>{let s=t,n=i;return o||(n=null,s=null,d()),{[c(e)]:r,stepId:s,executionId:n}})),t(this,O,"f").update({isDebug:this.debug})}}}M=X,L=new WeakMap,S=new WeakMap,U=new WeakMap,O=new WeakMap,W=new WeakMap,D=new WeakMap,P=new WeakMap,N=new WeakMap,E=new WeakSet,F=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 ")},K=function(){t(this,E,"m",F).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},R=function(){const t=["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"];M.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[c(e)])throw Error(`${e} cannot be empty`)}))},T=function(){const{stepId:e,executionId:i}=h(this.flowId);t(this,U,"f").update({stepId:e,executionId:i})},B=function(i,r){a&&"function"==typeof a||this.logger.error("SDK was not loaded properly",a,JSON.stringify(a));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},M.sdkConfigOverrides),{projectId:i,baseUrl:r});t(this,S,"f")&&(o.customStorage=t(this,S,"f")),this.sdk=a(o),["start","next"].forEach((t=>{const i=this.sdk.flow[t],r=p(i,1e3,3);this.sdk.flow[t]=(...i)=>e(this,void 0,void 0,(function*(){try{return yield r(...i)}catch(e){return this.logger.error(`Error in sdk flow ${t} function`,e),{error:{errorCode:I,errorDescription:e.toString()}}}}))}))},H=function(i,r,o){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:r}=i;if(o("projectId")||o("baseUrl")){if(!e)return;t(this,E,"m",B).call(this,e,r)}t(this,N,"f").call(this,i)}))},J=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,E,"m",V).call(this))}))},V=function(){return e(this,void 0,void 0,(function*(){const t=f({projectId:this.projectId,filename:x,assetsFolder:j,baseUrl:this.baseStaticUrl});try{return yield g(t,"json"),!0}catch(t){return!1}}))},q=function(e){i(this,W,Object.assign(Object.assign({},t(this,W,"f")),e.detail),"f")},$=function(){var e;null===(e=t(this,D,"f"))||void 0===e||e.remove(),i(this,D,null,"f")},z=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,D,document.createElement("descope-debugger"),"f"),Object.assign(t(this,D,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("../debugger-wc.js"),document.body.appendChild(t(this,D,"f"))):t(this,E,"m",$).call(this)}))},Q=function(e,i){var r;e&&this.debug&&(null===(r=t(this,D,"f"))||void 0===r||r.updateData({title:e,description:i}))},X.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.0.1"}};export{X as default};
2
2
  //# sourceMappingURL=BaseDescopeWc.js.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- !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 g=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 f(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;class v extends Error{}function m(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 b(e,t){if("string"!=typeof e)throw new v("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 v(`Invalid token specified: missing part #${n+1}`);let i;try{i=m(o)}catch(e){throw new v(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new v(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}v.prototype.name="InvalidTokenError";var w={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},sso:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const y="<region>",k=`https://api.${y}descope.com`,I=6e5,S="dct",C=()=>{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")}},O=[503,520,521,522,524,530],x=[100,5e3,5e3],A=e=>new Promise((t=>setTimeout(t,e))),E=e=>async function(...t){let n=await e(...t),o=0;for(;O.includes(n.status)&&o<x.length;)await A(x[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 j;const U=()=>{if(j)return j;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 j=`${t}-${n}`,j};var R;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(R||(R={}));const $=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(y,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},T=(...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)),{})),L={"Content-Type":"application/json"},P=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},W=(e,t)=>{const n={"x-descope-sdk-session-id":U(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.67.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},N=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var M=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||k,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=>C().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await E(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return C().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:E(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:g,token:f}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:T(P(t,f),W(t,o),(null==n?void 0:n.baseHeaders)||{},N(v)?L:{},h),method:g,body:v};null!==s&&(m.credentials=s||"include");const b=await c($({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:R.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:R.post,token:i}),patch:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:R.patch,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:R.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:R.delete,token:o}),hooks:r,buildUrl:(e,n)=>$({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}}))},_=429;function D(e,t,n){var o;let i=q(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[S])===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 q(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return b(e)}function F(e){const{exp:t}=q(e);return(new Date).getTime()/1e3>t}function H(e){let t=q(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function J(e,t){return D(e,t,"permissions")}function V(e,t){return D(e,t,"roles")}const K=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function B(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===_&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}function z(e){var t;return(null===(t=q(e))||void 0===t?void 0:t[S])||""}const Z=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),G=(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 "))},X=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Y=e=>t=>e.test(t),Q=Y(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),ee=Y(/^\+[1-9]{1}[0-9]{3,14}$/),te=Z(Q,'"{val}" is not a valid email'),ne=Z(ee,'"{val}" is not a valid phone number'),oe=Z((e=>e.length>=1),"Minimum length is 1");const ie=Z((e=>"string"==typeof e),"Input is not a string"),re=Z((e=>Array.isArray(e)),"Input is not an array"),se=Z((e=>"boolean"==typeof e),"Input is not a boolean"),ae=Z((e=>void 0===e),"Input is defined"),le=G([ie(),ae()],"Input is not a string or undefined"),ce=G([re(),se()],"Input is not an array or boolean"),de=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>X(...e).validate(n[t]))),t(...n)),ue=e=>[ie(`"${e}" must be a string`)],he=e=>[le(`"${e}" must be string or undefined`)],pe=e=>[ie(`"${e}" must be a string`),oe(`"${e}" must not be empty`)],ge=e=>[ie(`"${e}" must be a string`),te()],fe=e=>[ie(`"${e}" must be a string`),ne()],ve=de(pe("accessKey")),me=e=>({exchange:ve(((t,n)=>B(e.post(w.accessKey.exchange,{loginOptions:n},{token:t}))))}),be=(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),we=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||I,I)});var ye,ke;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(ye||(ye={})),function(e){e.email="email"}(ke||(ke={}));const Ie=Object.assign(Object.assign({},ye),ke);var Se;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Se||(Se={}));const Ce=pe("loginId"),Oe=de(pe("token")),xe=de(Ce),Ae=de(pe("pendingRef")),Ee=de(Ce,ge("email")),je=e=>({verify:Oe((t=>B(e.post(w.enchantedLink.verify,{token:t})))),signIn:xe(((n,o,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return B(e.post(K(w.enchantedLink.signIn,Ie.email),{loginId:n,URI:o,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:xe(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return B(e.post(K(w.enchantedLink.signUpOrIn,Ie.email),{loginId:n,URI:o,loginOptions:s,providerId:r}))})),signUp:xe(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(K(w.enchantedLink.signUp,Ie.email),{loginId:n,URI:o,user:i,loginOptions:a,providerId:s}))})),waitForSession:Ae(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=we(n);let s;const a=setInterval((async()=>{const n=await e.post(w.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(B(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Ee(((t,n,o,i,r)=>B(e.post(w.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),Ue=de(pe("flowId")),Re=de(pe("executionId"),pe("stepId"),pe("interactionId")),$e=e=>({start:Ue(((t,n,o,i,r,s,a,l=!1)=>B(e.post(w.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:Re(((t,n,o,i,r,s,a=!1)=>B(e.post(w.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s,isCustomScreen:a}))))}),Te=pe("loginId"),Le=de(pe("token")),Pe=de(Te),We=de(Te,fe("phone")),Ne=de(Te,ge("email")),Me=Object.keys(Ie).filter((e=>e!==ye.voice&&e!==ye.im)),_e=e=>({verify:Le((t=>B(e.post(w.magicLink.verify,{token:t})))),signIn:Me.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Pe(((n,i,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return B(e.post(K(w.magicLink.signIn,o),{loginId:n,URI:i,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:Me.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Pe(((n,i,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return B(e.post(K(w.magicLink.signUp,o),{loginId:n,URI:i,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:Me.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Pe(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(K(w.magicLink.signUpOrIn,o),{loginId:n,URI:i,loginOptions:a,providerId:s}))}))})),{}),update:{email:Ne(((t,n,o,i,r)=>B(e.post(w.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(ye).filter((e=>e!==ye.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:We(((t,o,i,r,s)=>B(e.post(K(w.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var De;!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"}(De||(De={}));const qe=de(pe("code")),Fe=e=>({start:Object.assign(((t,n,o,i,r)=>B(e.post(w.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:i}))),Object.keys(De).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i,r)=>B(e.post(w.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:i}))})),{})),exchange:qe((t=>B(e.post(w.oauth.exchange,{code:t})))),startNative:(t,n,o)=>B(e.post(w.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>B(e.post(w.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>B(e.get(w.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>B(e.post(w.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>B(e.post(w.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),He=pe("appId"),Je=de(He),Ve=e=>({connect:Je(((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,B(e.post(w.outbound.connect,{appId:t,tenantId:i,tenantLevel:r,options:n},{token:o}))}))}),Ke=pe("loginId"),Be=de(Ke,pe("code")),ze=de(Ke),Ze=de(Ke,fe("phone")),Ge=de(Ke,ge("email")),Xe=e=>({verify:Object.keys(Ie).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Be(((t,o)=>B(e.post(K(w.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Ie).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:ze(((n,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return B(e.post(K(w.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Ie).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:ze(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(K(w.otp.signUp,o),{loginId:n,user:i,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Ie).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:ze(((n,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return B(e.post(K(w.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:Ge(((t,n,o,i)=>B(e.post(w.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ze(((t,o,i,r)=>B(e.post(K(w.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),Ye=de(pe("tenant")),Qe=de(pe("code")),et=e=>({start:Ye(((t,n,o,i,r,s,a,l)=>B(e.post(w.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:Qe((t=>B(e.post(w.sso.exchange,{code:t}))))}),tt=pe("loginId"),nt=de(tt,pe("code")),ot=de(tt),it=de(tt),rt=e=>({signUp:ot(((t,n)=>B(e.post(w.totp.signUp,{loginId:t,user:n})))),verify:nt(((t,n,o,i)=>B(e.post(w.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),update:it(((t,n)=>B(e.post(w.totp.update,{loginId:t},{token:n}))))}),st=pe("loginId"),at=pe("newPassword"),lt=de(st,pe("password")),ct=de(st),dt=de(st,at),ut=de(st,pe("oldPassword"),at),ht=e=>({signUp:lt(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(w.password.signUp,{loginId:n,password:o,user:i,loginOptions:a,providerId:s}))})),signIn:lt(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return B(e.post(w.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:r}))})),sendReset:ct(((t,n,o)=>B(e.post(w.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:dt(((t,n,o)=>B(e.post(w.password.update,{loginId:t,newPassword:n},{token:o})))),replace:ut(((t,n,o)=>B(e.post(w.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>B(e.get(w.password.policy))}),pt=ue("loginId"),gt=pe("loginId"),ft=pe("origin"),vt=de(gt,ft,pe("name")),mt=de(gt,ft),bt=de(pt,ft),wt=de(gt,ft,he("token")),yt=de(pe("transactionId"),pe("response")),kt=e=>({signUp:{start:vt(((t,n,o,i,r)=>B(e.post(w.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,loginOptions:r,passkeyOptions:i})))),finish:yt(((t,n)=>B(e.post(w.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:bt(((t,n,o,i,r)=>B(e.post(w.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:yt(((t,n)=>B(e.post(w.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:mt(((t,n,o,i)=>B(e.post(w.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:o}))))},update:{start:wt(((t,n,o,i,r)=>B(e.post(w.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i,mfa:r},{token:o})))),finish:yt(((t,n)=>B(e.post(w.webauthn.update.finish,{transactionId:t,response:n}))))}}),It=ue("loginId"),St=de(It),Ct=de(pe("pendingRef")),Ot=e=>({signUpOrIn:St(((n,o={})=>{var{providerId:i}=o,r=t(o,["providerId"]);return B(e.post(w.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:i}))})),signUp:St(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return B(e.post(w.notp.signUp,{loginId:n,user:o,providerId:r,loginOptions:s}))})),signIn:St(((n,o={},i)=>{var{providerId:r}=o,s=t(o,["providerId"]);return B(e.post(w.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:i}))})),waitForSession:Ct(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=we(n);let s;const a=setInterval((async()=>{const n=await e.post(w.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(B(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),xt=de(pe("token")),At=de(he("token"));var Et,jt=de([(Et=pe("projectId"),Z(((e,t)=>n=>X(...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",Et))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=M({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:me(l),otp:Xe(l),magicLink:_e(l),enchantedLink:je(l),oauth:Fe(l),outbound:Ve(l),sso:et(l),saml:et(l),totp:rt(l),notp:Ot(l),webauthn:kt(l),password:ht(l),flow:$e(l),refresh:At(((e,t,n,o)=>{const i={};n&&(i.externalToken=n);const r=o?w.tryRefresh:w.refresh;return B(l.post(r,i,{token:e,queryParams:t}))})),selectTenant:de([ie("tenantId")],[le('"token" must be string or undefined')])(((e,t)=>B(l.post(w.selectTenant,{tenant:e},{token:t})))),logout:At((e=>B(l.post(w.logout,{},{token:e})))),logoutAll:At((e=>B(l.post(w.logoutAll,{},{token:e})))),me:At((e=>B(l.get(w.me,{token:e})))),myTenants:de([ce('"tenants" must a string array or a boolean')],[le('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,B(l.post(w.myTenants,n,{token:t}))})),history:At((e=>B(l.get(w.history,{token:e})))),isJwtExpired:xt(F),getTenants:xt(H),getJwtPermissions:xt(J),getJwtRoles:xt(V),getCurrentTenant:xt(z),httpClient:l};var l})),Ut=Object.assign(jt,{DeliveryMethods:Ie});
2
- /*! js-cookie v3.0.8 | MIT */function Rt(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 $t=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=Rt({},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,"",Rt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Rt({},this.attributes,t))},withConverter:function(t){return e(Rt({},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 Tt={default:"endpoint"},Lt="Blocked by CSP",Pt="The endpoint parameter is not a valid URL",Wt="Failed to load the JS script of the agent",Nt="9319";function Mt(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===Lt||s===Pt)n.exclude(),r=0;else if(s===Nt)n.exclude();else if(s===Wt){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 _t="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Dt=_t;function qt(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:_t,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 Mt(e,Ft)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Nt?new Error(Wt):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 Ft(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(Pt);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(Wt))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(Lt)})).then(Ht)}function Ht(){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(Nt);return n}const Jt="3.2.0",Vt="undefined"!=typeof window,Kt=Math.pow(2,31)-1,Bt=`https://descopecdn.com/npm/oidc-client-ts@${Jt}/dist/browser/oidc-client-ts.min.js`,zt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Jt}/dist/browser/oidc-client-ts.min.js`,Zt=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let Gt;const Xt=e=>{try{return b(e).exp}catch(e){return null}},Yt=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Xt(n)},Qt=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?Xt(o):void 0)},en=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||Qt(e),cookieExpiration:e.cookieExpiration||Yt(e)},s)},tn=(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},nn=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 en(n)},on=()=>Vt&&!!window.descopeBridge,rn=(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 Zt.includes(n)},sn=void 0!==Gt||Vt&&void 0!==window.localStorage,an=(e,t)=>{var n,o;return null===(o=null===(n=Gt||Vt&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},ln=e=>{var t,n;return null===(n=null===(t=Gt||Vt&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},cn=e=>{var t,n;return null===(n=null===(t=Gt||Vt&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},dn=e=>{var t,n,o,i,r;return null!==(r=null!==(n=null===(t=null==Gt?void 0:Gt.key)||void 0===t?void 0:t.call(Gt,e))&&void 0!==n?n:Vt&&(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},un=e=>{var t,n;return Vt&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},hn=e=>{var t,n;try{Vt&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},pn=(...e)=>{console.debug(...e)},gn=(...e)=>{console.warn(...e)},fn=(e,t)=>{let n;var o;return t>0?(n=1e3*t,pn(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>Kt&&(pn(`Timeout is too large (${n}ms), setting it to ${Kt}ms`),n=Kt),n},vn="DS",mn="DSR",bn="DSI",wn="DSRCN";function yn(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=kn(o);$t.set(e,t,{path:i,domain:c?o:void 0,expires:l,sameSite:r,secure:a})}}function kn(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 In=e=>(null==e?void 0:e.cookieName)||vn,Sn=e=>(null==e?void 0:e.cookieName)||mn;function Cn(e="",t){return $t.get(Sn(t))||ln(`${e}${mn}`)||""}function On(e="",t){return $t.get(In(t))||ln(`${e}${vn}`)||""}function xn(e=""){return ln(`${e}${bn}`)||""}function An(e="",t,n,o){cn(`${e}${mn}`),cn(`${e}${vn}`),cn(`${e}${bn}`),cn(`${e}${wn}`);const i=In(t);$t.remove(i,null==o?void 0:o.session);const r=Sn(n);$t.remove(r,null==o?void 0:o.refresh)}const En=(e,t,n)=>o=>{const i=Object.assign(o,{token:o.token||Cn(e,t)});if(!n){const t=function(e=""){return ln(`${e}${wn}`)}(e);t&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return ln(`${e}DTD`)||""}(e);return r&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-trusted-device-token":r})),i},jn=Vt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Un="vsid",Rn="vrid",$n="fp",Tn=(e=!1)=>{const t=ln($n);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Ln=async(e,t=jn)=>{try{if(Tn())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=qt({apiKey:e,endpoint:[o.toString(),Tt],scriptUrlPattern:[r,Dt]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Un]:e,[Rn]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};an($n,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Pn=e=>{const t=Tn(!0);return t&&e.body&&(e.body.fpData=t),e},Wn="descopeFlowNonce",Nn="X-Descope-Flow-Nonce",Mn="/v1/flow/start",_n="/v1/flow/next",Dn=(e,t=Wn)=>`${t}${e}`,qn=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Fn=e=>{var t;return e.path===_n&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?qn(e.body.executionId):null},Hn="dls_last_user_login_id",Jn="dls_last_user_display_name",Vn=e=>an(Hn,e),Kn=()=>ln(Hn),Bn=()=>ln(Jn),zn=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=Kn(),r=Bn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)},Zn="DSLI",Gn=e=>async(...t)=>{const n=await e(...t);return hn(Zn),n};function Xn(){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 Yn(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ro(n.publicKey.challenge),n.publicKey.user.id=ro(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=ro(e.id)})),n}(e);try{return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:so(n.rawId),type:n.type,response:{attestationObject:so(n.response.attestationObject),clientDataJSON:so(n.response.clientDataJSON)}})}catch(e){throw await to(e,t,!0)}var n}async function Qn(e){const t=oo(e);try{return io(await navigator.credentials.get(t))}catch(e){throw await to(e,t,!1)}}async function eo(e,t){const n=oo(e);n.signal=t.signal,n.mediation="conditional";try{return io(await navigator.credentials.get(n))}catch(e){throw await to(e,n,!1)}}async function to(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 no())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 no(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function no(e=!1){var t,n;if(!Vt)return Promise.resolve(!1);if(on()){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 oo(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ro(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=ro(e.id)})),n}function io(e){return JSON.stringify({id:e.id,rawId:so(e.rawId),type:e.type,response:{authenticatorData:so(e.response.authenticatorData),clientDataJSON:so(e.response.clientDataJSON),signature:so(e.response.signature),userHandle:e.response.userHandle?so(e.response.userHandle):void 0}})}function ro(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function so(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ao,lo=(ao=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 Yn(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 Qn(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 Yn(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await Qn(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 Yn(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:Yn,get:Qn,isSupported:no,conditional:eo}}),(...e)=>{const t=ao(...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 co="/fedcm/config",uo=()=>{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 ho(e,t){var n;try{await po(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function po(e,t){var n,o;const i=await async function(e,t="google",n,o,i){const r=uo(),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 go=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await no(),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 fo;const vo=(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",(()=>{vo(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),mo=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{fo||(fo=(async()=>{try{return require("oidc-client-ts")}catch(e){return vo([Bt,zt],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await fo;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)))),an(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=ln(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||xn(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return cn(i),t||window.location.replace(s),r}}},bo=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Gt=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return Vt?(o&&i&&Ln(o).catch((()=>null)),e(tn(r,{beforeRequest:Pn}))):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.3"},t.baseHeaders)}))),(e=>t=>{const n=Xn(),o=Xn(),i=Xn(),r=Xn(),s=e(tn(t,{afterRequest:async(e,t)=>{if(rn(e,t))pn("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 nn(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 nn(t);s&&o.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=be(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=Wn}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return e(s);((e=Wn)=>{try{if(!sn)return;for(let i=0;i<(void 0,n=void 0,void 0,null!==(o=null!==(t=null==Gt?void 0:Gt.length)&&void 0!==t?t:Vt&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);i++){const t=dn(i);if(t&&t.startsWith(e)){const n=ln(t);if(n)try{JSON.parse(n).expiry<Date.now()&&cn(t)}catch(e){cn(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(r);const a=e(tn(s,{afterRequest:async(e,t)=>{if(e.path!==Mn&&e.path!==_n)return;const{nonce:n,executionId:o}=await(async(e,t)=>{try{const n=t.headers.get(Nn);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=Fn(e)),{nonce:n,executionId:qn(o)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&o&&((e,t,n,o=Wn)=>{try{const i=Dn(e,o),r=n?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:n};an(i,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(o,n,e.path===Mn,r)},beforeRequest:e=>{if(e.path===_n){const t=Fn(e);if(t){const n=((e,t=Wn)=>{try{const n=Dn(e,t),o=ln(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(((e,t=Wn)=>{try{const n=Dn(e,t);cn(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):i.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,r);n&&(e.headers=e.headers||{},e.headers[Nn]=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(tn(t,{afterRequest:async(e,t)=>{if(rn(e,t))return void hn(Zn);const n=await nn(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,o;try{Vt&&(null===(o=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o||o.call(n,e,t))}catch(e){}})(Zn,String(n.sessionExpiration))}}));return be(n,["logout","logoutAll","oidc.logout"],Gn)}),(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||on())return Object.assign(e(i),{markUserActive:()=>{gn("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&&(pn("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Vt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(pn("Expiration time passed, refreshing session"),g.refresh(Cn()||d))}));const g=e(tn(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i,nextRefreshSeconds:r}=await nn(t);if(rn(e,t))pn("Session invalidated, canceling all timers"),a();else if(n||i){if(c=((e,t)=>{if(t)return new Date(1e3*t);pn("Could not extract expiration time from session token, trying to decode the token");try{const t=b(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!c)return void pn("Could not extract expiration time from session token");d=o,h=r>0;const e=fn(c,r);if(a(),e<=2e4)return void pn("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});pn(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Vt&&"hidden"===document.visibilityState)pn("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return pn("Skipping refresh due to timer - user is idle"),void(p=!0);pn("Refreshing session due to timer"),g.refresh(Cn()||o)}}),e)}}}));return Object.assign(be(g,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return pn("Clearing all timers"),a(),n})),{markUserActive:u?()=>{pn("markUserActive() called"),h||pn("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(pn("User became active after skipped refresh, triggering refresh"),p=!1,a(),g.refresh(Cn()||d))}:()=>{gn("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:Kn,getLastUserDisplayName:Bn});const s=e(tn(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=en((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?(Vn(r),(e=>{an(Jn,e)})(s)):(null==i?void 0:i.loginId)&&Vn(i.loginId)}}));let a=be(s,["flow.start"],zn);return a=be(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(cn(Hn),cn(Jn)),o})(i)),Object.assign(a,{getLastUserLoginId:Kn,getLastUserDisplayName:Bn})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!o||!Vt)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(tn(Object.assign({refreshCookieName:a},l),{beforeRequest:En(s,r,a),afterRequest:async(e,t)=>{if(rn(e,t))pn("Session invalidated, clearing persisted tokens"),An(s,i,r,c);else{const e=await nn(t);e.cookieName?an(`${s||""}${wn}`,e.cookieName):e.refreshJwt&&cn(`${s||""}${wn}`);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){cn(`${n}${mn}`);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=Sn(o);s&&"https:"!==window.location.protocol&&gn("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});yn(l,c,d);const h=kn(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=Sn(o);$t.remove(e),an(`${n}${mn}`,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=In(t);o&&"https:"!==window.location.protocol&&gn("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});yn(r,l,c);const d=kn(i);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?i:void 0}})}else an(`${n}${vn}`,l);return e.idToken&&an(`${n}${bn}`,e.idToken),d&&an(`${n}DTD`,d),u})(e,i,s,r);n&&(c=n)}}})),u=be(d,["logout","logoutAll","oidc.logout"],((e,t,n,o)=>i=>async(...r)=>{const s=await i(...r);return An(e,t,n,null==o?void 0:o()),s})(s,i,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Cn(s,r),getSessionToken:()=>On(s,i),getIdToken:()=>xn(s)})}))((e=>{const t=Ut(e),n=mo(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,i)=>{var r;if(on())return pn(`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&&Vt&&void 0!==window.localStorage&&!un(Zn)&&!ln(Hn)&&!un("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=On(),a=Cn();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){pn("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:go(t),webauthn:lo(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){ho(o,e)},requestAuthentication(e){ho(o,e)}},async oneTap(e,t,n,i,r){await po(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+co),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>Vt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+co);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})),wo="undefined"!=typeof localStorage,yo="J151000",ko="E103205",Io="E108201",So=wo&&localStorage.getItem("base.content.url")||"",Co="base.ui.components.url";wo&&localStorage.getItem(Co),wo&&localStorage.getItem(Co);const Oo="descope-login-flow",xo="code",Ao="redirect_mode",Eo="err",jo="data-exclude-field",Uo="data-exclude-next",Ro="dls_last_auth",$o="dls_last_submitted_login_id",To="state_id",Lo="saml_idp_state_id",Po="wsfed_idp_state_id",Wo="saml_idp_username",No="descope_idp_initiated",Mo="sso_app_id",_o="custom_app_id",Do="third_party_app_id",qo="third_party_app_state_id",Fo="oidc_login_hint",Ho="oidc_prompt",Jo="oidc_resource",Vo="oidc_error_redirect_uri",Ko="application_scopes",Bo="data-type",zo="redirect",Zo="poll",Go="webauthnCreate",Xo="webauthnGet",Yo="nativeBridge",Qo="loadForm",ei="submit",ti="polling",ni=["descope-multi-select-combo-box","descope-text-area"],oi="dls_last_auth_in_flight",ii=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts","data","totp","notp","sentTo","sso","selfProvisionDomains"];var ri;!function(e){e.backward="backward",e.forward="forward"}(ri||(ri={}));const si=["descope-enriched-text"];function ai(e){return new URLSearchParams(window.location.search).get(e)}function li(e){if(window.history.replaceState&&ai(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function ci(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?ri.forward:n<o?ri.backward:void 0}const di=e=>{let[t="",n=""]=(ai(Oo)||"").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 ui(){li(Oo)}const hi=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),pi=(e,t)=>{const{executionId:n,stepId:o,executionFlowId:i}=di(e);if(i&&e!==i)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&ui();const r=ai("t")||void 0;r&&li("t");const s=ai(xo)||void 0;s&&li(xo);const a="popup"===ai(Ao);a&&li(Ao);const l=ai(Eo)||void 0;l&&li(Eo);const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:ai("ra-challenge"),redirectAuthCallbackUrl:ai("ra-callback"),redirectAuthBackupCallbackUri:ai("ra-backup-callback"),redirectAuthInitiator:ai("ra-initiator")},p=ai(To);p&&li(To);const g=ai(Lo);g&&li(Lo);const f=ai(Po);f&&li(Po);const v=ai(Wo);g&&li(Wo);const m=ai(No);m&&li(No);const b=ai(Mo);b&&li(Mo);const w=ai(_o);w&&li(_o);const y=ai(Do);y&&li(Do);const k=ai(qo);k&&li(qo);const I=ai(Ko);I&&li(Ko);const S=ai(Fo);S&&li(Fo);const C=ai(Ho);C&&li(Ho);const O=ai(Vo);O&&li(Vo);const x=ai(Jo);x&&li(Jo);return{executionId:n,stepId:o,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:g,wsfedIdpStateId:f,samlIdpUsername:v,descopeIdpInitiated:"true"===m,ssoAppId:b,customAppId:w,oidcLoginHint:S,oidcPrompt:C,oidcErrorRedirectUri:O,oidcResource:x,thirdPartyAppId:y,thirdPartyAppStateId:k,applicationScopes:I}}},gi=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}})},fi=(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 vi(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 mi=(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),bi=e=>null==e?void 0:e.submit(),wi=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},yi=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},ki={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"},Ii=(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},Si=[{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(ki).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=Ii(e,"recoveryCodes");if(t)return Array.isArray(t.data)?t.data.map((e=>e.value)):[]})(e.componentsConfig)},{key:"outboundApp",from:e=>(e=>{const t=Ii(e,"outboundApp");if(t)return{label:t.label,iconSrc:t["icon-src"],appId:t["data-descope-outbound-oauth-app-id"]}})(e.componentsConfig)}],Ci=e=>{const t=(n=e.screenState,o=(e,t)=>ii.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!o(t,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 Si.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},Oi=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function xi(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}const Ai=(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};var Ei,ji,Ui,Ri;function $i(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(!$i(r,s))return!1}else if(r!==s)return!1}return!0}class Ti{constructor(e={},{forceUpdate:t=!1}={}){Ei.set(this,void 0),ji.set(this,{}),Ui.set(this,0),Ri.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,Ei,"f")):e,n=Object.assign(Object.assign({},o(this,Ei,"f")),t),r=o(this,Ei,"f");i(this,Ei,n,"f"),Object.freeze(o(this,Ei,"f")),setTimeout((()=>{Object.values(o(this,ji,"f")).forEach((({cb:e,selector:t,forceUpdate:i})=>{const s=t(r),a=t(n);(o(this,Ri,"f")||i||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!$i(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},i(this,Ei,e,"f"),i(this,Ri,t,"f")}get current(){return Object.assign({},o(this,Ei,"f"))}set forceUpdate(e){i(this,Ri,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return i(this,Ui,o(this,Ui,"f")+1,"f"),o(this,ji,"f")[o(this,Ui,"f")]={cb:e,selector:t,forceUpdate:n},o(this,Ui,"f").toString()}unsubscribe(e){const t=!!o(this,ji,"f")[e];return t&&delete o(this,ji,"f")[e],t}unsubscribeAll(){return i(this,ji,{},"f"),!0}}Ei=new WeakMap,ji=new WeakMap,Ui=new WeakMap,Ri=new WeakMap;const Li=["*","#","/","(",")","[","]","_","<",">","`"],Pi=e=>{const t=Li.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")},Wi=["disabled"],Ni=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${jo}])`)).forEach((e=>{e.value=n}))}))},Mi=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),_i=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,o)=>n?(e=>"string"!=typeof e?e:e.replace(Pi("\\"),"\\$1"))(Mi(t,o)):Mi(t,o))),Di=(e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(o=e.localName,si.includes(o));var o;e.textContent=_i(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",_i(i,t))}))},qi=(e,t,n)=>{e.querySelectorAll(`[${Bo}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Fi=(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})`))},Hi=(e,n,o,i)=>{var r,s;qi(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),qi(e,"notp-link",null===(s=null==n?void 0:n.notp)||void 0===s?void 0:s.redirectUrl),Di(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=_i(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])=>{Wi.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)},Ji=gi((()=>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 vi(100,n,o)}catch(e){return console.error("Conditional login check failed",e),!1}})))),Vi=(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))]};let Ki;const Bi=(e,t)=>{Ki?Ki.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},zi=e=>Ki?Ki.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,Zi="dls_ab_testing_id",Gi={"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 Xi(e,t){const n={};try{Object.assign(n,JSON.parse(zi(Ro)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function Yi(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||Bi(Ro,JSON.stringify(e)))}function Qi(){try{return JSON.parse(zi(oi)||"{}")}catch(e){return{}}}function er(e){try{t=oi,Ki?Ki.removeItem(t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(t)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}var t}const tr=["error","warn","info","debug"],nr={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},or=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,nr))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e||nr),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return tr.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})),ir="undefined"!=typeof localStorage,rr="https://static.descope.com/pages",sr="https://static2.descope.com/pages",ar=ir&&localStorage.getItem("base.content.url")||"",lr=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,cr=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})),dr=l((e=>{var t,n;const i=r(or,cr)(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})),ur=e=>t=>{var n,i,s;const a=r(or,cr,dr)(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};ur.missingAttrValidator=lr;const hr=l((e=>{const t=r(ur({"project-id":lr}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),pr=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),gr="Trying the next fallback URL...",fr=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 vr=l((e=>{var t,n,s,a,l,c,d;const u=r(or,hr,pr)(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 fr(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}. ${gr}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${gr}`)}}})(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=ar||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")===rr&&l.push(o(this,t,"m",c).call(this,e,sr));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(rr)||l.push(o(this,t,"m",c).call(this,e,rr)),l.push(o(this,t,"m",c).call(this,e,sr))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o=rr}){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})),mr=l((e=>{var t,n;const i=r(ur({"project-id":lr}))(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})),br=l((e=>{var t,n,s,a,l;const c=r(vr,mr,cr)(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})),wr=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],yr=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()}`},kr=(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)})),Ir=(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)}))}))},Sr=l((e=>{const t=r(or)(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 Ir(s,r),o}catch(e){t(o,!0)}else try{return await kr(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("/","_")}-${yr(a)}`};return i&&(l.integrity=i),[...e,l]}),[]))([...o,this.baseCdnUrl,...wr],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}"`)}))}}})),Cr="base.ui.components.url",Or=ir&&localStorage.getItem(Cr),xr=l((e=>{var t,n,s,a,l,c,d;const u=r(or,br,Sr)(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=Or?void 0:await o(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[Or],i),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),Ar=l((e=>{var t,n,i;const s=r(cr,dr)(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 Er{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 jr=l((e=>{const t=r(Ar)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new Er(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}}})),Ur="content-root",Rr="root",$r=l((e=>{const t=r(jr)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${Rr}">\n <div id="${Ur}"></div>\n </div>\n `,this.injectStyle(`\n #${Rr}, #${Ur} {\n height: 100%;\n }\n #${Rr} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(Ur),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Rr)}}})),Tr=(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+Tr(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 Lr(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]=Lr(n[e]||{},o)}else n[e]="string"==typeof o?(n[e]||"")+o:o;return n}const Pr=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",Wr=l((e=>{const t=r(ur({tenant:Pr}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),Nr=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Mr=l((e=>{var t,n,s,a,l,c,d,u,h,p,g,f,v,m,b,w,y,k,I,S,C,O;const x=r(ur({theme:Nr}),Wr,vr,cr,xr,br,$r,dr,jr)(e);return O=class extends x{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,C,"f").call(this,"os"===this.getAttribute("theme"))})),C.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")||"theme"}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,C=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}"]{${Tr({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");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")},g=async function(){const e=this.tenantId;if(e)try{const{body:t}=await this.fetchStaticResource(`${e}/theme.json`,"json");return t}catch(e){this.logger.error("Cannot fetch tenant theme file","make sure that your tenantId, projectId & flowId are correct")}},f=function(){return o(this,d,"f")||i(this,d,o(this,t,"m",g).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",f);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",f);a.componentsThemeManager.themes={light:Lr((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:Lr((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)},O})),_r=(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?_r(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),_r(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}),[]),Dr=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}));l((e=>{var t,n,s,a,l,c,d;return d=class extends(r(cr,or)(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 hl})),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}));const qr="descope-modal";var Fr,Hr,Jr,Vr,Kr;class Br{constructor(e,t){Fr.set(this,void 0),this.nodeName="",i(this,Fr,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,Fr,"f"))}get ele(){var e,t;const n="function"==typeof o(this,Fr,"f")?o(this,Fr,"f").call(this):o(this,Fr,"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}}Fr=new WeakMap;class zr extends Br{constructor(...e){super(...e),Hr.add(this),Jr.set(this,void 0),Vr.set(this,void 0),this.nodeName="descope-modal",o(this,Hr,"m",Kr).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,Hr,"m",Kr).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,Jr,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,Jr,"f").content.cloneNode(!0)))}setContent(e){i(this,Jr,e,"f"),this.reset()}remove(){var e,t;null===(e=o(this,Vr,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}}Jr=new WeakMap,Vr=new WeakMap,Hr=new WeakSet,Kr=function(){if(o(this,Vr,"f"))return;const e=this.ele;e&&(i(this,Vr,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,Vr,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};class Zr extends Br{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()}}l((e=>{var t,n;const i=r(cr,$r,xr)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends zr{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(qr);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([qr]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n}));const Gr="descope-notification";l((e=>{var t,n;const i=r(cr,$r,xr)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Zr{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(Gr);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([Gr])}},t=new WeakMap,n})),l((e=>class extends(or(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 Xr=l((e=>{const t=r(ur({"widget-id":lr}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}}));l((e=>{const t=r(br,Xr)(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]}}})),l((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=f(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:""}})),l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),l((e=>{var n,i,r;return r=class extends(Mr(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}));const Yr=["input","change"];function Qr(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 es(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 ts(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 ns(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function os(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const is=new Map;const rs={equal:(e,t)=>e===t||es(e)===es(t),"not-equal":(e,t)=>e!==t&&es(e)!==es(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(es(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(es(t)),"greater-than":(e,t)=>{const n=Qr(e),o=Qr(t);return n.ok&&o.ok&&n.value>o.value},"greater-than-or-equal":(e,t)=>{const n=Qr(e),o=Qr(t);return n.ok&&o.ok&&n.value>=o.value},"less-than":(e,t)=>{const n=Qr(e),o=Qr(t);return n.ok&&o.ok&&n.value<o.value},"less-than-or-equal":(e,t)=>{const n=Qr(e),o=Qr(t);return n.ok&&o.ok&&n.value<=o.value},empty:e=>os(e),"not-empty":e=>!os(e),"is-true":e=>{const t=ts(e);return t.ok&&t.value},"is-false":e=>{const t=ts(e);return t.ok&&!t.value},in:(e,t)=>{const n=ns(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=ns(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(is.has(e))return null!==(t=is.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return is.set(e,n),n}(es(t));return null!==n&&n.test(e)}};function ss(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=>ss(e,t))):e.value}function as(e,t){const n=rs[e.operator];if(!n)return!1;return n(ss(e.target,t),ss(e.predicate,t))}function ls(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=>as(e,t))):o.every((e=>as(e,t))))}(e,t)))}function cs(e,t){const n={};return(null!=e?e:[]).forEach((e=>{var o;ls(e,t)&&(null!==(o=e.componentIds)&&void 0!==o?o:[]).forEach((t=>{n[t]=e.action}))})),n}const ds=["hide","disable","read-only"];const us=/(["\\])/g;function hs(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(us,"\\$1")}function ps(e,t){return Array.from(e.querySelectorAll(`[id="${hs(t)}"]`))}function gs(e,t,n){return Object.keys(t).forEach((o=>{const i=t[o];n[o]!==i&&ps(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&&ps(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 fs="component-conditions:";function vs(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 ms(e,t){const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((n=>e[n]===t[n]))}function bs(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function ws(e,t,n){const o={};return n.forEach((n=>{e[n]?o[n]=e[n]:t[n]&&(o[n]=t[n])})),o}const ys=l((e=>{var t,n,s,a,l,c;const d=r(or)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,bs())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{ds.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${ds.map((e=>`"${e}"`)).join(", ")}`)})),gs(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(`${fs} no real-time rules to apply on this screen`);this.logger.info(`${fs} 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="${hs(t)}"]`)||e.querySelector(`[name="${hs(n)}"]`)}(e,t);if(!n)return;const o=vs(n);void 0!==o&&(p[t]=o)}));const g=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),f={},v={};Object.entries(null!==(d=null==r?void 0:r.componentsState)&&void 0!==d?d:{}).forEach((([e,t])=>{g.has(e)&&(v[e]=t)})),Object.entries(null!==(u=null==r?void 0:r.serverOnlyComponentsState)&&void 0!==u?u:{}).forEach((([e,t])=>{g.has(e)&&(f[e]=t)}));const m={conditions:h,touchedIds:g,snapshot:p,applied:v,serverBaseline:f,debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:e},b=ws(cs(h,p),f,g);ms(v,b)||(m.applied=gs(e,v,b)),m.inputHandler=e=>o(this,t,"m",s).call(this,e),Yr.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${fs} listening for "${Yr.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,jo))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]=vs(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=ws(cs(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${fs} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const i=e.applied;ms(i,t)||(this.logger.debug(`${fs} form changed — updating components: was ${JSON.stringify(i)}, now ${JSON.stringify(t)}`),e.applied=gs(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&&gs(e.root,e.applied,{}),Yr.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)}))),i(this,n,bs(),"f")},c})),ks="project-id",Is="flow-id",Ss=e=>{const t=(e=>{const t=e.getAttribute(ks),n=e.getAttribute(Is);return t&&n?Array.from(e.ownerDocument.querySelectorAll("descope-wc")).filter((e=>e.getAttribute(ks)===t&&e.getAttribute(Is)===n)):[]})(e);return t.length>1&&t[0]!==e},Cs=l((e=>{var t,n,s,a;const l=r(or)(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!==ks&&e!==Is||o(this,t,"m",s).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){queueMicrotask((()=>{if(!this.isConnected)return;const e=this.getAttribute(ks),t=this.getAttribute(Is),r=`${e}|${t}`;o(this,n,"f")!==r&&Ss(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})),Os=["externalId","email","phone"],xs=["newPassword","password"],As="data-username-anchor",Es=e=>{var t;if(!e)return"";try{const n=null===(t=window.sessionStorage)||void 0===t?void 0:t.getItem($o);if(!n)return"";const o=JSON.parse(n);return o.executionId===e&&o.loginId||""}catch(e){return""}},js=(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"]',...Os.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(jo,"true"),t.setAttribute(As,"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")},Us=l((e=>{var t,n,s,a,l;const c=r(or)(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:[Es(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(`[${As}="true"]`).forEach((e=>e.remove())),js(this,o(this,t,"a",s).contentRootElement,o(this,n,"f"),this.logger)}captureLastSubmittedLoginId(e={},n){const i=wi(e,Os);i&&((e,t)=>{var n;if(e&&t)try{null===(n=window.sessionStorage)||void 0===n||n.setItem($o,JSON.stringify({executionId:t,loginId:e}))}catch(e){}})(i,n||o(this,t,"a",a))}storeCredentials(e={}){var t,i,r,s,a;const l=wi(e,Os)||(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]),c=wi(e,xs);if(l&&c)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:l,password:c});null===(a=null===(s=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===s?void 0:s.store)||void 0===a||a.call(s,e)}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 Rs,$s,Ts,Ls,Ps,Ws,Ns,Ms,_s,Ds,qs,Fs,Hs,Js,Vs,Ks,Bs,zs,Zs,Gs,Xs,Ys;const Qs=r(Mr,vr,Dr,ys,Cs,Us,jr)(HTMLElement);class ea extends Qs{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(),Rs.add(this),Ts.set(this,!1),Ls.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,Rs,"m",Ys).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)}},Ps.set(this,new Ti),Ws.set(this,new Ti),Ns.set(this,{}),this.getComponentsContext=()=>o(this,Ns,"f"),this.nextRequestStatus=new Ti({isLoading:!1}),Ms.set(this,void 0),_s.set(this,{popstate:o(this,Rs,"m",Js).bind(this),componentsContext:o(this,Rs,"m",Zs).bind(this)}),Ds.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,Ds,e,"f"),o(this,Rs,"m",Fs).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 _r(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return e=this.formConfig,t="value",Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]])));var e,t}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const e=JSON.parse(this.getAttribute("outbound-app-scopes"));return e||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return o(this,Ls,"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,Ls,e,"f"),(e=>{Ki=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=ni.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(),n="projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{};return n||(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,Ws,"f").subscribe(o(this,Rs,"m",Xs).bind(this)),o(this,Ws,"f").update({isDebug:this.debug}),o(this,Rs,"m",Hs).call(this),yield o(this,Rs,"m",Bs).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:g,ssoQueryParams:f}=pi(this.flowId,this.loggerWrapper);window.addEventListener("popstate",o(this,_s,"f").popstate),window.addEventListener("components-context",o(this,_s,"f").componentsContext),o(this,Ps,"f").subscribe(o(this,Rs,"m",Ks).bind(this)),o(this,Ps,"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:g},f)),i(this,Ts,!0,"f")}))}disconnectedCallback(){var e;o(this,Ps,"f").unsubscribeAll(),o(this,Ws,"f").unsubscribeAll(),o(this,Rs,"m",Gs).call(this),window.removeEventListener("popstate",o(this,_s,"f").popstate),window.removeEventListener("components-context",o(this,_s,"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,Ts,"f")&&t!==n&&$s.observedAttributes.includes(e)){o(this,Rs,"m",Hs).call(this);const i=null===t;o(this,Ps,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,ui()),{[hi(e)]:n,stepId:r,executionId:s}})),o(this,Ws,"f").update({isDebug:this.debug})}}}var ta,na,oa,ia,ra,sa,aa,la,ca,da,ua,ha,pa,ga,fa,va,ma,ba,wa,ya,ka,Ia,Sa,Ca,Oa,xa,Aa,Ea,ja,Ua,Ra,$a,Ta,La,Pa,Wa,Na,Ma,_a;$s=ea,Ts=new WeakMap,Ls=new WeakMap,Ps=new WeakMap,Ws=new WeakMap,Ns=new WeakMap,Ms=new WeakMap,_s=new WeakMap,Ds=new WeakMap,Rs=new WeakSet,qs=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 ")},Fs=function(){o(this,Rs,"m",qs).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Hs=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"];$s.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[hi(t)])throw Error(`${t} cannot be empty`)}))},Js=function(){const{stepId:e,executionId:t}=di(this.flowId);o(this,Ps,"f").update({stepId:e,executionId:t})},Vs=function(e,t){bo&&"function"==typeof bo||this.logger.error("SDK was not loaded properly",bo,JSON.stringify(bo));const i=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},$s.sdkConfigOverrides),{projectId:e,baseUrl:t});o(this,Ls,"f")&&(i.customStorage=o(this,Ls,"f")),this.sdk=bo(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:yo,errorDescription:t.toString()}}}}))}))},Ks=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,Rs,"m",Vs).call(this,t,n)}o(this,Ds,"f").call(this,e)}))},Bs=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield o(this,Rs,"m",zs).call(this))}))},zs=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(So||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}}))},Zs=function(e){i(this,Ns,Object.assign(Object.assign({},o(this,Ns,"f")),e.detail),"f")},Gs=function(){var e;null===(e=o(this,Ms,"f"))||void 0===e||e.remove(),i(this,Ms,null,"f")},Xs=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,Ms,document.createElement("descope-debugger"),"f"),Object.assign(o(this,Ms,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return vl})),document.body.appendChild(o(this,Ms,"f"))):o(this,Rs,"m",Gs).call(this)}))},Ys=function(e,t){var n;e&&this.debug&&(null===(n=o(this,Ms,"f"))||void 0===n||n.updateData({title:e,description:t}))},ea.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.70.7"}};class Da extends ea{static set sdkConfigOverrides(e){ea.sdkConfigOverrides=e}static get sdkConfigOverrides(){return ea.sdkConfigOverrides}constructor(){const e=new Ti({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),ta.add(this),this.stepState=new Ti({}),na.set(this,void 0),oa.set(this,null),ia.set(this,null),ra.set(this,{visibilitychange:o(this,ta,"m",sa).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},ga.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},va.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,ta,"m",ma).call(this,t):t()})),ba.set(this,((e,t,r,s,a=!1)=>{const l=[ko,"E103202",Io];if(this.flowState.current.action===Zo){if(o(this,ya,"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,na,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,ti,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 vi(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,ba,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===yo)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,ba,"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,ba,"f").call(this,e,t,r,s),o(this,ka,"f").call(this,p)}))),d),"f")}})),wa.set(this,(()=>{clearTimeout(o(this,na,"f")),i(this,na,null,"f")})),ya.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),ka.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,g,f;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,ta,"m",Ma).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!==ko&&d!==Io||!this.isRestartOnError||o(this,ta,"m",pa).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===(g=e.data)||void 0===g?void 0:g.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!==Zo&&o(this,wa,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&Yi(Object.assign(Object.assign({},w),{lastUsedPerScreen:Qi()})),er(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,ta,"m",Ma).call(this,"success",t)}this.storeLastAuthenticatedUser&&Yi(w,!0),k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:C,screen:O,redirect:x,webauthn:A,error:E,samlIdpResponse:j,wsFedIdpResponse:U,nativeResponse:R}=e.data,$=Date.now();y!==Zo?(this.loggerWrapper.info(`Step "${C||`#${S}`}" is ${m}`,"",{screen:O,status:m,stepId:S,stepName:C,action:y,error:E}),(null===(f=O.state)||void 0===f?void 0:f.clientScripts)&&i(this,ia,this.loadSdkScripts(O.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:C,executionId:I,action:y,redirectTo:null==x?void 0:x.url,redirectIsPopup:null==x?void 0:x.isPopup,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==A?void 0:A.transactionId,webauthnOptions:null==A?void 0:A.options,samlIdpResponseUrl:null==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.relayState,wsFedIdpResponseUrl:null==U?void 0:U.url,wsFedIdpResponseWresult:null==U?void 0:U.wresult,wsFedIdpResponseWctx:null==U?void 0:U.wctx,nativeResponseType:null==R?void 0:R.type,nativePayload:null==R?void 0:R.payload,reqTimestamp:$})):this.flowState.update({action:y,reqTimestamp:$})})),Ia.set(this,gi((()=>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)}}))))),Ea.set(this,null),$a.set(this,yi(((e,t,i)=>n(this,void 0,void 0,(function*(){var n,r,s;if("true"===e.getAttribute("formnovalidate")||o(this,ta,"m",xa).call(this)){const a=null==e?void 0:e.getAttribute("id");o(this,ta,"m",Pa).call(this,e,a,i),o(this,ta,"m",ja).call(this,e);const l=yield o(this,ta,"m",Aa).call(this),c=(s=e,Array.from((null==s?void 0:s.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}),{}));this.nextRequestStatus.update({isLoading:!0});const d=Object.assign(Object.assign(Object.assign({},c),l),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin}),u=yield t(a,d);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(l,null===(r=null==u?void 0:u.data)||void 0===r?void 0:r.executionId),this.storeCredentials(l)}}))))),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(xo),e=(null===(i=o.searchParams)||void 0===i?void 0:i.get(Eo))||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(Oo).split("_").pop();o(this,wa,"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:{[xi(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,ta,"m",ua).call(this),window.addEventListener("visibilitychange",o(this,ra,"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,wa,"f").call(this),null===(e=o(this,oa,"f"))||void 0===e||e.abort(),i(this,oa,null,"f"),window.removeEventListener("visibilitychange",o(this,ra,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const o=f(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:g,screenId:v,screenState:m,redirectTo:b,redirectIsPopup:w,redirectUrl:y,token:k,code:I,isPopup:S,exchangeError:C,webauthnTransactionId:O,webauthnOptions:x,redirectAuthCodeChallenge:A,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:U,locale:R,samlIdpResponseUrl:$,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:L,wsFedIdpResponseUrl:P,wsFedIdpResponseWresult:W,wsFedIdpResponseWctx:N,nativeResponseType:M,nativePayload:_,reqTimestamp:D}=e,q=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 F,H,J;const V=(()=>{const e=zi(Zi);if(!e){const e=Math.floor(100*Math.random()+1);return Bi(Zi,e.toString()),e}return Number(e)})(),{outboundAppId:K}=this,{outboundAppScopes:B}=this,z=this.sdk.getLastUserLoginId(),Z=yield this.getFlowConfig(),G=yield this.getProjectConfig(),X=Object.entries(G.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Y=E&&A?{callbackUrl:E,codeChallenge:A,backupCallbackUri:j}:void 0,Q=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let ee={};if(!p){er(this.loggerWrapper);const e=[...Z.clientScripts||[],...Z.sdkScripts||[]];if(Z.conditions){let t=[];({startScreenId:F,conditionInteractionId:J,startScreenName:H,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=Gi[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:z,code:I,token:k,abTestingKey:V,lastAuth:Xi(z,this.loggerWrapper)},Z.conditions)),e.push(...t||[])}else Z.condition?({startScreenId:F,conditionInteractionId:J}=((e,t)=>{var n;const o=null===(n=Gi[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}})(Z.condition,{loginId:z,code:I,token:k,abTestingKey:V,lastAuth:Xi(z,this.loggerWrapper)})):(H=Z.startScreenName,F=Z.startScreenId);if(i(this,ia,this.loadSdkScripts(e),"f"),Z.fingerprintEnabled&&Z.fingerprintKey?yield Ln(Z.fingerprintKey,this.baseUrl):cn($n),!mi(F,q)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Y},q),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:Xi(z,this.loggerWrapper),abTestingKey:V,locale:f(R).locale,nativeOptions:Q,outboundAppId:K,outboundAppScopes:B}),J,"",G.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),I?{exchangeCode:I,idpInitiated:!0}:{}),q.descopeIdpInitiated&&{idpInitiated:!0}),k?{token:k}:{}),q.oidcLoginHint?{externalId:q.oidcLoginHint}:{}));return o(this,ka,"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,ta,"m",_a).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,ei,Z.version,G.componentsVersion,{token:k,exchangeCode:I,exchangeError:C});return o(this,ka,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===Qo&&$&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!T)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)})($,T,L||"",bi)}if(g===Qo&&P&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>s(e)))){if(!W)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,W,N||"",bi)}if(g===zo&&(s("redirectTo")||s("deferredRedirect"))){if(!b)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===b)return;if("android"===U&&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=Ai(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,ta,"m",Ma).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,ta,"m",Ma).call(this,"popupclosed",{});return}if(g===Go||g===Xo){if(!O||!x)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t,n,r;null===(l=o(this,oa,"f"))||void 0===l||l.abort(),i(this,oa,null,"f");try{e=g===Go?yield this.sdk.webauthn.helpers.create(x):yield this.sdk.webauthn.helpers.get(x)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name,n=e.reason,r=e.message}const s=yield this.sdk.flow.next(p,h,ei,Z.version,G.componentsVersion,{transactionId:O,response:e,failure:t,failureReason:n,failureMessage:r});o(this,ka,"f").call(this,s)}if(g===Yo)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,ei,Z.version,G.componentsVersion,e);o(this,ka,"f").call(this,t)})),o(this,ta,"m",ca).call(this,M,_),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&o(this,ba,"f").call(this,p,h,Z.version,G.componentsVersion),!v&&!F)return void this.loggerWrapper.warn("No screen was found to show");const te=F||v,ne=yield this.getHtmlFilenameWithLocale(R,te),{oidcLoginHint:oe,oidcPrompt:ie,oidcErrorRedirectUri:re,oidcResource:se,samlIdpUsername:ae}=q,le={direction:ci(h,r.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:z,name:this.sdk.getLastUserDisplayName()||z},componentsConfig:Object.assign(Object.assign(Object.assign({},Z.componentsConfig),ee),null==m?void 0:m.componentsConfig)}),htmlFilename:`${te}.html`,htmlLocaleFilename:ne,screenId:te,stepName:e.stepName||H,samlIdpUsername:ae,oidcLoginHint:oe,oidcPrompt:ie,oidcErrorRedirectUri:re,oidcResource:se,action:g,locale:f(R).locale},ce=Xi(z,this.loggerWrapper);mi(F,q)?le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==Z?void 0:Z.clientScripts)||[];yield o(this,ta,"m",Ta).call(this,n);const i=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Y},q),{lastAuth:ce,preview:this.preview,abTestingKey:V,client:this.client}),y&&{redirectUrl:y}),{locale:f(R).locale,nativeOptions:Q,outboundAppId:K,outboundAppScopes:B}),J,e,G.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),Oi(t)),I&&{exchangeCode:I,idpInitiated:!0}),q.descopeIdpInitiated&&{idpInitiated:!0}),k&&{token:k}),le.next.isCustomScreen);return o(this,ka,"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,ta,"m",Ta).call(this,n);const i=yield this.sdk.flow.next(p,h,e,Z.version,G.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),Oi(t)),le.next.isCustomScreen);return o(this,ka,"f").call(this,i),i}))),this.loggerWrapper.debug("Got a screen with id",le.screenId),yield o(this,ta,"m",fa).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 g=p.content.cloneNode(!0),f=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield o(this,ta,"m",Ca).call(this,g,d):g.querySelectorAll(`descope-button[${Bo}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!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),Hi(g,u,this.formConfig,this.loggerWrapper),this.applyComponentsState(g,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)}))}))})(g,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)}))}))})(g,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,i;yield f;const r=this.contentRootElement;var s,a;s=r,a=null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image,Fi(s,"descope-totp-image",a),((e,t)=>{Fi(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,g,u.cssVars,this.loggerWrapper),r.replaceChildren(g);const l=!t.htmlFilename;setTimeout((()=>{o(this,ta,"m",Ua).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)=>{Ni(e,null==t?void 0:t.inputs),Ni(e,null==t?void 0:t.form)})(r,u),this.initRealtimeConditions(r,u),o(this,ta,"m",Oa).call(this,{isFirstScreen:l,isCustomScreen:!1,stepName:e.stepName}),fi(r,this.autoFocus,l),o(this,ta,"m",Wa).call(this,h)})),o(this,ta,"m",Na).call(this,d,h);r.querySelector(`[${Bo}="polling"]`)&&d(ti,{})}));c?o(this,ta,"m",ma).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${jo}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}na=new WeakMap,oa=new WeakMap,ia=new WeakMap,ra=new WeakMap,ga=new WeakMap,va=new WeakMap,ba=new WeakMap,wa=new WeakMap,ya=new WeakMap,ka=new WeakMap,Ia=new WeakMap,Ea=new WeakMap,$a=new WeakMap,ta=new WeakSet,sa=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},aa=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,ta,"m",ca).call(this,"beforeScreen",{screen:e,context:t})}))}))},la=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&o(this,ta,"m",ca).call(this,"afterScreen",{screen:e})},ca=function(e,t){o(this,ta,"m",Ma).call(this,"bridge",{type:e,payload:t})},da=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(`[${Bo}="${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()},ua=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,ta,"m",da).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,ta,"m",ha).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})},ha=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=""}))})),fi(this.contentRootElement,this.autoFocus,!1))},pa=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")}))},fa=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=t(r,["next","stepName"]),c=Ci(l);let d=yield o(this,ta,"m",aa).call(this,a,c,s);d||(d=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,c,s,this)));const u=!this.stepState.current.htmlFilename;if(o(this,va,"f").call(this,d),s&&(s.isCustomScreen=d),o(this,ga,"f")!==d){const[e,t]=["flow","custom"].sort((()=>d?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),i(this,ga,d,"f"),d?this.stepState.unsubscribeAll():o(this,ta,"m",ua).call(this)}d?(this.loggerWrapper.debug("Showing a custom screen"),o(this,ta,"m",Oa).call(this,{isFirstScreen:u,isCustomScreen:d,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=d}))},ma=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")},Sa=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)}))}},Ca=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,oa,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Ji())){const{options:e,transactionId:r}=(yield o(this,Ia,"f").call(this))||{};e&&r&&(o(this,ta,"m",Sa).call(this,s),i(this,oa,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,o(this,oa,"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)})))}}))},Oa=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&o(this,ta,"m",Ma).call(this,"ready",{}),t||o(this,ta,"m",la).call(this,n),o(this,ta,"m",Ma).call(this,"page-updated",{screenName:n}),o(this,ta,"m",Ma).call(this,"screen-updated",{screenName:n})},xa=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},Aa=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})),{})}))},ja=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;this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",c);if(!0===(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.abandoned)&&a.length)return i(this,ia,(()=>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,Ea,"f")),i(this,Ea,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),c())}),"f"),window.addEventListener("pageshow",o(this,Ea,"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())}))},Ua=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>o(this,ta,"m",Ra).call(this,e)))},Ra=function(e){if(!e)return;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)}))},Ta=function(e){return n(this,void 0,void 0,(function*(){if(o(this,ia,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield o(this,ia,"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{if("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 vi(5e3,Promise.all(i),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},La=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,$a,"f").call(this,n,e,t)}))}))},Pa=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=Qi();n[e]=t,Bi(oi,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},Wa=function(e){var t;const n=null===(t=Xi(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))},Na=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${Uo}]), [data-type="button"]:not([${Uo}]`).forEach((n=>{n.onclick=()=>{o(this,$a,"f").call(this,n,e,t)}})),o(this,ta,"m",La).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${jo}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Ma=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},_a=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",Da);const qa=(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 Fa,Ha,Ja,Va,Ka,Ba,za,Za,Ga,Xa;const Ya=document.createElement("template");Ya.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 Qa=r(jr)(HTMLElement);let el=class extends Qa{constructor(){var e;super(),Fa.add(this),Ha.set(this,new g({messages:[]})),Ja.set(this,void 0),Va.set(this,void 0),Ka.set(this,void 0),Ba.set(this,{resize:o(this,Fa,"m",Xa).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Ya.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,Ja,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Ja,"f").style.top="32px",o(this,Ja,"f").style.left=window.innerWidth-300-32+"px",i(this,Va,o(this,Ja,"f").querySelector(".content"),"f"),i(this,Ka,o(this,Ja,"f").querySelector(".header"),"f")}updateData(e){o(this,Ha,"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]=qa(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,Ja,"f"),o(this,Ka,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Ba,"f").resize),(e=o(this,Ja,"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,Ja,"f").onresize=o(this,Fa,"m",Ga).bind(this),o(this,Ha,"f").subscribe(o(this,Fa,"m",za).bind(this))}disconnectedCallback(){o(this,Ha,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Ba,"f").resize)}};Ha=new WeakMap,Ja=new WeakMap,Va=new WeakMap,Ka=new WeakMap,Ba=new WeakMap,Fa=new WeakSet,za=function(e){o(this,Fa,"m",Za).call(this,e),o(this,Fa,"m",Ga).call(this)},Za=function(e){o(this,Va,"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("")},Ga=function(){o(this,Va,"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)}))},Xa=function(){const[e,t]=qa(o(this,Ja,"f"),Number.parseInt(o(this,Ja,"f").style.left,10),Number.parseInt(o(this,Ja,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Ja,"f").style.top=`${t}px`,o(this,Ja,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",el);var tl,nl,ol,il,rl,sl,al,ll,cl,dl,ul,hl=Object.freeze({__proto__:null,default:el});const pl=document.createElement("template");pl.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 gl=r(jr)(HTMLElement);class fl extends gl{constructor(){super(),tl.add(this),nl.set(this,new Ti({messages:[]})),ol.set(this,void 0),il.set(this,void 0),rl.set(this,void 0),sl.set(this,{resize:o(this,tl,"m",ul).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(pl.content.cloneNode(!0)),i(this,ol,this.shadowRoot.querySelector(".debugger"),"f"),i(this,il,o(this,ol,"f").querySelector(".content"),"f"),i(this,rl,o(this,ol,"f").querySelector(".header"),"f"),o(this,tl,"m",al).call(this)}updateData(e){o(this,nl,"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,n;null===(t=e.init)||void 0===t||t.call(this),((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]=Vi(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,ol,"f"),o(this,rl,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,sl,"f").resize),(n=o(this,ol,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&n.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},o(this,ol,"f").onresize=o(this,tl,"m",dl).bind(this),o(this,nl,"f").subscribe(o(this,tl,"m",ll).bind(this))}))}disconnectedCallback(){o(this,nl,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,sl,"f").resize)}}nl=new WeakMap,ol=new WeakMap,il=new WeakMap,rl=new WeakMap,sl=new WeakMap,tl=new WeakSet,al=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,ol,"f").style.top="32px",o(this,ol,"f").style.left=window.innerWidth-300-32+"px"},ll=function(e){o(this,tl,"m",cl).call(this,e),o(this,tl,"m",dl).call(this)},cl=function(e){o(this,il,"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("")},dl=function(){o(this,il,"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)}))},ul=function(){const[e,t]=Vi(o(this,ol,"f"),Number.parseInt(o(this,ol,"f").style.left,10),Number.parseInt(o(this,ol,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,ol,"f").style.top=`${t}px`,o(this,ol,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",fl);var vl=Object.freeze({__proto__:null,default:fl})}();
1
+ !function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function n(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((i=i.apply(e,t||[])).next())}))}function i(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function o(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e={})=>{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 i=e(n);return i[t]=!0,i}};var c,d,u,h;function p(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!p(r,s))return!1}else if(r!==s)return!1}return!0}let g=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(i(this,c,"f")):e,n=Object.assign(Object.assign({},i(this,c,"f")),t);if(i(this,h,"f")||!p(i(this,c,"f"),n)){const e=i(this,c,"f");o(this,c,n,"f"),Object.freeze(i(this,c,"f")),setTimeout((()=>{Object.values(i(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,c,e,"f"),o(this,h,t,"f")}get current(){return Object.assign({},i(this,c,"f"))}subscribe(e){return o(this,u,i(this,u,"f")+1,"f"),i(this,d,"f")[i(this,u,"f")]=e,i(this,u,"f").toString()}unsubscribe(e){const t=!!i(this,d,"f")[e];return t&&delete i(this,d,"f")[e],t}unsubscribeAll(){return o(this,d,{},"f"),!0}};function f(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;class v extends Error{}function m(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 b(e,t){if("string"!=typeof e)throw new v("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,i=e.split(".")[n];if("string"!=typeof i)throw new v(`Invalid token specified: missing part #${n+1}`);let o;try{o=m(i)}catch(e){throw new v(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new v(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}v.prototype.name="InvalidTokenError";var w={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},sso:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const y="<region>",k=`https://api.${y}descope.com`,I=6e5,S="dct",C=()=>{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")}},O=[503,520,521,522,524,530],x=[100,5e3,5e3],A=e=>new Promise((t=>setTimeout(t,e))),E=e=>async function(...t){let n=await e(...t),i=0;for(;O.includes(n.status)&&i<x.length;)await A(x[i]),n=await e(...t),i++;i>0&&(n.retries=i);const o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n};let j;const U=()=>{if(j)return j;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 j=`${t}-${n}`,j};var R;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(R||(R={}));const $=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(y,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,i)=>{r=`${r}${0===i?"?":""}${t}=${encodeURIComponent(n[t])}${i===e.length-1?"":"&"}`}))}return r},T=(...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)),{})),L={"Content-Type":"application/json"},P=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},W=(e,t)=>{const n={"x-descope-sdk-session-id":U(),"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},N=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var M=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||k,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=>C().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await E(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return C().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:E(n)})(o,a),d=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:g,token:f}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:T(P(t,f),W(t,i),(null==n?void 0:n.baseHeaders)||{},N(v)?L:{},h),method:g,body:v};null!==s&&(m.credentials=s||"include");const b=await c($({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===(o=b.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function i(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function o(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;i();)if(","===e.charAt(n)){for(s=n,n+=1,i(),a=n;n<e.length&&o();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(r,e.length))}return t}(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:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:R.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:R.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:R.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:R.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:R.delete,token:i}),hooks:r,buildUrl:(e,n)=>$({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},_=429;function D(e,t,n){var i;let o=q(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[S])===t)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[t]}const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function q(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return b(e)}function F(e){const{exp:t}=q(e);return(new Date).getTime()/1e3>t}function H(e){let t=q(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function J(e,t){return D(e,t,"permissions")}function V(e,t){return D(e,t,"roles")}const K=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function B(e,t){var n;const i=await e,o={code:i.status,ok:i.ok,response:i},r=await i.clone().json();return i.ok?o.data=r:(o.error=r,i.status===_&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function z(e){var t;return(null===(t=q(e))||void 0===t?void 0:t[S])||""}const Z=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),G=(e,t)=>(n=t)=>t=>{const i=e.filter((e=>e(t)));return!(i.length<e.length)&&(n?n.replace("{val}",t):i.join(" OR "))},X=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Y=e=>t=>e.test(t),Q=Y(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),ee=Y(/^\+[1-9]{1}[0-9]{3,14}$/),te=Z(Q,'"{val}" is not a valid email'),ne=Z(ee,'"{val}" is not a valid phone number'),ie=Z((e=>e.length>=1),"Minimum length is 1");const oe=Z((e=>"string"==typeof e),"Input is not a string"),re=Z((e=>Array.isArray(e)),"Input is not an array"),se=Z((e=>"boolean"==typeof e),"Input is not a boolean"),ae=Z((e=>void 0===e),"Input is defined"),le=G([oe(),ae()],"Input is not a string or undefined"),ce=G([re(),se()],"Input is not an array or boolean"),de=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>X(...e).validate(n[t]))),t(...n)),ue=e=>[oe(`"${e}" must be a string`)],he=e=>[le(`"${e}" must be string or undefined`)],pe=e=>[oe(`"${e}" must be a string`),ie(`"${e}" must not be empty`)],ge=e=>[oe(`"${e}" must be a string`),te()],fe=e=>[oe(`"${e}" must be a string`),ne()],ve=de(pe("accessKey")),me=e=>({exchange:ve(((t,n)=>B(e.post(w.accessKey.exchange,{loginOptions:n},{token:t}))))}),be=(e,t,n)=>(t.forEach((t=>{const i=t.split(".");let o=i.shift(),r=e;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=n(s)})),e),we=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||I,I)});var ye,ke;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(ye||(ye={})),function(e){e.email="email"}(ke||(ke={}));const Ie=Object.assign(Object.assign({},ye),ke);var Se;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Se||(Se={}));const Ce=pe("loginId"),Oe=de(pe("token")),xe=de(Ce),Ae=de(pe("pendingRef")),Ee=de(Ce,ge("email")),je=e=>({verify:Oe((t=>B(e.post(w.enchantedLink.verify,{token:t})))),signIn:xe(((n,i,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return B(e.post(K(w.enchantedLink.signIn,Ie.email),{loginId:n,URI:i,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:xe(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return B(e.post(K(w.enchantedLink.signUpOrIn,Ie.email),{loginId:n,URI:i,loginOptions:s,providerId:r}))})),signUp:xe(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(K(w.enchantedLink.signUp,Ie.email),{loginId:n,URI:i,user:o,loginOptions:a,providerId:s}))})),waitForSession:Ae(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=we(n);let s;const a=setInterval((async()=>{const n=await e.post(w.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(B(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Ee(((t,n,i,o,r)=>B(e.post(w.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),Ue=de(pe("flowId")),Re=de(pe("executionId"),pe("stepId"),pe("interactionId")),$e=e=>({start:Ue(((t,n,i,o,r,s,a,l=!1)=>B(e.post(w.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:Re(((t,n,i,o,r,s,a=!1)=>B(e.post(w.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s,isCustomScreen:a}))))}),Te=pe("loginId"),Le=de(pe("token")),Pe=de(Te),We=de(Te,fe("phone")),Ne=de(Te,ge("email")),Me=Object.keys(Ie).filter((e=>e!==ye.voice&&e!==ye.im)),_e=e=>({verify:Le((t=>B(e.post(w.magicLink.verify,{token:t})))),signIn:Me.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Pe(((n,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return B(e.post(K(w.magicLink.signIn,i),{loginId:n,URI:o,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:Me.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Pe(((n,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return B(e.post(K(w.magicLink.signUp,i),{loginId:n,URI:o,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:Me.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Pe(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(K(w.magicLink.signUpOrIn,i),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:Ne(((t,n,i,o,r)=>B(e.post(w.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(ye).filter((e=>e!==ye.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:We(((t,i,o,r,s)=>B(e.post(K(w.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var De;!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"}(De||(De={}));const qe=de(pe("code")),Fe=e=>({start:Object.assign(((t,n,i,o,r)=>B(e.post(w.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(De).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>B(e.post(w.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:qe((t=>B(e.post(w.oauth.exchange,{code:t})))),startNative:(t,n,i)=>B(e.post(w.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>B(e.post(w.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>B(e.get(w.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>B(e.post(w.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>B(e.post(w.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),He=pe("appId"),Je=de(He),Ve=e=>({connect:Je(((t,n,i)=>{const o=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,B(e.post(w.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:n},{token:i}))}))}),Ke=pe("loginId"),Be=de(Ke,pe("code")),ze=de(Ke),Ze=de(Ke,fe("phone")),Ge=de(Ke,ge("email")),Xe=e=>({verify:Object.keys(Ie).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Be(((t,i)=>B(e.post(K(w.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(Ie).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:ze(((n,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return B(e.post(K(w.otp.signIn,i),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Ie).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:ze(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(K(w.otp.signUp,i),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Ie).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:ze(((n,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return B(e.post(K(w.otp.signUpOrIn,i),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:Ge(((t,n,i,o)=>B(e.post(w.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ze(((t,i,o,r)=>B(e.post(K(w.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),Ye=de(pe("tenant")),Qe=de(pe("code")),et=e=>({start:Ye(((t,n,i,o,r,s,a,l)=>B(e.post(w.sso.start,i||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},o&&{token:o}))))),exchange:Qe((t=>B(e.post(w.sso.exchange,{code:t}))))}),tt=pe("loginId"),nt=de(tt,pe("code")),it=de(tt),ot=de(tt),rt=e=>({signUp:it(((t,n)=>B(e.post(w.totp.signUp,{loginId:t,user:n})))),verify:nt(((t,n,i,o)=>B(e.post(w.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:ot(((t,n)=>B(e.post(w.totp.update,{loginId:t},{token:n}))))}),st=pe("loginId"),at=pe("newPassword"),lt=de(st,pe("password")),ct=de(st),dt=de(st,at),ut=de(st,pe("oldPassword"),at),ht=e=>({signUp:lt(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(w.password.signUp,{loginId:n,password:i,user:o,loginOptions:a,providerId:s}))})),signIn:lt(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return B(e.post(w.password.signIn,{loginId:n,password:i,loginOptions:s,providerId:r}))})),sendReset:ct(((t,n,i)=>B(e.post(w.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:dt(((t,n,i)=>B(e.post(w.password.update,{loginId:t,newPassword:n},{token:i})))),replace:ut(((t,n,i)=>B(e.post(w.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>B(e.get(w.password.policy))}),pt=ue("loginId"),gt=pe("loginId"),ft=ue("origin"),vt=de(gt,ft,pe("name")),mt=de(gt,ft),bt=de(pt,ft),wt=de(gt,ft,he("token")),yt=de(pe("transactionId"),pe("response")),kt=e=>({signUp:{start:vt(((t,n,i,o,r)=>B(e.post(w.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,loginOptions:r,passkeyOptions:o})))),finish:yt(((t,n)=>B(e.post(w.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:bt(((t,n,i,o,r)=>B(e.post(w.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:yt(((t,n)=>B(e.post(w.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:mt(((t,n,i,o)=>B(e.post(w.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i}))))},update:{start:wt(((t,n,i,o,r)=>B(e.post(w.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o,mfa:r},{token:i})))),finish:yt(((t,n)=>B(e.post(w.webauthn.update.finish,{transactionId:t,response:n}))))}}),It=ue("loginId"),St=de(It),Ct=de(pe("pendingRef")),Ot=e=>({signUpOrIn:St(((n,i={})=>{var{providerId:o}=i,r=t(i,["providerId"]);return B(e.post(w.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:o}))})),signUp:St(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return B(e.post(w.notp.signUp,{loginId:n,user:i,providerId:r,loginOptions:s}))})),signIn:St(((n,i={},o)=>{var{providerId:r}=i,s=t(i,["providerId"]);return B(e.post(w.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:o}))})),waitForSession:Ct(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=we(n);let s;const a=setInterval((async()=>{const n=await e.post(w.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(B(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),xt=de(pe("token")),At=de(he("token"));var Et,jt=de([(Et=pe("projectId"),Z(((e,t)=>n=>X(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=n.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<i;)r=r[n[o++]];return o&&o===i&&void 0!==r?r:void 0})(n,e)))("projectId",Et))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=M({baseUrl:i,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:me(l),otp:Xe(l),magicLink:_e(l),enchantedLink:je(l),oauth:Fe(l),outbound:Ve(l),sso:et(l),saml:et(l),totp:rt(l),notp:Ot(l),webauthn:kt(l),password:ht(l),flow:$e(l),refresh:At(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const r=i?w.tryRefresh:w.refresh;return B(l.post(r,o,{token:e,queryParams:t}))})),selectTenant:de([oe("tenantId")],[le('"token" must be string or undefined')])(((e,t)=>B(l.post(w.selectTenant,{tenant:e},{token:t})))),logout:At((e=>B(l.post(w.logout,{},{token:e})))),logoutAll:At((e=>B(l.post(w.logoutAll,{},{token:e})))),me:At((e=>B(l.get(w.me,{token:e})))),myTenants:de([ce('"tenants" must a string array or a boolean')],[le('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,B(l.post(w.myTenants,n,{token:t}))})),history:At((e=>B(l.get(w.history,{token:e})))),isJwtExpired:xt(F),getTenants:xt(H),getJwtPermissions:xt(J),getJwtRoles:xt(V),getCurrentTenant:xt(z),httpClient:l};var l})),Ut=Object.assign(jt,{DeliveryMethods:Ie});
2
+ /*! js-cookie v3.0.8 | MIT */function Rt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)"__proto__"!==i&&(e[i]=n[i])}return e}var $t=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=Rt({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in i||(i[a]=t.read(s,a)),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",Rt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Rt({},this.attributes,t))},withConverter:function(t){return e(Rt({},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 Tt={default:"endpoint"},Lt="Blocked by CSP",Pt="The endpoint parameter is not a valid URL",Wt="Failed to load the JS script of the agent",Nt="9319";function Mt(e,t){var n,i,o,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Lt||s===Pt)n.exclude(),r=0;else if(s===Nt)n.exclude();else if(s===Wt){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var _t="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Dt=_t;function qt(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:_t,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return Mt(e,Ft)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Nt?new Error(Wt):e}(e)})).then((function(t){var n=t[0],i=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function Ft(e){return function(e,t,n){var i,o=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(Pt);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(Wt))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(Lt)})).then(Ht)}function Ht(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Nt);return n}const Jt="3.2.0",Vt="undefined"!=typeof window,Kt=Math.pow(2,31)-1,Bt=`https://descopecdn.com/npm/oidc-client-ts@${Jt}/dist/browser/oidc-client-ts.min.js`,zt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Jt}/dist/browser/oidc-client-ts.min.js`,Zt=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let Gt;const Xt=e=>{try{return b(e).exp}catch(e){return null}},Yt=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Xt(n)},Qt=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?Xt(i):void 0)},en=e=>{const{access_token:n,id_token:i,refresh_token:o,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:i,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||Qt(e),cookieExpiration:e.cookieExpiration||Yt(e)},s)},tn=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},nn=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 en(n)},on=()=>Vt&&!!window.descopeBridge,rn=(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 Zt.includes(n)},sn=void 0!==Gt||Vt&&void 0!==window.localStorage,an=(e,t)=>{var n,i;return null===(i=null===(n=Gt||Vt&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},ln=e=>{var t,n;return null===(n=null===(t=Gt||Vt&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},cn=e=>{var t,n;return null===(n=null===(t=Gt||Vt&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},dn=e=>{var t,n,i,o,r;return null!==(r=null!==(n=null===(t=null==Gt?void 0:Gt.key)||void 0===t?void 0:t.call(Gt,e))&&void 0!==n?n:Vt&&(null===(o=null===(i=window.localStorage)||void 0===i?void 0:i.key)||void 0===o?void 0:o.call(i,e)))&&void 0!==r?r:null},un=e=>{var t,n;return Vt&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},hn=e=>{var t,n;try{Vt&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},pn=(...e)=>{console.debug(...e)},gn=(...e)=>{console.warn(...e)},fn=(e,t)=>{let n;var i;return t>0?(n=1e3*t,pn(`Using provided nextRefreshSeconds: ${t}s`)):n=((i=e)?i.getTime()-(new Date).getTime():0)-2e4,n>Kt&&(pn(`Timeout is too large (${n}ms), setting it to ${Kt}ms`),n=Kt),n},vn="DS",mn="DSR",bn="DSI",wn="DSRCN";function yn(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=kn(i);$t.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}function kn(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 In=e=>(null==e?void 0:e.cookieName)||vn,Sn=e=>(null==e?void 0:e.cookieName)||mn;function Cn(e="",t){return $t.get(Sn(t))||ln(`${e}${mn}`)||""}function On(e="",t){return $t.get(In(t))||ln(`${e}${vn}`)||""}function xn(e=""){return ln(`${e}${bn}`)||""}function An(e="",t,n,i){cn(`${e}${mn}`),cn(`${e}${vn}`),cn(`${e}${bn}`),cn(`${e}${wn}`);const o=In(t);$t.remove(o,null==i?void 0:i.session);const r=Sn(n);$t.remove(r,null==i?void 0:i.refresh)}const En=(e,t,n)=>i=>{const o=Object.assign(i,{token:i.token||Cn(e,t)});if(!n){const t=function(e=""){return ln(`${e}${wn}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return ln(`${e}DTD`)||""}(e);return r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r})),o},jn=Vt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Un="vsid",Rn="vrid",$n="fp",Tn=(e=!1)=>{const t=ln($n);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Ln=async(e,t=jn)=>{try{if(Tn())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=qt({apiKey:e,endpoint:[i.toString(),Tt],scriptUrlPattern:[r,Dt]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Un]:e,[Rn]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};an($n,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Pn=e=>{const t=Tn(!0);return t&&e.body&&(e.body.fpData=t),e},Wn="descopeFlowNonce",Nn="X-Descope-Flow-Nonce",Mn="/v1/flow/start",_n="/v1/flow/next",Dn=(e,t=Wn)=>`${t}${e}`,qn=(e,t=Wn)=>{try{const n=Dn(e,t),i=ln(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(Fn(e,t),null):{value:o.value,seq:o.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},Fn=(e,t=Wn)=>{try{const n=Dn(e,t);cn(n)}catch(e){console.error("Error removing flow nonce:",e)}},Hn=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Jn=e=>{var t;return e.path===_n&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Hn(e.body.executionId):null},Vn="dls_last_user_login_id",Kn="dls_last_user_display_name",Bn=e=>an(Vn,e),zn=()=>ln(Vn),Zn=()=>ln(Kn),Gn=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=zn(),r=Zn();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)},Xn="DSLI",Yn=e=>async(...t)=>{const n=await e(...t);return hn(Xn),n};function Qn(){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 ei(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ai(n.publicKey.challenge),n.publicKey.user.id=ai(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=ai(e.id)})),n}(e);try{return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:li(n.rawId),type:n.type,response:{attestationObject:li(n.response.attestationObject),clientDataJSON:li(n.response.clientDataJSON)}})}catch(e){throw await ii(e,t,!0)}var n}async function ti(e){const t=ri(e);try{return si(await navigator.credentials.get(t))}catch(e){throw await ii(e,t,!1)}}async function ni(e,t){const n=ri(e);n.signal=t.signal,n.mediation="conditional";try{return si(await navigator.credentials.get(n))}catch(e){throw await ii(e,n,!1)}}async function ii(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var i,o;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await oi())return"webauthn_unsupported";const s="platform"===(null===(o=null===(i=null==t?void 0:t.publicKey)||void 0===i?void 0:i.authenticatorSelection)||void 0===o?void 0:o.authenticatorAttachment);return n&&s&&!await oi(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function oi(e=!1){var t,n;if(!Vt)return Promise.resolve(!1);if(on()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const i=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return i&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():i}function ri(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ai(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=ai(e.id)})),n}function si(e){return JSON.stringify({id:e.id,rawId:li(e.rawId),type:e.type,response:{authenticatorData:li(e.response.authenticatorData),clientDataJSON:li(e.response.clientDataJSON),signature:li(e.response.signature),userHandle:e.response.userHandle?li(e.response.userHandle):void 0}})}function ai(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function li(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ci,di=(ci=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await ei(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await ti(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await ei(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await ti(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await ei(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:ei,get:ti,isSupported:oi,conditional:ni}}),(...e)=>{const t=ci(...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 ui="/fedcm/config",hi=()=>{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 pi(e,t){var n;try{await gi(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function gi(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=hi(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var fi=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await oi(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let vi;const mi=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{mi(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),bi=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{vi||(vi=(async()=>{try{return require("oidc-client-ts")}catch(e){return mi([Bt,zt],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await vi;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new i(d),stateUserKey:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),an(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var o;const{client:r}=await i(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:r}=await i(),s=(e=>{const t=ln(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||xn(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return cn(o),t||window.location.replace(s),r}}},wi=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Gt=n,e(t)}),(e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return Vt?(i&&o&&Ln(i).catch((()=>null)),e(tn(r,{beforeRequest:Pn}))):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=Qn(),i=Qn(),o=Qn(),r=Qn(),s=e(tn(t,{afterRequest:async(e,t)=>{if(rn(e,t))pn("Session invalidated, notifying subscribers with empty values"),i.pub(null),o.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await nn(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await nn(t);s&&i.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=be(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var i;const{enableFlowNonce:o=!0,nonceStoragePrefix:r=Wn}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!o)return e(s);((e=Wn)=>{try{if(!sn)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(i=null!==(t=null==Gt?void 0:Gt.length)&&void 0!==t?t:Vt&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==i?i:0);o++){const t=dn(o);if(t&&t.startsWith(e)){const n=ln(t);if(n)try{JSON.parse(n).expiry<Date.now()&&cn(t)}catch(e){cn(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,i})(r);const a=e(tn(s,{afterRequest:async(e,t)=>{var n;if(e.path!==Mn&&e.path!==_n)return;const{nonce:i,seq:o,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(Nn),i=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const i=Number(n);return Number.isSafeInteger(i)?i:void 0})(n);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=Jn(e)),{nonce:n,seq:i,executionId:Hn(o)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!i||!s)return;const a=e.path===Mn,l=null===(n=qn(s,r))||void 0===n?void 0:n.seq;!a&&void 0!==o&&void 0!==l&&o<=l||((e,t,n,i=Wn,o)=>{try{const r=Dn(e,i),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:o};an(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,i,a,r,null!=o?o:a?void 0:l)},beforeRequest:e=>{if(e.path===_n){const t=Jn(e);if(t){const n=((e,t=Wn)=>{var n,i;return null!==(i=null===(n=qn(e,t))||void 0===n?void 0:n.value)&&void 0!==i?i:null})(t,r);n&&(e.headers=e.headers||{},e.headers[Nn]=n)}}return e}}));if(null===(i=a.flow)||void 0===i?void 0:i.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const i=e;let o;e=new Promise((e=>{o=e})),await i;try{return await t(...n)}finally{o()}}}return a}),(e=>t=>{const n=e(tn(t,{afterRequest:async(e,t)=>{if(rn(e,t))return void hn(Xn);const n=await nn(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,i;try{Vt&&(null===(i=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i||i.call(n,e,t))}catch(e){}})(Xn,String(n.sessionExpiration))}}));return be(n,["logout","logoutAll","oidc.logout"],Yn)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);const r=!!i,s="object"==typeof i&&(null==i?void 0:i.customActivityTracking);if(!r||on())return Object.assign(e(o),{markUserActive:()=>{gn("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&&(pn("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Vt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(pn("Expiration time passed, refreshing session"),g.refresh(Cn()||d))}));const g=e(tn(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o,nextRefreshSeconds:r}=await nn(t);if(rn(e,t))pn("Session invalidated, canceling all timers"),a();else if(n||o){if(c=((e,t)=>{if(t)return new Date(1e3*t);pn("Could not extract expiration time from session token, trying to decode the token");try{const t=b(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!c)return void pn("Could not extract expiration time from session token");d=i,h=r>0;const e=fn(c,r);if(a(),e<=2e4)return void pn("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});pn(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Vt&&"hidden"===document.visibilityState)pn("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return pn("Skipping refresh due to timer - user is idle"),void(p=!0);pn("Refreshing session due to timer"),g.refresh(Cn()||i)}}),e)}}}));return Object.assign(be(g,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return pn("Clearing all timers"),a(),n})),{markUserActive:u?()=>{pn("markUserActive() called"),h||pn("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(pn("User became active after skipped refresh, triggering refresh"),p=!1,a(),g.refresh(Cn()||d))}:()=>{gn("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:zn,getLastUserDisplayName:Zn});const s=e(tn(r,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=en((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],s=null==i?void 0:i.name;r?(Bn(r),(e=>{an(Kn,e)})(s)):(null==o?void 0:o.loginId)&&Bn(o.loginId)}}));let a=be(s,["flow.start"],Gn);return a=be(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(cn(Vn),cn(Kn)),i})(o)),Object.assign(a,{getLastUserLoginId:zn,getLastUserDisplayName:Zn})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!i||!Vt)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(tn(Object.assign({refreshCookieName:a},l),{beforeRequest:En(s,r,a),afterRequest:async(e,t)=>{if(rn(e,t))pn("Session invalidated, clearing persisted tokens"),An(s,o,r,c);else{const e=await nn(t);e.cookieName?an(`${s||""}${wn}`,e.cookieName):e.refreshJwt&&cn(`${s||""}${wn}`);const n=((e={},t=!1,n="",i=!1)=>{var o,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d}=e;let u;if(c)if(i){cn(`${n}${mn}`);const t=i.sameSite||"Strict",s=null===(o=i.secure)||void 0===o||o,a=null!==(r=i.domain)&&void 0!==r?r:e.cookieDomain,l=Sn(i);s&&"https:"!==window.location.protocol&&gn("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});yn(l,c,d);const h=kn(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=Sn(i);$t.remove(e),an(`${n}${mn}`,c)}if(l)if(t){const n=t.sameSite||"Strict",i=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=In(t);i&&"https:"!==window.location.protocol&&gn("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i,cookieDomain:o});yn(r,l,c);const d=kn(o);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?o:void 0}})}else an(`${n}${vn}`,l);return e.idToken&&an(`${n}${bn}`,e.idToken),d&&an(`${n}DTD`,d),u})(e,o,s,r);n&&(c=n)}}})),u=be(d,["logout","logoutAll","oidc.logout"],((e,t,n,i)=>o=>async(...r)=>{const s=await o(...r);return An(e,t,n,null==i?void 0:i()),s})(s,o,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Cn(s,r),getSessionToken:()=>On(s,o),getIdToken:()=>xn(s)})}))((e=>{const t=Ut(e),n=bi(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;if(on())return pn(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&Vt&&void 0!==window.localStorage&&!un(Xn)&&!ln(Vn)&&!un("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=On(),a=Cn();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){pn("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:s?"t":"f",dcr:a?"t":"f"},l,o)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:fi(t),webauthn:di(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){pi(i,e)},requestAuthentication(e){pi(i,e)}},async oneTap(e,t,n,o,r){await gi(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+ui),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>Vt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+ui);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var i,o})),yi="undefined"!=typeof localStorage,ki="J151000",Ii="E103205",Si="E108201",Ci=yi&&localStorage.getItem("base.content.url")||"",Oi="base.ui.components.url";yi&&localStorage.getItem(Oi),yi&&localStorage.getItem(Oi);const xi="descope-login-flow",Ai="code",Ei="redirect_mode",ji="err",Ui="data-exclude-field",Ri="data-exclude-next",$i="dls_last_auth",Ti="dls_last_submitted_login_id",Li="state_id",Pi="saml_idp_state_id",Wi="wsfed_idp_state_id",Ni="saml_idp_username",Mi="descope_idp_initiated",_i="sso_app_id",Di="custom_app_id",qi="third_party_app_id",Fi="third_party_app_state_id",Hi="oidc_login_hint",Ji="oidc_prompt",Vi="oidc_resource",Ki="oidc_error_redirect_uri",Bi="application_scopes",zi="data-type",Zi="redirect",Gi="poll",Xi="webauthnCreate",Yi="webauthnGet",Qi="nativeBridge",eo="loadForm",to="submit",no="polling",io=["descope-multi-select-combo-box","descope-text-area"],oo="dls_last_auth_in_flight",ro=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts","data","totp","notp","sentTo","sso","selfProvisionDomains"];var so;!function(e){e.backward="backward",e.forward="forward"}(so||(so={}));const ao=["descope-enriched-text"];function lo(e){return new URLSearchParams(window.location.search).get(e)}function co(e){if(window.history.replaceState&&lo(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 uo(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?so.forward:n<i?so.backward:void 0}const ho=e=>{let[t="",n=""]=(lo(xi)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function po(){co(xi)}const go=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),fo=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=ho(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&po();const r=lo("t")||void 0;r&&co("t");const s=lo(Ai)||void 0;s&&co(Ai);const a="popup"===lo(Ei);a&&co(Ei);const l=lo(ji)||void 0;l&&co(ji);const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:lo("ra-challenge"),redirectAuthCallbackUrl:lo("ra-callback"),redirectAuthBackupCallbackUri:lo("ra-backup-callback"),redirectAuthInitiator:lo("ra-initiator")},p=lo(Li);p&&co(Li);const g=lo(Pi);g&&co(Pi);const f=lo(Wi);f&&co(Wi);const v=lo(Ni);g&&co(Ni);const m=lo(Mi);m&&co(Mi);const b=lo(_i);b&&co(_i);const w=lo(Di);w&&co(Di);const y=lo(qi);y&&co(qi);const k=lo(Fi);k&&co(Fi);const I=lo(Bi);I&&co(Bi);const S=lo(Hi);S&&co(Hi);const C=lo(Ji);C&&co(Ji);const O=lo(Ki);O&&co(Ki);const x=lo(Vi);x&&co(Vi);return{executionId:n,stepId:i,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:g,wsfedIdpStateId:f,samlIdpUsername:v,descopeIdpInitiated:"true"===m,ssoAppId:b,customAppId:w,oidcLoginHint:S,oidcPrompt:C,oidcErrorRedirectUri:O,oidcResource:x,thirdPartyAppId:y,thirdPartyAppStateId:k,applicationScopes:I}}},vo=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})},mo=(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 bo(e,t,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),i(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const wo=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:i,samlIdpUsername:o,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||i||o||r||s||a||l||c||d||u||h||p),yo=e=>null==e?void 0:e.submit(),ko=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Io=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},So={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"},Co=(e,t)=>{var n;const i=null==e?void 0:e.componentsDynamicAttrs;if(!i)return;const o=Object.entries(i).find((([e])=>(e=>{var t;return null===(t=e.match(/\[data-name=["']([^"']+)["']\]/))||void 0===t?void 0:t[1]})(e)===t));return null===(n=null==o?void 0:o[1])||void 0===n?void 0:n.attributes},Oo=[{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(So).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=Co(e,"recoveryCodes");if(t)return Array.isArray(t.data)?t.data.map((e=>e.value)):[]})(e.componentsConfig)},{key:"outboundApp",from:e=>(e=>{const t=Co(e,"outboundApp");if(t)return{label:t.label,iconSrc:t["icon-src"],appId:t["data-descope-outbound-oauth-app-id"]}})(e.componentsConfig)}],xo=e=>{const t=(n=e.screenState,i=(e,t)=>ro.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!i(t,e)))));var n,i;const{screenState:{errorText:o,errorType:r}}=e;(o||r)&&(t.error={text:o,type:r}),e.action&&(t.action=e.action);const s=(e=>{if(!e)return;const t={};return Oo.forEach((({key:n,from:i})=>{const o=i(e);void 0!==o&&(t[n]=o)})),Object.keys(t).length?t:void 0})(e.screenState);return s&&(t.data=s),t},Ao=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Eo(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}const jo=(e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,l=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",c=window.open(l,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c};var Uo,Ro,$o,To;function Lo(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Lo(r,s))return!1}else if(r!==s)return!1}return!0}class Po{constructor(e={},{forceUpdate:t=!1}={}){Uo.set(this,void 0),Ro.set(this,{}),$o.set(this,0),To.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,Uo,"f")):e,n=Object.assign(Object.assign({},i(this,Uo,"f")),t),r=i(this,Uo,"f");o(this,Uo,n,"f"),Object.freeze(i(this,Uo,"f")),setTimeout((()=>{Object.values(i(this,Ro,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,To,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!Lo(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,Uo,e,"f"),o(this,To,t,"f")}get current(){return Object.assign({},i(this,Uo,"f"))}set forceUpdate(e){o(this,To,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,$o,i(this,$o,"f")+1,"f"),i(this,Ro,"f")[i(this,$o,"f")]={cb:e,selector:t,forceUpdate:n},i(this,$o,"f").toString()}unsubscribe(e){const t=!!i(this,Ro,"f")[e];return t&&delete i(this,Ro,"f")[e],t}unsubscribeAll(){return o(this,Ro,{},"f"),!0}}Uo=new WeakMap,Ro=new WeakMap,$o=new WeakMap,To=new WeakMap;const Wo=["*","#","/","(",")","[","]","_","<",">","`"],No=e=>{const t=Wo.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")},Mo=["disabled"],_o=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Ui}])`)).forEach((e=>{e.value=n}))}))},Do=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),qo=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?(e=>"string"!=typeof e?e:e.replace(No("\\"),"\\$1"))(Do(t,i)):Do(t,i))),Fo=(e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(i=e.localName,ao.includes(i));var i;e.textContent=qo(e.textContent,t,n);const o=e.getAttribute("href");o&&e.setAttribute("href",qo(o,t))}))},Ho=(e,t,n)=>{e.querySelectorAll(`[${zi}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Jo=(e,t,n)=>{var i,o;const r=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},Vo=(e,n,i,o)=>{var r,s;Ho(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),Ho(e,"notp-link",null===(s=null==n?void 0:n.notp)||void 0===s?void 0:s.redirectUrl),Fo(e,n),((e,n,i)=>{if(!n)return;const{componentsDynamicAttrs:o}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});o&&Object.keys(o).forEach((e=>{const t=o[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(s[e]=n)}})),Object.keys(s).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=s[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==n?void 0:n.componentsConfig,o),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=qo(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])=>{Mo.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i)},Ko=vo((()=>n(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield bo(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}})))),Bo=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};let zo;const Zo=(e,t)=>{zo?zo.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},Go=e=>zo?zo.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,Xo="dls_ab_testing_id",Yo={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||((e.abTestingKey||0)<n||(e.abTestingKey||0)>i)},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function Qo(e,t){const n={};try{Object.assign(n,JSON.parse(Go($i)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function er(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||Zo($i,JSON.stringify(e)))}function tr(){try{return JSON.parse(Go(oo)||"{}")}catch(e){return{}}}function nr(e){try{t=oo,zo?zo.removeItem(t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(t)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}var t}const ir=["error","warn","info","debug"],or={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},rr=l((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,i(this,t,"m",r).call(this,or))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||or),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return ir.reduce(((t,n)=>(t[n]=(...t)=>{var i;this.onLogEvent(n,t),null===(i=e[n])||void 0===i||i.call(e,...t)},t)),{})},s})),sr="undefined"!=typeof localStorage,ar="https://static.descope.com/pages",lr="https://static2.descope.com/pages",cr=sr&&localStorage.getItem("base.content.url")||"",dr=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,ur=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)&&i(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),hr=l((e=>{var t,n;const o=r(rr,ur)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=i(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){i(this,t,"f")[e]||(i(this,t,"f")[e]=[]);const o=i(this,t,"f")[e].push(n);return()=>i(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),pr=e=>t=>{var n,o,s;const a=r(rr,ur,hr)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,i(this,n,"m",o).bind(this))}async init(){var e;l.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},s};pr.missingAttrValidator=dr;const gr=l((e=>{const t=r(pr({"project-id":dr}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),fr=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),vr="Trying the next fallback URL...",mr=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};const br=l((e=>{var t,n,s,a,l,c,d;const u=r(rr,gr,fr)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const r=i(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];o(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;i(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:i}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await mr(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${vr}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${vr}`)}}})(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=cr||this.baseStaticUrl;if(r)return i(this,t,"m",c).call(this,e,r);i(this,n,"f")!==this.baseUrl&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"),i(this,a,"f").clear());const l=[];if(i(this,s,"f"))l.push(i(this,t,"m",c).call(this,e,i(this,s,"f"))),i(this,s,"f")===ar&&l.push(i(this,t,"m",c).call(this,e,lr));else{const n=this.baseUrl+"/pages";this.baseUrl&&!i(this,a,"f").has(n)&&l.push(i(this,t,"m",c).call(this,e,n)),i(this,a,"f").has(ar)||l.push(i(this,t,"m",c).call(this,e,ar)),l.push(i(this,t,"m",c).call(this,e,lr))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i=ar}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}({projectId:this.projectId,filename:e,baseUrl:t})},d})),wr=l((e=>{var t,n;const o=r(pr({"project-id":dr}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return i(this,t,"f").set(e,n),()=>{i(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(i(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=i(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),yr=l((e=>{var t,n,s,a,l;const c=r(br,wr,ur)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,t,"m",n).bind(this))}get config(){return i(this,s,"f")||o(this,s,i(this,a,"f").call(this),"f"),i(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},l})),kr=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],Ir=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()}`},Sr=(e,t,n)=>new Promise(((i,o)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),i(r)},r.src=t.toString(),document.body.appendChild(r)})),Cr=(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)}))}))},Or=l((e=>{const t=r(rr)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const i of e){const{id:e,url:o,integrity:r}=i,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await Cr(s,r),i}catch(e){t(i,!0)}else try{return await Sr(e,o,r),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="",o)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${i}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${Ir(a)}`};return o&&(l.integrity=o),[...e,l]}),[]))([...i,this.baseCdnUrl,...kr],e,t,n,o),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),xr="base.ui.components.url",Ar=sr&&localStorage.getItem(xr),Er=l((e=>{var t,n,s,a,l,c,d;const u=r(rr,yr,Or)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return i(this,a,"f")||o(this,a,i(this,t,"m",c).call(this),"f"),i(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>i(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await i(this,t,"m",n).call(this),o=Ar?void 0:await i(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[Ar],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),jr=l((e=>{var t,n,o;const s=r(ur,hr)(e);return o=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",i(this,t,"m",n).bind(this)),i(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class Ur{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 Rr=l((e=>{const t=r(jr)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new Ur(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),$r="content-root",Tr="root",Lr=l((e=>{const t=r(Rr)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${Tr}">\n <div id="${$r}"></div>\n </div>\n `,this.injectStyle(`\n #${Tr}, #${$r} {\n height: 100%;\n }\n #${Tr} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById($r),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Tr)}}})),Pr=(e,t,n="")=>Object.entries(e).reduce(((e,[i,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(i))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${i}`:i;if("object"==typeof o&&null!==o)return e+Pr(o,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),"");function Wr(e,t){const n=Object.assign({},e);for(const[e,i]of Object.entries(t||{}))if(null!=i)if("object"==typeof i){if(0===Object.keys(i).length)continue;n[e]=Wr(n[e]||{},i)}else n[e]="string"==typeof i?(n[e]||"")+i:i;return n}const Nr=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",Mr=l((e=>{const t=r(pr({tenant:Nr}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),_r=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Dr=l((e=>{var t,n,s,a,l,c,d,u,h,p,g,f,v,m,b,w,y,k,I,S,C,O;const x=r(pr({theme:_r}),Mr,br,ur,Er,yr,Lr,hr,Rr)(e);return O=class extends x{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,(()=>{i(this,t,"m",S).call(this),i(this,C,"f").call(this,"os"===this.getAttribute("theme"))})),C.set(this,(e=>{var n,o,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,t,"m",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")||"theme"}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,I,"f").call(this),await Promise.all([i(this,t,"m",p).call(this),i(this,t,"m",v).call(this),i(this,t,"m",b).call(this)]),i(this,t,"m",m).call(this),this.observeAttributes(["theme"],i(this,I,"f")),this.observeAttributes(["theme-override"],(()=>i(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{o(this,d,null,"f"),i(this,t,"m",v).call(this),i(this,t,"m",b).call(this)})),this.observeAttributes(["style-id"],(()=>{o(this,c,null,"f"),i(this,t,"m",y).call(this),i(this,t,"m",p).call(this),i(this,t,"m",b).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,I=new WeakMap,C=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,i,o,r,s,a;const l=null===(o=null===(i=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===i?void 0:i.colors)||void 0===o?void 0:o.primary,c=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${Pr({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");return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},h=function(){return i(this,c,"f")||(o(this,c,i(this,t,"m",u).call(this),"f"),i(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,c,"f")},p=async function(){var e,r;const s=await i(this,t,"a",h);if(!s)return;const a=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"");i(this,n,"f")?i(this,n,"f").replaceSync(a):o(this,n,this.injectStyle(a,{prepend:!0}),"f")},g=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.")}},f=function(){return i(this,d,"f")||o(this,d,i(this,t,"m",g).call(this),"f"),i(this,d,"f")},v=async function(){var e,n,r,a;if(!this.tenantId)return void(null===(e=i(this,s,"f"))||void 0===e||e.replaceSync(""));const l=await i(this,t,"a",f);if(!l)return void(null===(n=i(this,s,"f"))||void 0===n||n.replaceSync(""));const c=((null===(r=l.light)||void 0===r?void 0:r.globals)||"")+((null===(a=l.dark)||void 0===a?void 0:a.globals)||"");i(this,s,"f")?i(this,s,"f").replaceSync(c):o(this,s,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=i(this,a,"f"))||void 0===e||e.replaceSync(""));const n=i(this,t,"m",l).call(this);i(this,a,"f")?i(this,a,"f").replaceSync(n):o(this,a,this.injectStyle(n),"f")},b=async function(){var e,n,o,r;const s=await i(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await i(this,t,"a",f);a.componentsThemeManager.themes={light:Wr((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:Wr((null===(o=null==s?void 0:s.dark)||void 0===o?void 0:o.components)||{},(null===(r=null==l?void 0:l.dark)||void 0===r?void 0:r.components)||{})}},w=async function(){var e,t;const{projectConfig:n}=await this.config||{},i=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},y=async function(){const e=await i(this,t,"m",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(){i(this,t,"m",y).call(this),i(this,t,"m",k).call(this)},O})),qr=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?qr(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),qr(e[i],`${t+i}.`));const r="object"==typeof e[i]?e[i]:{value:e[i]},s=Object.assign(Object.assign({},n),{[t+i]:r,[`form.${t}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),Fr=l((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r}));l((e=>{var t,n,s,a,l,c,d;return d=class extends(r(ur,rr)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),"debug"===e&&i(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&i(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=i(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(i(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return gl})),document.body.appendChild(i(this,n,"f"))},l=function(){this.debug?i(this,t,"m",a).call(this):i(this,t,"m",s).call(this)},c=function(e,t){var o;e&&(null===(o=i(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},d}));const Hr="descope-modal";var Jr,Vr,Kr,Br,zr;class Zr{constructor(e,t){Jr.set(this,void 0),this.nodeName="",o(this,Jr,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const i="function"==typeof e?e():e;i&&(clearInterval(n),t(i))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(i(this,Jr,"f"))}get ele(){var e,t;const n="function"==typeof i(this,Jr,"f")?i(this,Jr,"f").call(this):i(this,Jr,"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}}Jr=new WeakMap;class Gr extends Zr{constructor(...e){super(...e),Vr.add(this),Kr.set(this,void 0),Br.set(this,void 0),this.nodeName="descope-modal",i(this,Vr,"m",zr).call(this)}get isOpen(){var e;return"true"===(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("opened"))}get isClosed(){return!this.isOpen}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),i(this,Vr,"m",zr).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),i(this,Kr,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,Kr,"f").content.cloneNode(!0)))}setContent(e){o(this,Kr,e,"f"),this.reset()}remove(){var e,t;null===(e=i(this,Br,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}}Kr=new WeakMap,Br=new WeakMap,Vr=new WeakSet,zr=function(){if(i(this,Br,"f"))return;const e=this.ele;e&&(o(this,Br,new MutationObserver((t=>{t.forEach(((n,i)=>{var o;const r="true"===n.oldValue,s=t[i+1]?t[i+1].oldValue:e.getAttribute("opened");r&&"true"!==s&&(null===(o=this.afterClose)||void 0===o||o.call(this))}))})),"f"),i(this,Br,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};class Xr extends Zr{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()}}l((e=>{var t,n;const o=r(ur,Lr,Er)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Gr{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(Hr);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Hr]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n}));const Yr="descope-notification";l((e=>{var t,n;const o=r(ur,Lr,Er)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Xr{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(Yr);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([Yr])}},t=new WeakMap,n})),l((e=>class extends(rr(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 Qr=l((e=>{const t=r(pr({"widget-id":dr}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}}));l((e=>{const t=r(yr,Qr)(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]}}})),l((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=f(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:""}})),l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),l((e=>{var n,o,r;return r=class extends(Dr(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:i(this,n,"m",o).call(this,l),client:Object.assign(Object.assign({},this.clientInput),s)},c))}},n=new WeakSet,o=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},r}));const es=["input","change"];function ts(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 ns(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 is(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 os(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function rs(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const ss=new Map;const as={equal:(e,t)=>e===t||ns(e)===ns(t),"not-equal":(e,t)=>e!==t&&ns(e)!==ns(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(ns(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(ns(t)),"greater-than":(e,t)=>{const n=ts(e),i=ts(t);return n.ok&&i.ok&&n.value>i.value},"greater-than-or-equal":(e,t)=>{const n=ts(e),i=ts(t);return n.ok&&i.ok&&n.value>=i.value},"less-than":(e,t)=>{const n=ts(e),i=ts(t);return n.ok&&i.ok&&n.value<i.value},"less-than-or-equal":(e,t)=>{const n=ts(e),i=ts(t);return n.ok&&i.ok&&n.value<=i.value},empty:e=>rs(e),"not-empty":e=>!rs(e),"is-true":e=>{const t=is(e);return t.ok&&t.value},"is-false":e=>{const t=is(e);return t.ok&&!t.value},in:(e,t)=>{const n=os(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=os(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(ss.has(e))return null!==(t=ss.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return ss.set(e,n),n}(ns(t));return null!==n&&n.test(e)}};function ls(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=>ls(e,t))):e.value}function cs(e,t){const n=as[e.operator];if(!n)return!1;return n(ls(e.target,t),ls(e.predicate,t))}function ds(e,t){var n;return(null!==(n=e.rules)&&void 0!==n?n:[]).some((e=>function(e,t){var n;const i=null!==(n=e.atomicConditions)&&void 0!==n?n:[];return!!i.length&&(e.logicalOr?i.some((e=>cs(e,t))):i.every((e=>cs(e,t))))}(e,t)))}function us(e,t){const n={};return(null!=e?e:[]).forEach((e=>{var i;ds(e,t)&&(null!==(i=e.componentIds)&&void 0!==i?i:[]).forEach((t=>{n[t]=e.action}))})),n}const hs=["hide","disable","read-only"];const ps=/(["\\])/g;function gs(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(ps,"\\$1")}function fs(e,t){return Array.from(e.querySelectorAll(`[id="${gs(t)}"]`))}function vs(e,t,n){return Object.keys(t).forEach((i=>{const o=t[i];n[i]!==o&&fs(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove("hidden");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,o)))})),Object.keys(n).forEach((i=>{const o=n[i],r=t[i];o!==r&&fs(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add("hidden");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,o)))})),Object.assign({},n)}const ms="component-conditions:";function bs(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 ws(e,t){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every((n=>e[n]===t[n]))}function ys(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function ks(e,t,n){const i={};return n.forEach((n=>{e[n]?i[n]=e[n]:t[n]&&(i[n]=t[n])})),i}const Is=l((e=>{var t,n,s,a,l,c;const d=r(rr)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,ys())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{hs.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${hs.map((e=>`"${e}"`)).join(", ")}`)})),vs(e,{},t))}initRealtimeConditions(e,r){var a,c,d,u;i(this,t,"m",l).call(this);const h=null!==(a=null==r?void 0:r.realtimeComponentsConditions)&&void 0!==a?a:[];if(!h.length)return void this.logger.debug(`${ms} no real-time rules to apply on this screen`);this.logger.info(`${ms} found ${h.length} real-time rule(s) for this screen`);const p={};Object.entries(null!==(c=null==r?void 0:r.form)&&void 0!==c?c:{}).forEach((([e,t])=>{p[`form.${e}`]=t})),function(e){const t=new Set,n=e=>{var i;e&&("form"===e.kind&&e.form?t.add(e.form):"list"===e.kind&&(null!==(i=e.items)&&void 0!==i?i:[]).forEach(n))};return(null!=e?e:[]).forEach((e=>{var t;return(null!==(t=e.rules)&&void 0!==t?t:[]).forEach((e=>{var t;return(null!==(t=e.atomicConditions)&&void 0!==t?t:[]).forEach((e=>{n(e.target),n(e.predicate)}))}))})),t}(h).forEach((t=>{const n=function(e,t){const n=t.startsWith("form.")?t.slice(5):t;return e.querySelector(`[name="${gs(t)}"]`)||e.querySelector(`[name="${gs(n)}"]`)}(e,t);if(!n)return;const i=bs(n);void 0!==i&&(p[t]=i)}));const g=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),f={},v={};Object.entries(null!==(d=null==r?void 0:r.componentsState)&&void 0!==d?d:{}).forEach((([e,t])=>{g.has(e)&&(v[e]=t)})),Object.entries(null!==(u=null==r?void 0:r.serverOnlyComponentsState)&&void 0!==u?u:{}).forEach((([e,t])=>{g.has(e)&&(f[e]=t)}));const m={conditions:h,touchedIds:g,snapshot:p,applied:v,serverBaseline:f,debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:e},b=ks(us(h,p),f,g);ws(v,b)||(m.applied=vs(e,v,b)),m.inputHandler=e=>i(this,t,"m",s).call(this,e),es.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${ms} listening for "${es.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))}}o(this,n,m,"f")}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(e){var o,r;const s=i(this,n,"f");if(!s.root||s.paused)return;const l=e.target;if(!l)return;if(null===(o=l.hasAttribute)||void 0===o?void 0:o.call(l,Ui))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]=bs(l),s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout((()=>{s.debounceTimer=null,i(this,t,"m",a).call(this)}),50)},a=function(){const e=i(this,n,"f");if(!e.root)return;let t;try{t=ks(us(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${ms} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const o=e.applied;ws(o,t)||(this.logger.debug(`${ms} form changed — updating components: was ${JSON.stringify(o)}, now ${JSON.stringify(t)}`),e.applied=vs(e.root,o,t))},l=function(){const e=i(this,n,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&(Object.keys(e.applied).length>0&&e.root.isConnected&&vs(e.root,e.applied,{}),es.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)}))),o(this,n,ys(),"f")},c})),Ss="project-id",Cs="flow-id",Os=e=>{const t=(e=>{const t=e.getAttribute(Ss),n=e.getAttribute(Cs);return t&&n?Array.from(e.ownerDocument.querySelectorAll("descope-wc")).filter((e=>e.getAttribute(Ss)===t&&e.getAttribute(Cs)===n)):[]})(e);return t.length>1&&t[0]!==e},xs=l((e=>{var t,n,s,a;const l=r(rr)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}connectedCallback(){var e;null===(e=super.connectedCallback)||void 0===e||e.call(this),i(this,t,"m",s).call(this)}attributeChangedCallback(e,n,o){var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),n===o||e!==Ss&&e!==Cs||i(this,t,"m",s).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){queueMicrotask((()=>{if(!this.isConnected)return;const e=this.getAttribute(Ss),t=this.getAttribute(Cs),r=`${e}|${t}`;i(this,n,"f")!==r&&Os(this)&&(o(this,n,r,"f"),this.logger.warn("Multiple Descope flow components detected on the same page",`The same flow ("${t}") and project ("${e}") are running more than once on this page. This is not supported and may cause the flow to behave unexpectedly.`))}))},a})),As=["externalId","email","phone"],Es=["newPassword","password"],js="data-username-anchor",Us=e=>{var t;if(!e)return"";try{const n=null===(t=window.sessionStorage)||void 0===t?void 0:t.getItem(Ti);if(!n)return"";const i=JSON.parse(n);return i.executionId===e&&i.loginId||""}catch(e){return""}},Rs=(e,t,n,i)=>{var o;const r=(null==n?void 0:n.email)||(null===(o=null==n?void 0:n.loginIds)||void 0===o?void 0:o[0]);(e=>e.querySelector("descope-new-password")||e.querySelector("descope-password"))(t)?r?(e=>{const t=['input[autocomplete="username"]',...As.map((e=>`[name="${e}"]`))].join(", ");return e.some((e=>e.querySelector(t)))})([e,t])?i.debug("Username anchor: screen already has an identifier field"):(i.debug("Username anchor: injecting hidden username input"),e.appendChild((e=>{const t=document.createElement("input");return t.setAttribute("autocomplete","username"),t.setAttribute("name","username"),t.setAttribute("type","email"),t.setAttribute("readonly","true"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-hidden","true"),t.setAttribute(Ui,"true"),t.setAttribute(js,"true"),t.setAttribute("value",e),t.value=e,Object.assign(t.style,{position:"absolute",opacity:"0",pointerEvents:"none",height:"0",border:"0"}),t})(r))):i.debug("Username anchor: no user identifier available"):i.debug("Username anchor: no password component on screen")},$s=l((e=>{var t,n,s,a,l;const c=r(rr)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}updateScreenUser(e){var r,l,c;o(this,n,{email:null==e?void 0:e.email,loginIds:(null===(r=null==e?void 0:e.loginIds)||void 0===r?void 0:r.length)?e.loginIds:[Us(i(this,t,"a",a))||(null===(c=null===(l=i(this,t,"a",s).sdk)||void 0===l?void 0:l.getLastUserLoginId)||void 0===c?void 0:c.call(l))].filter(Boolean)},"f")}updateUsernameAnchor(){document.querySelectorAll(`[${js}="true"]`).forEach((e=>e.remove())),Rs(this,i(this,t,"a",s).contentRootElement,i(this,n,"f"),this.logger)}captureLastSubmittedLoginId(e={},n){const o=ko(e,As);o&&((e,t)=>{var n;if(e&&t)try{null===(n=window.sessionStorage)||void 0===n||n.setItem(Ti,JSON.stringify({executionId:t,loginId:e}))}catch(e){}})(o,n||i(this,t,"a",a))}storeCredentials(e={}){var t,o,r,s,a;const l=ko(e,As)||(null===(t=i(this,n,"f"))||void 0===t?void 0:t.email)||(null===(r=null===(o=i(this,n,"f"))||void 0===o?void 0:o.loginIds)||void 0===r?void 0:r[0]),c=ko(e,Es);if(l&&c)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:l,password:c});null===(a=null===(s=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===s?void 0:s.store)||void 0===a||a.call(s,e)}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=i(this,t,"a",s).flowState)||void 0===e?void 0:e.current)||void 0===n?void 0:n.executionId)||""},l}));var Ts,Ls,Ps,Ws,Ns,Ms,_s,Ds,qs,Fs,Hs,Js,Vs,Ks,Bs,zs,Zs,Gs,Xs,Ys,Qs,ea;const ta=r(Dr,br,Fr,Is,xs,$s,Rr)(HTMLElement);class na extends ta{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(),Ts.add(this),Ps.set(this,!1),Ws.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,Ts,"m",ea).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)}},Ns.set(this,new Po),Ms.set(this,new Po),_s.set(this,{}),this.getComponentsContext=()=>i(this,_s,"f"),this.nextRequestStatus=new Po({isLoading:!1}),Ds.set(this,void 0),qs.set(this,{popstate:i(this,Ts,"m",Ks).bind(this),componentsContext:i(this,Ts,"m",Xs).bind(this)}),Fs.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,Fs,e,"f"),i(this,Ts,"m",Js).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 qr(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return e=this.formConfig,t="value",Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]])));var e,t}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const e=JSON.parse(this.getAttribute("outbound-app-scopes"));return e||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return i(this,Ws,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");o(this,Ws,e,"f"),(e=>{zo=e})(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=io.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig(),n="projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{};return n||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),i(this,Ms,"f").subscribe(i(this,Ts,"m",Qs).bind(this)),i(this,Ms,"f").update({isDebug:this.debug}),i(this,Ts,"m",Vs).call(this),yield i(this,Ts,"m",Zs).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:g,ssoQueryParams:f}=fo(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,qs,"f").popstate),window.addEventListener("components-context",i(this,qs,"f").componentsContext),i(this,Ns,"f").subscribe(i(this,Ts,"m",zs).bind(this)),i(this,Ns,"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:g},f)),o(this,Ps,!0,"f")}))}disconnectedCallback(){var e;i(this,Ns,"f").unsubscribeAll(),i(this,Ms,"f").unsubscribeAll(),i(this,Ts,"m",Ys).call(this),window.removeEventListener("popstate",i(this,qs,"f").popstate),window.removeEventListener("components-context",i(this,qs,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,n){var o;if(null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,t,n),this.shadowRoot.isConnected&&i(this,Ps,"f")&&t!==n&&Ls.observedAttributes.includes(e)){i(this,Ts,"m",Vs).call(this);const o=null===t;i(this,Ns,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,po()),{[go(e)]:n,stepId:r,executionId:s}})),i(this,Ms,"f").update({isDebug:this.debug})}}}var ia,oa,ra,sa,aa,la,ca,da,ua,ha,pa,ga,fa,va,ma,ba,wa,ya,ka,Ia,Sa,Ca,Oa,xa,Aa,Ea,ja,Ua,Ra,$a,Ta,La,Pa,Wa,Na,Ma,_a,Da,qa;Ls=na,Ps=new WeakMap,Ws=new WeakMap,Ns=new WeakMap,Ms=new WeakMap,_s=new WeakMap,Ds=new WeakMap,qs=new WeakMap,Fs=new WeakMap,Ts=new WeakSet,Hs=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 ")},Js=function(){i(this,Ts,"m",Hs).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Vs=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"];Ls.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[go(t)])throw Error(`${t} cannot be empty`)}))},Ks=function(){const{stepId:e,executionId:t}=ho(this.flowId);i(this,Ns,"f").update({stepId:e,executionId:t})},Bs=function(e,t){wi&&"function"==typeof wi||this.logger.error("SDK was not loaded properly",wi,JSON.stringify(wi));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},Ls.sdkConfigOverrides),{projectId:e,baseUrl:t});i(this,Ws,"f")&&(o.customStorage=i(this,Ws,"f")),this.sdk=wi(o),["start","next"].forEach((e=>{const t=function(e,t,i){return(...o)=>n(this,void 0,void 0,(function*(){let n;const r=i+1;for(let s=0;s<r;s++)try{return yield e(...o)}catch(e){n=e,s<i&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw n}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...i)=>n(this,void 0,void 0,(function*(){try{return yield t(...i)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:ki,errorDescription:t.toString()}}}}))}))},zs=function(e,t,o){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(o("projectId")||o("baseUrl")){if(!t)return;i(this,Ts,"m",Bs).call(this,t,n)}i(this,Fs,"f").call(this,e)}))},Zs=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,Ts,"m",Gs).call(this))}))},Gs=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(Ci||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},Xs=function(e){o(this,_s,Object.assign(Object.assign({},i(this,_s,"f")),e.detail),"f")},Ys=function(){var e;null===(e=i(this,Ds,"f"))||void 0===e||e.remove(),o(this,Ds,null,"f")},Qs=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,Ds,document.createElement("descope-debugger"),"f"),Object.assign(i(this,Ds,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return bl})),document.body.appendChild(i(this,Ds,"f"))):i(this,Ts,"m",Ys).call(this)}))},ea=function(e,t){var n;e&&this.debug&&(null===(n=i(this,Ds,"f"))||void 0===n||n.updateData({title:e,description:t}))},na.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.0.1"}};class Fa extends na{static set sdkConfigOverrides(e){na.sdkConfigOverrides=e}static get sdkConfigOverrides(){return na.sdkConfigOverrides}constructor(){const e=new Po({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),ia.add(this),this.stepState=new Po({}),oa.set(this,void 0),ra.set(this,null),sa.set(this,null),aa.set(this,{visibilitychange:i(this,ia,"m",la).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},va.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},ba.set(this,(e=>{const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?i(this,ia,"m",wa).call(this,t):t()})),ya.set(this,((e,t,r,s,a=!1)=>{const l=[Ii,"E103202",Si];if(this.flowState.current.action===Gi){if(i(this,Ia,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;o(this,oa,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,o;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,no,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 bo(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,ya,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===ki)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,ya,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==p?void 0:p.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(p.error,null,4)),(null===(o=null==p?void 0:p.error)||void 0===o?void 0:o.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):i(this,ya,"f").call(this,e,t,r,s),i(this,Sa,"f").call(this,p)}))),d),"f")}})),ka.set(this,(()=>{clearTimeout(i(this,oa,"f")),o(this,oa,null,"f")})),Ia.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),Sa.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,g,f;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;i(this,ia,"m",Da).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&d!==Ii&&d!==Si||!this.isRestartOnError||i(this,ia,"m",fa).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(g=e.data)||void 0===g?void 0:g.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!==Gi&&i(this,ka,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&er(Object.assign(Object.assign({},w),{lastUsedPerScreen:tr()})),nr(this.loggerWrapper);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void i(this,ia,"m",Da).call(this,"success",t)}this.storeLastAuthenticatedUser&&er(w,!0),k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:C,screen:O,redirect:x,webauthn:A,error:E,samlIdpResponse:j,wsFedIdpResponse:U,nativeResponse:R}=e.data,$=Date.now();y!==Gi?(this.loggerWrapper.info(`Step "${C||`#${S}`}" is ${m}`,"",{screen:O,status:m,stepId:S,stepName:C,action:y,error:E}),(null===(f=O.state)||void 0===f?void 0:f.clientScripts)&&o(this,sa,this.loadSdkScripts(O.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:C,executionId:I,action:y,redirectTo:null==x?void 0:x.url,redirectIsPopup:null==x?void 0:x.isPopup,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==A?void 0:A.transactionId,webauthnOptions:null==A?void 0:A.options,samlIdpResponseUrl:null==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.relayState,wsFedIdpResponseUrl:null==U?void 0:U.url,wsFedIdpResponseWresult:null==U?void 0:U.wresult,wsFedIdpResponseWctx:null==U?void 0:U.wctx,nativeResponseType:null==R?void 0:R.type,nativePayload:null==R?void 0:R.payload,reqTimestamp:$})):this.flowState.update({action:y,reqTimestamp:$})})),Ca.set(this,vo((()=>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)}}))))),Ua.set(this,null),La.set(this,Io(((e,t,o)=>n(this,void 0,void 0,(function*(){var n,r,s;if("true"===e.getAttribute("formnovalidate")||i(this,ia,"m",Ea).call(this)){const a=null==e?void 0:e.getAttribute("id");i(this,ia,"m",Na).call(this,e,a,o),i(this,ia,"m",Ra).call(this,e);const l=yield i(this,ia,"m",ja).call(this),c=(s=e,Array.from((null==s?void 0:s.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}));this.nextRequestStatus.update({isLoading:!0});const d=Object.assign(Object.assign(Object.assign({},c),l),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin}),u=yield t(a,d);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(l,null===(r=null==u?void 0:u.data)||void 0===r?void 0:r.executionId),this.storeCredentials(l)}}))))),this.flowState=e}nativeResume(e,t){var n,o,r,s,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const i=new URL(c.url);t=null===(n=i.searchParams)||void 0===n?void 0:n.get(Ai),e=(null===(o=i.searchParams)||void 0===o?void 0:o.get(ji))||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(xi).split("_").pop();i(this,ka,"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:{[Eo(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,i,o;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}(null===(i=globalThis.descope)||void 0===i?void 0:i[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.17",`dist/${e.id}.js`));const s=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((n,i)=>{try{const i=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t);const n=this.nextRequestStatus.subscribe((()=>{var o;this.loggerWrapper.debug("Stopping script",e.id),(null===(o=i.stop)||void 0===o?void 0:o.call(i))&&(this.nextRequestStatus.unsubscribe(n),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}))}}catch(e){i(e)}}))}))))),o=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([i,o])}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,ia,"m",pa).call(this),window.addEventListener("visibilitychange",i(this,aa,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),i(this,ka,"f").call(this),null===(e=i(this,ra,"f"))||void 0===e||e.abort(),o(this,ra,null,"f"),window.removeEventListener("visibilitychange",i(this,aa,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=f(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:g,screenId:v,screenState:m,redirectTo:b,redirectIsPopup:w,redirectUrl:y,token:k,code:I,isPopup:S,exchangeError:C,webauthnTransactionId:O,webauthnOptions:x,redirectAuthCodeChallenge:A,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:U,locale:R,samlIdpResponseUrl:$,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:L,wsFedIdpResponseUrl:P,wsFedIdpResponseWresult:W,wsFedIdpResponseWctx:N,nativeResponseType:M,nativePayload:_,reqTimestamp:D}=e,q=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 F,H,J;const V=(()=>{const e=Go(Xo);if(!e){const e=Math.floor(100*Math.random()+1);return Zo(Xo,e.toString()),e}return Number(e)})(),{outboundAppId:K}=this,{outboundAppScopes:B}=this,z=this.sdk.getLastUserLoginId(),Z=yield this.getFlowConfig(),G=yield this.getProjectConfig(),X=Object.entries(G.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Y=E&&A?{callbackUrl:E,codeChallenge:A,backupCallbackUri:j}:void 0,Q=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let ee={};if(!p){nr(this.loggerWrapper);const e=[...Z.clientScripts||[],...Z.sdkScripts||[]];if(Z.conditions){let t=[];({startScreenId:F,conditionInteractionId:J,startScreenName:H,clientScripts:t,componentsConfig:ee}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const r=null===(o=Yo[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:z,code:I,token:k,abTestingKey:V,lastAuth:Qo(z,this.loggerWrapper)},Z.conditions)),e.push(...t||[])}else Z.condition?({startScreenId:F,conditionInteractionId:J}=((e,t)=>{var n;const i=null===(n=Yo[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(Z.condition,{loginId:z,code:I,token:k,abTestingKey:V,lastAuth:Qo(z,this.loggerWrapper)})):(H=Z.startScreenName,F=Z.startScreenId);if(o(this,sa,this.loadSdkScripts(e),"f"),Z.fingerprintEnabled&&Z.fingerprintKey?yield Ln(Z.fingerprintKey,this.baseUrl):cn($n),!wo(F,q)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Y},q),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:Qo(z,this.loggerWrapper),abTestingKey:V,locale:f(R).locale,nativeOptions:Q,outboundAppId:K,outboundAppScopes:B}),J,"",G.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),I?{exchangeCode:I,idpInitiated:!0}:{}),q.descopeIdpInitiated&&{idpInitiated:!0}),k?{token:k}:{}),q.oidcLoginHint?{externalId:q.oidcLoginHint}:{}));return i(this,Sa,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:S,code:I,exchangeError:C,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),S&&(s("code")&&I||s("exchangeError")&&C))return void i(this,ia,"m",qa).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,to,Z.version,G.componentsVersion,{token:k,exchangeCode:I,exchangeError:C});return i(this,Sa,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===eo&&$&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!T)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})($,T,L||"",yo)}if(g===eo&&P&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>s(e)))){if(!W)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e;const r=(e,t)=>{const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n};o.appendChild(r("wa","wsignin1.0")),o.appendChild(r("wresult",t)),o.appendChild(r("wctx",n));const s=document.createElement("input");s.type="submit",s.id="WSFedSubmitButton",s.value="Continue",s.style.display="none",o.appendChild(s),document.body.appendChild(o),i(o)})(P,W,N||"",yo)}if(g===Zi&&(s("redirectTo")||s("deferredRedirect"))){if(!b)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===b)return;if("android"===U&&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=jo(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 o=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const i=t?this.popupOrigin:window.location.origin;if(e.origin!==i)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${i}"`);const{action:o,data:r}=e.data||{};"code"===o&&(n=!0,this.flowState.update({code:r.code,exchangeError:r.exchangeError}))};let r;this.loggerWrapper.debug("Starting popup closed detection");const s=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(s),i(this,ia,"m",Da).call(this,"popupclosed",{abandoned:!n}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==r||r())}),1e3);if(t)window.addEventListener("message",o),r=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",o)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=o,r=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(b),this.flowState.update({redirectTo:"no-op"}),i(this,ia,"m",Da).call(this,"popupclosed",{});return}if(g===Xi||g===Yi){if(!O||!x)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t,n,r;null===(l=i(this,ra,"f"))||void 0===l||l.abort(),o(this,ra,null,"f");try{e=g===Xi?yield this.sdk.webauthn.helpers.create(x):yield this.sdk.webauthn.helpers.get(x)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name,n=e.reason,r=e.message}const s=yield this.sdk.flow.next(p,h,to,Z.version,G.componentsVersion,{transactionId:O,response:e,failure:t,failureReason:n,failureMessage:r});i(this,Sa,"f").call(this,s)}if(g===Qi)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,to,Z.version,G.componentsVersion,e);i(this,Sa,"f").call(this,t)})),i(this,ia,"m",ua).call(this,M,_),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&i(this,ya,"f").call(this,p,h,Z.version,G.componentsVersion),!v&&!F)return void this.loggerWrapper.warn("No screen was found to show");const te=F||v,ne=yield this.getHtmlFilenameWithLocale(R,te),{oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,samlIdpUsername:ae}=q,le={direction:uo(h,r.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:z,name:this.sdk.getLastUserDisplayName()||z},componentsConfig:Object.assign(Object.assign(Object.assign({},Z.componentsConfig),ee),null==m?void 0:m.componentsConfig)}),htmlFilename:`${te}.html`,htmlLocaleFilename:ne,screenId:te,stepName:e.stepName||H,samlIdpUsername:ae,oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,action:g,locale:f(R).locale},ce=Qo(z,this.loggerWrapper);wo(F,q)?le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==Z?void 0:Z.clientScripts)||[];yield i(this,ia,"m",Pa).call(this,n);const o=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Y},q),{lastAuth:ce,preview:this.preview,abTestingKey:V,client:this.client}),y&&{redirectUrl:y}),{locale:f(R).locale,nativeOptions:Q,outboundAppId:K,outboundAppScopes:B}),J,e,G.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),Ao(t)),I&&{exchangeCode:I,idpInitiated:!0}),q.descopeIdpInitiated&&{idpInitiated:!0}),k&&{token:k}),le.next.isCustomScreen);return i(this,Sa,"f").call(this,o),o})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==m?void 0:m.clientScripts)||[];yield i(this,ia,"m",Pa).call(this,n);const o=yield this.sdk.flow.next(p,h,e,Z.version,G.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),Ao(t)),le.next.isCustomScreen);return i(this,Sa,"f").call(this,o),o}))),this.loggerWrapper.debug("Got a screen with id",le.screenId),yield i(this,ia,"m",ma).call(this,le),this.stepState.update(le)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r,s;const{htmlFilename:a,htmlLocaleFilename:l,direction:c,next:d,screenState:u,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen"),this.updateScreenUser(null==u?void 0:u.user);const p=document.createElement("template");p.innerHTML=yield this.getPageContent(a,l);const g=p.content.cloneNode(!0),f=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield i(this,ia,"m",xa).call(this,g,d):g.querySelectorAll(`descope-button[${zi}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(o=u.form)||void 0===o?void 0:o.loginId)||(null===(r=u.form)||void 0===r?void 0:r.email)||(u.form||(u.form={}),u.form.loginId=e.samlIdpUsername,u.form.email=e.samlIdpUsername),Vo(g,u,this.formConfig,this.loggerWrapper),this.applyComponentsState(g,null==u?void 0:u.componentsState);const{geo:v}=null!==(s=yield this.getExecutionContext())&&void 0!==s?s:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,i])=>{Array.from(e.querySelectorAll(`[${n}="${i}"]`)).forEach((e=>{e.setAttribute(n,t||i)}))}))})(g,v),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`[${t}="${i}"]`)).forEach((e=>{e.setAttribute(t,n||i)}))}))})(g,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,o;yield f;const r=this.contentRootElement;var s,a;s=r,a=null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image,Jo(s,"descope-totp-image",a),((e,t)=>{Jo(e,"descope-notp-image",t)})(r,null===(o=null==u?void 0:u.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,g,u.cssVars,this.loggerWrapper),r.replaceChildren(g);const l=!t.htmlFilename;setTimeout((()=>{i(this,ia,"m",$a).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const i=()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))};if("true"===t.getAttribute("invalid")||(null===(n=t.value)||void 0===n?void 0:n.length))return void i();const o={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(o.timer),o.timer=void 0)};o.timer=setTimeout((()=>{e.removeEventListener("click",r),i(),o.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(r),((e,t)=>{_o(e,null==t?void 0:t.inputs),_o(e,null==t?void 0:t.form)})(r,u),this.initRealtimeConditions(r,u),i(this,ia,"m",Aa).call(this,{isFirstScreen:l,isCustomScreen:!1,stepName:e.stepName}),mo(r,this.autoFocus,l),i(this,ia,"m",Ma).call(this,h)})),i(this,ia,"m",_a).call(this,d,h);r.querySelector(`[${zi}="polling"]`)&&d(no,{})}));c?i(this,ia,"m",wa).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${Ui}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}oa=new WeakMap,ra=new WeakMap,sa=new WeakMap,aa=new WeakMap,va=new WeakMap,ba=new WeakMap,ya=new WeakMap,ka=new WeakMap,Ia=new WeakMap,Sa=new WeakMap,Ca=new WeakMap,Ua=new WeakMap,La=new WeakMap,ia=new WeakSet,la=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},ca=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,ia,"m",ua).call(this,"beforeScreen",{screen:e,context:t})}))}))},da=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,ia,"m",ua).call(this,"afterScreen",{screen:e})},ua=function(e,t){i(this,ia,"m",Da).call(this,"bridge",{type:e,payload:t})},ha=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${zi}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},pa=function(){var e,n,o;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=t(void 0===n?{}:n,["errorText","errorType"]),o=t(e,["screenState"]);return Object.assign(Object.assign({},o),{screenState:i})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,ia,"m",ha).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,ia,"m",ga).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})},ga=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=""}))})),mo(this.contentRootElement,this.autoFocus,!1))},fa=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")}))},ma=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=t(r,["next","stepName"]),c=xo(l);let d=yield i(this,ia,"m",ca).call(this,a,c,s);d||(d=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,c,s,this)));const u=!this.stepState.current.htmlFilename;if(i(this,ba,"f").call(this,d),s&&(s.isCustomScreen=d),i(this,va,"f")!==d){const[e,t]=["flow","custom"].sort((()=>d?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,va,d,"f"),d?this.stepState.unsubscribeAll():i(this,ia,"m",pa).call(this)}d?(this.loggerWrapper.debug("Showing a custom screen"),i(this,ia,"m",Aa).call(this,{isFirstScreen:u,isCustomScreen:d,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=d}))},wa=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")},Oa=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)}))}},xa=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,ra,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Ko())){const{options:e,transactionId:r}=(yield i(this,Ca,"f").call(this))||{};e&&r&&(i(this,ia,"m",Oa).call(this,s),o(this,ra,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,ra,"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)})))}}))},Aa=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,ia,"m",Da).call(this,"ready",{}),t||i(this,ia,"m",da).call(this,n),i(this,ia,"m",Da).call(this,"page-updated",{screenName:n}),i(this,ia,"m",Da).call(this,"screen-updated",{screenName:n})},Ea=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,i;"slot"===t.localName||t.classList.contains("hidden")||(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(i=t.checkValidity)||void 0===i?void 0:i.call(t)))})),e},ja=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})),{})}))},Ra=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;this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",c);if(!0===(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.abandoned)&&a.length)return o(this,sa,(()=>n(this,void 0,void 0,(function*(){try{yield this.loadSdkScripts(a)}catch(e){this.loggerWrapper.warn("Failed to refresh client scripts on popup close",null==e?void 0:e.message)}})))(),"f"),void l();l();const i=yield this.getFlowConfig(),r=[...i.clientScripts||[],...i.sdkScripts||[]];this.loadSdkScripts(r)})),d=()=>{var e;window.removeEventListener("pageshow",i(this,Ua,"f")),o(this,Ua,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),c())}),"f"),window.addEventListener("pageshow",i(this,Ua,"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())}))},$a=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,ia,"m",Ta).call(this,e)))},Ta=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},Pa=function(e){return n(this,void 0,void 0,(function*(){if(i(this,sa,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,sa,"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{if("function"==typeof e.present){(yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`)}}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const o=[];for(const e of t)"function"==typeof e.refresh&&o.push(e.refresh());if(o.length>0)try{yield bo(5e3,Promise.all(o),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Wa=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var o;(null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))&&i(this,La,"f").call(this,n,e,t)}))}))},Na=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=tr();n[e]=t,Zo(oo,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},Ma=function(e){var t;const n=null===(t=Qo(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const i=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);i&&o&&(o.replaceWith(i),i.appendChild(o))},_a=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${Ri}]), [data-type="button"]:not([${Ri}]`).forEach((n=>{n.onclick=()=>{i(this,La,"f").call(this,n,e,t)}})),i(this,ia,"m",Wa).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Ui}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Da=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},qa=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s={data:{code:t,exchangeError:n},action:"code"};if("descope-wc"===o&&r){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",r);try{window.opener.postMessage(s,r)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(s),t.close()}try{window.close()}catch(e){}},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Fa);const Ha=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};var Ja,Va,Ka,Ba,za,Za,Ga,Xa,Ya,Qa;const el=document.createElement("template");el.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 tl=r(Rr)(HTMLElement);let nl=class extends tl{constructor(){var e;super(),Ja.add(this),Va.set(this,new g({messages:[]})),Ka.set(this,void 0),Ba.set(this,void 0),za.set(this,void 0),Za.set(this,{resize:i(this,Ja,"m",Qa).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(el.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),o(this,Ka,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Ka,"f").style.top="32px",i(this,Ka,"f").style.left=window.innerWidth-300-32+"px",o(this,Ba,i(this,Ka,"f").querySelector(".content"),"f"),o(this,za,i(this,Ka,"f").querySelector(".header"),"f")}updateData(e){i(this,Va,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Ha(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,Ka,"f"),i(this,za,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Za,"f").resize),(e=i(this,Ka,"f")).onmousemove=t=>{var n;const i=t.target;(i.w&&i.w!==i.offsetWidth||i.h&&i.h!==i.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),i.w=i.offsetWidth,i.h=i.offsetHeight},i(this,Ka,"f").onresize=i(this,Ja,"m",Ya).bind(this),i(this,Va,"f").subscribe(i(this,Ja,"m",Ga).bind(this))}disconnectedCallback(){i(this,Va,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Za,"f").resize)}};Va=new WeakMap,Ka=new WeakMap,Ba=new WeakMap,za=new WeakMap,Za=new WeakMap,Ja=new WeakSet,Ga=function(e){i(this,Ja,"m",Xa).call(this,e),i(this,Ja,"m",Ya).call(this)},Xa=function(e){i(this,Ba,"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("")},Ya=function(){i(this,Ba,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),i=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;i||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Qa=function(){const[e,t]=Ha(i(this,Ka,"f"),Number.parseInt(i(this,Ka,"f").style.left,10),Number.parseInt(i(this,Ka,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Ka,"f").style.top=`${t}px`,i(this,Ka,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",nl);var il,ol,rl,sl,al,ll,cl,dl,ul,hl,pl,gl=Object.freeze({__proto__:null,default:nl});const fl=document.createElement("template");fl.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 vl=r(Rr)(HTMLElement);class ml extends vl{constructor(){super(),il.add(this),ol.set(this,new Po({messages:[]})),rl.set(this,void 0),sl.set(this,void 0),al.set(this,void 0),ll.set(this,{resize:i(this,il,"m",pl).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(fl.content.cloneNode(!0)),o(this,rl,this.shadowRoot.querySelector(".debugger"),"f"),o(this,sl,i(this,rl,"f").querySelector(".content"),"f"),o(this,al,i(this,rl,"f").querySelector(".header"),"f"),i(this,il,"m",cl).call(this)}updateData(e){i(this,ol,"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,n;null===(t=e.init)||void 0===t||t.call(this),((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Bo(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,rl,"f"),i(this,al,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,ll,"f").resize),(n=i(this,rl,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&n.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},i(this,rl,"f").onresize=i(this,il,"m",hl).bind(this),i(this,ol,"f").subscribe(i(this,il,"m",dl).bind(this))}))}disconnectedCallback(){i(this,ol,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,ll,"f").resize)}}ol=new WeakMap,rl=new WeakMap,sl=new WeakMap,al=new WeakMap,ll=new WeakMap,il=new WeakSet,cl=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,rl,"f").style.top="32px",i(this,rl,"f").style.left=window.innerWidth-300-32+"px"},dl=function(e){i(this,il,"m",ul).call(this,e),i(this,il,"m",hl).call(this)},ul=function(e){i(this,sl,"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("")},hl=function(){i(this,sl,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},pl=function(){const[e,t]=Bo(i(this,rl,"f"),Number.parseInt(i(this,rl,"f").style.left,10),Number.parseInt(i(this,rl,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,rl,"f").style.top=`${t}px`,i(this,rl,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",ml);var bl=Object.freeze({__proto__:null,default:ml})}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/web-component",
3
- "version": "3.70.7",
3
+ "version": "4.0.1",
4
4
  "author": "Descope Team <info@descope.com>",
5
5
  "homepage": "https://github.com/descope/descope-js",
6
6
  "bugs": {
@@ -71,8 +71,8 @@
71
71
  "tslib": "2.8.1",
72
72
  "@fingerprintjs/fingerprintjs-pro": "3.11.6",
73
73
  "@descope/sdk-helpers": "0.9.0",
74
- "@descope/sdk-mixins": "0.23.2",
75
- "@descope/web-js-sdk": "1.51.3",
74
+ "@descope/sdk-mixins": "0.24.0",
75
+ "@descope/web-js-sdk": "1.51.4",
76
76
  "@descope/escape-markdown": "0.1.6"
77
77
  },
78
78
  "overrides": {