@descope/web-component 3.52.3 → 3.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -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,P,F,A,y,x,E,I,G,j=require("../helpers/storage.js"),S=require("../helpers/flowInputs.js"),M=require("../mixins/formMountMixin.js"),O=require("../constants/content.js"),U=require("../constants/general.js");function L(t){return Object.freeze({__proto__:null,default:t})}const q=e.compose(r.themeMixin,i.staticResourcesMixin,M.formMountMixin,s.injectStyleMixin)(HTMLElement);class R extends q{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",G).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",x).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 tenantId(){return this.getAttribute("tenant")||void 0}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"),j.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",A).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(){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)}attributeChangedCallback(e,i,r){if(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=R,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"];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})},P=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];this.sdk.flow[e]=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){try{return yield i(...e)}catch(t){return{error:{errorCode:U.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",P).call(this,i,s)}t.__classPrivateFieldGet(this,m,"f").call(this,e)}))},A=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:O.CONFIG_FILENAME,assetsFolder:O.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield a.fetchContent(t,"json"),!0}catch(t){return!1}}))},x=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 L(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,v,"f"))):t.__classPrivateFieldGet(this,u,"m",E).call(this)}))},G=function(e,i){var r;e&&this.debug&&(null===(r=t.__classPrivateFieldGet(this,v,"f"))||void 0===r||r.updateData({title:e,description:i}))},R.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.52.3"}},module.exports=R;
|
|
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,P,F,A,y,x,E,I,G,j=require("../helpers/storage.js"),S=require("../helpers/flowInputs.js"),M=require("../mixins/formMountMixin.js"),O=require("../constants/content.js"),U=require("../constants/general.js");function L(t){return Object.freeze({__proto__:null,default:t})}const q=e.compose(r.themeMixin,i.staticResourcesMixin,M.formMountMixin,s.injectStyleMixin)(HTMLElement);class R extends q{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",G).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",x).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 tenantId(){return this.getAttribute("tenant")||void 0}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"),j.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",A).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(){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)}attributeChangedCallback(e,i,r){if(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=R,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"];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})},P=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];this.sdk.flow[e]=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){try{return yield i(...e)}catch(t){return{error:{errorCode:U.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",P).call(this,i,s)}t.__classPrivateFieldGet(this,m,"f").call(this,e)}))},A=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:O.CONFIG_FILENAME,assetsFolder:O.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield a.fetchContent(t,"json"),!0}catch(t){return!1}}))},x=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 L(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,v,"f"))):t.__classPrivateFieldGet(this,u,"m",E).call(this)}))},G=function(e,i){var r;e&&this.debug&&(null===(r=t.__classPrivateFieldGet(this,v,"f"))||void 0===r||r.updateData({title:e,description:i}))},R.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.53.0"}},module.exports=R;
|
|
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 u}from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as a}from"../constants/index.js";import{handleUrlParams as l,clearRunIdsFromUrl as d,camelCase as c,getRunIdsFromUrl as h,getContentUrl as g,fetchContent as f}from"../helpers/helpers.js";import p from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{setCustomStorage as m}from"../helpers/storage.js";import{transformFlowInputFormData as b,extractNestedAttribute as v}from"../helpers/flowInputs.js";import{formMountMixin as w}from"../mixins/formMountMixin.js";import{CONFIG_FILENAME as k,PREV_VER_ASSETS_FOLDER as C}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as y}from"../constants/general.js";var A,x,I,j,E,L,S,U,M,O,W,D,P,N,F,K,R,T,B,H,J,V;const q=r(s,o,w,n)(HTMLElement);class z extends q{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(),A.add(this),I.set(this,!1),j.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,A,"m",V).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)}},E.set(this,new p),L.set(this,new p),S.set(this,{}),this.getComponentsContext=()=>t(this,S,"f"),this.nextRequestStatus=new p({isLoading:!1}),U.set(this,void 0),M.set(this,{popstate:t(this,A,"m",N).bind(this),componentsContext:t(this,A,"m",B).bind(this)}),O.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,O,r,"f"),t(this,A,"m",D).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}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 b(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return v(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,j,"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,j,t,"f"),m(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=a.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 u=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===u.length)return void u[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,L,"f").subscribe(t(this,A,"m",J).bind(this)),t(this,L,"f").update({isDebug:this.debug}),t(this,A,"m",P).call(this),yield t(this,A,"m",R).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:u,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:g,redirectAuthCodeChallenge:f,redirectAuthInitiator:p,ssoQueryParams:m}=l(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t(this,M,"f").popstate),window.addEventListener("components-context",t(this,M,"f").componentsContext),t(this,E,"f").subscribe(t(this,A,"m",K).bind(this)),t(this,E,"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:u,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:g,redirectAuthCodeChallenge:f,redirectAuthInitiator:p},m)),i(this,I,!0,"f")}))}disconnectedCallback(){t(this,E,"f").unsubscribeAll(),t(this,L,"f").unsubscribeAll(),t(this,A,"m",H).call(this),window.removeEventListener("popstate",t(this,M,"f").popstate),window.removeEventListener("components-context",t(this,M,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t(this,I,"f")&&i!==r&&x.observedAttributes.includes(e)){t(this,A,"m",P).call(this);const o=null===i;t(this,E,"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,L,"f").update({isDebug:this.debug})}}}x=z,I=new WeakMap,j=new WeakMap,E=new WeakMap,L=new WeakMap,S=new WeakMap,U=new WeakMap,M=new WeakMap,O=new WeakMap,A=new WeakSet,W=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 ")},D=function(){t(this,A,"m",W).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},P=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"];x.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[c(e)])throw Error(`${e} cannot be empty`)}))},N=function(){const{stepId:e,executionId:i}=h(this.flowId);t(this,E,"f").update({stepId:e,executionId:i})},F=function(i,r){u&&"function"==typeof u||this.logger.error("SDK was not loaded properly",u,JSON.stringify(u));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},x.sdkConfigOverrides),{projectId:i,baseUrl:r});t(this,j,"f")&&(o.customStorage=t(this,j,"f")),this.sdk=u(o),["start","next"].forEach((t=>{const i=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>e(this,void 0,void 0,(function*(){try{return yield i(...t)}catch(t){return{error:{errorCode:y,errorDescription:t.toString()}}}}))}))},K=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,A,"m",F).call(this,e,r)}t(this,O,"f").call(this,i)}))},R=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,A,"m",T).call(this))}))},T=function(){return e(this,void 0,void 0,(function*(){const t=g({projectId:this.projectId,filename:k,assetsFolder:C,baseUrl:this.baseStaticUrl});try{return yield f(t,"json"),!0}catch(t){return!1}}))},B=function(e){i(this,S,Object.assign(Object.assign({},t(this,S,"f")),e.detail),"f")},H=function(){var e;null===(e=t(this,U,"f"))||void 0===e||e.remove(),i(this,U,null,"f")},J=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,U,document.createElement("descope-debugger"),"f"),Object.assign(t(this,U,"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,U,"f"))):t(this,A,"m",H).call(this)}))},V=function(e,i){var r;e&&this.debug&&(null===(r=t(this,U,"f"))||void 0===r||r.updateData({title:e,description:i}))},z.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.52.3"}};export{z 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 u}from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as a}from"../constants/index.js";import{handleUrlParams as l,clearRunIdsFromUrl as d,camelCase as c,getRunIdsFromUrl as h,getContentUrl as g,fetchContent as f}from"../helpers/helpers.js";import p from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{setCustomStorage as m}from"../helpers/storage.js";import{transformFlowInputFormData as b,extractNestedAttribute as v}from"../helpers/flowInputs.js";import{formMountMixin as w}from"../mixins/formMountMixin.js";import{CONFIG_FILENAME as k,PREV_VER_ASSETS_FOLDER as C}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as y}from"../constants/general.js";var A,x,I,j,E,L,S,U,M,O,W,D,P,N,F,K,R,T,B,H,J,V;const q=r(s,o,w,n)(HTMLElement);class z extends q{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(),A.add(this),I.set(this,!1),j.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,A,"m",V).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)}},E.set(this,new p),L.set(this,new p),S.set(this,{}),this.getComponentsContext=()=>t(this,S,"f"),this.nextRequestStatus=new p({isLoading:!1}),U.set(this,void 0),M.set(this,{popstate:t(this,A,"m",N).bind(this),componentsContext:t(this,A,"m",B).bind(this)}),O.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,O,r,"f"),t(this,A,"m",D).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}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 b(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return v(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,j,"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,j,t,"f"),m(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=a.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 u=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===u.length)return void u[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,L,"f").subscribe(t(this,A,"m",J).bind(this)),t(this,L,"f").update({isDebug:this.debug}),t(this,A,"m",P).call(this),yield t(this,A,"m",R).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:u,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:g,redirectAuthCodeChallenge:f,redirectAuthInitiator:p,ssoQueryParams:m}=l(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t(this,M,"f").popstate),window.addEventListener("components-context",t(this,M,"f").componentsContext),t(this,E,"f").subscribe(t(this,A,"m",K).bind(this)),t(this,E,"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:u,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:g,redirectAuthCodeChallenge:f,redirectAuthInitiator:p},m)),i(this,I,!0,"f")}))}disconnectedCallback(){t(this,E,"f").unsubscribeAll(),t(this,L,"f").unsubscribeAll(),t(this,A,"m",H).call(this),window.removeEventListener("popstate",t(this,M,"f").popstate),window.removeEventListener("components-context",t(this,M,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t(this,I,"f")&&i!==r&&x.observedAttributes.includes(e)){t(this,A,"m",P).call(this);const o=null===i;t(this,E,"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,L,"f").update({isDebug:this.debug})}}}x=z,I=new WeakMap,j=new WeakMap,E=new WeakMap,L=new WeakMap,S=new WeakMap,U=new WeakMap,M=new WeakMap,O=new WeakMap,A=new WeakSet,W=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 ")},D=function(){t(this,A,"m",W).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},P=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"];x.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[c(e)])throw Error(`${e} cannot be empty`)}))},N=function(){const{stepId:e,executionId:i}=h(this.flowId);t(this,E,"f").update({stepId:e,executionId:i})},F=function(i,r){u&&"function"==typeof u||this.logger.error("SDK was not loaded properly",u,JSON.stringify(u));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},x.sdkConfigOverrides),{projectId:i,baseUrl:r});t(this,j,"f")&&(o.customStorage=t(this,j,"f")),this.sdk=u(o),["start","next"].forEach((t=>{const i=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>e(this,void 0,void 0,(function*(){try{return yield i(...t)}catch(t){return{error:{errorCode:y,errorDescription:t.toString()}}}}))}))},K=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,A,"m",F).call(this,e,r)}t(this,O,"f").call(this,i)}))},R=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,A,"m",T).call(this))}))},T=function(){return e(this,void 0,void 0,(function*(){const t=g({projectId:this.projectId,filename:k,assetsFolder:C,baseUrl:this.baseStaticUrl});try{return yield f(t,"json"),!0}catch(t){return!1}}))},B=function(e){i(this,S,Object.assign(Object.assign({},t(this,S,"f")),e.detail),"f")},H=function(){var e;null===(e=t(this,U,"f"))||void 0===e||e.remove(),i(this,U,null,"f")},J=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,U,document.createElement("descope-debugger"),"f"),Object.assign(t(this,U,"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,U,"f"))):t(this,A,"m",H).call(this)}))},V=function(e,i){var r;e&&this.debug&&(null===(r=t(this,U,"f"))||void 0===r||r.updateData({title:e,description:i}))},z.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.53.0"}};export{z as default};
|
|
2
2
|
//# sourceMappingURL=BaseDescopeWc.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -267,12 +267,12 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
267
267
|
readonly cssRules: CSSRuleList;
|
|
268
268
|
} | CSSStyleSheet;
|
|
269
269
|
nonce: string;
|
|
270
|
-
"__#
|
|
270
|
+
"__#29741@#setNonce"(): void;
|
|
271
271
|
init(): Promise<void>;
|
|
272
|
-
"__#
|
|
272
|
+
"__#29736@#observeMappings": {};
|
|
273
273
|
observeAttribute(attrName: string, onAttrChange: (attrName: string, value: string) => void): () => any;
|
|
274
274
|
observeAttributes(attrs: string[], cb: (attrName: string, value: string) => void): () => void;
|
|
275
|
-
"__#
|
|
275
|
+
"__#29735@#isInit": boolean;
|
|
276
276
|
connectedCallback: (() => void) & (() => void) & (() => void);
|
|
277
277
|
accessKey: string;
|
|
278
278
|
readonly accessKeyLabel: string;
|
|
@@ -598,8 +598,8 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
598
598
|
tabIndex: number;
|
|
599
599
|
blur(): void;
|
|
600
600
|
focus(options?: FocusOptions): void;
|
|
601
|
-
"__#
|
|
602
|
-
"__#
|
|
601
|
+
"__#29734@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
602
|
+
"__#29734@#wrapLogger"(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>): _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
603
603
|
get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
604
604
|
set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
|
|
605
605
|
onLogEvent(logLevel: "error" | "warn" | "info" | "debug", data: any[]): void;
|
|
@@ -935,13 +935,17 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
935
935
|
focus(options?: FocusOptions): void;
|
|
936
936
|
};
|
|
937
937
|
} & (new (...params: any[]) => {
|
|
938
|
-
"__#
|
|
939
|
-
"__#
|
|
940
|
-
"__#
|
|
938
|
+
"__#29738@#lastBaseUrl"?: string;
|
|
939
|
+
"__#29738@#workingBaseUrl"?: string;
|
|
940
|
+
"__#29738@#failedUrls": Set<string>;
|
|
941
|
+
"__#29738@#getResourceUrls"(filename: string): (URL & {
|
|
941
942
|
baseUrl: string;
|
|
942
943
|
}) | (URL & {
|
|
943
944
|
baseUrl: string;
|
|
944
945
|
})[];
|
|
946
|
+
"__#29738@#createResourceUrl"(filename: string, baseUrl: string): URL & {
|
|
947
|
+
baseUrl: string;
|
|
948
|
+
};
|
|
945
949
|
fetchStaticResource<F extends "text" | "json">(filename: string, format: F): Promise<{
|
|
946
950
|
body: F extends "json" ? Record<string, any> : string;
|
|
947
951
|
headers: Record<string, string>;
|
|
@@ -1275,34 +1279,34 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1275
1279
|
blur(): void;
|
|
1276
1280
|
focus(options?: FocusOptions): void;
|
|
1277
1281
|
readonly projectId: string;
|
|
1278
|
-
"__#
|
|
1282
|
+
"__#29737@#handleError"(attrName: string, newValue: string): void;
|
|
1279
1283
|
init(): Promise<void>;
|
|
1280
|
-
"__#
|
|
1284
|
+
"__#29736@#observeMappings": {};
|
|
1281
1285
|
observeAttribute(attrName: string, onAttrChange: (attrName: string, value: string) => void): () => any;
|
|
1282
1286
|
observeAttributes(attrs: string[], cb: (attrName: string, value: string) => void): () => void;
|
|
1283
|
-
"__#
|
|
1284
|
-
"__#
|
|
1285
|
-
"__#
|
|
1287
|
+
"__#29735@#isInit": boolean;
|
|
1288
|
+
"__#29734@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
1289
|
+
"__#29734@#wrapLogger": ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger);
|
|
1286
1290
|
get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
1287
1291
|
set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
|
|
1288
1292
|
onLogEvent: ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void);
|
|
1289
1293
|
}) & (new (...params: any[]) => {
|
|
1290
|
-
"__#
|
|
1294
|
+
"__#29750@#globalStyle": _descope_sdk_mixins_static_resources_mixin.InjectedStyle;
|
|
1291
1295
|
readonly theme: _descope_sdk_mixins_static_resources_mixin.ThemeOptions;
|
|
1292
1296
|
readonly styleId: string;
|
|
1293
|
-
"__#
|
|
1294
|
-
"__#
|
|
1295
|
-
readonly "__#
|
|
1296
|
-
"__#
|
|
1297
|
-
"__#
|
|
1298
|
-
"__#
|
|
1297
|
+
"__#29750@#_themeResource": Promise<void | Record<string, any>>;
|
|
1298
|
+
"__#29750@#fetchTheme"(): Promise<Record<string, any>>;
|
|
1299
|
+
readonly "__#29750@#themeResource": Promise<void | Record<string, any>>;
|
|
1300
|
+
"__#29750@#loadGlobalStyle"(): Promise<void>;
|
|
1301
|
+
"__#29750@#loadComponentsStyle"(): Promise<void>;
|
|
1302
|
+
"__#29750@#getFontsConfig"(): Promise<Record<string, {
|
|
1299
1303
|
url?: string;
|
|
1300
1304
|
}>>;
|
|
1301
|
-
"__#
|
|
1302
|
-
"__#
|
|
1303
|
-
"__#
|
|
1304
|
-
"__#
|
|
1305
|
-
"__#
|
|
1305
|
+
"__#29750@#loadFonts"(): Promise<void>;
|
|
1306
|
+
"__#29750@#applyTheme"(): Promise<void>;
|
|
1307
|
+
"__#29750@#onThemeChange": () => void;
|
|
1308
|
+
"__#29750@#loadTheme"(): void;
|
|
1309
|
+
"__#29750@#toggleOsThemeChangeListener": (listen: boolean) => void;
|
|
1306
1310
|
init(): Promise<void>;
|
|
1307
1311
|
injectStyle: ((cssString: string, { prepend }?: {
|
|
1308
1312
|
prepend?: boolean;
|
|
@@ -1320,11 +1324,11 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1320
1324
|
readonly cssRules: CSSRuleList;
|
|
1321
1325
|
});
|
|
1322
1326
|
nonce: string;
|
|
1323
|
-
"__#
|
|
1324
|
-
"__#
|
|
1327
|
+
"__#29741@#setNonce": (() => void) & (() => void);
|
|
1328
|
+
"__#29736@#observeMappings": {};
|
|
1325
1329
|
observeAttribute: ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any);
|
|
1326
1330
|
observeAttributes: ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void);
|
|
1327
|
-
"__#
|
|
1331
|
+
"__#29735@#isInit": boolean;
|
|
1328
1332
|
connectedCallback: (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void);
|
|
1329
1333
|
accessKey: string;
|
|
1330
1334
|
readonly accessKeyLabel: string;
|
|
@@ -1650,24 +1654,25 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1650
1654
|
tabIndex: number;
|
|
1651
1655
|
blur(): void;
|
|
1652
1656
|
focus(options?: FocusOptions): void;
|
|
1653
|
-
"__#
|
|
1654
|
-
"__#
|
|
1657
|
+
"__#29734@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
1658
|
+
"__#29734@#wrapLogger": ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger);
|
|
1655
1659
|
get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
|
|
1656
1660
|
set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
|
|
1657
1661
|
onLogEvent: ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void);
|
|
1658
1662
|
contentRootElement: HTMLElement;
|
|
1659
1663
|
rootElement: HTMLElement;
|
|
1660
1664
|
readonly config: Promise<_descope_sdk_mixins_static_resources_mixin.Config>;
|
|
1661
|
-
"__#
|
|
1662
|
-
"__#
|
|
1663
|
-
"__#
|
|
1664
|
-
"__#
|
|
1665
|
+
"__#29740@#configCacheClear": (() => void) & (() => void);
|
|
1666
|
+
"__#29740@#_configResource": Promise<_descope_sdk_mixins_static_resources_mixin.Config>;
|
|
1667
|
+
"__#29740@#fetchConfig": (() => Promise<_descope_sdk_mixins_static_resources_mixin.Config>) & (() => Promise<_descope_sdk_mixins_static_resources_mixin.Config>);
|
|
1668
|
+
"__#29739@#callbacks": Map<string, () => void> & Map<string, () => void>;
|
|
1665
1669
|
onReset: ((sectionId: string, callback: () => void | Promise<void>) => () => void) & ((sectionId: string, callback: () => void | Promise<void>) => () => void);
|
|
1666
1670
|
reset: ((...sectionIds: string[]) => Promise<void>) & ((...sectionIds: string[]) => Promise<void>);
|
|
1667
|
-
"__#
|
|
1668
|
-
"__#
|
|
1669
|
-
"__#
|
|
1670
|
-
"__#
|
|
1671
|
+
"__#29737@#handleError": ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void);
|
|
1672
|
+
"__#29738@#lastBaseUrl"?: string;
|
|
1673
|
+
"__#29738@#workingBaseUrl"?: string;
|
|
1674
|
+
"__#29738@#failedUrls": Set<string>;
|
|
1675
|
+
"__#29738@#getResourceUrls": ((filename: string) => (URL & {
|
|
1671
1676
|
baseUrl: string;
|
|
1672
1677
|
}) | (URL & {
|
|
1673
1678
|
baseUrl: string;
|
|
@@ -1680,6 +1685,13 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1680
1685
|
}) | (URL & {
|
|
1681
1686
|
baseUrl: string;
|
|
1682
1687
|
})[]);
|
|
1688
|
+
"__#29738@#createResourceUrl": ((filename: string, baseUrl: string) => URL & {
|
|
1689
|
+
baseUrl: string;
|
|
1690
|
+
}) & ((filename: string, baseUrl: string) => URL & {
|
|
1691
|
+
baseUrl: string;
|
|
1692
|
+
}) & ((filename: string, baseUrl: string) => URL & {
|
|
1693
|
+
baseUrl: string;
|
|
1694
|
+
});
|
|
1683
1695
|
fetchStaticResource: (<F_1 extends "text" | "json">(filename: string, format: F_1) => Promise<{
|
|
1684
1696
|
body: F_1 extends "json" ? Record<string, any> : string;
|
|
1685
1697
|
headers: Record<string, string>;
|
|
@@ -1693,11 +1705,11 @@ declare const BaseClass: (new (...params: any[]) => {
|
|
|
1693
1705
|
readonly baseStaticUrl: string;
|
|
1694
1706
|
readonly baseUrl: string;
|
|
1695
1707
|
readonly projectId: string;
|
|
1696
|
-
"__#
|
|
1697
|
-
"__#
|
|
1708
|
+
"__#29744@#getComponentsVersion"(): Promise<string>;
|
|
1709
|
+
"__#29744@#descopeUi": Promise<any>;
|
|
1698
1710
|
readonly descopeUi: Promise<any>;
|
|
1699
|
-
"__#
|
|
1700
|
-
"__#
|
|
1711
|
+
"__#29744@#loadDescopeUiComponent"(componentName: string): Promise<any>;
|
|
1712
|
+
"__#29744@#getDescopeUi"(): Promise<any>;
|
|
1701
1713
|
loadDescopeUiComponents(templateOrComponentNames: string[] | HTMLTemplateElement): Promise<any[]>;
|
|
1702
1714
|
readonly baseCdnUrl: string;
|
|
1703
1715
|
injectNpmLib(libName: string, version: string, filePath?: string, overrides?: string[]): Promise<{
|
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"==typeof SuppressedError&&SuppressedError;class r extends Error{}function s(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 a(e,t){if("string"!=typeof e)throw new r("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 r(`Invalid token specified: missing part #${n+1}`);let i;try{i=s(o)}catch(e){throw new r(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new r(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}r.prototype.name="InvalidTokenError";var l={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"},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 c="<region>",d=`https://api.${c}descope.com`,u=6e5,p="dct",h=()=>{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")}},g=[521,524],f=e=>async(...t)=>{let n=await e(...t);g.includes(n.status)&&(n=await e(...t),n.retries=1);const o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n};let v;const m=()=>{if(v)return v;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 v=`${t}-${n}`,v};var b;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(b||(b={}));const w=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(c,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},y=(...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)),{})),k={"Content-Type":"application/json"},I=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},S=(e,t)=>{const n={"x-descope-sdk-session-id":m(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.53.1","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},O=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var C=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||d,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(...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=>h().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await f(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return h().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:f(n)})(i,a),u=async e=>{var i;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:p,queryParams:h,method:g,token:f}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:y(I(t,f),S(t,o),(null==n?void 0:n.baseHeaders)||{},O(v)?k:{},p),method:g,body:v};null!==s&&(m.credentials=s||"include");const b=await c(w({path:d,baseUrl:l,queryParams:h,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=((null===(i=b.headers)||void 0===i?void 0:i.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},b),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}return b};return{get:(e,{headers:t,queryParams:n,token:o}={})=>u({path:e,headers:t,queryParams:n,body:void 0,method:b.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>u({path:e,headers:n,queryParams:o,body:t,method:b.post,token:i}),patch:(e,t,{headers:n,queryParams:o,token:i}={})=>u({path:e,headers:n,queryParams:o,body:t,method:b.patch,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>u({path:e,headers:n,queryParams:o,body:t,method:b.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>u({path:e,headers:t,queryParams:n,body:void 0,method:b.delete,token:o}),hooks:r,buildUrl:(e,n)=>w({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}}))},x=429;function A(e,t,n){var o;let i=j(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[p])===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 j(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return a(e)}function E(e){const{exp:t}=j(e);return(new Date).getTime()/1e3>t}function U(e){let t=j(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function R(e,t){return A(e,t,"permissions")}function T(e,t){return A(e,t,"roles")}const $=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function L(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===x&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}function P(e){var t;return(null===(t=j(e))||void 0===t?void 0:t[p])||""}const W=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),N=(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 "))},M=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),_=e=>t=>e.test(t),D=_(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),q=_(/^\+[1-9]{1}[0-9]{3,14}$/),F=W(D,'"{val}" is not a valid email'),K=W(q,'"{val}" is not a valid phone number'),J=W((e=>e.length>=1),"Minimum length is 1");const V=W((e=>"string"==typeof e),"Input is not a string"),H=W((e=>Array.isArray(e)),"Input is not an array"),B=W((e=>"boolean"==typeof e),"Input is not a boolean"),z=W((e=>void 0===e),"Input is defined"),G=N([V(),z()],"Input is not a string or undefined"),Z=N([H(),B()],"Input is not an array or boolean"),X=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>M(...e).validate(n[t]))),t(...n)),Y=e=>[V(`"${e}" must be a string`)],Q=e=>[G(`"${e}" must be string or undefined`)],ee=e=>[V(`"${e}" must be a string`),J(`"${e}" must not be empty`)],te=e=>[V(`"${e}" must be a string`),F()],ne=e=>[V(`"${e}" must be a string`),K()],oe=X(ee("accessKey")),ie=e=>({exchange:oe(((t,n)=>L(e.post(l.accessKey.exchange,{loginOptions:n},{token:t}))))}),re=(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),se=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||u,u)});var ae,le;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(ae||(ae={})),function(e){e.email="email"}(le||(le={}));const ce=Object.assign(Object.assign({},ae),le);var de;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(de||(de={}));const ue=ee("loginId"),pe=X(ee("token")),he=X(ue),ge=X(ee("pendingRef")),fe=X(ue,te("email")),ve=e=>({verify:pe((t=>L(e.post(l.enchantedLink.verify,{token:t})))),signIn:he(((n,o,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return L(e.post($(l.enchantedLink.signIn,ce.email),{loginId:n,URI:o,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:he(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return L(e.post($(l.enchantedLink.signUpOrIn,ce.email),{loginId:n,URI:o,loginOptions:s,providerId:r}))})),signUp:he(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return L(e.post($(l.enchantedLink.signUp,ce.email),{loginId:n,URI:o,user:i,loginOptions:a,providerId:s}))})),waitForSession:ge(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=se(n);let s;const a=setInterval((async()=>{const n=await e.post(l.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(L(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:fe(((t,n,o,i,r)=>L(e.post(l.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),me=X(ee("flowId")),be=X(ee("executionId"),ee("stepId"),ee("interactionId")),we=e=>({start:me(((t,n,o,i,r,s,a,c=!1)=>L(e.post(l.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:c})))),next:be(((t,n,o,i,r,s,a=!1)=>L(e.post(l.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s,isCustomScreen:a}))))}),ye=ee("loginId"),ke=X(ee("token")),Ie=X(ye),Se=X(ye,ne("phone")),Oe=X(ye,te("email")),Ce=Object.keys(ce).filter((e=>e!==ae.voice)),xe=e=>({verify:ke((t=>L(e.post(l.magicLink.verify,{token:t})))),signIn:Ce.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ie(((n,i,r={},s)=>{var{providerId:a}=r,c=t(r,["providerId"]);return L(e.post($(l.magicLink.signIn,o),{loginId:n,URI:i,loginOptions:c,providerId:a},{token:s}))}))})),{}),signUp:Ce.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ie(((n,i,r,s={})=>{var{providerId:a}=s,c=t(s,["providerId"]);return L(e.post($(l.magicLink.signUp,o),{loginId:n,URI:i,user:r,loginOptions:c,providerId:a}))}))})),{}),signUpOrIn:Ce.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ie(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return L(e.post($(l.magicLink.signUpOrIn,o),{loginId:n,URI:i,loginOptions:a,providerId:s}))}))})),{}),update:{email:Oe(((t,n,o,i,r)=>L(e.post(l.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(ae).filter((e=>e!==ae.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Se(((t,o,i,r,s)=>L(e.post($(l.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var Ae;!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"}(Ae||(Ae={}));const je=X(ee("code")),Ee=e=>({start:Object.assign(((t,n,o,i,r)=>L(e.post(l.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:i}))),Object.keys(Ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i,r)=>L(e.post(l.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:i}))})),{})),exchange:je((t=>L(e.post(l.oauth.exchange,{code:t})))),startNative:(t,n,o)=>L(e.post(l.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>L(e.post(l.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>L(e.get(l.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>L(e.post(l.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>L(e.post(l.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),Ue=ee("appId"),Re=X(Ue),Te=e=>({connect:Re(((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,L(e.post(l.outbound.connect,{appId:t,tenantId:i,tenantLevel:r,options:n},{token:o}))}))}),$e=ee("loginId"),Le=X($e,ee("code")),Pe=X($e),We=X($e,ne("phone")),Ne=X($e,te("email")),Me=e=>({verify:Object.keys(ce).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Le(((t,o)=>L(e.post($(l.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(ce).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Pe(((n,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return L(e.post($(l.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(ce).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Pe(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return L(e.post($(l.otp.signUp,o),{loginId:n,user:i,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(ce).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Pe(((n,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return L(e.post($(l.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:Ne(((t,n,o,i)=>L(e.post(l.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:We(((t,o,i,r)=>L(e.post($(l.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),_e=X(ee("tenant")),De=X(ee("code")),qe=e=>({start:_e(((t,n,o,i,r,s,a,c)=>L(e.post(l.saml.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}),c&&{initiatedEmail:t})},i&&{token:i}))))),exchange:De((t=>L(e.post(l.saml.exchange,{code:t}))))}),Fe=ee("loginId"),Ke=X(Fe,ee("code")),Je=X(Fe),Ve=X(Fe),He=e=>({signUp:Je(((t,n)=>L(e.post(l.totp.signUp,{loginId:t,user:n})))),verify:Ke(((t,n,o,i)=>L(e.post(l.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),update:Ve(((t,n)=>L(e.post(l.totp.update,{loginId:t},{token:n}))))}),Be=ee("loginId"),ze=ee("newPassword"),Ge=X(Be,ee("password")),Ze=X(Be),Xe=X(Be,ze),Ye=X(Be,ee("oldPassword"),ze),Qe=e=>({signUp:Ge(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return L(e.post(l.password.signUp,{loginId:n,password:o,user:i,loginOptions:a,providerId:s}))})),signIn:Ge(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return L(e.post(l.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:r}))})),sendReset:Ze(((t,n,o)=>L(e.post(l.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Xe(((t,n,o)=>L(e.post(l.password.update,{loginId:t,newPassword:n},{token:o})))),replace:Ye(((t,n,o)=>L(e.post(l.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>L(e.get(l.password.policy))}),et=Y("loginId"),tt=ee("loginId"),nt=ee("origin"),ot=X(tt,nt,ee("name")),it=X(tt,nt),rt=X(et,nt),st=X(tt,nt,Q("token")),at=X(ee("transactionId"),ee("response")),lt=e=>({signUp:{start:ot(((t,n,o,i)=>L(e.post(l.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,passkeyOptions:i})))),finish:at(((t,n)=>L(e.post(l.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:rt(((t,n,o,i,r)=>L(e.post(l.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:at(((t,n)=>L(e.post(l.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:it(((t,n,o)=>L(e.post(l.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:o}))))},update:{start:st(((t,n,o,i)=>L(e.post(l.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i},{token:o})))),finish:at(((t,n)=>L(e.post(l.webauthn.update.finish,{transactionId:t,response:n}))))}}),ct=Y("loginId"),dt=X(ct),ut=X(ee("pendingRef")),pt=e=>({signUpOrIn:dt(((n,o={})=>{var{providerId:i}=o,r=t(o,["providerId"]);return L(e.post(l.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:i}))})),signUp:dt(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return L(e.post(l.notp.signUp,{loginId:n,user:o,providerId:r,loginOptions:s}))})),signIn:dt(((n,o={},i)=>{var{providerId:r}=o,s=t(o,["providerId"]);return L(e.post(l.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:i}))})),waitForSession:ut(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=se(n);let s;const a=setInterval((async()=>{const n=await e.post(l.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(L(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),ht=X(ee("token")),gt=X(Q("token"));var ft,vt=X([(ft=ee("projectId"),W(((e,t)=>n=>M(...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",ft))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return c=C({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:ie(c),otp:Me(c),magicLink:xe(c),enchantedLink:ve(c),oauth:Ee(c),outbound:Te(c),saml:qe(c),totp:He(c),notp:pt(c),webauthn:lt(c),password:Qe(c),flow:we(c),refresh:gt(((e,t,n,o)=>{const i={};n&&(i.externalToken=n);const r=o?l.tryRefresh:l.refresh;return L(c.post(r,i,{token:e,queryParams:t}))})),selectTenant:X([V("tenantId")],[G('"token" must be string or undefined')])(((e,t)=>L(c.post(l.selectTenant,{tenant:e},{token:t})))),logout:gt((e=>L(c.post(l.logout,{},{token:e})))),logoutAll:gt((e=>L(c.post(l.logoutAll,{},{token:e})))),me:gt((e=>L(c.get(l.me,{token:e})))),myTenants:X([Z('"tenants" must a string array or a boolean')],[G('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,L(c.post(l.myTenants,n,{token:t}))})),history:gt((e=>L(c.get(l.history,{token:e})))),isJwtExpired:ht(E),getTenants:ht(U),getJwtPermissions:ht(R),getJwtRoles:ht(T),getCurrentTenant:ht(P),httpClient:c};var c})),mt=Object.assign(vt,{DeliveryMethods:ce});
|
|
2
|
-
/*! js-cookie v3.0.5 | MIT */function bt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var wt=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=bt({},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(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",bt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,bt({},this.attributes,t))},withConverter:function(t){return e(bt({},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 yt={default:"endpoint"},kt="Blocked by CSP",It="The endpoint parameter is not a valid URL",St="Failed to load the JS script of the agent",Ot="9319";function Ct(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===kt||s===It)n.exclude(),r=0;else if(s===Ot)n.exclude();else if(s===St){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 xt="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",At=xt;function jt(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:xt,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 Ct(e,Et)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Ot?new Error(St):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 Et(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(It);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(St))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(kt)})).then(Ut)}function Ut(){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(Ot);return n}let Rt;const Tt=e=>{try{return a(e).exp}catch(e){return null}},$t=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Tt(n)},Lt=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?Tt(o):void 0)},Pt=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||Lt(e),cookieExpiration:e.cookieExpiration||$t(e)},s)},Wt=(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},Nt=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 Pt(n)},Mt=()=>"undefined"!=typeof window&&!!window.descopeBridge,_t=void 0!==Rt||"undefined"!=typeof localStorage,Dt=(e,t)=>{var n,o;return null===(o=null===(n=Rt||localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},qt=e=>{var t,n;return null===(n=null===(t=Rt||localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},Ft=e=>{var t,n;return null===(n=null===(t=Rt||localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},Kt=e=>{var t,n,o,i;return null!==(i=null!==(n=null===(t=null==Rt?void 0:Rt.key)||void 0===t?void 0:t.call(Rt,e))&&void 0!==n?n:null===(o=null===localStorage||void 0===localStorage?void 0:localStorage.key)||void 0===o?void 0:o.call(localStorage,e))&&void 0!==i?i:null},Jt=(...e)=>{console.debug(...e)},Vt="3.2.0",Ht="undefined"!=typeof window,Bt=Math.pow(2,31)-1,zt=`https://descopecdn.com/npm/oidc-client-ts@${Vt}/dist/browser/oidc-client-ts.min.js`,Gt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Vt}/dist/browser/oidc-client-ts.min.js`,Zt="DS",Xt="DSR",Yt="DSI";function Qt(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=en(o);wt.set(e,t,{path:i,domain:c?o:void 0,expires:l,sameSite:r,secure:a})}}function en(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 tn=e=>(null==e?void 0:e.cookieName)||Zt,nn=e=>(null==e?void 0:e.cookieName)||Xt;function on(e="",t){return wt.get(nn(t))||qt(`${e}${Xt}`)||""}function rn(e="",t){return wt.get(tn(t))||qt(`${e}${Zt}`)||""}function sn(e=""){return qt(`${e}${Yt}`)||""}function an(e="",t,n,o){Ft(`${e}${Xt}`),Ft(`${e}${Zt}`),Ft(`${e}${Yt}`);const i=tn(t);wt.remove(i,null==o?void 0:o.session);const r=nn(n);wt.remove(r,null==o?void 0:o.refresh)}const ln=(e,t)=>n=>Object.assign(n,{token:n.token||on(e,t)}),cn=Ht&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",dn="vsid",un="vrid",pn="fp",hn=(e=!1)=>{const t=qt(pn);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},gn=async(e,t=cn)=>{try{if(hn())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=jt({apiKey:e,endpoint:[o.toString(),yt],scriptUrlPattern:[r,At]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[dn]:e,[un]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};Dt(pn,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},fn=e=>{const t=hn(!0);return t&&e.body&&(e.body.fpData=t),e},vn="descopeFlowNonce",mn="X-Descope-Flow-Nonce",bn="/v1/flow/start",wn="/v1/flow/next",yn=(e,t=vn)=>`${t}${e}`,kn=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},In=e=>{var t;return e.path===wn&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?kn(e.body.executionId):null},Sn="dls_last_user_login_id",On="dls_last_user_display_name",Cn=e=>Dt(Sn,e),xn=()=>qt(Sn),An=()=>qt(On),jn=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=xn(),r=An();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)};function En(){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 Un(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Wn(n.publicKey.challenge),n.publicKey.user.id=Wn(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Wn(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Nn(n.rawId),type:n.type,response:{attestationObject:Nn(n.response.attestationObject),clientDataJSON:Nn(n.response.clientDataJSON)}});var n}async function Rn(e){const t=Ln(e);return Pn(await navigator.credentials.get(t))}async function Tn(e,t){const n=Ln(e);return n.signal=t.signal,n.mediation="conditional",Pn(await navigator.credentials.get(n))}async function $n(e=!1){var t,n;if(!Ht)return Promise.resolve(!1);if(Mt()){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 Ln(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Wn(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Wn(e.id)})),n}function Pn(e){return JSON.stringify({id:e.id,rawId:Nn(e.rawId),type:e.type,response:{authenticatorData:Nn(e.response.authenticatorData),clientDataJSON:Nn(e.response.clientDataJSON),signature:Nn(e.response.signature),userHandle:e.response.userHandle?Nn(e.response.userHandle):void 0}})}function Wn(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Nn(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Mn,_n=(Mn=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 Un(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 Rn(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 Un(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await Rn(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 Un(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:Un,get:Rn,isSupported:$n,conditional:Tn}}),(...e)=>{const t=Mn(...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 Dn="/fedcm/config",qn=()=>{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 Fn(e,t){var n;try{await Kn(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Kn(e,t){var n,o;const i=await async function(e,t="google",n,o,i){const r=qn(),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 Jn=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await $n(),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 Vn;const Hn=(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",(()=>{Hn(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Bn=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{Vn||(Vn=(async()=>{try{return require("oidc-client-ts")}catch(e){return Hn([zt,Gt],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await Vn;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)))),Dt(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(e={},t=!1)=>{const{client:n}=await o(),i=await n.createSigninRequest(e),{url:r}=i;return t||(window.location.href=r),{ok:!0,data:i}},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=qt(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||sn(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return Ft(i),t||window.location.replace(s),r}}},zn=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Rt=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return Ht?(o&&i&&gn(o).catch((()=>null)),e(Wt(r,{beforeRequest:fn}))):e(r)}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);if(!o||Mt())return e(i);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let l,c;Ht&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(Jt("Expiration time passed, refreshing session"),d.refresh(on()||c))}));const d=e(Wt(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i}=await Nt(t);if(401===(null==t?void 0:t.status))Jt("Received 401, canceling all timers"),r();else if(n||i){if(l=((e,t)=>{if(t)return new Date(1e3*t);Jt("Could not extract expiration time from session token, trying to decode the token");try{const t=a(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!l)return void Jt("Could not extract expiration time from session token");c=o;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>Bt&&(Jt(`Timeout is too large (${t}ms), setting it to ${Bt}ms`),t=Bt),t})(l);if(r(),e<=2e4)return void Jt("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Jt(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Jt("Refreshing session due to timer"),d.refresh(on()||o)}),e)}}}));return re(d,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Jt("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.41.0"},t.baseHeaders)}))),(e=>t=>{const n=En(),o=En(),i=En(),r=En(),s=e(Wt(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))o.pub(null),i.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await Nt(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 Nt(t);s&&o.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=re(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=>{const{enableFlowNonce:o=!0,nonceStoragePrefix:i=vn}=n,r=t(n,["enableFlowNonce","nonceStoragePrefix"]);return o?(((e=vn)=>{try{if(!_t)return;for(let o=0;o<(void 0,void 0,null!==(n=null!==(t=null==Rt?void 0:Rt.length)&&void 0!==t?t:null===localStorage||void 0===localStorage?void 0:localStorage.length)&&void 0!==n?n:0);o++){const t=Kt(o);if(t&&t.startsWith(e)){const n=qt(t);if(n)try{JSON.parse(n).expiry<Date.now()&&Ft(t)}catch(e){Ft(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n})(i),e(Wt(r,{afterRequest:async(e,t)=>{if(e.path!==bn&&e.path!==wn)return;const{nonce:n,executionId:o}=await(async(e,t)=>{try{const n=t.headers.get(mn);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=In(e)),{nonce:n,executionId:kn(o)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&o&&((e,t,n,o=vn)=>{try{const i=yn(e,o),r=n?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:n};Dt(i,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(o,n,e.path===bn,i)},beforeRequest:e=>{if(e.path===wn){const t=In(e);if(t){const n=((e,t=vn)=>{try{const n=yn(e,t),o=qt(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(((e,t=vn)=>{try{const n=yn(e,t);Ft(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,i);n&&(e.headers=e.headers||{},e.headers[mn]=n)}}return e}}))):e(r)}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(r),{getLastUserLoginId:xn,getLastUserDisplayName:An});const s=e(Wt(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=Pt((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?(Cn(r),(e=>{Dt(On,e)})(s)):(null==i?void 0:i.loginId)&&Cn(i.loginId)}}));let a=re(s,["flow.start"],jn);return a=re(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(Ft(Sn),Ft(On)),o})(i)),Object.assign(a,{getLastUserLoginId:xn,getLastUserDisplayName:An})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,refreshTokenViaCookie:r,storagePrefix:s}=n,a=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix"]);if(!o||!Ht)return e(a);let l;const c=e(Wt(a,{beforeRequest:ln(s,r),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);if(401===(null==t?void 0:t.status))n||an(s,i,r,l);else{const e=((e={},t=!1,n="",o=!1)=>{var i,r,s,a;const{sessionJwt:l,refreshJwt:c}=e;let d;if(c)if(o){Ft(`${n}${Xt}`);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=nn(o),u=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});Qt(l,c,u);const p=en(a);d=Object.assign(Object.assign({},d),{refresh:{path:u.cookiePath,domain:p?a:void 0}})}else{const e=nn(o);wt.remove(e),Dt(`${n}${Xt}`,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=tn(t),c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:o,cookieDomain:i});Qt(r,l,c);const u=en(i);d=Object.assign(Object.assign({},d),{session:{path:c.cookiePath,domain:u?i:void 0}})}else Dt(`${n}${Zt}`,l);return e.idToken&&Dt(`${n}${Yt}`,e.idToken),d})(await Nt(t),i,s,r);e&&(l=e)}}})),d=re(c,["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,(()=>l)));return Object.assign(d,{getRefreshToken:()=>on(s,r),getSessionToken:()=>rn(s,i),getIdToken:()=>sn(s)})}))((e=>{const t=mt(e),n=Bn(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,i)=>{var r;if(Mt())return Jt(`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()}})}const s=rn(),a=on();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){Jt("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:Jn(t),webauthn:_n(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){Fn(o,e)},requestAuthentication(e){Fn(o,e)}},async oneTap(e,t,n,i,r){await Kn(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+Dn),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>Ht&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+Dn);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})),Gn="undefined"!=typeof localStorage,Zn="J151000",Xn="E103205",Yn=Gn&&localStorage.getItem("base.content.url")||"",Qn="base.ui.components.url";Gn&&localStorage.getItem(Qn),Gn&&localStorage.getItem(Qn);const eo="descope-login-flow",to="code",no="redirect_mode",oo="data-exclude-field",io="data-exclude-next",ro="dls_last_auth",so="state_id",ao="saml_idp_state_id",lo="saml_idp_username",co="descope_idp_initiated",uo="sso_app_id",po="third_party_app_id",ho="third_party_app_state_id",go="oidc_login_hint",fo="oidc_prompt",vo="oidc_resource",mo="oidc_error_redirect_uri",bo="application_scopes",wo="data-type",yo="redirect",ko="poll",Io="webauthnCreate",So="webauthnGet",Oo="nativeBridge",Co="loadForm",xo="submit",Ao="polling",jo=["descope-multi-select-combo-box","descope-text-area"],Eo=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Uo;!function(e){e.backward="backward",e.forward="forward"}(Uo||(Uo={}));const Ro=["descope-enriched-text"];function To(e){return new URLSearchParams(window.location.search).get(e)}function $o(e){if(window.history.replaceState&&To(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 Lo(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Uo.forward:n<o?Uo.backward:void 0}const Po=e=>{let[t="",n=""]=(To(eo)||"").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 Wo(){$o(eo)}const No=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Mo=(e,t)=>{const{executionId:n,stepId:o,executionFlowId:i}=Po(e);if(i&&e!==i)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&Wo();const r=To("t")||void 0;r&&$o("t");const s=To(to)||void 0;s&&$o(to);const a="popup"===To(no);a&&$o(no);const l=To("err")||void 0;l&&$o("err");const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:p}={redirectAuthCodeChallenge:To("ra-challenge"),redirectAuthCallbackUrl:To("ra-callback"),redirectAuthBackupCallbackUri:To("ra-backup-callback"),redirectAuthInitiator:To("ra-initiator")},h=To(so);h&&$o(so);const g=To(ao);g&&$o(ao);const f=To(lo);g&&$o(lo);const v=To(co);v&&$o(co);const m=To(uo);m&&$o(uo);const b=To(po);b&&$o(po);const w=To(ho);w&&$o(ho);const y=To(bo);y&&$o(bo);const k=To(go);k&&$o(go);const I=To(fo);I&&$o(fo);const S=To(mo);S&&$o(mo);const O=To(vo);O&&$o(vo);return{executionId:n,stepId:o,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:p,ssoQueryParams:{oidcIdpStateId:h,samlIdpStateId:g,samlIdpUsername:f,descopeIdpInitiated:"true"===v,ssoAppId:m,oidcLoginHint:k,oidcPrompt:I,oidcErrorRedirectUri:S,oidcResource:O,thirdPartyAppId:b,thirdPartyAppStateId:w,applicationScopes:y}}},_o=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}})},Do=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}};function qo(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 Fo=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,oidcResource:l,thirdPartyAppId:c,thirdPartyAppStateId:d,applicationScopes:u})=>!(!e||t||n||o||i||r||s||a||l||c||d||u),Ko=e=>null==e?void 0:e.submit(),Jo=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Vo=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function Ho(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const Bo=e=>{var t,n,o;const i=(r=e.screenState,s=(e,t)=>Eo.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(r).filter((([e,t])=>!s(t,e)))));var r,s;const{screenState:{errorText:a,errorType:l}}=e;return(a||l)&&(i.error={text:a,type:l}),e.action&&(i.action=e.action),(null===(o=null===(n=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===n?void 0:n.thirdPartyAppApproveScopes)||void 0===o?void 0:o.data)&&(i.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),i},zo=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Go(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}const Zo=(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 Xo,Yo,Qo,ei;function ti(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(!ti(r,s))return!1}else if(r!==s)return!1}return!0}class ni{constructor(e={},{forceUpdate:t=!1}={}){Xo.set(this,void 0),Yo.set(this,{}),Qo.set(this,0),ei.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,Xo,"f")):e,n=Object.assign(Object.assign({},o(this,Xo,"f")),t),r=o(this,Xo,"f");i(this,Xo,n,"f"),Object.freeze(o(this,Xo,"f")),setTimeout((()=>{Object.values(o(this,Yo,"f")).forEach((({cb:e,selector:t,forceUpdate:i})=>{const s=t(r),a=t(n);(o(this,ei,"f")||i||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!ti(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},i(this,Xo,e,"f"),i(this,ei,t,"f")}get current(){return Object.assign({},o(this,Xo,"f"))}set forceUpdate(e){i(this,ei,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return i(this,Qo,o(this,Qo,"f")+1,"f"),o(this,Yo,"f")[o(this,Qo,"f")]={cb:e,selector:t,forceUpdate:n},o(this,Qo,"f").toString()}unsubscribe(e){const t=!!o(this,Yo,"f")[e];return t&&delete o(this,Yo,"f")[e],t}unsubscribeAll(){return i(this,Yo,{},"f"),!0}}Xo=new WeakMap,Yo=new WeakMap,Qo=new WeakMap,ei=new WeakMap;const oi=["*","#","/","(",")","[","]","_","<",">","`"],ii=e=>{const t=oi.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")},ri=["disabled"],si=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${oo}])`)).forEach((e=>{e.value=n}))}))},ai=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),li=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,o)=>n?(e=>"string"!=typeof e?e:e.replace(ii("\\"),"\\$1"))(ai(t,o)):ai(t,o))),ci=(e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(o=e.localName,Ro.includes(o));var o;e.textContent=li(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",li(i,t))}))},di=(e,t,n)=>{e.querySelectorAll(`[${wo}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},ui=(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})`))},pi=(e,n,o,i)=>{var r,s;di(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),di(e,"notp-link",null===(s=null==n?void 0:n.notp)||void 0===s?void 0:s.redirectUrl),ci(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=li(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])=>{ri.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o),((e,t={},n)=>{Object.entries(t).forEach((([t,o])=>{e.querySelectorAll(`[id="${CSS.escape(t)}"]`).forEach((e=>{switch(o){case"disable":e.setAttribute("disabled","true");break;case"hide":e.classList.add("hidden");break;default:null==n||n.error(`Unknown component state "${o}" for component with id "${t}"`,'Valid states are "disable" and "hide"')}}))}))})(e,null==n?void 0:n.componentsState,i)},hi=_o((()=>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 qo(100,n,o)}catch(e){return console.error("Conditional login check failed",e),!1}})))),gi=(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 fi;const vi=(e,t)=>{fi?fi.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},mi=e=>fi?fi.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,bi="dls_ab_testing_id",wi={"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 yi(e){const t={};try{Object.assign(t,JSON.parse(mi(ro)))}catch(e){}return(null==t?void 0:t.loginId)||e?t:{}}function ki(e,t){(null==e?void 0:e.authMethod)&&(t&&!(null==e?void 0:e.loginId)||vi(ro,JSON.stringify(e)))}function Ii(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const Si=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}},Oi=["error","warn","info","debug"],Ci=Si((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,console))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e||console),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return Oi.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})),xi="undefined"!=typeof localStorage,Ai=xi&&localStorage.getItem("base.content.url")||"",ji=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,Ei=Si((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})),Ui=Si((e=>{var t,n;const i=Ii(Ci,Ei)(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})),Ri=e=>t=>{var n,i,r;const s=Ii(Ci,Ei,Ui)(t),a=Object.keys(e);return r=class extends s{constructor(...e){super(...e),n.add(this),this.observeAttributes(a,o(this,n,"m",i).bind(this))}async init(){var e;a.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)},r};Ri.missingAttrValidator=ji;const Ti=Si((e=>{const t=Ii(Ri({"project-id":ji}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),$i=Si((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),Li="Trying the next fallback URL...",Pi=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)}};function Wi({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o="https://static.descope.com/pages"}){const i=new URL(o);return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.baseUrl=o,i}const Ni=Si((e=>{var t,n,r,s,a;const l=Ii(Ci,Ti,$i)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,void 0)}async fetchStaticResource(e,n){const a=o(this,t,"m",s).call(this,e),l=Array.isArray(a)?e=>{if(e!==a.length-1){const{baseUrl:t}=a[e];i(this,r,t,"f")}}: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 Pi(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}. ${Li}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${Li}`)}}})(a,{cache:"default"},{logger:this.logger,onSuccess:l});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,r=new WeakMap,t=new WeakSet,s=function(e){const t=Ai||this.baseStaticUrl;if(t)return Wi({projectId:this.projectId,filename:e,baseUrl:t});const s=o(this,n,"f")!==this.baseUrl,a=s&&!!this.baseUrl;s&&(i(this,n,this.baseUrl,"f"),i(this,r,void 0,"f"));const l=Wi({projectId:this.projectId,filename:e,baseUrl:o(this,r,"f")});if(!a)return l;return[Wi({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),l]},a})),Mi=Si((e=>{var t,n;const i=Ii(Ri({"project-id":ji}))(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})),_i=Si((e=>{var t,n,r,s,a;const l=Ii(Ni,Mi,Ei)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),r.set(this,void 0),s.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,r,"f")||i(this,r,o(this,s,"f").call(this),"f"),o(this,r,"f")}},r=new WeakMap,s=new WeakMap,t=new WeakSet,n=function(){i(this,r,void 0,"f")},a})),Di=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],qi=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()}`},Fi=(e,t)=>new Promise(((n,o)=>{const i=(e=>{const t=document.createElement("script");return t.id=e,t})(e);i.onerror=e=>{i.setAttribute("status","error"),o(e)},i.onload=()=>{i.setAttribute("status","loaded"),n(i)},i.src=t.toString(),document.body.appendChild(i)})),Ki=e=>"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)}))})),Ji=Si((e=>{const t=Ii(Ci)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",o=[]){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"`),(async(e,t)=>{for(const o of e){const{id:e,url:i}=o,r=(n=e,document.querySelector(`script#${n}`));if(r)try{return await Ki(r),o}catch(e){t(o,!0)}else try{return await Fi(e,i),o}catch(e){t(o,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,o="")=>e.reduce(((e,i)=>{const r=i;if(!r)return e;let s;try{s=new URL(r)}catch(e){throw new Error(`Invalid URL: ${r}`)}return"/"!==s.pathname||(s.pathname=`/npm/${t}@${n}/${o}`),[...e,{url:s,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${qi(s)}`}]}),[]))([...o,this.baseCdnUrl,...Di],e,t,n),((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}"`)}))}}})),Vi="base.ui.components.url",Hi=xi&&localStorage.getItem(Vi),Bi=Si((e=>{var t,n,r,s,a,l;const c=Ii(Ci,_i,Ji)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),r.set(this,void 0)}get descopeUi(){return o(this,r,"f")||i(this,r,o(this,t,"m",a).call(this),"f"),o(this,r,"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",s).call(this,e))))}},r=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(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(", ")}"`)},a=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{return await this.injectNpmLib("@descope/web-components-ui",await o(this,t,"m",n).call(this),"dist/umd/index.js",[Hi]),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},l})),zi=Si((e=>{var t,n,i;const r=Ii(Ei,Ui)(e);return i=class extends r{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",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 Gi{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 Zi=Si((e=>{const t=Ii(zi)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new Gi(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}}})),Xi="content-root",Yi="root",Qi=Si((e=>{const t=Ii(Zi)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${Yi}">\n <div id="${Xi}"></div>\n </div>\n `,this.injectStyle(`\n #${Yi}, #${Xi} {\n height: 100%;\n }\n #${Yi} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(Xi),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Yi)}}})),er=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',tr=Si((e=>{var t,n,r,s,a,l,c,d,u,p,h,g,f,v;const m=Ii(Ri({theme:er}),Ni,Ei,Bi,_i,Qi,Ui,Zi)(e);return v=class extends m{constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,void 0),h.set(this,(()=>{o(this,t,"m",g).call(this),o(this,f,"f").call(this,"os"===this.getAttribute("theme"))})),f.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",g).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"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,h,"f").call(this),await Promise.all([o(this,t,"m",l).call(this),o(this,t,"m",c).call(this)]),this.observeAttributes(["theme"],o(this,h,"f")),this.observeAttributes(["style-id"],(()=>{i(this,r,null,"f"),o(this,t,"m",u).call(this),o(this,t,"m",l).call(this),o(this,t,"m",c).call(this)}))}},n=new WeakMap,r=new WeakMap,h=new WeakMap,f=new WeakMap,t=new WeakSet,s=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")}},a=function(){return o(this,r,"f")||(i(this,r,o(this,t,"m",s).call(this),"f"),o(this,r,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,r,"f")},l=async function(){var e,r;const s=await o(this,t,"a",a);s&&(o(this,n,"f")||i(this,n,this.injectStyle(""),"f"),o(this,n,"f").replaceSync(((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)||"")))},c=async function(){var e,n;const i=await o(this,t,"a",a);if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},d=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},u=async function(){const e=await o(this,t,"m",d).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")},p=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)},g=function(){o(this,t,"m",u).call(this),o(this,t,"m",p).call(this)},v})),nr=(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?nr(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),nr(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}),[]),or=Si((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}));var ir,rr,sr,ar,lr,cr,dr,ur,pr,hr,gr,fr,vr,mr,br,wr,yr,kr,Ir,Sr,Or,Cr;const xr=Ii(tr,Ni,or,Zi)(HTMLElement);class Ar extends xr{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(),ir.add(this),sr.set(this,!1),ar.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,ir,"m",Cr).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)}},lr.set(this,new ni),cr.set(this,new ni),dr.set(this,{}),this.getComponentsContext=()=>o(this,dr,"f"),this.nextRequestStatus=new ni({isLoading:!1}),ur.set(this,void 0),pr.set(this,{popstate:o(this,ir,"m",mr).bind(this),componentsContext:o(this,ir,"m",Ir).bind(this)}),hr.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,hr,e,"f"),o(this,ir,"m",fr).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}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 nr(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,ar,"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,ar,e,"f"),(e=>{fi=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=jo.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,cr,"f").subscribe(o(this,ir,"m",Or).bind(this)),o(this,cr,"f").update({isDebug:this.debug}),o(this,ir,"m",vr).call(this),yield o(this,ir,"m",yr).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:p,redirectAuthCodeChallenge:h,redirectAuthInitiator:g,ssoQueryParams:f}=Mo(this.flowId,this.loggerWrapper);window.addEventListener("popstate",o(this,pr,"f").popstate),window.addEventListener("components-context",o(this,pr,"f").componentsContext),o(this,lr,"f").subscribe(o(this,ir,"m",wr).bind(this)),o(this,lr,"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:p,redirectAuthCodeChallenge:h,redirectAuthInitiator:g},f)),i(this,sr,!0,"f")}))}disconnectedCallback(){o(this,lr,"f").unsubscribeAll(),o(this,cr,"f").unsubscribeAll(),o(this,ir,"m",Sr).call(this),window.removeEventListener("popstate",o(this,pr,"f").popstate),window.removeEventListener("components-context",o(this,pr,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&o(this,sr,"f")&&t!==n&&rr.observedAttributes.includes(e)){o(this,ir,"m",vr).call(this);const i=null===t;o(this,lr,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,Wo()),{[No(e)]:n,stepId:r,executionId:s}})),o(this,cr,"f").update({isDebug:this.debug})}}}var jr,Er,Ur,Rr,Tr,$r,Lr,Pr,Wr,Nr,Mr,_r,Dr,qr,Fr,Kr,Jr,Vr,Hr,Br,zr,Gr,Zr,Xr,Yr,Qr,es,ts,ns,os,is,rs,ss,as,ls,cs,ds,us,ps,hs,gs,fs,vs,ms,bs,ws,ys,ks;rr=Ar,sr=new WeakMap,ar=new WeakMap,lr=new WeakMap,cr=new WeakMap,dr=new WeakMap,ur=new WeakMap,pr=new WeakMap,hr=new WeakMap,ir=new WeakSet,gr=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 ")},fr=function(){o(this,ir,"m",gr).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},vr=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"];rr.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[No(t)])throw Error(`${t} cannot be empty`)}))},mr=function(){const{stepId:e,executionId:t}=Po(this.flowId);o(this,lr,"f").update({stepId:e,executionId:t})},br=function(e,t){zn&&"function"==typeof zn||this.logger.error("SDK was not loaded properly",zn,JSON.stringify(zn));const i=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},rr.sdkConfigOverrides),{projectId:e,baseUrl:t});o(this,ar,"f")&&(i.customStorage=o(this,ar,"f")),this.sdk=zn(i),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>n(this,void 0,void 0,(function*(){try{return yield t(...e)}catch(e){return{error:{errorCode:Zn,errorDescription:e.toString()}}}}))}))},wr=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,ir,"m",br).call(this,t,n)}o(this,hr,"f").call(this,e)}))},yr=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield o(this,ir,"m",kr).call(this))}))},kr=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(Yn||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}}))},Ir=function(e){i(this,dr,Object.assign(Object.assign({},o(this,dr,"f")),e.detail),"f")},Sr=function(){var e;null===(e=o(this,ur,"f"))||void 0===e||e.remove(),i(this,ur,null,"f")},Or=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,ur,document.createElement("descope-debugger"),"f"),Object.assign(o(this,ur,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return xs})),document.body.appendChild(o(this,ur,"f"))):o(this,ir,"m",Sr).call(this)}))},Cr=function(e,t){var n;e&&this.debug&&(null===(n=o(this,ur,"f"))||void 0===n||n.updateData({title:e,description:t}))},Ar.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.52.3"}};class Is extends Ar{static set sdkConfigOverrides(e){Ar.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Ar.sdkConfigOverrides}constructor(){const e=new ni({deferredRedirect:!1});super(e.update.bind(e)),jr.add(this),this.stepState=new ni({}),Er.set(this,void 0),Ur.set(this,null),Rr.set(this,null),Tr.set(this,{visibilitychange:o(this,jr,"m",$r).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},qr.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},Kr.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,jr,"m",Jr).call(this,t):t()})),Vr.set(this,((e,t,r,s,a=!1)=>{const l=[Xn,"E103202"];if(this.flowState.current.action===ko){this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;i(this,Er,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,Ao,r,s,{}),p=document.hidden&&!a&&Date.now()-c>d+500;let h;p&&this.logger.debug("polling - The polling seems to be throttled");try{const e=p?1e3:6e3;h=yield qo(e,u)}catch(n){return this.logger.warn(`polling - The ${p?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,Vr,"f").call(this,e,t,r,s,p)}if((null===(n=null==h?void 0:h.error)||void 0===n?void 0:n.errorCode)===Zn)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,Vr,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==h?void 0:h.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(h.error,null,4)),(null===(i=null==h?void 0:h.error)||void 0===i?void 0:i.errorCode)&&l.includes(h.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):o(this,Vr,"f").call(this,e,t,r,s),o(this,Br,"f").call(this,h)}))),d),"f")}})),Hr.set(this,(()=>{clearTimeout(o(this,Er,"f")),i(this,Er,null,"f")})),Br.set(this,(e=>{var t,n,r,s,a,l,c,d,u,p,h,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,jr,"m",cs).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!==Xn||!this.isRestartOnError||o(this,jr,"m",Dr).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===(h=null===(p=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===p?void 0:p.state)||void 0===h?void 0:h.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!==ko&&o(this,Hr,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&ki(w);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void o(this,jr,"m",cs).call(this,"success",t)}this.storeLastAuthenticatedUser&&ki(w,!0),k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:O,screen:C,redirect:x,webauthn:A,error:j,samlIdpResponse:E,nativeResponse:U}=e.data,R=Date.now();y!==ko?(this.loggerWrapper.info(`Step "${O||`#${S}`}" is ${m}`,"",{screen:C,status:m,stepId:S,stepName:O,action:y,error:j}),(null===(f=C.state)||void 0===f?void 0:f.clientScripts)&&i(this,Rr,this.loadSdkScripts(C.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:O,executionId:I,action:y,redirectTo:null==x?void 0:x.url,redirectIsPopup:null==x?void 0:x.isPopup,screenId:null==C?void 0:C.id,screenState:null==C?void 0:C.state,webauthnTransactionId:null==A?void 0:A.transactionId,webauthnOptions:null==A?void 0:A.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,nativeResponseType:null==U?void 0:U.type,nativePayload:null==U?void 0:U.payload,reqTimestamp:R})):this.flowState.update({action:y,reqTimestamp:R})})),zr.set(this,_o((()=>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)}}))))),es.set(this,null),rs.set(this,Vo(((e,t)=>n(this,void 0,void 0,(function*(){var n,i;if("true"===e.getAttribute("formnovalidate")||o(this,jr,"m",Yr).call(this)){const r=null==e?void 0:e.getAttribute("id");o(this,jr,"m",ts).call(this,e);const s=yield o(this,jr,"m",Qr).call(this),a=(i=e,Array.from((null==i?void 0:i.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 l=Object.assign(Object.assign(Object.assign({},a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(r,l),this.nextRequestStatus.update({isLoading:!1}),o(this,jr,"m",ns).call(this,s)}}))))),this.flowState=e}nativeResume(e,t){var n,i,r,s,a;const l=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let{exchangeCode:e}=l;if(!e){e=null===(n=new URL(l.url).searchParams)||void 0===n?void 0:n.get(to)}null===(r=(i=this.nativeCallbacks).complete)||void 0===r||r.call(i,{exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(l.url),t=e.searchParams.get("t"),n=e.searchParams.get(eo).split("_").pop();o(this,Hr,"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}=l;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=l,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(a=(s=this.nativeCallbacks).complete)||void 0===a||a.call(s,l)}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:{[Go(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;const i=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(i){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=i;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}yield this.injectNpmLib("@descope/flow-scripts","1.0.13",`dist/${e.id}.js`);const r=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((n,o)=>{try{const o=r(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),this.nextRequestStatus.subscribe((()=>{var t;this.loggerWrapper.debug("Unloading script",e.id),null===(t=o.stop)||void 0===t||t.call(o)}))}}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,jr,"m",Mr).call(this),window.addEventListener("visibilitychange",o(this,Tr,"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,Hr,"f").call(this),null===(e=o(this,Ur,"f"))||void 0===e||e.abort(),i(this,Ur,null,"f"),window.removeEventListener("visibilitychange",o(this,Tr,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const o=Ho(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:p,executionId:h,action:g,screenId:f,screenState:v,redirectTo:m,redirectIsPopup:b,redirectUrl:w,token:y,code:k,isPopup:I,exchangeError:S,webauthnTransactionId:O,webauthnOptions:C,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:A,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:E,locale:U,samlIdpResponseUrl:R,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:$,nativeResponseType:L,nativePayload:P,reqTimestamp:W}=e,N=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","nativeResponseType","nativePayload","reqTimestamp"]);let M,_,D;const q=(()=>{const e=mi(bi);if(!e){const e=Math.floor(100*Math.random()+1);return vi(bi,e.toString()),e}return Number(e)})(),{outboundAppId:F}=this,{outboundAppScopes:K}=this,J=this.sdk.getLastUserLoginId(),V=yield this.getFlowConfig(),H=yield this.getProjectConfig(),B=Object.entries(H.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),z=A&&x?{callbackUrl:A,codeChallenge:x,backupCallbackUri:j}:void 0,G=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}:void 0;let Z={};if(!h){const e=[...V.clientScripts||[],...V.sdkScripts||[]];if(V.conditions){let t=[];({startScreenId:M,conditionInteractionId:D,startScreenName:_,clientScripts:t,componentsConfig:Z}=((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=wi[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:J,code:k,token:y,abTestingKey:q,lastAuth:yi(J)},V.conditions)),e.push(...t||[])}else V.condition?({startScreenId:M,conditionInteractionId:D}=((e,t)=>{var n;const o=null===(n=wi[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}})(V.condition,{loginId:J,code:k,token:y,abTestingKey:q,lastAuth:yi(J)})):(_=V.startScreenName,M=V.startScreenId);if(i(this,Rr,this.loadSdkScripts(e),"f"),V.fingerprintEnabled&&V.fingerprintKey?yield gn(V.fingerprintKey,this.baseUrl):Ft(pn),!Fo(M,N)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:z},N),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:yi(J),abTestingKey:q,locale:Ho(U).locale,nativeOptions:G,outboundAppId:F,outboundAppScopes:K}),D,"",H.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),N.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),N.oidcLoginHint?{externalId:N.oidcLoginHint}:{}));return o(this,Br,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:I,code:k,exchangeError:S,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),I&&(s("code")&&k||s("exchangeError")&&S))return void o(this,jr,"m",ds).call(this,h,k,S);if(h&&(s("token")&&y||s("code")&&k||s("exchangeError")&&S)){const e=yield this.sdk.flow.next(h,p,xo,V.version,H.componentsVersion,{token:y,exchangeCode:k,exchangeError:S});return o(this,Br,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===Co&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!R||!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)})(R,T,$||"",Ko)}if(g===yo&&(s("redirectTo")||s("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===m)return;if("android"===E&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${b}`),b){this.loggerWrapper.debug("Opening redirect in popup");const e=Zo(m,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));const n=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const n=t?this.popupOrigin:window.location.origin;if(e.origin!==n)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${n}"`);const{action:o,data:i}=e.data||{};"code"===o&&this.flowState.update({code:i.code,exchangeError:i.exchangeError})};let i;this.loggerWrapper.debug("Starting popup closed detection");const r=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(r),o(this,jr,"m",cs).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==i||i())}),1e3);if(t)window.addEventListener("message",n),i=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",n)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(h);e.onmessage=n,i=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),o(this,jr,"m",cs).call(this,"popupclosed",{});return}if(g===Io||g===So){if(!O||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=o(this,Ur,"f"))||void 0===l||l.abort(),i(this,Ur,null,"f");try{e=g===Io?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const n=yield this.sdk.flow.next(h,p,xo,V.version,H.componentsVersion,{transactionId:O,response:e,failure:t});o(this,Br,"f").call(this,n)}if(g===Oo)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(h,p,xo,V.version,H.componentsVersion,e);o(this,Br,"f").call(this,t)})),void o(this,jr,"m",Wr).call(this,L,P);if(s("action")&&o(this,Vr,"f").call(this,h,p,V.version,H.componentsVersion),!f&&!M)return void this.loggerWrapper.warn("No screen was found to show");const X=M||f,Y=yield this.getHtmlFilenameWithLocale(U,X),{oidcLoginHint:Q,oidcPrompt:ee,oidcErrorRedirectUri:te,oidcResource:ne,samlIdpUsername:oe}=N,ie={direction:Lo(p,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:J,name:this.sdk.getLastUserDisplayName()||J},componentsConfig:Object.assign(Object.assign(Object.assign({},V.componentsConfig),Z),null==v?void 0:v.componentsConfig)}),htmlFilename:`${X}.html`,htmlLocaleFilename:Y,screenId:X,stepName:e.stepName||_,samlIdpUsername:oe,oidcLoginHint:Q,oidcPrompt:ee,oidcErrorRedirectUri:te,oidcResource:ne,action:g},re=yi(J);Fo(M,N)?ie.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==V?void 0:V.clientScripts)||[];yield o(this,jr,"m",ss).call(this,n);const i=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:z},N),{lastAuth:re,preview:this.preview,abTestingKey:q,client:this.client}),w&&{redirectUrl:w}),{locale:Ho(U).locale,nativeOptions:G,outboundAppId:F,outboundAppScopes:K}),D,e,H.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),zo(t)),k&&{exchangeCode:k,idpInitiated:!0}),N.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}),ie.next.isCustomScreen);return o(this,Br,"f").call(this,i),i})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(ie.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==v?void 0:v.clientScripts)||[];yield o(this,jr,"m",ss).call(this,n);const i=yield this.sdk.flow.next(h,p,e,V.version,H.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),zo(t)),ie.next.isCustomScreen);return o(this,Br,"f").call(this,i),i}))),this.loggerWrapper.debug("Got a screen with id",ie.screenId),yield o(this,jr,"m",Fr).call(this,ie),this.stepState.update(ie)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var i,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:l,next:c,screenState:d}=e;this.loggerWrapper.debug("Rendering a flow screen");const u=document.createElement("template");u.innerHTML=yield this.getPageContent(s,a);const p=u.content.cloneNode(!0),h=this.loadDescopeUiComponents(u);this.sdk.webauthn.helpers.isSupported()?yield o(this,jr,"m",Zr).call(this,p,c):p.querySelectorAll(`descope-button[${wo}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(i=d.form)||void 0===i?void 0:i.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),pi(p,d,this.formConfig,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(p,g);const f=()=>n(this,void 0,void 0,(function*(){var n,i;yield h;const r=this.contentRootElement;var s,a;s=r,a=null===(n=null==d?void 0:d.totp)||void 0===n?void 0:n.image,ui(s,"descope-totp-image",a),((e,t)=>{ui(e,"descope-notp-image",t)})(r,null===(i=null==d?void 0:d.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,p,d.cssVars,this.loggerWrapper),r.replaceChildren(p);const l=!t.htmlFilename;setTimeout((()=>{o(this,jr,"m",os).call(this),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)=>{si(e,null==t?void 0:t.inputs),si(e,null==t?void 0:t.form)})(r,d),o(this,jr,"m",Xr).call(this,{isFirstScreen:l,isCustomScreen:!1,stepName:e.stepName}),Do(r,this.autoFocus,l)})),o(this,jr,"m",ls).call(this,c);r.querySelector(`[${wo}="polling"]`)&&c(Ao,{})}));l?o(this,jr,"m",Jr).call(this,f):f()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${oo}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}Er=new WeakMap,Ur=new WeakMap,Rr=new WeakMap,Tr=new WeakMap,qr=new WeakMap,Kr=new WeakMap,Vr=new WeakMap,Hr=new WeakMap,Br=new WeakMap,zr=new WeakMap,es=new WeakMap,rs=new WeakMap,jr=new WeakSet,$r=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Lr=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,jr,"m",Wr).call(this,"beforeScreen",{screen:e,context:t})}))}))},Pr=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&o(this,jr,"m",Wr).call(this,"afterScreen",{screen:e})},Wr=function(e,t){o(this,jr,"m",cs).call(this,"bridge",{type:e,payload:t})},Nr=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(`[${wo}="${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()},Mr=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,jr,"m",Nr).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,jr,"m",_r).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})},_r=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=""}))})),Do(this.contentRootElement,this.autoFocus,!1))},Dr=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")}))},Fr=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=Bo(l);let d=yield o(this,jr,"m",Lr).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,Kr,"f").call(this,d),s&&(s.isCustomScreen=d),o(this,qr,"f")!==d){const[e,t]=["flow","custom"].sort((()=>d?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),i(this,qr,d,"f"),d?this.stepState.unsubscribeAll():o(this,jr,"m",Mr).call(this)}d?(this.loggerWrapper.debug("Showing a custom screen"),o(this,jr,"m",Xr).call(this,{isFirstScreen:u,isCustomScreen:d,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=d}))},Jr=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")},Gr=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)}))}},Zr=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,Ur,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield hi())){const{options:e,transactionId:r}=(yield o(this,zr,"f").call(this))||{};e&&r&&(o(this,jr,"m",Gr).call(this,s),i(this,Ur,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,o(this,Ur,"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)})))}}))},Xr=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&o(this,jr,"m",cs).call(this,"ready",{}),t||o(this,jr,"m",Pr).call(this,n),o(this,jr,"m",cs).call(this,"page-updated",{screenName:n}),o(this,jr,"m",cs).call(this,"screen-updated",{screenName:n})},Yr=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,o;"slot"!==t.localName&&(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},Qr=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})),{})}))},ts=function(e){const t=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),r=()=>n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",r),e.removeAttribute("loading"),t.forEach((e=>{e.removeAttribute("disabled")}));const n=yield this.getFlowConfig(),o=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(o)})),s=()=>{var e;window.removeEventListener("pageshow",o(this,es,"f")),i(this,es,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),r())}),"f"),window.addEventListener("pageshow",o(this,es,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&r(),this.removeEventListener("popupclosed",r),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},a=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?(this.addEventListener("popupclosed",r,{once:!0}),e.setAttribute("loading","true"),t.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(a),s())}))},ns=function(e={}){var t,n;const o=Jo(e,["externalId","email","phone"]),i=Jo(e,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:i});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},os=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>o(this,jr,"m",is).call(this,e)))},is=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)}))},ss=function(e){return n(this,void 0,void 0,(function*(){if(o(this,Rr,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield o(this,Rr,"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 qo(5e3,Promise.all(i),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},as=function(e){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&o(this,rs,"f").call(this,t,e)}))}))},ls=function(e){this.contentRootElement.querySelectorAll(`descope-button:not([${io}]), [data-type="button"]:not([${io}]`).forEach((t=>{t.onclick=()=>{o(this,rs,"f").call(this,t,e)}})),o(this,jr,"m",as).call(this,e),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${oo}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},cs=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},ds=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",Is);const Ss=document.createElement("template");Ss.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 Os=Ii(Zi)(HTMLElement);class Cs extends Os{constructor(){super(),us.add(this),ps.set(this,new ni({messages:[]})),hs.set(this,void 0),gs.set(this,void 0),fs.set(this,void 0),vs.set(this,{resize:o(this,us,"m",ks).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ss.content.cloneNode(!0)),i(this,hs,this.shadowRoot.querySelector(".debugger"),"f"),i(this,gs,o(this,hs,"f").querySelector(".content"),"f"),i(this,fs,o(this,hs,"f").querySelector(".header"),"f"),o(this,us,"m",ms).call(this)}updateData(e){o(this,ps,"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]=gi(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,hs,"f"),o(this,fs,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,vs,"f").resize),(n=o(this,hs,"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,hs,"f").onresize=o(this,us,"m",ys).bind(this),o(this,ps,"f").subscribe(o(this,us,"m",bs).bind(this))}))}disconnectedCallback(){o(this,ps,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,vs,"f").resize)}}ps=new WeakMap,hs=new WeakMap,gs=new WeakMap,fs=new WeakMap,vs=new WeakMap,us=new WeakSet,ms=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,hs,"f").style.top="32px",o(this,hs,"f").style.left=window.innerWidth-300-32+"px"},bs=function(e){o(this,us,"m",ws).call(this,e),o(this,us,"m",ys).call(this)},ws=function(e){o(this,gs,"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("")},ys=function(){o(this,gs,"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)}))},ks=function(){const[e,t]=gi(o(this,hs,"f"),Number.parseInt(o(this,hs,"f").style.left,10),Number.parseInt(o(this,hs,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,hs,"f").style.top=`${t}px`,o(this,hs,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Cs);var xs=Object.freeze({__proto__:null,default:Cs})}();
|
|
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"==typeof SuppressedError&&SuppressedError;class r extends Error{}function s(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 a(e,t){if("string"!=typeof e)throw new r("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 r(`Invalid token specified: missing part #${n+1}`);let i;try{i=s(o)}catch(e){throw new r(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new r(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}r.prototype.name="InvalidTokenError";var l={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"},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 c="<region>",d=`https://api.${c}descope.com`,u=6e5,h="dct",p=()=>{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")}},g=[521,524],f=e=>async(...t)=>{let n=await e(...t);g.includes(n.status)&&(n=await e(...t),n.retries=1);const o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n};let v;const m=()=>{if(v)return v;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 v=`${t}-${n}`,v};var b;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(b||(b={}));const w=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(c,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},y=(...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)),{})),k={"Content-Type":"application/json"},I=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},S=(e,t)=>{const n={"x-descope-sdk-session-id":m(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.54.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},O=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var C=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||d,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(...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=>p().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await f(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return p().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:f(n)})(i,a),u=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:y(I(t,f),S(t,o),(null==n?void 0:n.baseHeaders)||{},O(v)?k:{},h),method:g,body:v};null!==s&&(m.credentials=s||"include");const b=await c(w({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=((null===(i=b.headers)||void 0===i?void 0:i.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},b),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}return b};return{get:(e,{headers:t,queryParams:n,token:o}={})=>u({path:e,headers:t,queryParams:n,body:void 0,method:b.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>u({path:e,headers:n,queryParams:o,body:t,method:b.post,token:i}),patch:(e,t,{headers:n,queryParams:o,token:i}={})=>u({path:e,headers:n,queryParams:o,body:t,method:b.patch,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>u({path:e,headers:n,queryParams:o,body:t,method:b.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>u({path:e,headers:t,queryParams:n,body:void 0,method:b.delete,token:o}),hooks:r,buildUrl:(e,n)=>w({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}}))},x=429;function A(e,t,n){var o;let i=j(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[h])===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 j(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return a(e)}function E(e){const{exp:t}=j(e);return(new Date).getTime()/1e3>t}function U(e){let t=j(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function R(e,t){return A(e,t,"permissions")}function T(e,t){return A(e,t,"roles")}const $=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function L(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===x&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}function P(e){var t;return(null===(t=j(e))||void 0===t?void 0:t[h])||""}const W=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),N=(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 "))},M=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),_=e=>t=>e.test(t),D=_(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),q=_(/^\+[1-9]{1}[0-9]{3,14}$/),F=W(D,'"{val}" is not a valid email'),K=W(q,'"{val}" is not a valid phone number'),J=W((e=>e.length>=1),"Minimum length is 1");const V=W((e=>"string"==typeof e),"Input is not a string"),H=W((e=>Array.isArray(e)),"Input is not an array"),B=W((e=>"boolean"==typeof e),"Input is not a boolean"),z=W((e=>void 0===e),"Input is defined"),G=N([V(),z()],"Input is not a string or undefined"),Z=N([H(),B()],"Input is not an array or boolean"),X=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>M(...e).validate(n[t]))),t(...n)),Y=e=>[V(`"${e}" must be a string`)],Q=e=>[G(`"${e}" must be string or undefined`)],ee=e=>[V(`"${e}" must be a string`),J(`"${e}" must not be empty`)],te=e=>[V(`"${e}" must be a string`),F()],ne=e=>[V(`"${e}" must be a string`),K()],oe=X(ee("accessKey")),ie=e=>({exchange:oe(((t,n)=>L(e.post(l.accessKey.exchange,{loginOptions:n},{token:t}))))}),re=(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),se=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||u,u)});var ae,le;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(ae||(ae={})),function(e){e.email="email"}(le||(le={}));const ce=Object.assign(Object.assign({},ae),le);var de;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(de||(de={}));const ue=ee("loginId"),he=X(ee("token")),pe=X(ue),ge=X(ee("pendingRef")),fe=X(ue,te("email")),ve=e=>({verify:he((t=>L(e.post(l.enchantedLink.verify,{token:t})))),signIn:pe(((n,o,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return L(e.post($(l.enchantedLink.signIn,ce.email),{loginId:n,URI:o,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:pe(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return L(e.post($(l.enchantedLink.signUpOrIn,ce.email),{loginId:n,URI:o,loginOptions:s,providerId:r}))})),signUp:pe(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return L(e.post($(l.enchantedLink.signUp,ce.email),{loginId:n,URI:o,user:i,loginOptions:a,providerId:s}))})),waitForSession:ge(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=se(n);let s;const a=setInterval((async()=>{const n=await e.post(l.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(L(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:fe(((t,n,o,i,r)=>L(e.post(l.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),me=X(ee("flowId")),be=X(ee("executionId"),ee("stepId"),ee("interactionId")),we=e=>({start:me(((t,n,o,i,r,s,a,c=!1)=>L(e.post(l.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:c})))),next:be(((t,n,o,i,r,s,a=!1)=>L(e.post(l.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s,isCustomScreen:a}))))}),ye=ee("loginId"),ke=X(ee("token")),Ie=X(ye),Se=X(ye,ne("phone")),Oe=X(ye,te("email")),Ce=Object.keys(ce).filter((e=>e!==ae.voice)),xe=e=>({verify:ke((t=>L(e.post(l.magicLink.verify,{token:t})))),signIn:Ce.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ie(((n,i,r={},s)=>{var{providerId:a}=r,c=t(r,["providerId"]);return L(e.post($(l.magicLink.signIn,o),{loginId:n,URI:i,loginOptions:c,providerId:a},{token:s}))}))})),{}),signUp:Ce.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ie(((n,i,r,s={})=>{var{providerId:a}=s,c=t(s,["providerId"]);return L(e.post($(l.magicLink.signUp,o),{loginId:n,URI:i,user:r,loginOptions:c,providerId:a}))}))})),{}),signUpOrIn:Ce.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ie(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return L(e.post($(l.magicLink.signUpOrIn,o),{loginId:n,URI:i,loginOptions:a,providerId:s}))}))})),{}),update:{email:Oe(((t,n,o,i,r)=>L(e.post(l.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(ae).filter((e=>e!==ae.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Se(((t,o,i,r,s)=>L(e.post($(l.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var Ae;!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"}(Ae||(Ae={}));const je=X(ee("code")),Ee=e=>({start:Object.assign(((t,n,o,i,r)=>L(e.post(l.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:i}))),Object.keys(Ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i,r)=>L(e.post(l.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:i}))})),{})),exchange:je((t=>L(e.post(l.oauth.exchange,{code:t})))),startNative:(t,n,o)=>L(e.post(l.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>L(e.post(l.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>L(e.get(l.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>L(e.post(l.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>L(e.post(l.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),Ue=ee("appId"),Re=X(Ue),Te=e=>({connect:Re(((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,L(e.post(l.outbound.connect,{appId:t,tenantId:i,tenantLevel:r,options:n},{token:o}))}))}),$e=ee("loginId"),Le=X($e,ee("code")),Pe=X($e),We=X($e,ne("phone")),Ne=X($e,te("email")),Me=e=>({verify:Object.keys(ce).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Le(((t,o)=>L(e.post($(l.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(ce).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Pe(((n,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return L(e.post($(l.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(ce).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Pe(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return L(e.post($(l.otp.signUp,o),{loginId:n,user:i,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(ce).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Pe(((n,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return L(e.post($(l.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:Ne(((t,n,o,i)=>L(e.post(l.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:We(((t,o,i,r)=>L(e.post($(l.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),_e=X(ee("tenant")),De=X(ee("code")),qe=e=>({start:_e(((t,n,o,i,r,s,a,c)=>L(e.post(l.saml.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}),c&&{initiatedEmail:t})},i&&{token:i}))))),exchange:De((t=>L(e.post(l.saml.exchange,{code:t}))))}),Fe=ee("loginId"),Ke=X(Fe,ee("code")),Je=X(Fe),Ve=X(Fe),He=e=>({signUp:Je(((t,n)=>L(e.post(l.totp.signUp,{loginId:t,user:n})))),verify:Ke(((t,n,o,i)=>L(e.post(l.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),update:Ve(((t,n)=>L(e.post(l.totp.update,{loginId:t},{token:n}))))}),Be=ee("loginId"),ze=ee("newPassword"),Ge=X(Be,ee("password")),Ze=X(Be),Xe=X(Be,ze),Ye=X(Be,ee("oldPassword"),ze),Qe=e=>({signUp:Ge(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return L(e.post(l.password.signUp,{loginId:n,password:o,user:i,loginOptions:a,providerId:s}))})),signIn:Ge(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return L(e.post(l.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:r}))})),sendReset:Ze(((t,n,o)=>L(e.post(l.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Xe(((t,n,o)=>L(e.post(l.password.update,{loginId:t,newPassword:n},{token:o})))),replace:Ye(((t,n,o)=>L(e.post(l.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>L(e.get(l.password.policy))}),et=Y("loginId"),tt=ee("loginId"),nt=ee("origin"),ot=X(tt,nt,ee("name")),it=X(tt,nt),rt=X(et,nt),st=X(tt,nt,Q("token")),at=X(ee("transactionId"),ee("response")),lt=e=>({signUp:{start:ot(((t,n,o,i)=>L(e.post(l.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,passkeyOptions:i})))),finish:at(((t,n)=>L(e.post(l.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:rt(((t,n,o,i,r)=>L(e.post(l.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:at(((t,n)=>L(e.post(l.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:it(((t,n,o)=>L(e.post(l.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:o}))))},update:{start:st(((t,n,o,i)=>L(e.post(l.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i},{token:o})))),finish:at(((t,n)=>L(e.post(l.webauthn.update.finish,{transactionId:t,response:n}))))}}),ct=Y("loginId"),dt=X(ct),ut=X(ee("pendingRef")),ht=e=>({signUpOrIn:dt(((n,o={})=>{var{providerId:i}=o,r=t(o,["providerId"]);return L(e.post(l.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:i}))})),signUp:dt(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return L(e.post(l.notp.signUp,{loginId:n,user:o,providerId:r,loginOptions:s}))})),signIn:dt(((n,o={},i)=>{var{providerId:r}=o,s=t(o,["providerId"]);return L(e.post(l.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:i}))})),waitForSession:ut(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=se(n);let s;const a=setInterval((async()=>{const n=await e.post(l.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(L(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),pt=X(ee("token")),gt=X(Q("token"));var ft,vt=X([(ft=ee("projectId"),W(((e,t)=>n=>M(...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",ft))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return c=C({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:ie(c),otp:Me(c),magicLink:xe(c),enchantedLink:ve(c),oauth:Ee(c),outbound:Te(c),saml:qe(c),totp:He(c),notp:ht(c),webauthn:lt(c),password:Qe(c),flow:we(c),refresh:gt(((e,t,n,o)=>{const i={};n&&(i.externalToken=n);const r=o?l.tryRefresh:l.refresh;return L(c.post(r,i,{token:e,queryParams:t}))})),selectTenant:X([V("tenantId")],[G('"token" must be string or undefined')])(((e,t)=>L(c.post(l.selectTenant,{tenant:e},{token:t})))),logout:gt((e=>L(c.post(l.logout,{},{token:e})))),logoutAll:gt((e=>L(c.post(l.logoutAll,{},{token:e})))),me:gt((e=>L(c.get(l.me,{token:e})))),myTenants:X([Z('"tenants" must a string array or a boolean')],[G('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,L(c.post(l.myTenants,n,{token:t}))})),history:gt((e=>L(c.get(l.history,{token:e})))),isJwtExpired:pt(E),getTenants:pt(U),getJwtPermissions:pt(R),getJwtRoles:pt(T),getCurrentTenant:pt(P),httpClient:c};var c})),mt=Object.assign(vt,{DeliveryMethods:ce});
|
|
2
|
+
/*! js-cookie v3.0.5 | MIT */function bt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var wt=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=bt({},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(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",bt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,bt({},this.attributes,t))},withConverter:function(t){return e(bt({},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 yt={default:"endpoint"},kt="Blocked by CSP",It="The endpoint parameter is not a valid URL",St="Failed to load the JS script of the agent",Ot="9319";function Ct(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===kt||s===It)n.exclude(),r=0;else if(s===Ot)n.exclude();else if(s===St){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 xt="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",At=xt;function jt(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:xt,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 Ct(e,Et)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Ot?new Error(St):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 Et(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(It);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(St))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(kt)})).then(Ut)}function Ut(){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(Ot);return n}const Rt="3.2.0",Tt="undefined"!=typeof window,$t=Math.pow(2,31)-1,Lt=`https://descopecdn.com/npm/oidc-client-ts@${Rt}/dist/browser/oidc-client-ts.min.js`,Pt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Rt}/dist/browser/oidc-client-ts.min.js`;let Wt;const Nt=e=>{try{return a(e).exp}catch(e){return null}},Mt=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Nt(n)},_t=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?Nt(o):void 0)},Dt=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||_t(e),cookieExpiration:e.cookieExpiration||Mt(e)},s)},qt=(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},Ft=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 Dt(n)},Kt=()=>Tt&&!!window.descopeBridge,Jt=void 0!==Wt||Tt&&void 0!==window.localStorage,Vt=(e,t)=>{var n,o;return null===(o=null===(n=Wt||Tt&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},Ht=e=>{var t,n;return null===(n=null===(t=Wt||Tt&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},Bt=e=>{var t,n;return null===(n=null===(t=Wt||Tt&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},zt=e=>{var t,n,o,i,r;return null!==(r=null!==(n=null===(t=null==Wt?void 0:Wt.key)||void 0===t?void 0:t.call(Wt,e))&&void 0!==n?n:Tt&&(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},Gt=(...e)=>{console.debug(...e)},Zt=e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>$t&&(Gt(`Timeout is too large (${t}ms), setting it to ${$t}ms`),t=$t),t},Xt="DS",Yt="DSR",Qt="DSI";function en(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=tn(o);wt.set(e,t,{path:i,domain:c?o:void 0,expires:l,sameSite:r,secure:a})}}function tn(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 nn=e=>(null==e?void 0:e.cookieName)||Xt,on=e=>(null==e?void 0:e.cookieName)||Yt;function rn(e="",t){return wt.get(on(t))||Ht(`${e}${Yt}`)||""}function sn(e="",t){return wt.get(nn(t))||Ht(`${e}${Xt}`)||""}function an(e=""){return Ht(`${e}${Qt}`)||""}function ln(e="",t,n,o){Bt(`${e}${Yt}`),Bt(`${e}${Xt}`),Bt(`${e}${Qt}`);const i=nn(t);wt.remove(i,null==o?void 0:o.session);const r=on(n);wt.remove(r,null==o?void 0:o.refresh)}const cn=(e,t)=>n=>{const o=Object.assign(n,{token:n.token||rn(e,t)}),i=function(e=""){return Ht(`${e}DTD`)||""}(e);return i&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":i})),o},dn=Tt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",un="vsid",hn="vrid",pn="fp",gn=(e=!1)=>{const t=Ht(pn);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},fn=async(e,t=dn)=>{try{if(gn())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=jt({apiKey:e,endpoint:[o.toString(),yt],scriptUrlPattern:[r,At]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[un]:e,[hn]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};Vt(pn,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},vn=e=>{const t=gn(!0);return t&&e.body&&(e.body.fpData=t),e},mn="descopeFlowNonce",bn="X-Descope-Flow-Nonce",wn="/v1/flow/start",yn="/v1/flow/next",kn=(e,t=mn)=>`${t}${e}`,In=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Sn=e=>{var t;return e.path===yn&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?In(e.body.executionId):null},On="dls_last_user_login_id",Cn="dls_last_user_display_name",xn=e=>Vt(On,e),An=()=>Ht(On),jn=()=>Ht(Cn),En=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=An(),r=jn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)};function Un(){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 Rn(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Nn(n.publicKey.challenge),n.publicKey.user.id=Nn(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Nn(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Mn(n.rawId),type:n.type,response:{attestationObject:Mn(n.response.attestationObject),clientDataJSON:Mn(n.response.clientDataJSON)}});var n}async function Tn(e){const t=Pn(e);return Wn(await navigator.credentials.get(t))}async function $n(e,t){const n=Pn(e);return n.signal=t.signal,n.mediation="conditional",Wn(await navigator.credentials.get(n))}async function Ln(e=!1){var t,n;if(!Tt)return Promise.resolve(!1);if(Kt()){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 Pn(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Nn(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Nn(e.id)})),n}function Wn(e){return JSON.stringify({id:e.id,rawId:Mn(e.rawId),type:e.type,response:{authenticatorData:Mn(e.response.authenticatorData),clientDataJSON:Mn(e.response.clientDataJSON),signature:Mn(e.response.signature),userHandle:e.response.userHandle?Mn(e.response.userHandle):void 0}})}function Nn(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Mn(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var _n,Dn=(_n=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 Rn(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 Tn(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 Rn(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await Tn(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 Rn(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:Rn,get:Tn,isSupported:Ln,conditional:$n}}),(...e)=>{const t=_n(...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 qn="/fedcm/config",Fn=()=>{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 Kn(e,t){var n;try{await Jn(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Jn(e,t){var n,o;const i=await async function(e,t="google",n,o,i){const r=Fn(),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 Vn=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Ln(),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 Hn;const Bn=(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",(()=>{Bn(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),zn=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{Hn||(Hn=(async()=>{try{return require("oidc-client-ts")}catch(e){return Bn([Lt,Pt],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await Hn;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)))),Vt(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(e={},t=!1)=>{const{client:n}=await o(),i=await n.createSigninRequest(e),{url:r}=i;return t||(window.location.href=r),{ok:!0,data:i}},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=Ht(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||an(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return Bt(i),t||window.location.replace(s),r}}},Gn=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Wt=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return Tt?(o&&i&&fn(o).catch((()=>null)),e(qt(r,{beforeRequest:vn}))):e(r)}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);if(!o||Kt())return e(i);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let l,c;Tt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(Gt("Expiration time passed, refreshing session"),d.refresh(rn()||c))}));const d=e(qt(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i}=await Ft(t);if(401===(null==t?void 0:t.status))Gt("Received 401, canceling all timers"),r();else if(n||i){if(l=((e,t)=>{if(t)return new Date(1e3*t);Gt("Could not extract expiration time from session token, trying to decode the token");try{const t=a(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!l)return void Gt("Could not extract expiration time from session token");c=o;const e=Zt(l);if(r(),e<=2e4)return void Gt("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Gt(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Gt("Refreshing session due to timer"),d.refresh(rn()||o)}),e)}}}));return re(d,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Gt("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.42.0"},t.baseHeaders)}))),(e=>t=>{const n=Un(),o=Un(),i=Un(),r=Un(),s=e(qt(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))o.pub(null),i.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await Ft(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 Ft(t);s&&o.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=re(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=>{const{enableFlowNonce:o=!0,nonceStoragePrefix:i=mn}=n,r=t(n,["enableFlowNonce","nonceStoragePrefix"]);return o?(((e=mn)=>{try{if(!Jt)return;for(let i=0;i<(void 0,n=void 0,void 0,null!==(o=null!==(t=null==Wt?void 0:Wt.length)&&void 0!==t?t:Tt&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);i++){const t=zt(i);if(t&&t.startsWith(e)){const n=Ht(t);if(n)try{JSON.parse(n).expiry<Date.now()&&Bt(t)}catch(e){Bt(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(i),e(qt(r,{afterRequest:async(e,t)=>{if(e.path!==wn&&e.path!==yn)return;const{nonce:n,executionId:o}=await(async(e,t)=>{try{const n=t.headers.get(bn);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=Sn(e)),{nonce:n,executionId:In(o)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&o&&((e,t,n,o=mn)=>{try{const i=kn(e,o),r=n?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:n};Vt(i,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(o,n,e.path===wn,i)},beforeRequest:e=>{if(e.path===yn){const t=Sn(e);if(t){const n=((e,t=mn)=>{try{const n=kn(e,t),o=Ht(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(((e,t=mn)=>{try{const n=kn(e,t);Bt(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,i);n&&(e.headers=e.headers||{},e.headers[bn]=n)}}return e}}))):e(r)}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(r),{getLastUserLoginId:An,getLastUserDisplayName:jn});const s=e(qt(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=Dt((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?(xn(r),(e=>{Vt(Cn,e)})(s)):(null==i?void 0:i.loginId)&&xn(i.loginId)}}));let a=re(s,["flow.start"],En);return a=re(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(Bt(On),Bt(Cn)),o})(i)),Object.assign(a,{getLastUserLoginId:An,getLastUserDisplayName:jn})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,refreshTokenViaCookie:r,storagePrefix:s}=n,a=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix"]);if(!o||!Tt)return e(a);let l;const c=e(qt(a,{beforeRequest:cn(s,r),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);if(401===(null==t?void 0:t.status))n||ln(s,i,r,l);else{const e=((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){Bt(`${n}${Yt}`);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=on(o),d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});en(l,c,d);const h=tn(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=on(o);wt.remove(e),Vt(`${n}${Yt}`,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=nn(t),c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:o,cookieDomain:i});en(r,l,c);const d=tn(i);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?i:void 0}})}else Vt(`${n}${Xt}`,l);return e.idToken&&Vt(`${n}${Qt}`,e.idToken),d&&Vt(`${n}DTD`,d),u})(await Ft(t),i,s,r);e&&(l=e)}}})),d=re(c,["logout","logoutAll","oidc.logout"],((e,t,n,o)=>i=>async(...r)=>{const s=await i(...r);return ln(e,t,n,null==o?void 0:o()),s})(s,i,r,(()=>l)));return Object.assign(d,{getRefreshToken:()=>rn(s,r),getSessionToken:()=>sn(s,i),getIdToken:()=>an(s)})}))((e=>{const t=mt(e),n=zn(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,i)=>{var r;if(Kt())return Gt(`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()}})}const s=sn(),a=rn();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){Gt("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:Vn(t),webauthn:Dn(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){Kn(o,e)},requestAuthentication(e){Kn(o,e)}},async oneTap(e,t,n,i,r){await Jn(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+qn),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>Tt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+qn);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})),Zn="undefined"!=typeof localStorage,Xn="J151000",Yn="E103205",Qn=Zn&&localStorage.getItem("base.content.url")||"",eo="base.ui.components.url";Zn&&localStorage.getItem(eo),Zn&&localStorage.getItem(eo);const to="descope-login-flow",no="code",oo="redirect_mode",io="data-exclude-field",ro="data-exclude-next",so="dls_last_auth",ao="state_id",lo="saml_idp_state_id",co="saml_idp_username",uo="descope_idp_initiated",ho="sso_app_id",po="third_party_app_id",go="third_party_app_state_id",fo="oidc_login_hint",vo="oidc_prompt",mo="oidc_resource",bo="oidc_error_redirect_uri",wo="application_scopes",yo="data-type",ko="redirect",Io="poll",So="webauthnCreate",Oo="webauthnGet",Co="nativeBridge",xo="loadForm",Ao="submit",jo="polling",Eo=["descope-multi-select-combo-box","descope-text-area"],Uo=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Ro;!function(e){e.backward="backward",e.forward="forward"}(Ro||(Ro={}));const To=["descope-enriched-text"];function $o(e){return new URLSearchParams(window.location.search).get(e)}function Lo(e){if(window.history.replaceState&&$o(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 Po(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Ro.forward:n<o?Ro.backward:void 0}const Wo=e=>{let[t="",n=""]=($o(to)||"").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 No(){Lo(to)}const Mo=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),_o=(e,t)=>{const{executionId:n,stepId:o,executionFlowId:i}=Wo(e);if(i&&e!==i)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&No();const r=$o("t")||void 0;r&&Lo("t");const s=$o(no)||void 0;s&&Lo(no);const a="popup"===$o(oo);a&&Lo(oo);const l=$o("err")||void 0;l&&Lo("err");const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:$o("ra-challenge"),redirectAuthCallbackUrl:$o("ra-callback"),redirectAuthBackupCallbackUri:$o("ra-backup-callback"),redirectAuthInitiator:$o("ra-initiator")},p=$o(ao);p&&Lo(ao);const g=$o(lo);g&&Lo(lo);const f=$o(co);g&&Lo(co);const v=$o(uo);v&&Lo(uo);const m=$o(ho);m&&Lo(ho);const b=$o(po);b&&Lo(po);const w=$o(go);w&&Lo(go);const y=$o(wo);y&&Lo(wo);const k=$o(fo);k&&Lo(fo);const I=$o(vo);I&&Lo(vo);const S=$o(bo);S&&Lo(bo);const O=$o(mo);O&&Lo(mo);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,samlIdpUsername:f,descopeIdpInitiated:"true"===v,ssoAppId:m,oidcLoginHint:k,oidcPrompt:I,oidcErrorRedirectUri:S,oidcResource:O,thirdPartyAppId:b,thirdPartyAppStateId:w,applicationScopes:y}}},Do=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}})},qo=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}};function Fo(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 Ko=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,oidcResource:l,thirdPartyAppId:c,thirdPartyAppStateId:d,applicationScopes:u})=>!(!e||t||n||o||i||r||s||a||l||c||d||u),Jo=e=>null==e?void 0:e.submit(),Vo=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Ho=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function Bo(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const zo=e=>{var t,n,o;const i=(r=e.screenState,s=(e,t)=>Uo.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(r).filter((([e,t])=>!s(t,e)))));var r,s;const{screenState:{errorText:a,errorType:l}}=e;return(a||l)&&(i.error={text:a,type:l}),e.action&&(i.action=e.action),(null===(o=null===(n=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===n?void 0:n.thirdPartyAppApproveScopes)||void 0===o?void 0:o.data)&&(i.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),i},Go=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Zo(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}const Xo=(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 Yo,Qo,ei,ti;function ni(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(!ni(r,s))return!1}else if(r!==s)return!1}return!0}class oi{constructor(e={},{forceUpdate:t=!1}={}){Yo.set(this,void 0),Qo.set(this,{}),ei.set(this,0),ti.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,Yo,"f")):e,n=Object.assign(Object.assign({},o(this,Yo,"f")),t),r=o(this,Yo,"f");i(this,Yo,n,"f"),Object.freeze(o(this,Yo,"f")),setTimeout((()=>{Object.values(o(this,Qo,"f")).forEach((({cb:e,selector:t,forceUpdate:i})=>{const s=t(r),a=t(n);(o(this,ti,"f")||i||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!ni(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},i(this,Yo,e,"f"),i(this,ti,t,"f")}get current(){return Object.assign({},o(this,Yo,"f"))}set forceUpdate(e){i(this,ti,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return i(this,ei,o(this,ei,"f")+1,"f"),o(this,Qo,"f")[o(this,ei,"f")]={cb:e,selector:t,forceUpdate:n},o(this,ei,"f").toString()}unsubscribe(e){const t=!!o(this,Qo,"f")[e];return t&&delete o(this,Qo,"f")[e],t}unsubscribeAll(){return i(this,Qo,{},"f"),!0}}Yo=new WeakMap,Qo=new WeakMap,ei=new WeakMap,ti=new WeakMap;const ii=["*","#","/","(",")","[","]","_","<",">","`"],ri=e=>{const t=ii.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")},si=["disabled"],ai=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${io}])`)).forEach((e=>{e.value=n}))}))},li=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),ci=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,o)=>n?(e=>"string"!=typeof e?e:e.replace(ri("\\"),"\\$1"))(li(t,o)):li(t,o))),di=(e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(o=e.localName,To.includes(o));var o;e.textContent=ci(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",ci(i,t))}))},ui=(e,t,n)=>{e.querySelectorAll(`[${yo}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},hi=(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})`))},pi=(e,n,o,i)=>{var r,s;ui(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),ui(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=ci(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])=>{si.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o),((e,t={},n)=>{Object.entries(t).forEach((([t,o])=>{e.querySelectorAll(`[id="${CSS.escape(t)}"]`).forEach((e=>{switch(o){case"disable":e.setAttribute("disabled","true");break;case"hide":e.classList.add("hidden");break;default:null==n||n.error(`Unknown component state "${o}" for component with id "${t}"`,'Valid states are "disable" and "hide"')}}))}))})(e,null==n?void 0:n.componentsState,i)},gi=Do((()=>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 Fo(100,n,o)}catch(e){return console.error("Conditional login check failed",e),!1}})))),fi=(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 vi;const mi=(e,t)=>{vi?vi.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},bi=e=>vi?vi.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,wi="dls_ab_testing_id",yi={"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 ki(e){const t={};try{Object.assign(t,JSON.parse(bi(so)))}catch(e){}return(null==t?void 0:t.loginId)||e?t:{}}function Ii(e,t){(null==e?void 0:e.authMethod)&&(t&&!(null==e?void 0:e.loginId)||mi(so,JSON.stringify(e)))}function Si(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const Oi=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}},Ci=["error","warn","info","debug"],xi={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},Ai=Oi((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,xi))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e||xi),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return Ci.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})),ji="undefined"!=typeof localStorage,Ei="https://static.descope.com/pages",Ui="https://static2.descope.com/pages",Ri=ji&&localStorage.getItem("base.content.url")||"",Ti=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,$i=Oi((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})),Li=Oi((e=>{var t,n;const i=Si(Ai,$i)(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})),Pi=e=>t=>{var n,i,r;const s=Si(Ai,$i,Li)(t),a=Object.keys(e);return r=class extends s{constructor(...e){super(...e),n.add(this),this.observeAttributes(a,o(this,n,"m",i).bind(this))}async init(){var e;a.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)},r};Pi.missingAttrValidator=Ti;const Wi=Oi((e=>{const t=Si(Pi({"project-id":Ti}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Ni=Oi((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),Mi="Trying the next fallback URL...",_i=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 Di=Oi((e=>{var t,n,r,s,a,l,c;const d=Si(Ai,Wi,Ni)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,void 0),s.set(this,new Set)}async fetchStaticResource(e,n){const l=o(this,t,"m",a).call(this,e),c=Array.isArray(l)?e=>{const{baseUrl:t}=l[e];i(this,r,t,"f");for(let t=0;t<e;t++){const e=l[t].baseUrl;o(this,s,"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 _i(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}. ${Mi}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${Mi}`)}}})(l,{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,r=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(e){const a=Ri||this.baseStaticUrl;if(a)return o(this,t,"m",l).call(this,e,a);o(this,n,"f")!==this.baseUrl&&(i(this,n,this.baseUrl,"f"),i(this,r,void 0,"f"),o(this,s,"f").clear());const c=[];if(o(this,r,"f"))c.push(o(this,t,"m",l).call(this,e,o(this,r,"f"))),o(this,r,"f")===Ei&&c.push(o(this,t,"m",l).call(this,e,Ui));else{const n=this.baseUrl+"/pages";this.baseUrl&&!o(this,s,"f").has(n)&&c.push(o(this,t,"m",l).call(this,e,n)),o(this,s,"f").has(Ei)||c.push(o(this,t,"m",l).call(this,e,Ei)),c.push(o(this,t,"m",l).call(this,e,Ui))}return 1===c.length?c[0]:c},l=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o=Ei}){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})},c})),qi=Oi((e=>{var t,n;const i=Si(Pi({"project-id":Ti}))(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})),Fi=Oi((e=>{var t,n,r,s,a;const l=Si(Di,qi,$i)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),r.set(this,void 0),s.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,r,"f")||i(this,r,o(this,s,"f").call(this),"f"),o(this,r,"f")}},r=new WeakMap,s=new WeakMap,t=new WeakSet,n=function(){i(this,r,void 0,"f")},a})),Ki=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],Ji=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()}`},Vi=(e,t)=>new Promise(((n,o)=>{const i=(e=>{const t=document.createElement("script");return t.id=e,t})(e);i.onerror=e=>{i.setAttribute("status","error"),o(e)},i.onload=()=>{i.setAttribute("status","loaded"),n(i)},i.src=t.toString(),document.body.appendChild(i)})),Hi=e=>"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)}))})),Bi=Oi((e=>{const t=Si(Ai)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",o=[]){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"`),(async(e,t)=>{for(const o of e){const{id:e,url:i}=o,r=(n=e,document.querySelector(`script#${n}`));if(r)try{return await Hi(r),o}catch(e){t(o,!0)}else try{return await Vi(e,i),o}catch(e){t(o,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,o="")=>e.reduce(((e,i)=>{const r=i;if(!r)return e;let s;try{s=new URL(r)}catch(e){throw new Error(`Invalid URL: ${r}`)}return"/"!==s.pathname||(s.pathname=`/npm/${t}@${n}/${o}`),[...e,{url:s,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${Ji(s)}`}]}),[]))([...o,this.baseCdnUrl,...Ki],e,t,n),((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}"`)}))}}})),zi="base.ui.components.url",Gi=ji&&localStorage.getItem(zi),Zi=Oi((e=>{var t,n,r,s,a,l;const c=Si(Ai,Fi,Bi)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),r.set(this,void 0)}get descopeUi(){return o(this,r,"f")||i(this,r,o(this,t,"m",a).call(this),"f"),o(this,r,"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",s).call(this,e))))}},r=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(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(", ")}"`)},a=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{return await this.injectNpmLib("@descope/web-components-ui",await o(this,t,"m",n).call(this),"dist/umd/index.js",[Gi]),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},l})),Xi=Oi((e=>{var t,n,i;const r=Si($i,Li)(e);return i=class extends r{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",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 Yi{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 Qi=Oi((e=>{const t=Si(Xi)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new Yi(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}}})),er="content-root",tr="root",nr=Oi((e=>{const t=Si(Qi)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${tr}">\n <div id="${er}"></div>\n </div>\n `,this.injectStyle(`\n #${tr}, #${er} {\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(er),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(tr)}}})),or=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ir=Oi((e=>{var t,n,r,s,a,l,c,d,u,h,p,g,f,v;const m=Si(Pi({theme:or}),Di,$i,Zi,Fi,nr,Li,Qi)(e);return v=class extends m{constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,void 0),p.set(this,(()=>{o(this,t,"m",g).call(this),o(this,f,"f").call(this,"os"===this.getAttribute("theme"))})),f.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",g).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"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,p,"f").call(this),await Promise.all([o(this,t,"m",l).call(this),o(this,t,"m",c).call(this)]),this.observeAttributes(["theme"],o(this,p,"f")),this.observeAttributes(["style-id"],(()=>{i(this,r,null,"f"),o(this,t,"m",u).call(this),o(this,t,"m",l).call(this),o(this,t,"m",c).call(this)}))}},n=new WeakMap,r=new WeakMap,p=new WeakMap,f=new WeakMap,t=new WeakSet,s=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")}},a=function(){return o(this,r,"f")||(i(this,r,o(this,t,"m",s).call(this),"f"),o(this,r,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,r,"f")},l=async function(){var e,r;const s=await o(this,t,"a",a);s&&(o(this,n,"f")||i(this,n,this.injectStyle(""),"f"),o(this,n,"f").replaceSync(((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)||"")))},c=async function(){var e,n;const i=await o(this,t,"a",a);if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},d=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},u=async function(){const e=await o(this,t,"m",d).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")},h=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)},g=function(){o(this,t,"m",u).call(this),o(this,t,"m",h).call(this)},v})),rr=(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?rr(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),rr(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}),[]),sr=Oi((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}));var ar,lr,cr,dr,ur,hr,pr,gr,fr,vr,mr,br,wr,yr,kr,Ir,Sr,Or,Cr,xr,Ar,jr;const Er=Si(ir,Di,sr,Qi)(HTMLElement);class Ur extends Er{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(),ar.add(this),cr.set(this,!1),dr.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,ar,"m",jr).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)}},ur.set(this,new oi),hr.set(this,new oi),pr.set(this,{}),this.getComponentsContext=()=>o(this,pr,"f"),this.nextRequestStatus=new oi({isLoading:!1}),gr.set(this,void 0),fr.set(this,{popstate:o(this,ar,"m",yr).bind(this),componentsContext:o(this,ar,"m",Cr).bind(this)}),vr.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,vr,e,"f"),o(this,ar,"m",br).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}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 rr(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,dr,"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,dr,e,"f"),(e=>{vi=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=Eo.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,hr,"f").subscribe(o(this,ar,"m",Ar).bind(this)),o(this,hr,"f").update({isDebug:this.debug}),o(this,ar,"m",wr).call(this),yield o(this,ar,"m",Sr).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}=_o(this.flowId,this.loggerWrapper);window.addEventListener("popstate",o(this,fr,"f").popstate),window.addEventListener("components-context",o(this,fr,"f").componentsContext),o(this,ur,"f").subscribe(o(this,ar,"m",Ir).bind(this)),o(this,ur,"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,cr,!0,"f")}))}disconnectedCallback(){o(this,ur,"f").unsubscribeAll(),o(this,hr,"f").unsubscribeAll(),o(this,ar,"m",xr).call(this),window.removeEventListener("popstate",o(this,fr,"f").popstate),window.removeEventListener("components-context",o(this,fr,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&o(this,cr,"f")&&t!==n&&lr.observedAttributes.includes(e)){o(this,ar,"m",wr).call(this);const i=null===t;o(this,ur,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,No()),{[Mo(e)]:n,stepId:r,executionId:s}})),o(this,hr,"f").update({isDebug:this.debug})}}}var Rr,Tr,$r,Lr,Pr,Wr,Nr,Mr,_r,Dr,qr,Fr,Kr,Jr,Vr,Hr,Br,zr,Gr,Zr,Xr,Yr,Qr,es,ts,ns,os,is,rs,ss,as,ls,cs,ds,us,hs,ps,gs,fs,vs,ms,bs,ws,ys,ks,Is,Ss,Os;lr=Ur,cr=new WeakMap,dr=new WeakMap,ur=new WeakMap,hr=new WeakMap,pr=new WeakMap,gr=new WeakMap,fr=new WeakMap,vr=new WeakMap,ar=new WeakSet,mr=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 ")},br=function(){o(this,ar,"m",mr).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},wr=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"];lr.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Mo(t)])throw Error(`${t} cannot be empty`)}))},yr=function(){const{stepId:e,executionId:t}=Wo(this.flowId);o(this,ur,"f").update({stepId:e,executionId:t})},kr=function(e,t){Gn&&"function"==typeof Gn||this.logger.error("SDK was not loaded properly",Gn,JSON.stringify(Gn));const i=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},lr.sdkConfigOverrides),{projectId:e,baseUrl:t});o(this,dr,"f")&&(i.customStorage=o(this,dr,"f")),this.sdk=Gn(i),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>n(this,void 0,void 0,(function*(){try{return yield t(...e)}catch(e){return{error:{errorCode:Xn,errorDescription:e.toString()}}}}))}))},Ir=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,ar,"m",kr).call(this,t,n)}o(this,vr,"f").call(this,e)}))},Sr=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield o(this,ar,"m",Or).call(this))}))},Or=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(Qn||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}}))},Cr=function(e){i(this,pr,Object.assign(Object.assign({},o(this,pr,"f")),e.detail),"f")},xr=function(){var e;null===(e=o(this,gr,"f"))||void 0===e||e.remove(),i(this,gr,null,"f")},Ar=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,gr,document.createElement("descope-debugger"),"f"),Object.assign(o(this,gr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Es})),document.body.appendChild(o(this,gr,"f"))):o(this,ar,"m",xr).call(this)}))},jr=function(e,t){var n;e&&this.debug&&(null===(n=o(this,gr,"f"))||void 0===n||n.updateData({title:e,description:t}))},Ur.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.53.0"}};class Cs extends Ur{static set sdkConfigOverrides(e){Ur.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Ur.sdkConfigOverrides}constructor(){const e=new oi({deferredRedirect:!1});super(e.update.bind(e)),Rr.add(this),this.stepState=new oi({}),Tr.set(this,void 0),$r.set(this,null),Lr.set(this,null),Pr.set(this,{visibilitychange:o(this,Rr,"m",Wr).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},Jr.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},Hr.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,Rr,"m",Br).call(this,t):t()})),zr.set(this,((e,t,r,s,a=!1)=>{const l=[Yn,"E103202"];if(this.flowState.current.action===Io){this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;i(this,Tr,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,jo,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 Fo(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,zr,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===Xn)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,zr,"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,zr,"f").call(this,e,t,r,s),o(this,Zr,"f").call(this,p)}))),d),"f")}})),Gr.set(this,(()=>{clearTimeout(o(this,Tr,"f")),i(this,Tr,null,"f")})),Zr.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,Rr,"m",hs).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!==Yn||!this.isRestartOnError||o(this,Rr,"m",Kr).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!==Io&&o(this,Gr,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&Ii(w);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void o(this,Rr,"m",hs).call(this,"success",t)}this.storeLastAuthenticatedUser&&Ii(w,!0),k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:O,screen:C,redirect:x,webauthn:A,error:j,samlIdpResponse:E,nativeResponse:U}=e.data,R=Date.now();y!==Io?(this.loggerWrapper.info(`Step "${O||`#${S}`}" is ${m}`,"",{screen:C,status:m,stepId:S,stepName:O,action:y,error:j}),(null===(f=C.state)||void 0===f?void 0:f.clientScripts)&&i(this,Lr,this.loadSdkScripts(C.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:O,executionId:I,action:y,redirectTo:null==x?void 0:x.url,redirectIsPopup:null==x?void 0:x.isPopup,screenId:null==C?void 0:C.id,screenState:null==C?void 0:C.state,webauthnTransactionId:null==A?void 0:A.transactionId,webauthnOptions:null==A?void 0:A.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,nativeResponseType:null==U?void 0:U.type,nativePayload:null==U?void 0:U.payload,reqTimestamp:R})):this.flowState.update({action:y,reqTimestamp:R})})),Xr.set(this,Do((()=>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)}}))))),os.set(this,null),ls.set(this,Ho(((e,t)=>n(this,void 0,void 0,(function*(){var n,i;if("true"===e.getAttribute("formnovalidate")||o(this,Rr,"m",ts).call(this)){const r=null==e?void 0:e.getAttribute("id");o(this,Rr,"m",is).call(this,e);const s=yield o(this,Rr,"m",ns).call(this),a=(i=e,Array.from((null==i?void 0:i.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 l=Object.assign(Object.assign(Object.assign({},a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(r,l),this.nextRequestStatus.update({isLoading:!1}),o(this,Rr,"m",rs).call(this,s)}}))))),this.flowState=e}nativeResume(e,t){var n,i,r,s,a;const l=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let{exchangeCode:e}=l;if(!e){e=null===(n=new URL(l.url).searchParams)||void 0===n?void 0:n.get(no)}null===(r=(i=this.nativeCallbacks).complete)||void 0===r||r.call(i,{exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(l.url),t=e.searchParams.get("t"),n=e.searchParams.get(to).split("_").pop();o(this,Gr,"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}=l;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=l,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(a=(s=this.nativeCallbacks).complete)||void 0===a||a.call(s,l)}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:{[Zo(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;const i=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(i){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=i;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}yield this.injectNpmLib("@descope/flow-scripts","1.0.13",`dist/${e.id}.js`);const r=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((n,o)=>{try{const o=r(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),this.nextRequestStatus.subscribe((()=>{var t;this.loggerWrapper.debug("Unloading script",e.id),null===(t=o.stop)||void 0===t||t.call(o)}))}}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,Rr,"m",qr).call(this),window.addEventListener("visibilitychange",o(this,Pr,"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,Gr,"f").call(this),null===(e=o(this,$r,"f"))||void 0===e||e.abort(),i(this,$r,null,"f"),window.removeEventListener("visibilitychange",o(this,Pr,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const o=Bo(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:f,screenState:v,redirectTo:m,redirectIsPopup:b,redirectUrl:w,token:y,code:k,isPopup:I,exchangeError:S,webauthnTransactionId:O,webauthnOptions:C,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:A,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:E,locale:U,samlIdpResponseUrl:R,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:$,nativeResponseType:L,nativePayload:P,reqTimestamp:W}=e,N=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","nativeResponseType","nativePayload","reqTimestamp"]);let M,_,D;const q=(()=>{const e=bi(wi);if(!e){const e=Math.floor(100*Math.random()+1);return mi(wi,e.toString()),e}return Number(e)})(),{outboundAppId:F}=this,{outboundAppScopes:K}=this,J=this.sdk.getLastUserLoginId(),V=yield this.getFlowConfig(),H=yield this.getProjectConfig(),B=Object.entries(H.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),z=A&&x?{callbackUrl:A,codeChallenge:x,backupCallbackUri:j}:void 0,G=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}:void 0;let Z={};if(!p){const e=[...V.clientScripts||[],...V.sdkScripts||[]];if(V.conditions){let t=[];({startScreenId:M,conditionInteractionId:D,startScreenName:_,clientScripts:t,componentsConfig:Z}=((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=yi[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:J,code:k,token:y,abTestingKey:q,lastAuth:ki(J)},V.conditions)),e.push(...t||[])}else V.condition?({startScreenId:M,conditionInteractionId:D}=((e,t)=>{var n;const o=null===(n=yi[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}})(V.condition,{loginId:J,code:k,token:y,abTestingKey:q,lastAuth:ki(J)})):(_=V.startScreenName,M=V.startScreenId);if(i(this,Lr,this.loadSdkScripts(e),"f"),V.fingerprintEnabled&&V.fingerprintKey?yield fn(V.fingerprintKey,this.baseUrl):Bt(pn),!Ko(M,N)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:z},N),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:ki(J),abTestingKey:q,locale:Bo(U).locale,nativeOptions:G,outboundAppId:F,outboundAppScopes:K}),D,"",H.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),N.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),N.oidcLoginHint?{externalId:N.oidcLoginHint}:{}));return o(this,Zr,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:I,code:k,exchangeError:S,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),I&&(s("code")&&k||s("exchangeError")&&S))return void o(this,Rr,"m",ps).call(this,p,k,S);if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&S)){const e=yield this.sdk.flow.next(p,h,Ao,V.version,H.componentsVersion,{token:y,exchangeCode:k,exchangeError:S});return o(this,Zr,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===xo&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!R||!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)})(R,T,$||"",Jo)}if(g===ko&&(s("redirectTo")||s("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===m)return;if("android"===E&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${b}`),b){this.loggerWrapper.debug("Opening redirect in popup");const e=Xo(m,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));const n=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const n=t?this.popupOrigin:window.location.origin;if(e.origin!==n)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${n}"`);const{action:o,data:i}=e.data||{};"code"===o&&this.flowState.update({code:i.code,exchangeError:i.exchangeError})};let i;this.loggerWrapper.debug("Starting popup closed detection");const r=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(r),o(this,Rr,"m",hs).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==i||i())}),1e3);if(t)window.addEventListener("message",n),i=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",n)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=n,i=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),o(this,Rr,"m",hs).call(this,"popupclosed",{});return}if(g===So||g===Oo){if(!O||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=o(this,$r,"f"))||void 0===l||l.abort(),i(this,$r,null,"f");try{e=g===So?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const n=yield this.sdk.flow.next(p,h,Ao,V.version,H.componentsVersion,{transactionId:O,response:e,failure:t});o(this,Zr,"f").call(this,n)}if(g===Co)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,Ao,V.version,H.componentsVersion,e);o(this,Zr,"f").call(this,t)})),void o(this,Rr,"m",_r).call(this,L,P);if(s("action")&&o(this,zr,"f").call(this,p,h,V.version,H.componentsVersion),!f&&!M)return void this.loggerWrapper.warn("No screen was found to show");const X=M||f,Y=yield this.getHtmlFilenameWithLocale(U,X),{oidcLoginHint:Q,oidcPrompt:ee,oidcErrorRedirectUri:te,oidcResource:ne,samlIdpUsername:oe}=N,ie={direction:Po(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:J,name:this.sdk.getLastUserDisplayName()||J},componentsConfig:Object.assign(Object.assign(Object.assign({},V.componentsConfig),Z),null==v?void 0:v.componentsConfig)}),htmlFilename:`${X}.html`,htmlLocaleFilename:Y,screenId:X,stepName:e.stepName||_,samlIdpUsername:oe,oidcLoginHint:Q,oidcPrompt:ee,oidcErrorRedirectUri:te,oidcResource:ne,action:g},re=ki(J);Ko(M,N)?ie.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==V?void 0:V.clientScripts)||[];yield o(this,Rr,"m",cs).call(this,n);const i=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:z},N),{lastAuth:re,preview:this.preview,abTestingKey:q,client:this.client}),w&&{redirectUrl:w}),{locale:Bo(U).locale,nativeOptions:G,outboundAppId:F,outboundAppScopes:K}),D,e,H.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),Go(t)),k&&{exchangeCode:k,idpInitiated:!0}),N.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}),ie.next.isCustomScreen);return o(this,Zr,"f").call(this,i),i})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(ie.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==v?void 0:v.clientScripts)||[];yield o(this,Rr,"m",cs).call(this,n);const i=yield this.sdk.flow.next(p,h,e,V.version,H.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),Go(t)),ie.next.isCustomScreen);return o(this,Zr,"f").call(this,i),i}))),this.loggerWrapper.debug("Got a screen with id",ie.screenId),yield o(this,Rr,"m",Vr).call(this,ie),this.stepState.update(ie)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var i,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:l,next:c,screenState:d}=e;this.loggerWrapper.debug("Rendering a flow screen");const u=document.createElement("template");u.innerHTML=yield this.getPageContent(s,a);const h=u.content.cloneNode(!0),p=this.loadDescopeUiComponents(u);this.sdk.webauthn.helpers.isSupported()?yield o(this,Rr,"m",Qr).call(this,h,c):h.querySelectorAll(`descope-button[${yo}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(i=d.form)||void 0===i?void 0:i.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),pi(h,d,this.formConfig,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(h,g);const f=()=>n(this,void 0,void 0,(function*(){var n,i;yield p;const r=this.contentRootElement;var s,a;s=r,a=null===(n=null==d?void 0:d.totp)||void 0===n?void 0:n.image,hi(s,"descope-totp-image",a),((e,t)=>{hi(e,"descope-notp-image",t)})(r,null===(i=null==d?void 0:d.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,h,d.cssVars,this.loggerWrapper),r.replaceChildren(h);const l=!t.htmlFilename;setTimeout((()=>{o(this,Rr,"m",ss).call(this),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)=>{ai(e,null==t?void 0:t.inputs),ai(e,null==t?void 0:t.form)})(r,d),o(this,Rr,"m",es).call(this,{isFirstScreen:l,isCustomScreen:!1,stepName:e.stepName}),qo(r,this.autoFocus,l)})),o(this,Rr,"m",us).call(this,c);r.querySelector(`[${yo}="polling"]`)&&c(jo,{})}));l?o(this,Rr,"m",Br).call(this,f):f()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${io}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}Tr=new WeakMap,$r=new WeakMap,Lr=new WeakMap,Pr=new WeakMap,Jr=new WeakMap,Hr=new WeakMap,zr=new WeakMap,Gr=new WeakMap,Zr=new WeakMap,Xr=new WeakMap,os=new WeakMap,ls=new WeakMap,Rr=new WeakSet,Wr=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Nr=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,Rr,"m",_r).call(this,"beforeScreen",{screen:e,context:t})}))}))},Mr=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&o(this,Rr,"m",_r).call(this,"afterScreen",{screen:e})},_r=function(e,t){o(this,Rr,"m",hs).call(this,"bridge",{type:e,payload:t})},Dr=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(`[${yo}="${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()},qr=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,Rr,"m",Dr).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,Rr,"m",Fr).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})},Fr=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=""}))})),qo(this.contentRootElement,this.autoFocus,!1))},Kr=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")}))},Vr=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=zo(l);let d=yield o(this,Rr,"m",Nr).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,Hr,"f").call(this,d),s&&(s.isCustomScreen=d),o(this,Jr,"f")!==d){const[e,t]=["flow","custom"].sort((()=>d?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),i(this,Jr,d,"f"),d?this.stepState.unsubscribeAll():o(this,Rr,"m",qr).call(this)}d?(this.loggerWrapper.debug("Showing a custom screen"),o(this,Rr,"m",es).call(this,{isFirstScreen:u,isCustomScreen:d,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=d}))},Br=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")},Yr=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)}))}},Qr=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,$r,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield gi())){const{options:e,transactionId:r}=(yield o(this,Xr,"f").call(this))||{};e&&r&&(o(this,Rr,"m",Yr).call(this,s),i(this,$r,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,o(this,$r,"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)})))}}))},es=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&o(this,Rr,"m",hs).call(this,"ready",{}),t||o(this,Rr,"m",Mr).call(this,n),o(this,Rr,"m",hs).call(this,"page-updated",{screenName:n}),o(this,Rr,"m",hs).call(this,"screen-updated",{screenName:n})},ts=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,o;"slot"!==t.localName&&(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},ns=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})),{})}))},is=function(e){const t=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),r=()=>n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",r),e.removeAttribute("loading"),t.forEach((e=>{e.removeAttribute("disabled")}));const n=yield this.getFlowConfig(),o=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(o)})),s=()=>{var e;window.removeEventListener("pageshow",o(this,os,"f")),i(this,os,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),r())}),"f"),window.addEventListener("pageshow",o(this,os,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&r(),this.removeEventListener("popupclosed",r),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},a=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?(this.addEventListener("popupclosed",r,{once:!0}),e.setAttribute("loading","true"),t.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(a),s())}))},rs=function(e={}){var t,n;const o=Vo(e,["externalId","email","phone"]),i=Vo(e,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:i});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},ss=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>o(this,Rr,"m",as).call(this,e)))},as=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)}))},cs=function(e){return n(this,void 0,void 0,(function*(){if(o(this,Lr,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield o(this,Lr,"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 Fo(5e3,Promise.all(i),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},ds=function(e){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&o(this,ls,"f").call(this,t,e)}))}))},us=function(e){this.contentRootElement.querySelectorAll(`descope-button:not([${ro}]), [data-type="button"]:not([${ro}]`).forEach((t=>{t.onclick=()=>{o(this,ls,"f").call(this,t,e)}})),o(this,Rr,"m",ds).call(this,e),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${io}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},hs=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},ps=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",Cs);const xs=document.createElement("template");xs.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 As=Si(Qi)(HTMLElement);class js extends As{constructor(){super(),gs.add(this),fs.set(this,new oi({messages:[]})),vs.set(this,void 0),ms.set(this,void 0),bs.set(this,void 0),ws.set(this,{resize:o(this,gs,"m",Os).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(xs.content.cloneNode(!0)),i(this,vs,this.shadowRoot.querySelector(".debugger"),"f"),i(this,ms,o(this,vs,"f").querySelector(".content"),"f"),i(this,bs,o(this,vs,"f").querySelector(".header"),"f"),o(this,gs,"m",ys).call(this)}updateData(e){o(this,fs,"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]=fi(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,vs,"f"),o(this,bs,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,ws,"f").resize),(n=o(this,vs,"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,vs,"f").onresize=o(this,gs,"m",Ss).bind(this),o(this,fs,"f").subscribe(o(this,gs,"m",ks).bind(this))}))}disconnectedCallback(){o(this,fs,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,ws,"f").resize)}}fs=new WeakMap,vs=new WeakMap,ms=new WeakMap,bs=new WeakMap,ws=new WeakMap,gs=new WeakSet,ys=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,vs,"f").style.top="32px",o(this,vs,"f").style.left=window.innerWidth-300-32+"px"},ks=function(e){o(this,gs,"m",Is).call(this,e),o(this,gs,"m",Ss).call(this)},Is=function(e){o(this,ms,"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("")},Ss=function(){o(this,ms,"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)}))},Os=function(){const[e,t]=fi(o(this,vs,"f"),Number.parseInt(o(this,vs,"f").style.left,10),Number.parseInt(o(this,vs,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,vs,"f").style.top=`${t}px`,o(this,vs,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",js);var Es=Object.freeze({__proto__:null,default:js})}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descope/web-component",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.53.0",
|
|
4
4
|
"author": "Descope Team <info@descope.com>",
|
|
5
5
|
"homepage": "https://github.com/descope/descope-js",
|
|
6
6
|
"bugs": {
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"tslib": "2.8.1",
|
|
72
72
|
"@fingerprintjs/fingerprintjs-pro": "3.11.6",
|
|
73
|
-
"@descope/sdk-mixins": "0.14.0",
|
|
74
|
-
"@descope/escape-markdown": "0.1.6",
|
|
75
73
|
"@descope/sdk-helpers": "0.5.1",
|
|
76
|
-
"@descope/web-js-sdk": "1.
|
|
74
|
+
"@descope/web-js-sdk": "1.42.0",
|
|
75
|
+
"@descope/sdk-mixins": "0.15.0",
|
|
76
|
+
"@descope/escape-markdown": "0.1.6"
|
|
77
77
|
},
|
|
78
78
|
"overrides": {
|
|
79
79
|
"terser": "5.37.0"
|