chordia-ui 3.4.0 → 3.4.2

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.
Files changed (38) hide show
  1. package/dist/Timeline.cjs.js +1 -6
  2. package/dist/Timeline.cjs.js.map +1 -1
  3. package/dist/Timeline.es.js +129 -597
  4. package/dist/Timeline.es.js.map +1 -1
  5. package/dist/TranscriptCard.cjs.js +7 -0
  6. package/dist/TranscriptCard.cjs.js.map +1 -0
  7. package/dist/TranscriptCard.es.js +474 -0
  8. package/dist/TranscriptCard.es.js.map +1 -0
  9. package/dist/UpdatedInteractionRecording.cjs.js +1 -1
  10. package/dist/UpdatedInteractionRecording.cjs.js.map +1 -1
  11. package/dist/UpdatedInteractionRecording.es.js +516 -420
  12. package/dist/UpdatedInteractionRecording.es.js.map +1 -1
  13. package/dist/components/UpdatedInteractionDetails.cjs.js +2 -2
  14. package/dist/components/UpdatedInteractionDetails.cjs.js.map +1 -1
  15. package/dist/components/UpdatedInteractionDetails.es.js +304 -285
  16. package/dist/components/UpdatedInteractionDetails.es.js.map +1 -1
  17. package/dist/components/media.cjs.js +1 -1
  18. package/dist/components/media.cjs.js.map +1 -1
  19. package/dist/components/media.es.js +9 -8
  20. package/dist/components/media.es.js.map +1 -1
  21. package/dist/index.cjs.js +1 -1
  22. package/dist/index.cjs2.js +1 -1
  23. package/dist/index.cjs2.js.map +1 -1
  24. package/dist/index.cjs3.js +2 -2
  25. package/dist/index.cjs3.js.map +1 -1
  26. package/dist/index.es.js +53 -52
  27. package/dist/index.es.js.map +1 -1
  28. package/dist/index.es2.js +1 -1
  29. package/dist/index.es2.js.map +1 -1
  30. package/dist/index.es3.js +11 -4
  31. package/dist/index.es3.js.map +1 -1
  32. package/dist/pages/interactionDetails.cjs.js +2 -2
  33. package/dist/pages/interactionDetails.cjs.js.map +1 -1
  34. package/dist/pages/interactionDetails.es.js +17 -16
  35. package/dist/pages/interactionDetails.es.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/components/UpdatedInteractionDetails/UpdatedInteractionDetails.jsx +125 -107
  38. package/src/components/UpdatedInteractionDetails/UpdatedInteractionRecording.jsx +342 -178
@@ -2,7 +2,7 @@
2
2
  <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />
3
3
  <input type="hidden" role="saml-relay-state" name="RelayState" value="${t}" />
4
4
  <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />
5
- `,document.body.appendChild(o),s(o)},Xs=i=>i==null?void 0:i.submit(),yt=(i,e)=>{const t=e.find(s=>i[s]);return t?i[t]:null},Zs=(i,e=100)=>{let t;return function(...s){t||i.apply(this,s),clearTimeout(t),t=setTimeout(()=>{t=null},e)}};function Ce(i){if(i)return{locale:i.toLowerCase(),fallback:i.toLowerCase()};const e=navigator.language;return e?e.includes("-")?{locale:e.toLowerCase(),fallback:e.split("-")[0].toLowerCase()}:{locale:e.toLowerCase(),fallback:e.toLowerCase()}:{locale:"",fallback:""}}const er=()=>{document.querySelectorAll('[data-hidden-input="true"]').forEach(i=>i.remove())},tr=i=>ns.includes(i),ir=i=>{var e,t,s;const o=(n=i.screenState,a=(u,c)=>os.includes(c)||c.startsWith("_"),Object.fromEntries(Object.entries(n).filter(([u,c])=>!a(c,u))));var n,a;const{screenState:{errorText:l,errorType:d}}=i;return(l||d)&&(o.error={text:l,type:d}),i.action&&(o.action=i.action),!((s=(t=(e=i.screenState)===null||e===void 0?void 0:e.componentsConfig)===null||t===void 0?void 0:t.thirdPartyAppApproveScopes)===null||s===void 0)&&s.data&&(o.inboundAppApproveScopes=i.screenState.componentsConfig.thirdPartyAppApproveScopes.data),o},St=i=>{const e=Object.assign({},i);return i.inboundAppApproveScopes&&(e.thirdPartyAppApproveScopes=i.inboundAppApproveScopes),e};function sr(i,e){return`${is}.${e?`${i}_${e}`:i}`}const rr=(i,e,t,s)=>{const o=window.screenLeft!==void 0?window.screenLeft:window.screen.left,n=window.screenTop!==void 0?window.screenTop:window.screen.top,a=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-t)/2+o,l=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-s)/2+n,d=function(){const c=navigator.userAgent||"",h=/\b(iPhone)\b/.test(c),p=/Safari/.test(c)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(c);return h&&p}()?"about:blank":"",u=window.open(d,e,`width=${t},height=${s},top=${l},left=${a},scrollbars=yes,resizable=yes`);return u.location.href=i,u.focus(),u};var D,X,ie,de;function li(i,e){const t=Object.getOwnPropertyNames(i),s=Object.getOwnPropertyNames(e);if(t.length!==s.length)return!1;for(let o=0;o<t.length;o+=1){const n=t[o],a=i[n],l=e[n];if(a===null||l===null){if(a!==l)return!1}else if(typeof a=="object"&&typeof l=="object"){if(!li(a,l))return!1}else if(a!==l)return!1}return!0}class ne{constructor(e={},{forceUpdate:t=!1}={}){D.set(this,void 0),X.set(this,{}),ie.set(this,0),de.set(this,!0),this.update=s=>{const o=typeof s=="function"?s(r.__classPrivateFieldGet(this,D,"f")):s,n=Object.assign(Object.assign({},r.__classPrivateFieldGet(this,D,"f")),o),a=r.__classPrivateFieldGet(this,D,"f");r.__classPrivateFieldSet(this,D,n,"f"),Object.freeze(r.__classPrivateFieldGet(this,D,"f")),setTimeout(()=>{Object.values(r.__classPrivateFieldGet(this,X,"f")).forEach(({cb:l,selector:d,forceUpdate:u})=>{const c=d(a),h=d(n);(r.__classPrivateFieldGet(this,de,"f")||u||(function(p){if(typeof p!="object"||p===null)return!1;const f=Object.getPrototypeOf(p);return f===Object.prototype||f===null}(h)?!li(c,h):c!==h))&&l(h,c,Bs(h,c))})},0)},r.__classPrivateFieldSet(this,D,e,"f"),r.__classPrivateFieldSet(this,de,t,"f")}get current(){return Object.assign({},r.__classPrivateFieldGet(this,D,"f"))}set forceUpdate(e){r.__classPrivateFieldSet(this,de,e,"f")}subscribe(e,t=o=>o,{forceUpdate:s=!1}={}){return r.__classPrivateFieldSet(this,ie,r.__classPrivateFieldGet(this,ie,"f")+1,"f"),r.__classPrivateFieldGet(this,X,"f")[r.__classPrivateFieldGet(this,ie,"f")]={cb:e,selector:t,forceUpdate:s},r.__classPrivateFieldGet(this,ie,"f").toString()}unsubscribe(e){const t=!!r.__classPrivateFieldGet(this,X,"f")[e];return t&&delete r.__classPrivateFieldGet(this,X,"f")[e],t}unsubscribeAll(){return r.__classPrivateFieldSet(this,X,{},"f"),!0}}D=new WeakMap,X=new WeakMap,ie=new WeakMap,de=new WeakMap;const or=["*","#","/","(",")","[","]","_","<",">","`"],nr=i=>{const e=or.map(t=>`${i}${t}`).join("|");return new RegExp(`(${e})`,"g")},ar=i=>typeof i!="string"?i:i.replace(nr("\\"),"\\$1"),lr=["disabled"],cr=(i,e,t="")=>{i.querySelectorAll(`[${Ue}="${e}"]`).forEach(s=>{s.textContent=t,s.classList[t?"remove":"add"]("hide")})},Ct=(i,e)=>{Object.entries(e||{}).forEach(([t,s])=>{Array.from(i.querySelectorAll(`*[name="${t}"]:not([${st}])`)).forEach(o=>{o.value=s})})},Pt=(i,e)=>e.split(".").reduce((t,s)=>(t==null?void 0:t[s])||"",i),We=(i,e,t)=>i.replace(/{{(.+?)}}/g,(s,o)=>t?ar(Pt(e,o)):Pt(e,o)),Ft=(i,e,t)=>{i.querySelectorAll(`[${Ue}="${e}"]`).forEach(s=>{s.setAttribute("href",t)})},dr=(i,e,t,s)=>{t&&Object.keys(t).forEach(o=>{if(!e.querySelector(o))return void s.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const n=customElements.get(o);n?Object.keys(t[o]).forEach(a=>{var l;const d=t[o],u=(l=n==null?void 0:n.cssVarList)===null||l===void 0?void 0:l[a];if(!u)return void s.info(`Could not find css variable name for ${a} in ${o}`,"Check if the css variable is defined in the component");const c=d[a];i.style.setProperty(u,c)}):s.debug(`Could not find component class for ${o}`,"Check if the component is registered")})},ci=(i,e,t)=>{var s,o;const n=(s=customElements.get(e))===null||s===void 0?void 0:s.cssVarList.url;t&&n&&((o=i==null?void 0:i.style)===null||o===void 0||o.setProperty(n,`url(data:image/jpg;base64,${t})`))},ur=(i,e,t,s)=>{var o,n;Ft(i,"totp-link",(o=e==null?void 0:e.totp)===null||o===void 0?void 0:o.provisionUrl),Ft(i,"notp-link",(n=e==null?void 0:e.notp)===null||n===void 0?void 0:n.redirectUrl),((a,l)=>{a.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach(d=>{const u=tr(d.localName);d.textContent=We(d.textContent,l,u);const c=d.getAttribute("href");c&&d.setAttribute("href",We(c,l))})})(i,e),((a,l,d)=>{if(!l)return;const{componentsDynamicAttrs:u}=l,c=r.__rest(l,["componentsDynamicAttrs"]),h=Object.keys(c).reduce((p,f)=>(p[`[name=${f}]`]=c[f],p),{});u&&Object.keys(u).forEach(p=>{const f=u[p];if(f){const{attributes:m}=f;m&&Object.keys(m).length&&(h[p]=m)}}),Object.keys(h).forEach(p=>{a.querySelectorAll(p).forEach(f=>{const m=h[p];Object.keys(m).forEach(S=>{let w=m[S];if(typeof w!="string")try{w=JSON.stringify(w)}catch(g){d.error(`Could not stringify value "${w}" for "${S}"`,g.message),w=""}f.setAttribute(S,w)})})})})(i,e==null?void 0:e.componentsConfig,s),((a,l)=>{a.querySelectorAll(`[${ss}]`).forEach(d=>{Array.from(d.attributes).forEach(u=>{u.value=We(u.value,l)})})})(i,e),((a,l)=>{Object.entries(l).forEach(([d,u])=>{a.querySelectorAll(`[name="${d}"]`).forEach(c=>{Object.entries(u).forEach(([h,p])=>{lr.includes(h)&&c.setAttribute(h,p)})})})})(i,t),((a,l={},d)=>{Object.entries(l).forEach(([u,c])=>{a.querySelectorAll(`[id="${CSS.escape(u)}"]`).forEach(h=>{switch(c){case"disable":h.setAttribute("disabled","true");break;case"hide":h.classList.add("hidden");break;default:d==null||d.error(`Unknown component state "${c}" for component with id "${u}"`,'Valid states are "disable" and "hide"')}})})})(i,e==null?void 0:e.componentsState,s)},hr=(i,e)=>{Ct(i,e==null?void 0:e.inputs),Ct(i,e==null?void 0:e.form)},pr=(i,e)=>{ci(i,"descope-totp-image",e)},gr=(i,e)=>{ci(i,"descope-notp-image",e)},vr=(i,e)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach(([t,s])=>{Array.from(i.querySelectorAll(`[${t}="${s}"]`)).forEach(o=>{o.setAttribute(t,e||s)})})},fr=(i,e)=>{Object.entries({lang:"autoDetect"}).forEach(([t,s])=>{Array.from(i.querySelectorAll(`[${t}="${s}"]`)).forEach(o=>{o.setAttribute(t,e||s)})})},mr=i=>{i.querySelectorAll(`descope-button[${Ue}="biometrics"]`).forEach(e=>e.setAttribute("disabled","true"))},_r=ni(()=>r.__awaiter(void 0,void 0,void 0,function*(){var i,e;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const t=Promise.all([(i=window.PublicKeyCredential)===null||i===void 0?void 0:i.isConditionalMediationAvailable(),(e=window.PublicKeyCredential)===null||e===void 0?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then(o=>o.every(n=>!!n)),s=Ys()>=108;return yield rt(100,t,s)}catch(t){return console.error("Conditional login check failed",t),!1}}));let fe;const di=(i,e)=>{fe?fe.setItem(i,e):(window==null?void 0:window.localStorage)!==void 0&&window.localStorage.setItem(i,e)},ui=i=>fe?fe.getItem(i):(window==null?void 0:window.localStorage)!==void 0?window.localStorage.getItem(i):null,br=i=>{fe=i},kt="dls_ab_testing_id",wr=()=>{const i=ui(kt);if(!i){const e=Math.floor(100*Math.random()+1);return di(kt,e.toString()),e}return Number(i)},hi={"lastAuth.loginId":{"not-empty":i=>{var e;return!!i.loginId||!!(!((e=i.lastAuth)===null||e===void 0)&&e.loginId)},empty:i=>{var e;return!i.loginId&&!(!((e=i.lastAuth)===null||e===void 0)&&e.loginId)}},idpInitiated:{"is-true":i=>!!i.code,"is-false":i=>!i.code},externalToken:{"is-true":i=>!!i.token,"is-false":i=>!i.token},abTestingKey:{"greater-than":(i,e)=>(i.abTestingKey||0)>e,"less-than":(i,e)=>(i.abTestingKey||0)<e,"greater-than-or-equal":(i,e)=>(i.abTestingKey||0)>=e,"less-than-or-equal":(i,e)=>(i.abTestingKey||0)<=e,"in-range":(i,e)=>{const[t,s]=e?e.split(",").map(Number):[void 0,void 0];return(i.abTestingKey||0)>=(t??0)&&(i.abTestingKey||0)<=(s??0)},"not-in-range":(i,e)=>{const[t,s]=e?e.split(",").map(Number):[void 0,void 0];return!(t!==void 0&&s!==void 0&&!Number.isNaN(t)&&!Number.isNaN(s))||(i.abTestingKey||0)<t||(i.abTestingKey||0)>s},"devised-by":(i,e)=>{const t=Number(e);return!Number.isNaN(t)&&(i.abTestingKey||0)%t==0}}},yr=(i,e)=>{var t;const s=(t=hi[i==null?void 0:i.key])===null||t===void 0?void 0:t[i.operator];if(!s)return{};const o=s(e,i.predicate)?i.met:i.unmet;return{startScreenId:o==null?void 0:o.screenId,startScreenName:o==null?void 0:o.screenName,conditionInteractionId:o==null?void 0:o.interactionId}},Sr=(i,e)=>{const t=e==null?void 0:e.find(({key:s,operator:o,predicate:n})=>{var a;if(s==="ELSE")return!0;const l=(a=hi[s])===null||a===void 0?void 0:a[o];return!!(l!=null&&l(i,n))});return t?{startScreenId:t.met.screenId,startScreenName:t.met.screenName,conditionInteractionId:t.met.interactionId,clientScripts:t.met.clientScripts,componentsConfig:t.met.componentsConfig}:{}};function Pe(i){const e={};try{Object.assign(e,JSON.parse(ui(Vt)))}catch{}return e!=null&&e.loginId||i?e:{}}function Et(i,e){i!=null&&i.authMethod&&(e&&!(i!=null&&i.loginId)||di(Vt,JSON.stringify(i)))}const Cr=["error","warn","info","debug"],At={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},me=r.h(i=>{var e,t,s,o;return o=class extends i{constructor(){super(...arguments),e.add(this),t.set(this,r.__classPrivateFieldGet(this,e,"m",s).call(this,At))}set logger(a){r.__classPrivateFieldSet(this,t,r.__classPrivateFieldGet(this,e,"m",s).call(this,a||At),"f")}get logger(){return r.__classPrivateFieldGet(this,t,"f")}onLogEvent(a,l){}},t=new WeakMap,e=new WeakSet,s=function(a){return Cr.reduce((l,d)=>(l[d]=(...u)=>{var c;this.onLogEvent(d,u),(c=a[d])===null||c===void 0||c.call(a,...u)},l),{})},o}),pi=typeof localStorage<"u",Pr="base.content.url",ke="https://static.descope.com/pages",xt="https://static2.descope.com/pages",Fr=pi&&localStorage.getItem(Pr)||"",kr="v2-beta",ot=(i,e)=>!e&&`${i} cannot be empty, please make sure to set this attribute`,_e=r.h(i=>{var e,t;return t=class extends i{constructor(){super(...arguments),e.set(this,!0)}connectedCallback(){var o,n;(o=super.connectedCallback)===null||o===void 0||o.call(this),!((n=this.shadowRoot)===null||n===void 0)&&n.isConnected&&r.__classPrivateFieldGet(this,e,"f")&&(r.__classPrivateFieldSet(this,e,!1,"f"),this.init())}async init(){}},e=new WeakMap,t}),Er=(i,e)=>{Array.from(i.attributes).forEach(s=>e(s.name)),new MutationObserver(s=>{s.forEach(o=>{o.type==="attributes"&&e(o.attributeName)})}).observe(i,{attributes:!0})},nt=r.h(i=>{var e,t;const s=r.r(me,_e)(i);return t=class extends s{constructor(){super(...arguments),e.set(this,{})}async init(){var n;await((n=super.init)===null||n===void 0?void 0:n.call(this)),Er(this,a=>{var l;(l=r.__classPrivateFieldGet(this,e,"f")[a])===null||l===void 0||l.forEach(d=>{d(a,this.getAttribute(a))})})}observeAttribute(n,a){r.__classPrivateFieldGet(this,e,"f")[n]||(r.__classPrivateFieldGet(this,e,"f")[n]=[]);const l=r.__classPrivateFieldGet(this,e,"f")[n].push(a);return()=>r.__classPrivateFieldGet(this,e,"f")[n].splice(l,1)}observeAttributes(n,a){const l=n.reduce((d,u)=>(d.push(this.observeAttribute(u,a)),d),[]);return()=>l.forEach(d=>d())}},e=new WeakMap,t}),je=i=>e=>{var t,s,o;const n=r.r(me,_e,nt)(e),a=Object.keys(i);return o=class extends n{constructor(...d){super(...d),t.add(this),this.observeAttributes(a,r.__classPrivateFieldGet(this,t,"m",s).bind(this))}async init(){var d;a.forEach(u=>r.__classPrivateFieldGet(this,t,"m",s).call(this,u,this.getAttribute(u))),await((d=super.init)===null||d===void 0?void 0:d.call(this))}},t=new WeakSet,s=function(d,u){const c=i[d],h=typeof c=="function"?c(d,u):c;h&&this.logger.error(h)},o};je.missingAttrValidator=ot;const Ar=r.h(i=>{const e=r.r(je({"project-id":ot}))(i);return class extends e{get projectId(){return this.getAttribute("project-id")}}}),xr=r.h(i=>class extends i{get baseUrl(){return this.getAttribute("base-url")||""}}),It="Trying the next fallback URL...",Ir=async(i,e,{logger:t}={})=>{try{return await fetch(i,e)}catch(s){return t==null||t.debug(`Network error fetching URL ${i} [${s.message}], retrying...`),fetch(i,e)}},$r=async(i,e,{logger:t,onSuccess:s}={})=>{const o=Array.isArray(i)?i:[i];for(let n=0;n<o.length;n++){const a=o[n],l=n===o.length-1;try{const d=await Ir(a.toString(),e,{logger:t});if(d.ok)return s==null||s(n),t==null||t.debug(`Successfully fetched URL ${a}`),d;const u=`Error fetching URL ${a} [${d.status}]`;if(l)throw new Error(u);t==null||t.debug(`${u}. ${It}`)}catch(d){const u=`Error fetching URL ${a} [${d.message}]`;if(l)throw new Error(u);t==null||t.debug(`${u}. ${It}`)}}};function Or({projectId:i,filename:e,assetsFolder:t=kr,baseUrl:s=ke}){const o=new URL(s);return o.pathname=r.s(o.pathname,i,t,e),o.baseUrl=s,o}const at=r.h(i=>{var e,t,s,o,n,a,l;const d=r.r(me,Ar,xr)(i);return l=class extends d{constructor(){super(...arguments),e.add(this),t.set(this,void 0),s.set(this,void 0),o.set(this,new Set)}async fetchStaticResource(c,h){const p=r.__classPrivateFieldGet(this,e,"m",n).call(this,c),f=Array.isArray(p)?m=>{const{baseUrl:S}=p[m];r.__classPrivateFieldSet(this,s,S,"f");for(let w=0;w<m;w++){const g=p[w].baseUrl;r.__classPrivateFieldGet(this,o,"f").add(g)}}:null;try{const m=await $r(p,{cache:"default"},{logger:this.logger,onSuccess:f});return{body:await m[h](),headers:Object.fromEntries(m.headers.entries())}}catch(m){this.logger.error(m.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},t=new WeakMap,s=new WeakMap,o=new WeakMap,e=new WeakSet,n=function(c){const h=Fr||this.baseStaticUrl;if(h)return r.__classPrivateFieldGet(this,e,"m",a).call(this,c,h);r.__classPrivateFieldGet(this,t,"f")!==this.baseUrl&&(r.__classPrivateFieldSet(this,t,this.baseUrl,"f"),r.__classPrivateFieldSet(this,s,void 0,"f"),r.__classPrivateFieldGet(this,o,"f").clear());const p=[];if(r.__classPrivateFieldGet(this,s,"f"))p.push(r.__classPrivateFieldGet(this,e,"m",a).call(this,c,r.__classPrivateFieldGet(this,s,"f"))),r.__classPrivateFieldGet(this,s,"f")===ke&&p.push(r.__classPrivateFieldGet(this,e,"m",a).call(this,c,xt));else{const f=this.baseUrl+"/pages";this.baseUrl&&!r.__classPrivateFieldGet(this,o,"f").has(f)&&p.push(r.__classPrivateFieldGet(this,e,"m",a).call(this,c,f)),r.__classPrivateFieldGet(this,o,"f").has(ke)||p.push(r.__classPrivateFieldGet(this,e,"m",a).call(this,c,ke)),p.push(r.__classPrivateFieldGet(this,e,"m",a).call(this,c,xt))}return p.length===1?p[0]:p},a=function(c,h){return Or({projectId:this.projectId,filename:c,baseUrl:h})},l}),Gr="config.json",Mr=r.h(i=>{var e,t;const s=r.r(je({"project-id":ot}))(i);return t=class extends s{constructor(){super(...arguments),e.set(this,new Map)}onReset(n,a){if(r.__classPrivateFieldGet(this,e,"f").has(n))throw new Error(`Callback for sectionId ${n} already exists`);return r.__classPrivateFieldGet(this,e,"f").set(n,a),()=>{r.__classPrivateFieldGet(this,e,"f").delete(n)}}async reset(...n){n.length===0?await Promise.all(Array.from(r.__classPrivateFieldGet(this,e,"f").values()).map(a=>a())):await Promise.all(n.map(a=>{var l;if(!r.__classPrivateFieldGet(this,e,"f").has(a))throw new Error(`Callback for sectionId ${a} does not exist`);return(l=r.__classPrivateFieldGet(this,e,"f").get(a))===null||l===void 0?void 0:l()}))}},e=new WeakMap,t}),gi=r.h(i=>{var e,t,s,o,n;const a=r.r(at,Mr,_e)(i);return n=class extends a{constructor(){super(...arguments),e.add(this),s.set(this,void 0),o.set(this,async()=>{try{const{body:d,headers:u}=await this.fetchStaticResource(Gr,"json");return{projectConfig:d,executionContext:{geo:u["x-geo"]}}}catch{this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}})}async init(){await super.init(),this.onReset("config",r.__classPrivateFieldGet(this,e,"m",t).bind(this))}get config(){return r.__classPrivateFieldGet(this,s,"f")||r.__classPrivateFieldSet(this,s,r.__classPrivateFieldGet(this,o,"f").call(this),"f"),r.__classPrivateFieldGet(this,s,"f")}},s=new WeakMap,o=new WeakMap,e=new WeakSet,t=function(){r.__classPrivateFieldSet(this,s,void 0,"f")},n}),Ur=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],jr=i=>document.querySelector(`script#${i}`),Rr=i=>i.getAttribute("status")==="loaded",Tr=i=>i.getAttribute("status")==="error",Lr=i=>{let e=0;const t=i.toString();for(let s=0;s<t.length;s++){const o=t.charCodeAt(s);e=(e<<5)-e+o,e=e&e}return`${Math.abs(e).toString()}`},Wr=(i,e)=>{const t=document.createElement("script");return t.id=i,e&&(t.integrity=e,t.crossOrigin="anonymous"),window.DESCOPE_NONCE&&t.setAttribute("nonce",window.DESCOPE_NONCE),t},Nr=(i,e,t)=>new Promise((s,o)=>{const n=Wr(i,t);n.onerror=a=>{n.setAttribute("status","error"),o(a)},n.onload=()=>{n.setAttribute("status","loaded"),s(n)},n.src=e.toString(),document.body.appendChild(n)}),Dr=(i,e)=>{if(e){const t=i.integrity;if(t!==e)return Promise.reject(new Error(`Integrity mismatch: expected ${e}, found ${t}`))}return Rr(i)?Promise.resolve(i):Tr(i)?Promise.reject():new Promise((t,s)=>{i.addEventListener("load",()=>{t(i)}),i.addEventListener("error",o=>{s(o)})})},Vr=async(i,e)=>{for(const t of i){const{id:s,url:o,integrity:n}=t,a=jr(s);if(a)try{return await Dr(a,n),t}catch{e(t,!0)}else try{return await Nr(s,o,n),t}catch{e(t,!1)}}throw new Error("All scripts failed to load")},qr=(i,e,t,s="",o)=>i.reduce((n,a)=>{const l=a;if(!l)return n;let d;try{d=new URL(l)}catch{throw new Error(`Invalid URL: ${l}`)}d.pathname!=="/"||(d.pathname=`/npm/${e}@${t}/${s}`);const c={url:d,id:`npmlib-${e.replaceAll("@","").replaceAll("/","_")}-${Lr(d)}`};return o&&(c.integrity=o),[...n,c]},[]),Br=r.h(i=>{const e=r.r(me)(i);return class extends e{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(s,o,n="",a=[],l){return this.logger.debug(`Injecting npm lib: "${s}" with version: "${o}"${l?" with SRI integrity check":""}`),Vr(qr([...a,this.baseCdnUrl,...Ur],s,o,n,l),(d,u)=>{if(u){this.logger.error(`Existing script cannot be loaded: "${d.url}"`);return}this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${d.url}"`)})}}}),Kr=i=>[...Array.from(i.content.querySelectorAll("*")).reduce((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e,new Set)],lt="base.ui.components.url",Hr=pi&&localStorage.getItem(lt),Jr="dist/umd/index.js",zr="@descope/web-components-ui",Yr=r.h(i=>{var e,t,s,o,n,a,l;const d=r.r(me,gi,Br)(i);return l=class extends d{constructor(){super(...arguments),e.add(this),o.set(this,void 0)}get descopeUi(){return r.__classPrivateFieldGet(this,o,"f")||r.__classPrivateFieldSet(this,o,r.__classPrivateFieldGet(this,e,"m",a).call(this),"f"),r.__classPrivateFieldGet(this,o,"f")}async loadDescopeUiComponents(c){const h=Array.isArray(c)?c:Kr(c);return Promise.all(h.map(p=>r.__classPrivateFieldGet(this,e,"m",n).call(this,p)))}},o=new WeakMap,e=new WeakSet,t=async function(){var c;const h=await this.config,p=(c=h==null?void 0:h.projectConfig)===null||c===void 0?void 0:c.componentsVersion;return p?this.logger.debug(`Got component version "${p}"`):this.logger.error("Could not get components version"),p},s=async function(){var c;const h=await this.config,p=(c=h==null?void 0:h.projectConfig)===null||c===void 0?void 0:c.componentsVersionSri;return p&&this.logger.debug("SRI hash available for components"),p},n=async function(c){if(!!customElements.get(c)){this.logger.debug(`Loading component "${c}" is skipped as it is already defined`);return}const p=await this.descopeUi;if(!p[c]){this.logger.error(`Cannot load UI component "${c}"`,`Descope UI does not have a component named "${c}", available components are: "${Object.keys(p).join(", ")}"`);return}try{return await p[c]()}catch(f){if(f.name==="NotSupportedError")console.debug(`Encountered an error while attempting to define the "${c}" component, it is likely that this component is already defined`);else throw f}},a=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const c=await r.__classPrivateFieldGet(this,e,"m",t).call(this),h=await r.__classPrivateFieldGet(this,e,"m",s).call(this);return await this.injectNpmLib(zr,c,Jr,[Hr],h),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(c){throw this.logger.error(c),new Error("DescopeUI was not loaded")}},l}),Qr=r.h(i=>{var e,t,s;const o=r.r(_e,nt)(i);return s=class extends o{constructor(){super(...arguments),e.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var a;await((a=super.init)===null||a===void 0?void 0:a.call(this)),this.observeAttribute("nonce",r.__classPrivateFieldGet(this,e,"m",t).bind(this)),r.__classPrivateFieldGet(this,e,"m",t).call(this)}},e=new WeakSet,t=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},s});class Xr{constructor(e,t,{prepend:s=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(s?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return(e=this.styleEle.sheet)===null||e===void 0?void 0:e.cssRules}}const Re=r.h(i=>{const e=r.r(Qr)(i);return class extends e{injectStyle(s,{prepend:o=!1}={}){let n;try{n=new CSSStyleSheet}catch{n=new Xr(this.shadowRoot,this.nonce,{prepend:o})}if(s&&n.replaceSync(s),n instanceof CSSStyleSheet){const a=this.shadowRoot;if(a&&"adoptedStyleSheets"in a){const l=[...a.adoptedStyleSheets||[]];l[o?"unshift":"push"](n),a.adoptedStyleSheets=l}}return n}}}),Ne="content-root",Fe="root",Zr=r.h(i=>{const e=r.r(Re)(i);return class extends e{constructor(...s){var o,n;super(...s),this.attachShadow({mode:"open"}).innerHTML=`
5
+ `,document.body.appendChild(o),s(o)},Xs=i=>i==null?void 0:i.submit(),yt=(i,e)=>{const t=e.find(s=>i[s]);return t?i[t]:null},Zs=(i,e=100)=>{let t;return function(...s){t||i.apply(this,s),clearTimeout(t),t=setTimeout(()=>{t=null},e)}};function Ce(i){if(i)return{locale:i.toLowerCase(),fallback:i.toLowerCase()};const e=navigator.language;return e?e.includes("-")?{locale:e.toLowerCase(),fallback:e.split("-")[0].toLowerCase()}:{locale:e.toLowerCase(),fallback:e.toLowerCase()}:{locale:"",fallback:""}}const er=()=>{document.querySelectorAll('[data-hidden-input="true"]').forEach(i=>i.remove())},tr=i=>ns.includes(i),ir=i=>{var e,t,s;const o=(n=i.screenState,a=(u,c)=>os.includes(c)||c.startsWith("_"),Object.fromEntries(Object.entries(n).filter(([u,c])=>!a(c,u))));var n,a;const{screenState:{errorText:l,errorType:d}}=i;return(l||d)&&(o.error={text:l,type:d}),i.action&&(o.action=i.action),!((s=(t=(e=i.screenState)===null||e===void 0?void 0:e.componentsConfig)===null||t===void 0?void 0:t.thirdPartyAppApproveScopes)===null||s===void 0)&&s.data&&(o.inboundAppApproveScopes=i.screenState.componentsConfig.thirdPartyAppApproveScopes.data),o},St=i=>{const e=Object.assign({},i);return i.inboundAppApproveScopes&&(e.thirdPartyAppApproveScopes=i.inboundAppApproveScopes),e};function sr(i,e){return`${is}.${e?`${i}_${e}`:i}`}const rr=(i,e,t,s)=>{const o=window.screenLeft!==void 0?window.screenLeft:window.screen.left,n=window.screenTop!==void 0?window.screenTop:window.screen.top,a=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-t)/2+o,l=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-s)/2+n,d=function(){const c=navigator.userAgent||"",h=/\b(iPhone)\b/.test(c),p=/Safari/.test(c)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(c);return h&&p}()?"about:blank":"",u=window.open(d,e,`width=${t},height=${s},top=${l},left=${a},scrollbars=yes,resizable=yes`);return u.location.href=i,u.focus(),u};var D,X,ie,de;function li(i,e){const t=Object.getOwnPropertyNames(i),s=Object.getOwnPropertyNames(e);if(t.length!==s.length)return!1;for(let o=0;o<t.length;o+=1){const n=t[o],a=i[n],l=e[n];if(a===null||l===null){if(a!==l)return!1}else if(typeof a=="object"&&typeof l=="object"){if(!li(a,l))return!1}else if(a!==l)return!1}return!0}class ne{constructor(e={},{forceUpdate:t=!1}={}){D.set(this,void 0),X.set(this,{}),ie.set(this,0),de.set(this,!0),this.update=s=>{const o=typeof s=="function"?s(r.__classPrivateFieldGet(this,D,"f")):s,n=Object.assign(Object.assign({},r.__classPrivateFieldGet(this,D,"f")),o),a=r.__classPrivateFieldGet(this,D,"f");r.__classPrivateFieldSet(this,D,n,"f"),Object.freeze(r.__classPrivateFieldGet(this,D,"f")),setTimeout(()=>{Object.values(r.__classPrivateFieldGet(this,X,"f")).forEach(({cb:l,selector:d,forceUpdate:u})=>{const c=d(a),h=d(n);(r.__classPrivateFieldGet(this,de,"f")||u||(function(p){if(typeof p!="object"||p===null)return!1;const f=Object.getPrototypeOf(p);return f===Object.prototype||f===null}(h)?!li(c,h):c!==h))&&l(h,c,Bs(h,c))})},0)},r.__classPrivateFieldSet(this,D,e,"f"),r.__classPrivateFieldSet(this,de,t,"f")}get current(){return Object.assign({},r.__classPrivateFieldGet(this,D,"f"))}set forceUpdate(e){r.__classPrivateFieldSet(this,de,e,"f")}subscribe(e,t=o=>o,{forceUpdate:s=!1}={}){return r.__classPrivateFieldSet(this,ie,r.__classPrivateFieldGet(this,ie,"f")+1,"f"),r.__classPrivateFieldGet(this,X,"f")[r.__classPrivateFieldGet(this,ie,"f")]={cb:e,selector:t,forceUpdate:s},r.__classPrivateFieldGet(this,ie,"f").toString()}unsubscribe(e){const t=!!r.__classPrivateFieldGet(this,X,"f")[e];return t&&delete r.__classPrivateFieldGet(this,X,"f")[e],t}unsubscribeAll(){return r.__classPrivateFieldSet(this,X,{},"f"),!0}}D=new WeakMap,X=new WeakMap,ie=new WeakMap,de=new WeakMap;const or=["*","#","/","(",")","[","]","_","<",">","`"],nr=i=>{const e=or.map(t=>`${i}${t}`).join("|");return new RegExp(`(${e})`,"g")},ar=i=>typeof i!="string"?i:i.replace(nr("\\"),"\\$1"),lr=["disabled"],cr=(i,e,t="")=>{i.querySelectorAll(`[${Ue}="${e}"]`).forEach(s=>{s.textContent=t,s.classList[t?"remove":"add"]("hide")})},Ct=(i,e)=>{Object.entries(e||{}).forEach(([t,s])=>{Array.from(i.querySelectorAll(`*[name="${t}"]:not([${st}])`)).forEach(o=>{o.value=s})})},Pt=(i,e)=>e.split(".").reduce((t,s)=>(t==null?void 0:t[s])||"",i),We=(i,e,t)=>i.replace(/{{(.+?)}}/g,(s,o)=>t?ar(Pt(e,o)):Pt(e,o)),Ft=(i,e,t)=>{i.querySelectorAll(`[${Ue}="${e}"]`).forEach(s=>{s.setAttribute("href",t)})},dr=(i,e,t,s)=>{t&&Object.keys(t).forEach(o=>{if(!e.querySelector(o))return void s.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const n=customElements.get(o);n?Object.keys(t[o]).forEach(a=>{var l;const d=t[o],u=(l=n==null?void 0:n.cssVarList)===null||l===void 0?void 0:l[a];if(!u)return void s.info(`Could not find css variable name for ${a} in ${o}`,"Check if the css variable is defined in the component");const c=d[a];i.style.setProperty(u,c)}):s.debug(`Could not find component class for ${o}`,"Check if the component is registered")})},ci=(i,e,t)=>{var s,o;const n=(s=customElements.get(e))===null||s===void 0?void 0:s.cssVarList.url;t&&n&&((o=i==null?void 0:i.style)===null||o===void 0||o.setProperty(n,`url(data:image/jpg;base64,${t})`))},ur=(i,e,t,s)=>{var o,n;Ft(i,"totp-link",(o=e==null?void 0:e.totp)===null||o===void 0?void 0:o.provisionUrl),Ft(i,"notp-link",(n=e==null?void 0:e.notp)===null||n===void 0?void 0:n.redirectUrl),((a,l)=>{a.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach(d=>{const u=tr(d.localName);d.textContent=We(d.textContent,l,u);const c=d.getAttribute("href");c&&d.setAttribute("href",We(c,l))})})(i,e),((a,l,d)=>{if(!l)return;const{componentsDynamicAttrs:u}=l,c=r.__rest(l,["componentsDynamicAttrs"]),h=Object.keys(c).reduce((p,f)=>(p[`[name=${f}]`]=c[f],p),{});u&&Object.keys(u).forEach(p=>{const f=u[p];if(f){const{attributes:m}=f;m&&Object.keys(m).length&&(h[p]=m)}}),Object.keys(h).forEach(p=>{a.querySelectorAll(p).forEach(f=>{const m=h[p];Object.keys(m).forEach(S=>{let w=m[S];if(typeof w!="string")try{w=JSON.stringify(w)}catch(g){d.error(`Could not stringify value "${w}" for "${S}"`,g.message),w=""}f.setAttribute(S,w)})})})})(i,e==null?void 0:e.componentsConfig,s),((a,l)=>{a.querySelectorAll(`[${ss}]`).forEach(d=>{Array.from(d.attributes).forEach(u=>{u.value=We(u.value,l)})})})(i,e),((a,l)=>{Object.entries(l).forEach(([d,u])=>{a.querySelectorAll(`[name="${d}"]`).forEach(c=>{Object.entries(u).forEach(([h,p])=>{lr.includes(h)&&c.setAttribute(h,p)})})})})(i,t),((a,l={},d)=>{Object.entries(l).forEach(([u,c])=>{a.querySelectorAll(`[id="${CSS.escape(u)}"]`).forEach(h=>{switch(c){case"disable":h.setAttribute("disabled","true");break;case"hide":h.classList.add("hidden");break;default:d==null||d.error(`Unknown component state "${c}" for component with id "${u}"`,'Valid states are "disable" and "hide"')}})})})(i,e==null?void 0:e.componentsState,s)},hr=(i,e)=>{Ct(i,e==null?void 0:e.inputs),Ct(i,e==null?void 0:e.form)},pr=(i,e)=>{ci(i,"descope-totp-image",e)},gr=(i,e)=>{ci(i,"descope-notp-image",e)},vr=(i,e)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach(([t,s])=>{Array.from(i.querySelectorAll(`[${t}="${s}"]`)).forEach(o=>{o.setAttribute(t,e||s)})})},fr=(i,e)=>{let t=e;if(e)try{const[s]=Intl.getCanonicalLocales(e);s&&(t=s)}catch{}Object.entries({lang:"autoDetect"}).forEach(([s,o])=>{Array.from(i.querySelectorAll(`[${s}="${o}"]`)).forEach(n=>{n.setAttribute(s,t||o)})})},mr=i=>{i.querySelectorAll(`descope-button[${Ue}="biometrics"]`).forEach(e=>e.setAttribute("disabled","true"))},_r=ni(()=>r.__awaiter(void 0,void 0,void 0,function*(){var i,e;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const t=Promise.all([(i=window.PublicKeyCredential)===null||i===void 0?void 0:i.isConditionalMediationAvailable(),(e=window.PublicKeyCredential)===null||e===void 0?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then(o=>o.every(n=>!!n)),s=Ys()>=108;return yield rt(100,t,s)}catch(t){return console.error("Conditional login check failed",t),!1}}));let fe;const di=(i,e)=>{fe?fe.setItem(i,e):(window==null?void 0:window.localStorage)!==void 0&&window.localStorage.setItem(i,e)},ui=i=>fe?fe.getItem(i):(window==null?void 0:window.localStorage)!==void 0?window.localStorage.getItem(i):null,br=i=>{fe=i},kt="dls_ab_testing_id",wr=()=>{const i=ui(kt);if(!i){const e=Math.floor(100*Math.random()+1);return di(kt,e.toString()),e}return Number(i)},hi={"lastAuth.loginId":{"not-empty":i=>{var e;return!!i.loginId||!!(!((e=i.lastAuth)===null||e===void 0)&&e.loginId)},empty:i=>{var e;return!i.loginId&&!(!((e=i.lastAuth)===null||e===void 0)&&e.loginId)}},idpInitiated:{"is-true":i=>!!i.code,"is-false":i=>!i.code},externalToken:{"is-true":i=>!!i.token,"is-false":i=>!i.token},abTestingKey:{"greater-than":(i,e)=>(i.abTestingKey||0)>e,"less-than":(i,e)=>(i.abTestingKey||0)<e,"greater-than-or-equal":(i,e)=>(i.abTestingKey||0)>=e,"less-than-or-equal":(i,e)=>(i.abTestingKey||0)<=e,"in-range":(i,e)=>{const[t,s]=e?e.split(",").map(Number):[void 0,void 0];return(i.abTestingKey||0)>=(t??0)&&(i.abTestingKey||0)<=(s??0)},"not-in-range":(i,e)=>{const[t,s]=e?e.split(",").map(Number):[void 0,void 0];return!(t!==void 0&&s!==void 0&&!Number.isNaN(t)&&!Number.isNaN(s))||(i.abTestingKey||0)<t||(i.abTestingKey||0)>s},"devised-by":(i,e)=>{const t=Number(e);return!Number.isNaN(t)&&(i.abTestingKey||0)%t==0}}},yr=(i,e)=>{var t;const s=(t=hi[i==null?void 0:i.key])===null||t===void 0?void 0:t[i.operator];if(!s)return{};const o=s(e,i.predicate)?i.met:i.unmet;return{startScreenId:o==null?void 0:o.screenId,startScreenName:o==null?void 0:o.screenName,conditionInteractionId:o==null?void 0:o.interactionId}},Sr=(i,e)=>{const t=e==null?void 0:e.find(({key:s,operator:o,predicate:n})=>{var a;if(s==="ELSE")return!0;const l=(a=hi[s])===null||a===void 0?void 0:a[o];return!!(l!=null&&l(i,n))});return t?{startScreenId:t.met.screenId,startScreenName:t.met.screenName,conditionInteractionId:t.met.interactionId,clientScripts:t.met.clientScripts,componentsConfig:t.met.componentsConfig}:{}};function Pe(i){const e={};try{Object.assign(e,JSON.parse(ui(Vt)))}catch{}return e!=null&&e.loginId||i?e:{}}function Et(i,e){i!=null&&i.authMethod&&(e&&!(i!=null&&i.loginId)||di(Vt,JSON.stringify(i)))}const Cr=["error","warn","info","debug"],At={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},me=r.h(i=>{var e,t,s,o;return o=class extends i{constructor(){super(...arguments),e.add(this),t.set(this,r.__classPrivateFieldGet(this,e,"m",s).call(this,At))}set logger(a){r.__classPrivateFieldSet(this,t,r.__classPrivateFieldGet(this,e,"m",s).call(this,a||At),"f")}get logger(){return r.__classPrivateFieldGet(this,t,"f")}onLogEvent(a,l){}},t=new WeakMap,e=new WeakSet,s=function(a){return Cr.reduce((l,d)=>(l[d]=(...u)=>{var c;this.onLogEvent(d,u),(c=a[d])===null||c===void 0||c.call(a,...u)},l),{})},o}),pi=typeof localStorage<"u",Pr="base.content.url",ke="https://static.descope.com/pages",xt="https://static2.descope.com/pages",Fr=pi&&localStorage.getItem(Pr)||"",kr="v2-beta",ot=(i,e)=>!e&&`${i} cannot be empty, please make sure to set this attribute`,_e=r.h(i=>{var e,t;return t=class extends i{constructor(){super(...arguments),e.set(this,!0)}connectedCallback(){var o,n;(o=super.connectedCallback)===null||o===void 0||o.call(this),!((n=this.shadowRoot)===null||n===void 0)&&n.isConnected&&r.__classPrivateFieldGet(this,e,"f")&&(r.__classPrivateFieldSet(this,e,!1,"f"),this.init())}async init(){}},e=new WeakMap,t}),Er=(i,e)=>{Array.from(i.attributes).forEach(s=>e(s.name)),new MutationObserver(s=>{s.forEach(o=>{o.type==="attributes"&&e(o.attributeName)})}).observe(i,{attributes:!0})},nt=r.h(i=>{var e,t;const s=r.r(me,_e)(i);return t=class extends s{constructor(){super(...arguments),e.set(this,{})}async init(){var n;await((n=super.init)===null||n===void 0?void 0:n.call(this)),Er(this,a=>{var l;(l=r.__classPrivateFieldGet(this,e,"f")[a])===null||l===void 0||l.forEach(d=>{d(a,this.getAttribute(a))})})}observeAttribute(n,a){r.__classPrivateFieldGet(this,e,"f")[n]||(r.__classPrivateFieldGet(this,e,"f")[n]=[]);const l=r.__classPrivateFieldGet(this,e,"f")[n].push(a);return()=>r.__classPrivateFieldGet(this,e,"f")[n].splice(l,1)}observeAttributes(n,a){const l=n.reduce((d,u)=>(d.push(this.observeAttribute(u,a)),d),[]);return()=>l.forEach(d=>d())}},e=new WeakMap,t}),je=i=>e=>{var t,s,o;const n=r.r(me,_e,nt)(e),a=Object.keys(i);return o=class extends n{constructor(...d){super(...d),t.add(this),this.observeAttributes(a,r.__classPrivateFieldGet(this,t,"m",s).bind(this))}async init(){var d;a.forEach(u=>r.__classPrivateFieldGet(this,t,"m",s).call(this,u,this.getAttribute(u))),await((d=super.init)===null||d===void 0?void 0:d.call(this))}},t=new WeakSet,s=function(d,u){const c=i[d],h=typeof c=="function"?c(d,u):c;h&&this.logger.error(h)},o};je.missingAttrValidator=ot;const Ar=r.h(i=>{const e=r.r(je({"project-id":ot}))(i);return class extends e{get projectId(){return this.getAttribute("project-id")}}}),xr=r.h(i=>class extends i{get baseUrl(){return this.getAttribute("base-url")||""}}),It="Trying the next fallback URL...",Ir=async(i,e,{logger:t}={})=>{try{return await fetch(i,e)}catch(s){return t==null||t.debug(`Network error fetching URL ${i} [${s.message}], retrying...`),fetch(i,e)}},$r=async(i,e,{logger:t,onSuccess:s}={})=>{const o=Array.isArray(i)?i:[i];for(let n=0;n<o.length;n++){const a=o[n],l=n===o.length-1;try{const d=await Ir(a.toString(),e,{logger:t});if(d.ok)return s==null||s(n),t==null||t.debug(`Successfully fetched URL ${a}`),d;const u=`Error fetching URL ${a} [${d.status}]`;if(l)throw new Error(u);t==null||t.debug(`${u}. ${It}`)}catch(d){const u=`Error fetching URL ${a} [${d.message}]`;if(l)throw new Error(u);t==null||t.debug(`${u}. ${It}`)}}};function Or({projectId:i,filename:e,assetsFolder:t=kr,baseUrl:s=ke}){const o=new URL(s);return o.pathname=r.s(o.pathname,i,t,e),o.baseUrl=s,o}const at=r.h(i=>{var e,t,s,o,n,a,l;const d=r.r(me,Ar,xr)(i);return l=class extends d{constructor(){super(...arguments),e.add(this),t.set(this,void 0),s.set(this,void 0),o.set(this,new Set)}async fetchStaticResource(c,h){const p=r.__classPrivateFieldGet(this,e,"m",n).call(this,c),f=Array.isArray(p)?m=>{const{baseUrl:S}=p[m];r.__classPrivateFieldSet(this,s,S,"f");for(let w=0;w<m;w++){const g=p[w].baseUrl;r.__classPrivateFieldGet(this,o,"f").add(g)}}:null;try{const m=await $r(p,{cache:"default"},{logger:this.logger,onSuccess:f});return{body:await m[h](),headers:Object.fromEntries(m.headers.entries())}}catch(m){this.logger.error(m.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},t=new WeakMap,s=new WeakMap,o=new WeakMap,e=new WeakSet,n=function(c){const h=Fr||this.baseStaticUrl;if(h)return r.__classPrivateFieldGet(this,e,"m",a).call(this,c,h);r.__classPrivateFieldGet(this,t,"f")!==this.baseUrl&&(r.__classPrivateFieldSet(this,t,this.baseUrl,"f"),r.__classPrivateFieldSet(this,s,void 0,"f"),r.__classPrivateFieldGet(this,o,"f").clear());const p=[];if(r.__classPrivateFieldGet(this,s,"f"))p.push(r.__classPrivateFieldGet(this,e,"m",a).call(this,c,r.__classPrivateFieldGet(this,s,"f"))),r.__classPrivateFieldGet(this,s,"f")===ke&&p.push(r.__classPrivateFieldGet(this,e,"m",a).call(this,c,xt));else{const f=this.baseUrl+"/pages";this.baseUrl&&!r.__classPrivateFieldGet(this,o,"f").has(f)&&p.push(r.__classPrivateFieldGet(this,e,"m",a).call(this,c,f)),r.__classPrivateFieldGet(this,o,"f").has(ke)||p.push(r.__classPrivateFieldGet(this,e,"m",a).call(this,c,ke)),p.push(r.__classPrivateFieldGet(this,e,"m",a).call(this,c,xt))}return p.length===1?p[0]:p},a=function(c,h){return Or({projectId:this.projectId,filename:c,baseUrl:h})},l}),Gr="config.json",Mr=r.h(i=>{var e,t;const s=r.r(je({"project-id":ot}))(i);return t=class extends s{constructor(){super(...arguments),e.set(this,new Map)}onReset(n,a){if(r.__classPrivateFieldGet(this,e,"f").has(n))throw new Error(`Callback for sectionId ${n} already exists`);return r.__classPrivateFieldGet(this,e,"f").set(n,a),()=>{r.__classPrivateFieldGet(this,e,"f").delete(n)}}async reset(...n){n.length===0?await Promise.all(Array.from(r.__classPrivateFieldGet(this,e,"f").values()).map(a=>a())):await Promise.all(n.map(a=>{var l;if(!r.__classPrivateFieldGet(this,e,"f").has(a))throw new Error(`Callback for sectionId ${a} does not exist`);return(l=r.__classPrivateFieldGet(this,e,"f").get(a))===null||l===void 0?void 0:l()}))}},e=new WeakMap,t}),gi=r.h(i=>{var e,t,s,o,n;const a=r.r(at,Mr,_e)(i);return n=class extends a{constructor(){super(...arguments),e.add(this),s.set(this,void 0),o.set(this,async()=>{try{const{body:d,headers:u}=await this.fetchStaticResource(Gr,"json");return{projectConfig:d,executionContext:{geo:u["x-geo"]}}}catch{this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}})}async init(){await super.init(),this.onReset("config",r.__classPrivateFieldGet(this,e,"m",t).bind(this))}get config(){return r.__classPrivateFieldGet(this,s,"f")||r.__classPrivateFieldSet(this,s,r.__classPrivateFieldGet(this,o,"f").call(this),"f"),r.__classPrivateFieldGet(this,s,"f")}},s=new WeakMap,o=new WeakMap,e=new WeakSet,t=function(){r.__classPrivateFieldSet(this,s,void 0,"f")},n}),Ur=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],jr=i=>document.querySelector(`script#${i}`),Rr=i=>i.getAttribute("status")==="loaded",Tr=i=>i.getAttribute("status")==="error",Lr=i=>{let e=0;const t=i.toString();for(let s=0;s<t.length;s++){const o=t.charCodeAt(s);e=(e<<5)-e+o,e=e&e}return`${Math.abs(e).toString()}`},Wr=(i,e)=>{const t=document.createElement("script");return t.id=i,e&&(t.integrity=e,t.crossOrigin="anonymous"),window.DESCOPE_NONCE&&t.setAttribute("nonce",window.DESCOPE_NONCE),t},Nr=(i,e,t)=>new Promise((s,o)=>{const n=Wr(i,t);n.onerror=a=>{n.setAttribute("status","error"),o(a)},n.onload=()=>{n.setAttribute("status","loaded"),s(n)},n.src=e.toString(),document.body.appendChild(n)}),Dr=(i,e)=>{if(e){const t=i.integrity;if(t!==e)return Promise.reject(new Error(`Integrity mismatch: expected ${e}, found ${t}`))}return Rr(i)?Promise.resolve(i):Tr(i)?Promise.reject():new Promise((t,s)=>{i.addEventListener("load",()=>{t(i)}),i.addEventListener("error",o=>{s(o)})})},Vr=async(i,e)=>{for(const t of i){const{id:s,url:o,integrity:n}=t,a=jr(s);if(a)try{return await Dr(a,n),t}catch{e(t,!0)}else try{return await Nr(s,o,n),t}catch{e(t,!1)}}throw new Error("All scripts failed to load")},qr=(i,e,t,s="",o)=>i.reduce((n,a)=>{const l=a;if(!l)return n;let d;try{d=new URL(l)}catch{throw new Error(`Invalid URL: ${l}`)}d.pathname!=="/"||(d.pathname=`/npm/${e}@${t}/${s}`);const c={url:d,id:`npmlib-${e.replaceAll("@","").replaceAll("/","_")}-${Lr(d)}`};return o&&(c.integrity=o),[...n,c]},[]),Br=r.h(i=>{const e=r.r(me)(i);return class extends e{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(s,o,n="",a=[],l){return this.logger.debug(`Injecting npm lib: "${s}" with version: "${o}"${l?" with SRI integrity check":""}`),Vr(qr([...a,this.baseCdnUrl,...Ur],s,o,n,l),(d,u)=>{if(u){this.logger.error(`Existing script cannot be loaded: "${d.url}"`);return}this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${d.url}"`)})}}}),Kr=i=>[...Array.from(i.content.querySelectorAll("*")).reduce((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e,new Set)],lt="base.ui.components.url",Hr=pi&&localStorage.getItem(lt),Jr="dist/umd/index.js",zr="@descope/web-components-ui",Yr=r.h(i=>{var e,t,s,o,n,a,l;const d=r.r(me,gi,Br)(i);return l=class extends d{constructor(){super(...arguments),e.add(this),o.set(this,void 0)}get descopeUi(){return r.__classPrivateFieldGet(this,o,"f")||r.__classPrivateFieldSet(this,o,r.__classPrivateFieldGet(this,e,"m",a).call(this),"f"),r.__classPrivateFieldGet(this,o,"f")}async loadDescopeUiComponents(c){const h=Array.isArray(c)?c:Kr(c);return Promise.all(h.map(p=>r.__classPrivateFieldGet(this,e,"m",n).call(this,p)))}},o=new WeakMap,e=new WeakSet,t=async function(){var c;const h=await this.config,p=(c=h==null?void 0:h.projectConfig)===null||c===void 0?void 0:c.componentsVersion;return p?this.logger.debug(`Got component version "${p}"`):this.logger.error("Could not get components version"),p},s=async function(){var c;const h=await this.config,p=(c=h==null?void 0:h.projectConfig)===null||c===void 0?void 0:c.componentsVersionSri;return p&&this.logger.debug("SRI hash available for components"),p},n=async function(c){if(!!customElements.get(c)){this.logger.debug(`Loading component "${c}" is skipped as it is already defined`);return}const p=await this.descopeUi;if(!p[c]){this.logger.error(`Cannot load UI component "${c}"`,`Descope UI does not have a component named "${c}", available components are: "${Object.keys(p).join(", ")}"`);return}try{return await p[c]()}catch(f){if(f.name==="NotSupportedError")console.debug(`Encountered an error while attempting to define the "${c}" component, it is likely that this component is already defined`);else throw f}},a=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const c=await r.__classPrivateFieldGet(this,e,"m",t).call(this),h=await r.__classPrivateFieldGet(this,e,"m",s).call(this);return await this.injectNpmLib(zr,c,Jr,[Hr],h),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(c){throw this.logger.error(c),new Error("DescopeUI was not loaded")}},l}),Qr=r.h(i=>{var e,t,s;const o=r.r(_e,nt)(i);return s=class extends o{constructor(){super(...arguments),e.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var a;await((a=super.init)===null||a===void 0?void 0:a.call(this)),this.observeAttribute("nonce",r.__classPrivateFieldGet(this,e,"m",t).bind(this)),r.__classPrivateFieldGet(this,e,"m",t).call(this)}},e=new WeakSet,t=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},s});class Xr{constructor(e,t,{prepend:s=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(s?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return(e=this.styleEle.sheet)===null||e===void 0?void 0:e.cssRules}}const Re=r.h(i=>{const e=r.r(Qr)(i);return class extends e{injectStyle(s,{prepend:o=!1}={}){let n;try{n=new CSSStyleSheet}catch{n=new Xr(this.shadowRoot,this.nonce,{prepend:o})}if(s&&n.replaceSync(s),n instanceof CSSStyleSheet){const a=this.shadowRoot;if(a&&"adoptedStyleSheets"in a){const l=[...a.adoptedStyleSheets||[]];l[o?"unshift":"push"](n),a.adoptedStyleSheets=l}}return n}}}),Ne="content-root",Fe="root",Zr=r.h(i=>{const e=r.r(Re)(i);return class extends e{constructor(...s){var o,n;super(...s),this.attachShadow({mode:"open"}).innerHTML=`
6
6
  <div id="${Fe}">
7
7
  <div id="${Ne}"></div>
8
8
  </div>
@@ -46,5 +46,5 @@ Make sure to test it without the override UI components URL!`,"color: black; bac
46
46
  .hidden {
47
47
  display: none;
48
48
  }
49
- `)},vi=function(){r.__classPrivateFieldGet(this,x,"m",$t).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},qe=function(){const i=["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"];Ee.observedAttributes.forEach(e=>{if(!i.includes(e)&&!this[oi(e)])throw Error(`${e} cannot be empty`)})},fi=function(){const{stepId:i,executionId:e}=si(this.flowId);r.__classPrivateFieldGet(this,Z,"f").update({stepId:i,executionId:e})},Ot=function(i,e){r.Ee&&typeof r.Ee=="function"||this.logger.error("SDK was not loaded properly",r.Ee,JSON.stringify(r.Ee));const t=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},Ee.sdkConfigOverrides),{projectId:i,baseUrl:e});r.__classPrivateFieldGet(this,ae,"f")&&(t.customStorage=r.__classPrivateFieldGet(this,ae,"f")),this.sdk=r.Ee(t),["start","next"].forEach(s=>{const o=this.sdk.flow[s],n=as(o,1e3,3);this.sdk.flow[s]=(...a)=>r.__awaiter(this,void 0,void 0,function*(){try{return yield n(...a)}catch(l){return this.logger.error(`Error in sdk flow ${s} function`,l),{error:{errorCode:Nt,errorDescription:l.toString()}}}})})},mi=function(i,e,t){return r.__awaiter(this,void 0,void 0,function*(){const{projectId:s,baseUrl:o}=i;if(t("projectId")||t("baseUrl")){if(!s)return;r.__classPrivateFieldGet(this,x,"m",Ot).call(this,s,o)}r.__classPrivateFieldGet(this,Me,"f").call(this,i)})},_i=function(){return r.__awaiter(this,void 0,void 0,function*(){const i=yield this.getConfig();return"isMissingConfig"in i&&i.isMissingConfig&&(yield r.__classPrivateFieldGet(this,x,"m",Gt).call(this))})},Gt=function(){return r.__awaiter(this,void 0,void 0,function*(){const i=cs({projectId:this.projectId,filename:Yi,assetsFolder:zi,baseUrl:this.baseStaticUrl});try{return yield ls(i,"json"),!0}catch{return!1}})},bi=function(i){r.__classPrivateFieldSet(this,ge,Object.assign(Object.assign({},r.__classPrivateFieldGet(this,ge,"f")),i.detail),"f")},Be=function(){var i;(i=r.__classPrivateFieldGet(this,J,"f"))===null||i===void 0||i.remove(),r.__classPrivateFieldSet(this,J,null,"f")},wi=function(i){return r.__awaiter(this,arguments,void 0,function*({isDebug:e}){e?(r.__classPrivateFieldSet(this,J,document.createElement("descope-debugger"),"f"),Object.assign(r.__classPrivateFieldGet(this,J,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then(()=>require("./debugger-wc.cjs.js")),document.body.appendChild(r.__classPrivateFieldGet(this,J,"f"))):r.__classPrivateFieldGet(this,x,"m",Be).call(this)})},yi=function(i,e){var t;i&&this.debug&&((t=r.__classPrivateFieldGet(this,J,"f"))===null||t===void 0||t.updateData({title:i,description:e}))},ve.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.58.0"}};var b,ue,q,le,xe,Si,Mt,Ut,Ie,jt,Ke,Rt,Ci,$e,Pi,He,Je,oe,he,ze,V,Ye,Tt,Fi,Qe,ki,Ei,pe,Ai,xi,Ii,Lt,Oe,Xe,Wt,$i,B,Oi;class Gi extends ve{static set sdkConfigOverrides(e){ve.sdkConfigOverrides=e}static get sdkConfigOverrides(){return ve.sdkConfigOverrides}constructor(){const e=new ne({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),b.add(this),this.stepState=new ne({}),ue.set(this,void 0),q.set(this,null),le.set(this,null),xe.set(this,{visibilitychange:r.__classPrivateFieldGet(this,b,"m",Si).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},$e.set(this,!1),this.handleRedirect=t=>{window.location.assign(t)},He.set(this,t=>{const s=()=>{this.contentRootElement.classList.toggle("hidden",t),this.slotElement.classList.toggle("hidden",!t),t&&(this.contentRootElement.innerHTML="")};t&&this.contentRootElement.hasChildNodes()?r.__classPrivateFieldGet(this,b,"m",Je).call(this,s):s()}),oe.set(this,(t,s,o,n,a=!1)=>{const l=[mt,Bi];if(this.flowState.current.action===N.poll){if(r.__classPrivateFieldGet(this,ze,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const d=Date.now(),u=a?500:2e3;r.__classPrivateFieldSet(this,ue,setTimeout(()=>r.__awaiter(this,void 0,void 0,function*(){var c,h;this.logger.debug("polling - Calling next");const p=this.sdk.flow.next(t,s,ce.polling,o,n,{}),f=document.hidden&&!a&&Date.now()-d>u+500;let m;f&&this.logger.debug("polling - The polling seems to be throttled");try{m=yield rt(f?1e3:6e3,p)}catch{return this.logger.warn(`polling - The ${f?"throttled fetch":"fetch"} call timed out or was aborted`),void r.__classPrivateFieldGet(this,oe,"f").call(this,t,s,o,n,f)}if(((c=m==null?void 0:m.error)===null||c===void 0?void 0:c.errorCode)===Nt)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void r.__classPrivateFieldGet(this,oe,"f").call(this,t,s,o,n);this.logger.debug("polling - Got a response"),m!=null&&m.error&&this.logger.debug("polling - Response has an error",JSON.stringify(m.error,null,4)),!((h=m==null?void 0:m.error)===null||h===void 0)&&h.errorCode&&l.includes(m.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):r.__classPrivateFieldGet(this,oe,"f").call(this,t,s,o,n),r.__classPrivateFieldGet(this,V,"f").call(this,m)}),u),"f")}}),he.set(this,()=>{clearTimeout(r.__classPrivateFieldGet(this,ue,"f")),r.__classPrivateFieldSet(this,ue,null,"f")}),ze.set(this,()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)),V.set(this,t=>{var s,o,n,a,l,d,u,c,h,p,f,m,S;if(!(t!=null&&t.ok)){const W=(s=t==null?void 0:t.response)===null||s===void 0?void 0:s.url,z=`${(o=t==null?void 0:t.response)===null||o===void 0?void 0:o.status} - ${(n=t==null?void 0:t.response)===null||n===void 0?void 0:n.statusText}`;r.__classPrivateFieldGet(this,b,"m",B).call(this,"error",(t==null?void 0:t.error)||{errorCode:Vi,errorDescription:z,errorMessage:W}),this.loggerWrapper.error(((a=t==null?void 0:t.error)===null||a===void 0?void 0:a.errorDescription)||W,((l=t==null?void 0:t.error)===null||l===void 0?void 0:l.errorMessage)||z);const I=(d=t==null?void 0:t.error)===null||d===void 0?void 0:d.errorCode;return void(I!==qi&&I!==mt||!this.isRestartOnError||r.__classPrivateFieldGet(this,b,"m",Ci).call(this))}(c=(u=t.data)===null||u===void 0?void 0:u.runnerLogs)===null||c===void 0||c.forEach(W=>{const{level:z,title:I,log:U}=W;z&&this.loggerWrapper[z]?this.loggerWrapper[z](I,U):this.loggerWrapper.info(I,U)});const w=(f=(p=(h=t.data)===null||h===void 0?void 0:h.screen)===null||p===void 0?void 0:p.state)===null||f===void 0?void 0:f.errorText;!((m=t.data)===null||m===void 0)&&m.error?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${w?`${w} - `:""}${t.data.error.message}`):w&&this.loggerWrapper.error(w);const{status:g,authInfo:v,lastAuth:_,action:y,openInNewTabUrl:$}=t.data;if(y!==N.poll&&r.__classPrivateFieldGet(this,he,"f").call(this),g==="completed"){this.storeLastAuthenticatedUser&&Et(_);const W=Object.assign({},v);return t.data.output&&Object.keys(t.data.output).length>0&&(W.flowOutput=t.data.output),void r.__classPrivateFieldGet(this,b,"m",B).call(this,"success",W)}this.storeLastAuthenticatedUser&&Et(_,!0),$&&window.open($,"_blank");const{executionId:O,stepId:M,stepName:j,screen:R,redirect:ee,webauthn:T,error:be,samlIdpResponse:L,nativeResponse:te}=t.data,we=Date.now();y!==N.poll?(this.loggerWrapper.info(`Step "${j||`#${M}`}" is ${g}`,"",{screen:R,status:g,stepId:M,stepName:j,action:y,error:be}),!((S=R.state)===null||S===void 0)&&S.clientScripts&&r.__classPrivateFieldSet(this,le,this.loadSdkScripts(R.state.clientScripts),"f"),this.flowState.update({stepId:M,stepName:j,executionId:O,action:y,redirectTo:ee==null?void 0:ee.url,redirectIsPopup:ee==null?void 0:ee.isPopup,screenId:R==null?void 0:R.id,screenState:R==null?void 0:R.state,webauthnTransactionId:T==null?void 0:T.transactionId,webauthnOptions:T==null?void 0:T.options,samlIdpResponseUrl:L==null?void 0:L.url,samlIdpResponseSamlResponse:L==null?void 0:L.samlResponse,samlIdpResponseRelayState:L==null?void 0:L.relayState,nativeResponseType:te==null?void 0:te.type,nativePayload:te==null?void 0:te.payload,reqTimestamp:we})):this.flowState.update({action:y,reqTimestamp:we})}),Ye.set(this,ni(()=>r.__awaiter(this,void 0,void 0,function*(){var t;try{const s=yield this.sdk.webauthn.signIn.start("",window.location.origin);return s.ok||this.loggerWrapper.warn("Webauthn start failed",(t=s==null?void 0:s.error)===null||t===void 0?void 0:t.errorMessage),s.data}catch(s){this.loggerWrapper.warn("Webauthn start failed",s.message)}}))),pe.set(this,null),Oe.set(this,Zs((t,s)=>r.__awaiter(this,void 0,void 0,function*(){var o;if(t.getAttribute("formnovalidate")==="true"||r.__classPrivateFieldGet(this,b,"m",ki).call(this)){const n=t==null?void 0:t.getAttribute("id");r.__classPrivateFieldGet(this,b,"m",Ai).call(this,t);const a=yield r.__classPrivateFieldGet(this,b,"m",Ei).call(this),l=Ks(t);this.nextRequestStatus.update({isLoading:!0});const d=Object.assign(Object.assign(Object.assign({},l),a),{origin:((o=this.nativeOptions)===null||o===void 0?void 0:o.origin)||window.location.origin});yield s(n,d),this.nextRequestStatus.update({isLoading:!1}),r.__classPrivateFieldGet(this,b,"m",xi).call(this,a)}}))),this.flowState=e}nativeResume(e,t){var s,o,n,a,l,d;const u=JSON.parse(t);if(e==="oauthWeb"||e==="sso"){let c,{exchangeCode:h}=u;if(!h){const p=new URL(u.url);h=(s=p.searchParams)===null||s===void 0?void 0:s.get(tt),c=((o=p.searchParams)===null||o===void 0?void 0:o.get(it))||void 0}(a=(n=this.nativeCallbacks).complete)===null||a===void 0||a.call(n,{exchangeCode:h,exchangeError:c,idpInitiated:!0})}else if(e==="magicLink"){const c=new URL(u.url),h=c.searchParams.get(et),p=c.searchParams.get(Ze).split("_").pop();r.__classPrivateFieldGet(this,he,"f").call(this),this.flowState.update({token:h,stepId:p,action:void 0})}else if(e==="beforeScreen"){const{screenResolve:c}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:h}=u;h||(this.nativeCallbacks.screenNext=null),c==null||c(h)}else if(e==="resumeScreen"){const{interactionId:c,form:h}=u,{screenNext:p}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,p==null||p(c,h)}else(d=(l=this.nativeCallbacks).complete)===null||d===void 0||d.call(l,u)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map(t=>t.moduleRes).filter(t=>!!t)}loadSdkScripts(e){if(!(e!=null&&e.length))return null;const t=(n,a)=>l=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[sr(n.id,n.resultKey)]:l},bubbles:!0,composed:!0})),a(n.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map(n=>n.id).join(", ")}`);const s=Promise.all(e==null?void 0:e.map(n=>r.__awaiter(this,void 0,void 0,function*(){var a,l;const d=this.shadowRoot.querySelector(`[data-script-id="${n.id}"]`);if(d){this.loggerWrapper.debug("Script already loaded",n.id);const{moduleRes:c}=d;return(a=c==null?void 0:c.start)===null||a===void 0||a.call(c),c}yield this.injectNpmLib("@descope/flow-scripts","1.0.14",`dist/${n.id}.js`);const u=(l=globalThis.descope)===null||l===void 0?void 0:l[n.id];return new Promise((c,h)=>{try{const p=u(n.initArgs,{baseUrl:this.baseUrl,ref:this},t(n,c),this.loggerWrapper);if(p){const f=document.createElement("div");f.setAttribute("data-script-id",n.id),f.moduleRes=p,this.shadowRoot.appendChild(f),this.nextRequestStatus.subscribe(()=>{var m;this.loggerWrapper.debug("Unloading script",n.id),(m=p.stop)===null||m===void 0||m.call(p)})}}catch(p){h(p)}})}))),o=new Promise(n=>{setTimeout(()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),n(!0)},ii)});return Promise.race([s,o])}get isDismissScreenErrorOnInput(){return this.getAttribute("dismiss-screen-error-on-input")==="true"}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return r.__awaiter(this,void 0,void 0,function*(){var t,s;this.shadowRoot.isConnected&&((t=this.flowState)===null||t===void 0||t.subscribe(this.onFlowChange.bind(this)),r.__classPrivateFieldGet(this,b,"m",Ke).call(this),window.addEventListener("visibilitychange",r.__classPrivateFieldGet(this,xe,"f").visibilitychange)),yield(s=e.init)===null||s===void 0?void 0:s.call(this)})}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),r.__classPrivateFieldGet(this,he,"f").call(this),(e=r.__classPrivateFieldGet(this,q,"f"))===null||e===void 0||e.abort(),r.__classPrivateFieldSet(this,q,null,"f"),window.removeEventListener("visibilitychange",r.__classPrivateFieldGet(this,xe,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return r.__awaiter(this,void 0,void 0,function*(){let s;const o=Ce(e),n=yield this.getTargetLocales();return n.includes(o.locale)?s=`${t}-${o.locale}.html`:n.includes(o.fallback)&&(s=`${t}-${o.fallback}.html`),s})}getPageContent(e,t){return r.__awaiter(this,void 0,void 0,function*(){if(t)try{const{body:s}=yield this.fetchStaticResource(t,"text");return s}catch(s){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,s)}try{const{body:s}=yield this.fetchStaticResource(e,"text");return s}catch(s){this.loggerWrapper.error("Failed to fetch flow page",s.message)}return null})}onFlowChange(e,t,s){return r.__awaiter(this,void 0,void 0,function*(){var o,n;const{projectId:a,flowId:l,tenant:d,stepId:u,executionId:c,action:h,screenId:p,screenState:f,redirectTo:m,redirectIsPopup:S,redirectUrl:w,token:g,code:v,isPopup:_,exchangeError:y,webauthnTransactionId:$,webauthnOptions:O,redirectAuthCodeChallenge:M,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:R,redirectAuthInitiator:ee,locale:T,samlIdpResponseUrl:be,samlIdpResponseSamlResponse:L,samlIdpResponseRelayState:te,nativeResponseType:we,nativePayload:W,reqTimestamp:z}=e,I=r.__rest(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 U,Te,ye;const Se=wr(),{outboundAppId:ct}=this,{outboundAppScopes:dt}=this,K=this.sdk.getLastUserLoginId(),k=yield this.getFlowConfig(),H=yield this.getProjectConfig(),ut=Object.entries(H.flows||{}).reduce((F,[C,G])=>(F[C]=G.version,F),{}),ht=j&&M?{callbackUrl:j,codeChallenge:M,backupCallbackUri:R}:void 0,pt=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 gt={};if(!c){const F=[...k.clientScripts||[],...k.sdkScripts||[]];if(k.conditions){let C=[];({startScreenId:U,conditionInteractionId:ye,startScreenName:Te,clientScripts:C,componentsConfig:gt}=Sr({loginId:K,code:v,token:g,abTestingKey:Se,lastAuth:Pe(K)},k.conditions)),F.push(...C||[])}else k.condition?{startScreenId:U,conditionInteractionId:ye}=yr(k.condition,{loginId:K,code:v,token:g,abTestingKey:Se,lastAuth:Pe(K)}):(Te=k.startScreenName,U=k.startScreenId);if(r.__classPrivateFieldSet(this,le,this.loadSdkScripts(F),"f"),k.fingerprintEnabled&&k.fingerprintKey?yield r.X(k.fingerprintKey,this.baseUrl):r.Z(),!wt(U,I)){const C=yield this.sdk.flow.start(l,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:ht},I),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:Pe(K),abTestingKey:Se,locale:Ce(T).locale,nativeOptions:pt,outboundAppId:ct,outboundAppScopes:dt}),ye,"",H.componentsVersion,ut,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),v?{exchangeCode:v,idpInitiated:!0}:{}),I.descopeIdpInitiated&&{idpInitiated:!0}),g?{token:g}:{}),I.oidcLoginHint?{externalId:I.oidcLoginHint}:{}));return r.__classPrivateFieldGet(this,V,"f").call(this,C),void(((o=C==null?void 0:C.data)===null||o===void 0?void 0:o.status)!=="completed"&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:_,code:v,exchangeError:y,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),_&&(s("code")&&v||s("exchangeError")&&y))return void r.__classPrivateFieldGet(this,b,"m",Oi).call(this,c,v,y);if(c&&(s("token")&&g||s("code")&&v||s("exchangeError")&&y)){const F=yield this.sdk.flow.next(c,u,ce.submit,k.version,H.componentsVersion,{token:g,exchangeCode:v,exchangeError:y});return r.__classPrivateFieldGet(this,V,"f").call(this,F),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(h===N.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some(F=>s(F))){if(!be||!L)return void this.loggerWrapper.error("Did not get saml idp params data to load");Qs(be,L,te||"",Xs)}if(h===N.redirect&&(s("redirectTo")||s("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if(m==="no-op")return;if(ee==="android"&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${S}`),S){this.loggerWrapper.debug("Opening redirect in popup");const F=rr(m,"?",598,700),C=this.shouldUsePopupPostMessage();C&&(F.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(C?"postMessage":"BroadcastChannel"));const G=Q=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(Q.data));const vt=C?this.popupOrigin:window.location.origin;if(Q.origin!==vt)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${Q.origin}", expected: "${vt}"`);const{action:Di,data:ft}=Q.data||{};Di==="code"&&this.flowState.update({code:ft.code,exchangeError:ft.exchangeError})};let A;this.loggerWrapper.debug("Starting popup closed detection");const Ni=setInterval(()=>{F.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(Ni),r.__classPrivateFieldGet(this,b,"m",B).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),A==null||A())},1e3);if(C)window.addEventListener("message",G),A=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",G)};else{this.loggerWrapper.debug("Creating broadcast channel");const Q=new BroadcastChannel(c);Q.onmessage=G,A=()=>{this.loggerWrapper.debug("Closing channel"),Q.close()}}}else this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),r.__classPrivateFieldGet(this,b,"m",B).call(this,"popupclosed",{});return}if(h===N.webauthnCreate||h===N.webauthnGet){if(!$||!O)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let F,C;(n=r.__classPrivateFieldGet(this,q,"f"))===null||n===void 0||n.abort(),r.__classPrivateFieldSet(this,q,null,"f");try{F=h===N.webauthnCreate?yield this.sdk.webauthn.helpers.create(O):yield this.sdk.webauthn.helpers.get(O)}catch(A){A.name==="InvalidStateError"?this.loggerWrapper.warn("WebAuthn operation failed",A.message):A.name!=="NotAllowedError"&&this.loggerWrapper.error(A.message),C=A.name}const G=yield this.sdk.flow.next(c,u,ce.submit,k.version,H.componentsVersion,{transactionId:$,response:F,failure:C});r.__classPrivateFieldGet(this,V,"f").call(this,G)}if(h===N.nativeBridge)return this.nativeCallbacks.complete=F=>r.__awaiter(this,void 0,void 0,function*(){const C=yield this.sdk.flow.next(c,u,ce.submit,k.version,H.componentsVersion,F);r.__classPrivateFieldGet(this,V,"f").call(this,C)}),r.__classPrivateFieldGet(this,b,"m",Ie).call(this,we,W),void setTimeout(()=>{this.dispatchEvent(new Event("popupclosed"))},500);if((s("action")||s("deferredPolling"))&&r.__classPrivateFieldGet(this,oe,"f").call(this,c,u,k.version,H.componentsVersion),!p&&!U)return void this.loggerWrapper.warn("No screen was found to show");const Le=U||p,Mi=yield this.getHtmlFilenameWithLocale(T,Le),{oidcLoginHint:Ui,oidcPrompt:ji,oidcErrorRedirectUri:Ri,oidcResource:Ti,samlIdpUsername:Li}=I,Y={direction:ds(u,t.stepId),screenState:Object.assign(Object.assign({},f),{form:Object.assign(Object.assign({},this.formConfigValues),f==null?void 0:f.form),lastAuth:{loginId:K,name:this.sdk.getLastUserDisplayName()||K},componentsConfig:Object.assign(Object.assign(Object.assign({},k.componentsConfig),gt),f==null?void 0:f.componentsConfig)}),htmlFilename:`${Le}.html`,htmlLocaleFilename:Mi,screenId:Le,stepName:e.stepName||Te,samlIdpUsername:Li,oidcLoginHint:Ui,oidcPrompt:ji,oidcErrorRedirectUri:Ri,oidcResource:Ti,action:h,locale:Ce(T).locale},Wi=Pe(K);wt(U,I)?Y.next=(F,C)=>r.__awaiter(this,void 0,void 0,function*(){const G=(k==null?void 0:k.clientScripts)||[];yield r.__classPrivateFieldGet(this,b,"m",Xe).call(this,G);const A=yield this.sdk.flow.start(l,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:ht},I),{lastAuth:Wi,preview:this.preview,abTestingKey:Se,client:this.client}),w&&{redirectUrl:w}),{locale:Ce(T).locale,nativeOptions:pt,outboundAppId:ct,outboundAppScopes:dt}),ye,F,H.componentsVersion,ut,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),St(C)),v&&{exchangeCode:v,idpInitiated:!0}),I.descopeIdpInitiated&&{idpInitiated:!0}),g&&{token:g}),Y.next.isCustomScreen);return r.__classPrivateFieldGet(this,V,"f").call(this,A),A}):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(Y.next=(F,C)=>r.__awaiter(this,void 0,void 0,function*(){const G=(f==null?void 0:f.clientScripts)||[];yield r.__classPrivateFieldGet(this,b,"m",Xe).call(this,G);const A=yield this.sdk.flow.next(c,u,F,k.version,H.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),St(C)),Y.next.isCustomScreen);return r.__classPrivateFieldGet(this,V,"f").call(this,A),A})),this.loggerWrapper.debug("Got a screen with id",Y.screenId),yield r.__classPrivateFieldGet(this,b,"m",Pi).call(this,Y),this.stepState.update(Y)})}onStepChange(e,t){return r.__awaiter(this,void 0,void 0,function*(){var s,o,n;const{htmlFilename:a,htmlLocaleFilename:l,direction:d,next:u,screenState:c}=e;this.loggerWrapper.debug("Rendering a flow screen");const h=document.createElement("template");h.innerHTML=yield this.getPageContent(a,l);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield r.__classPrivateFieldGet(this,b,"m",Fi).call(this,p,u):mr(p),!e.samlIdpUsername||!((s=c.form)===null||s===void 0)&&s.loginId||!((o=c.form)===null||o===void 0)&&o.email||(c.form||(c.form={}),c.form.loginId=e.samlIdpUsername,c.form.email=e.samlIdpUsername),ur(p,c,this.formConfig,this.loggerWrapper);const{geo:m}=(n=yield this.getExecutionContext())!==null&&n!==void 0?n:{};vr(p,m),fr(p,e.locale);const S=()=>r.__awaiter(this,void 0,void 0,function*(){var w,g;yield f;const v=this.contentRootElement;pr(v,(w=c==null?void 0:c.totp)===null||w===void 0?void 0:w.image),gr(v,(g=c==null?void 0:c.notp)===null||g===void 0?void 0:g.image),dr(v,p,c.cssVars,this.loggerWrapper),v.replaceChildren(p);const _=!t.htmlFilename;setTimeout(()=>{r.__classPrivateFieldGet(this,b,"m",Ii).call(this),this.validateOnBlur&&zs(v),hr(v,c),r.__classPrivateFieldGet(this,b,"m",Qe).call(this,{isFirstScreen:_,isCustomScreen:!1,stepName:e.stepName}),ai(v,this.autoFocus,_)}),r.__classPrivateFieldGet(this,b,"m",$i).call(this,u),v.querySelector(`[${Ue}="polling"]`)&&u(ce.polling,{})});d?r.__classPrivateFieldGet(this,b,"m",Je).call(this,S):S()})}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${st}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch{return!1}return!0}}ue=new WeakMap,q=new WeakMap,le=new WeakMap,xe=new WeakMap,$e=new WeakMap,He=new WeakMap,oe=new WeakMap,he=new WeakMap,ze=new WeakMap,V=new WeakMap,Ye=new WeakMap,pe=new WeakMap,Oe=new WeakMap,b=new WeakSet,Si=function(){document.hidden||setTimeout(()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})},300)},Mt=function(i,e,t){return r.__awaiter(this,void 0,void 0,function*(){var s;return((s=this.nativeOptions)===null||s===void 0?void 0:s.bridgeVersion)>=2&&new Promise(o=>{this.nativeCallbacks.screenNext=t,this.nativeCallbacks.screenResolve=o,r.__classPrivateFieldGet(this,b,"m",Ie).call(this,"beforeScreen",{screen:i,context:e})})})},Ut=function(i){var e;((e=this.nativeOptions)===null||e===void 0?void 0:e.bridgeVersion)>=2&&r.__classPrivateFieldGet(this,b,"m",Ie).call(this,"afterScreen",{screen:i})},Ie=function(i,e){r.__classPrivateFieldGet(this,b,"m",B).call(this,"bridge",{type:i,payload:e})},jt=function({errorText:i,errorType:e}){const t=()=>{var s;let o=i;try{o=((s=this.errorTransformer)===null||s===void 0?void 0:s.call(this,{text:i,type:e}))||i}catch(n){this.loggerWrapper.error("Error transforming error message",n.message)}cr(this.contentRootElement,"error-message",o)};this.addEventListener("screen-updated",t,{once:!0}),t()},Ke=function(){var i,e,t;(i=this.stepState)===null||i===void 0||i.subscribe(this.onStepChange.bind(this),s=>{var o=s.screenState,n=r.__rest(o===void 0?{}:o,["errorText","errorType"]),a=r.__rest(s,["screenState"]);return Object.assign(Object.assign({},a),{screenState:n})}),(e=this.stepState)===null||e===void 0||e.subscribe(r.__classPrivateFieldGet(this,b,"m",jt).bind(this),s=>{var o,n;return{errorText:(o=s==null?void 0:s.screenState)===null||o===void 0?void 0:o.errorText,errorType:(n=s==null?void 0:s.screenState)===null||n===void 0?void 0:n.errorType}},{forceUpdate:!0}),(t=this.stepState)===null||t===void 0||t.subscribe(r.__classPrivateFieldGet(this,b,"m",Rt).bind(this),s=>{var o,n;return{errorText:(o=s==null?void 0:s.screenState)===null||o===void 0?void 0:o.errorText,errorType:(n=s==null?void 0:s.screenState)===null||n===void 0?void 0:n.errorType}},{forceUpdate:!0})},Rt=function({errorText:i,errorType:e}){(e||i)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach(t=>{t.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach(s=>{s.value=""})}),ai(this.contentRootElement,this.autoFocus,!1))},Ci=function(){return r.__awaiter(this,void 0,void 0,function*(){this.loggerWrapper.debug("Trying to restart the flow");const i=yield this.getComponentsVersion();this.reset(),i===(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")})},Pi=function(i){return r.__awaiter(this,void 0,void 0,function*(){var e;const t=Object.assign(Object.assign({},this.stepState.current),i),{next:s,stepName:o}=t,n=r.__rest(t,["next","stepName"]),a=ir(n);let l=yield r.__classPrivateFieldGet(this,b,"m",Mt).call(this,o,a,s);l||(l=!!(yield(e=this.onScreenUpdate)===null||e===void 0?void 0:e.call(this,o,a,s,this)));const d=!this.stepState.current.htmlFilename;if(r.__classPrivateFieldGet(this,He,"f").call(this,l),s&&(s.isCustomScreen=l),r.__classPrivateFieldGet(this,$e,"f")!==l){const[u,c]=["flow","custom"].sort(()=>l?-1:1);this.loggerWrapper.debug(`Switching from ${c} screen to ${u} screen`),r.__classPrivateFieldSet(this,$e,l,"f"),l?this.stepState.unsubscribeAll():r.__classPrivateFieldGet(this,b,"m",Ke).call(this)}l?(this.loggerWrapper.debug("Showing a custom screen"),r.__classPrivateFieldGet(this,b,"m",Qe).call(this,{isFirstScreen:d,isCustomScreen:l,stepName:i.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=l})},Je=function(i){this.contentRootElement.addEventListener("transitionend",()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),i()},{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},Tt=function(i){const e=i.getAttribute("name");if(!["email"].includes(e)){const t=`user-${e}`;i.setAttribute("name",t),i.addEventListener("input",()=>{i.setAttribute("name",i.value?e:t)})}},Fi=function(i,e){return r.__awaiter(this,void 0,void 0,function*(){var t;(t=r.__classPrivateFieldGet(this,q,"f"))===null||t===void 0||t.abort();const s=i.querySelector('*[autocomplete="webauthn"]');if(s&&(yield _r())){const{options:o,transactionId:n}=(yield r.__classPrivateFieldGet(this,Ye,"f").call(this))||{};o&&n&&(r.__classPrivateFieldGet(this,b,"m",Tt).call(this,s),r.__classPrivateFieldSet(this,q,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(o,r.__classPrivateFieldGet(this,q,"f")).then(a=>r.__awaiter(this,void 0,void 0,function*(){e(s.id,{transactionId:n,response:a})})).catch(a=>{a.name!=="AbortError"&&this.loggerWrapper.error("Conditional login failed",a.message)}))}})},Qe=function({isFirstScreen:i,isCustomScreen:e,stepName:t}){i&&r.__classPrivateFieldGet(this,b,"m",B).call(this,"ready",{}),e||r.__classPrivateFieldGet(this,b,"m",Ut).call(this,t),r.__classPrivateFieldGet(this,b,"m",B).call(this,"page-updated",{screenName:t}),r.__classPrivateFieldGet(this,b,"m",B).call(this,"screen-updated",{screenName:t})},ki=function(){let i=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach(e=>{var t,s;e.localName==="slot"||e.classList.contains("hidden")||((t=e.reportValidity)===null||t===void 0||t.call(e),i&&(i=(s=e.checkValidity)===null||s===void 0?void 0:s.call(e)))}),i},Ei=function(){return r.__awaiter(this,void 0,void 0,function*(){const i=this.getInputs();return(yield Promise.all(i.map(e=>r.__awaiter(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}),{})})},Ai=function(i){const e=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter(n=>n!==i),t=()=>r.__awaiter(this,void 0,void 0,function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",t),i.removeAttribute("loading"),e.forEach(l=>{l.removeAttribute("disabled")});const n=yield this.getFlowConfig(),a=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(a)}),s=()=>{var n;window.removeEventListener("pageshow",r.__classPrivateFieldGet(this,pe,"f")),r.__classPrivateFieldSet(this,pe,l=>{l.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),t())},"f"),window.addEventListener("pageshow",r.__classPrivateFieldGet(this,pe,"f"),{once:!0});const a=(n=this.stepState)===null||n===void 0?void 0:n.subscribe((l,d)=>{l===d&&t(),this.removeEventListener("popupclosed",t),this.stepState.unsubscribe(a)},l=>l.screenId,{forceUpdate:!0})},o=this.nextRequestStatus.subscribe(({isLoading:n})=>{n?(this.addEventListener("popupclosed",t,{once:!0}),i.setAttribute("loading","true"),e.forEach(a=>a.setAttribute("disabled","true"))):(this.nextRequestStatus.unsubscribe(o),s())})},xi=function(i={}){var e,t;const s=yt(i,["externalId","email","phone"]),o=yt(i,["newPassword","password"]);if(s&&o)try{if(!globalThis.PasswordCredential)return;const n=new globalThis.PasswordCredential({id:s,password:o});(t=(e=navigator==null?void 0:navigator.credentials)===null||e===void 0?void 0:e.store)===null||t===void 0||t.call(e,n)}catch(n){this.loggerWrapper.error("Could not store credentials",n.message)}},Ii=function(){er(),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach(i=>r.__classPrivateFieldGet(this,b,"m",Lt).call(this,i))},Lt=function(i){i&&i.querySelectorAll("input").forEach(e=>{const t=e.getAttribute("slot"),s=`input-${i.id}-${t}`,o=document.createElement("slot");o.setAttribute("name",s),o.setAttribute("slot",t),i.appendChild(o),e.setAttribute("slot",s),this.appendChild(e)})},Xe=function(i){return r.__awaiter(this,void 0,void 0,function*(){if(r.__classPrivateFieldGet(this,le,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const o=Date.now();yield r.__classPrivateFieldGet(this,le,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-o).toString())}const e=this.loadSdkScriptsModules(),t=i.map(o=>o.id);for(const o of e)if(t.includes(o.id))try{typeof o.present=="function"&&((yield o.present())||this.loggerWrapper.debug(`Sdk script ${o.id} was cancelled`))}catch(n){this.loggerWrapper.error(`Failed to present ${o.id} script module`,n.message)}const s=[];for(const o of e)typeof o.refresh=="function"&&s.push(o.refresh());if(s.length>0)try{yield rt(ii,Promise.all(s),null)}catch(o){this.loggerWrapper.error("Failed to refresh script module",o.message)}})},Wt=function(i){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach(e=>{e.addEventListener("input",()=>{var t;!((t=e.checkValidity)===null||t===void 0)&&t.call(e)&&r.__classPrivateFieldGet(this,Oe,"f").call(this,e,i)})})},$i=function(i){this.contentRootElement.querySelectorAll(`descope-button:not([${bt}]), [data-type="button"]:not([${bt}]`).forEach(e=>{e.onclick=()=>{r.__classPrivateFieldGet(this,Oe,"f").call(this,e,i)}}),r.__classPrivateFieldGet(this,b,"m",Wt).call(this,i),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${st}])`).forEach(e=>{e.addEventListener("input",()=>{this.stepState.update(t=>Object.assign(Object.assign({},t),{screenState:Object.assign(Object.assign({},t.screenState),{errorText:"",errorType:""})}))})})},B=function(i,e){this.dispatchEvent(new CustomEvent(i,{detail:e}))},Oi=function(i,e,t){var s;const[o,n]=((s=window.name)===null||s===void 0?void 0:s.split("|"))||[],a={data:{code:e,exchangeError:t},action:"code"};if(o==="descope-wc"&&n){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",n);try{window.opener.postMessage(a,n)}catch(l){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",l==null?void 0:l.message)}}else{this.loggerWrapper.debug("Creating popup channel",i);const l=new BroadcastChannel(i);l.postMessage(a),l.close()}try{window.close()}catch{}};customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Gi);const co=Object.freeze(Object.defineProperty({__proto__:null,default:Gi},Symbol.toStringTag,{value:"Module"}));exports.c=ne;exports.index=co;exports.injectStyleMixin=Re;
49
+ `)},vi=function(){r.__classPrivateFieldGet(this,x,"m",$t).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},qe=function(){const i=["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"];Ee.observedAttributes.forEach(e=>{if(!i.includes(e)&&!this[oi(e)])throw Error(`${e} cannot be empty`)})},fi=function(){const{stepId:i,executionId:e}=si(this.flowId);r.__classPrivateFieldGet(this,Z,"f").update({stepId:i,executionId:e})},Ot=function(i,e){r.Ee&&typeof r.Ee=="function"||this.logger.error("SDK was not loaded properly",r.Ee,JSON.stringify(r.Ee));const t=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},Ee.sdkConfigOverrides),{projectId:i,baseUrl:e});r.__classPrivateFieldGet(this,ae,"f")&&(t.customStorage=r.__classPrivateFieldGet(this,ae,"f")),this.sdk=r.Ee(t),["start","next"].forEach(s=>{const o=this.sdk.flow[s],n=as(o,1e3,3);this.sdk.flow[s]=(...a)=>r.__awaiter(this,void 0,void 0,function*(){try{return yield n(...a)}catch(l){return this.logger.error(`Error in sdk flow ${s} function`,l),{error:{errorCode:Nt,errorDescription:l.toString()}}}})})},mi=function(i,e,t){return r.__awaiter(this,void 0,void 0,function*(){const{projectId:s,baseUrl:o}=i;if(t("projectId")||t("baseUrl")){if(!s)return;r.__classPrivateFieldGet(this,x,"m",Ot).call(this,s,o)}r.__classPrivateFieldGet(this,Me,"f").call(this,i)})},_i=function(){return r.__awaiter(this,void 0,void 0,function*(){const i=yield this.getConfig();return"isMissingConfig"in i&&i.isMissingConfig&&(yield r.__classPrivateFieldGet(this,x,"m",Gt).call(this))})},Gt=function(){return r.__awaiter(this,void 0,void 0,function*(){const i=cs({projectId:this.projectId,filename:Yi,assetsFolder:zi,baseUrl:this.baseStaticUrl});try{return yield ls(i,"json"),!0}catch{return!1}})},bi=function(i){r.__classPrivateFieldSet(this,ge,Object.assign(Object.assign({},r.__classPrivateFieldGet(this,ge,"f")),i.detail),"f")},Be=function(){var i;(i=r.__classPrivateFieldGet(this,J,"f"))===null||i===void 0||i.remove(),r.__classPrivateFieldSet(this,J,null,"f")},wi=function(i){return r.__awaiter(this,arguments,void 0,function*({isDebug:e}){e?(r.__classPrivateFieldSet(this,J,document.createElement("descope-debugger"),"f"),Object.assign(r.__classPrivateFieldGet(this,J,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then(()=>require("./debugger-wc.cjs.js")),document.body.appendChild(r.__classPrivateFieldGet(this,J,"f"))):r.__classPrivateFieldGet(this,x,"m",Be).call(this)})},yi=function(i,e){var t;i&&this.debug&&((t=r.__classPrivateFieldGet(this,J,"f"))===null||t===void 0||t.updateData({title:i,description:e}))},ve.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.58.1"}};var b,ue,q,le,xe,Si,Mt,Ut,Ie,jt,Ke,Rt,Ci,$e,Pi,He,Je,oe,he,ze,V,Ye,Tt,Fi,Qe,ki,Ei,pe,Ai,xi,Ii,Lt,Oe,Xe,Wt,$i,B,Oi;class Gi extends ve{static set sdkConfigOverrides(e){ve.sdkConfigOverrides=e}static get sdkConfigOverrides(){return ve.sdkConfigOverrides}constructor(){const e=new ne({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),b.add(this),this.stepState=new ne({}),ue.set(this,void 0),q.set(this,null),le.set(this,null),xe.set(this,{visibilitychange:r.__classPrivateFieldGet(this,b,"m",Si).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},$e.set(this,!1),this.handleRedirect=t=>{window.location.assign(t)},He.set(this,t=>{const s=()=>{this.contentRootElement.classList.toggle("hidden",t),this.slotElement.classList.toggle("hidden",!t),t&&(this.contentRootElement.innerHTML="")};t&&this.contentRootElement.hasChildNodes()?r.__classPrivateFieldGet(this,b,"m",Je).call(this,s):s()}),oe.set(this,(t,s,o,n,a=!1)=>{const l=[mt,Bi];if(this.flowState.current.action===N.poll){if(r.__classPrivateFieldGet(this,ze,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const d=Date.now(),u=a?500:2e3;r.__classPrivateFieldSet(this,ue,setTimeout(()=>r.__awaiter(this,void 0,void 0,function*(){var c,h;this.logger.debug("polling - Calling next");const p=this.sdk.flow.next(t,s,ce.polling,o,n,{}),f=document.hidden&&!a&&Date.now()-d>u+500;let m;f&&this.logger.debug("polling - The polling seems to be throttled");try{m=yield rt(f?1e3:6e3,p)}catch{return this.logger.warn(`polling - The ${f?"throttled fetch":"fetch"} call timed out or was aborted`),void r.__classPrivateFieldGet(this,oe,"f").call(this,t,s,o,n,f)}if(((c=m==null?void 0:m.error)===null||c===void 0?void 0:c.errorCode)===Nt)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void r.__classPrivateFieldGet(this,oe,"f").call(this,t,s,o,n);this.logger.debug("polling - Got a response"),m!=null&&m.error&&this.logger.debug("polling - Response has an error",JSON.stringify(m.error,null,4)),!((h=m==null?void 0:m.error)===null||h===void 0)&&h.errorCode&&l.includes(m.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):r.__classPrivateFieldGet(this,oe,"f").call(this,t,s,o,n),r.__classPrivateFieldGet(this,V,"f").call(this,m)}),u),"f")}}),he.set(this,()=>{clearTimeout(r.__classPrivateFieldGet(this,ue,"f")),r.__classPrivateFieldSet(this,ue,null,"f")}),ze.set(this,()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)),V.set(this,t=>{var s,o,n,a,l,d,u,c,h,p,f,m,S;if(!(t!=null&&t.ok)){const W=(s=t==null?void 0:t.response)===null||s===void 0?void 0:s.url,z=`${(o=t==null?void 0:t.response)===null||o===void 0?void 0:o.status} - ${(n=t==null?void 0:t.response)===null||n===void 0?void 0:n.statusText}`;r.__classPrivateFieldGet(this,b,"m",B).call(this,"error",(t==null?void 0:t.error)||{errorCode:Vi,errorDescription:z,errorMessage:W}),this.loggerWrapper.error(((a=t==null?void 0:t.error)===null||a===void 0?void 0:a.errorDescription)||W,((l=t==null?void 0:t.error)===null||l===void 0?void 0:l.errorMessage)||z);const I=(d=t==null?void 0:t.error)===null||d===void 0?void 0:d.errorCode;return void(I!==qi&&I!==mt||!this.isRestartOnError||r.__classPrivateFieldGet(this,b,"m",Ci).call(this))}(c=(u=t.data)===null||u===void 0?void 0:u.runnerLogs)===null||c===void 0||c.forEach(W=>{const{level:z,title:I,log:U}=W;z&&this.loggerWrapper[z]?this.loggerWrapper[z](I,U):this.loggerWrapper.info(I,U)});const w=(f=(p=(h=t.data)===null||h===void 0?void 0:h.screen)===null||p===void 0?void 0:p.state)===null||f===void 0?void 0:f.errorText;!((m=t.data)===null||m===void 0)&&m.error?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${w?`${w} - `:""}${t.data.error.message}`):w&&this.loggerWrapper.error(w);const{status:g,authInfo:v,lastAuth:_,action:y,openInNewTabUrl:$}=t.data;if(y!==N.poll&&r.__classPrivateFieldGet(this,he,"f").call(this),g==="completed"){this.storeLastAuthenticatedUser&&Et(_);const W=Object.assign({},v);return t.data.output&&Object.keys(t.data.output).length>0&&(W.flowOutput=t.data.output),void r.__classPrivateFieldGet(this,b,"m",B).call(this,"success",W)}this.storeLastAuthenticatedUser&&Et(_,!0),$&&window.open($,"_blank");const{executionId:O,stepId:M,stepName:j,screen:R,redirect:ee,webauthn:T,error:be,samlIdpResponse:L,nativeResponse:te}=t.data,we=Date.now();y!==N.poll?(this.loggerWrapper.info(`Step "${j||`#${M}`}" is ${g}`,"",{screen:R,status:g,stepId:M,stepName:j,action:y,error:be}),!((S=R.state)===null||S===void 0)&&S.clientScripts&&r.__classPrivateFieldSet(this,le,this.loadSdkScripts(R.state.clientScripts),"f"),this.flowState.update({stepId:M,stepName:j,executionId:O,action:y,redirectTo:ee==null?void 0:ee.url,redirectIsPopup:ee==null?void 0:ee.isPopup,screenId:R==null?void 0:R.id,screenState:R==null?void 0:R.state,webauthnTransactionId:T==null?void 0:T.transactionId,webauthnOptions:T==null?void 0:T.options,samlIdpResponseUrl:L==null?void 0:L.url,samlIdpResponseSamlResponse:L==null?void 0:L.samlResponse,samlIdpResponseRelayState:L==null?void 0:L.relayState,nativeResponseType:te==null?void 0:te.type,nativePayload:te==null?void 0:te.payload,reqTimestamp:we})):this.flowState.update({action:y,reqTimestamp:we})}),Ye.set(this,ni(()=>r.__awaiter(this,void 0,void 0,function*(){var t;try{const s=yield this.sdk.webauthn.signIn.start("",window.location.origin);return s.ok||this.loggerWrapper.warn("Webauthn start failed",(t=s==null?void 0:s.error)===null||t===void 0?void 0:t.errorMessage),s.data}catch(s){this.loggerWrapper.warn("Webauthn start failed",s.message)}}))),pe.set(this,null),Oe.set(this,Zs((t,s)=>r.__awaiter(this,void 0,void 0,function*(){var o;if(t.getAttribute("formnovalidate")==="true"||r.__classPrivateFieldGet(this,b,"m",ki).call(this)){const n=t==null?void 0:t.getAttribute("id");r.__classPrivateFieldGet(this,b,"m",Ai).call(this,t);const a=yield r.__classPrivateFieldGet(this,b,"m",Ei).call(this),l=Ks(t);this.nextRequestStatus.update({isLoading:!0});const d=Object.assign(Object.assign(Object.assign({},l),a),{origin:((o=this.nativeOptions)===null||o===void 0?void 0:o.origin)||window.location.origin});yield s(n,d),this.nextRequestStatus.update({isLoading:!1}),r.__classPrivateFieldGet(this,b,"m",xi).call(this,a)}}))),this.flowState=e}nativeResume(e,t){var s,o,n,a,l,d;const u=JSON.parse(t);if(e==="oauthWeb"||e==="sso"){let c,{exchangeCode:h}=u;if(!h){const p=new URL(u.url);h=(s=p.searchParams)===null||s===void 0?void 0:s.get(tt),c=((o=p.searchParams)===null||o===void 0?void 0:o.get(it))||void 0}(a=(n=this.nativeCallbacks).complete)===null||a===void 0||a.call(n,{exchangeCode:h,exchangeError:c,idpInitiated:!0})}else if(e==="magicLink"){const c=new URL(u.url),h=c.searchParams.get(et),p=c.searchParams.get(Ze).split("_").pop();r.__classPrivateFieldGet(this,he,"f").call(this),this.flowState.update({token:h,stepId:p,action:void 0})}else if(e==="beforeScreen"){const{screenResolve:c}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:h}=u;h||(this.nativeCallbacks.screenNext=null),c==null||c(h)}else if(e==="resumeScreen"){const{interactionId:c,form:h}=u,{screenNext:p}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,p==null||p(c,h)}else(d=(l=this.nativeCallbacks).complete)===null||d===void 0||d.call(l,u)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map(t=>t.moduleRes).filter(t=>!!t)}loadSdkScripts(e){if(!(e!=null&&e.length))return null;const t=(n,a)=>l=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[sr(n.id,n.resultKey)]:l},bubbles:!0,composed:!0})),a(n.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map(n=>n.id).join(", ")}`);const s=Promise.all(e==null?void 0:e.map(n=>r.__awaiter(this,void 0,void 0,function*(){var a,l;const d=this.shadowRoot.querySelector(`[data-script-id="${n.id}"]`);if(d){this.loggerWrapper.debug("Script already loaded",n.id);const{moduleRes:c}=d;return(a=c==null?void 0:c.start)===null||a===void 0||a.call(c),c}yield this.injectNpmLib("@descope/flow-scripts","1.0.14",`dist/${n.id}.js`);const u=(l=globalThis.descope)===null||l===void 0?void 0:l[n.id];return new Promise((c,h)=>{try{const p=u(n.initArgs,{baseUrl:this.baseUrl,ref:this},t(n,c),this.loggerWrapper);if(p){const f=document.createElement("div");f.setAttribute("data-script-id",n.id),f.moduleRes=p,this.shadowRoot.appendChild(f),this.nextRequestStatus.subscribe(()=>{var m;this.loggerWrapper.debug("Unloading script",n.id),(m=p.stop)===null||m===void 0||m.call(p)})}}catch(p){h(p)}})}))),o=new Promise(n=>{setTimeout(()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),n(!0)},ii)});return Promise.race([s,o])}get isDismissScreenErrorOnInput(){return this.getAttribute("dismiss-screen-error-on-input")==="true"}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return r.__awaiter(this,void 0,void 0,function*(){var t,s;this.shadowRoot.isConnected&&((t=this.flowState)===null||t===void 0||t.subscribe(this.onFlowChange.bind(this)),r.__classPrivateFieldGet(this,b,"m",Ke).call(this),window.addEventListener("visibilitychange",r.__classPrivateFieldGet(this,xe,"f").visibilitychange)),yield(s=e.init)===null||s===void 0?void 0:s.call(this)})}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),r.__classPrivateFieldGet(this,he,"f").call(this),(e=r.__classPrivateFieldGet(this,q,"f"))===null||e===void 0||e.abort(),r.__classPrivateFieldSet(this,q,null,"f"),window.removeEventListener("visibilitychange",r.__classPrivateFieldGet(this,xe,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return r.__awaiter(this,void 0,void 0,function*(){let s;const o=Ce(e),n=yield this.getTargetLocales();return n.includes(o.locale)?s=`${t}-${o.locale}.html`:n.includes(o.fallback)&&(s=`${t}-${o.fallback}.html`),s})}getPageContent(e,t){return r.__awaiter(this,void 0,void 0,function*(){if(t)try{const{body:s}=yield this.fetchStaticResource(t,"text");return s}catch(s){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,s)}try{const{body:s}=yield this.fetchStaticResource(e,"text");return s}catch(s){this.loggerWrapper.error("Failed to fetch flow page",s.message)}return null})}onFlowChange(e,t,s){return r.__awaiter(this,void 0,void 0,function*(){var o,n;const{projectId:a,flowId:l,tenant:d,stepId:u,executionId:c,action:h,screenId:p,screenState:f,redirectTo:m,redirectIsPopup:S,redirectUrl:w,token:g,code:v,isPopup:_,exchangeError:y,webauthnTransactionId:$,webauthnOptions:O,redirectAuthCodeChallenge:M,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:R,redirectAuthInitiator:ee,locale:T,samlIdpResponseUrl:be,samlIdpResponseSamlResponse:L,samlIdpResponseRelayState:te,nativeResponseType:we,nativePayload:W,reqTimestamp:z}=e,I=r.__rest(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 U,Te,ye;const Se=wr(),{outboundAppId:ct}=this,{outboundAppScopes:dt}=this,K=this.sdk.getLastUserLoginId(),k=yield this.getFlowConfig(),H=yield this.getProjectConfig(),ut=Object.entries(H.flows||{}).reduce((F,[C,G])=>(F[C]=G.version,F),{}),ht=j&&M?{callbackUrl:j,codeChallenge:M,backupCallbackUri:R}:void 0,pt=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 gt={};if(!c){const F=[...k.clientScripts||[],...k.sdkScripts||[]];if(k.conditions){let C=[];({startScreenId:U,conditionInteractionId:ye,startScreenName:Te,clientScripts:C,componentsConfig:gt}=Sr({loginId:K,code:v,token:g,abTestingKey:Se,lastAuth:Pe(K)},k.conditions)),F.push(...C||[])}else k.condition?{startScreenId:U,conditionInteractionId:ye}=yr(k.condition,{loginId:K,code:v,token:g,abTestingKey:Se,lastAuth:Pe(K)}):(Te=k.startScreenName,U=k.startScreenId);if(r.__classPrivateFieldSet(this,le,this.loadSdkScripts(F),"f"),k.fingerprintEnabled&&k.fingerprintKey?yield r.X(k.fingerprintKey,this.baseUrl):r.Z(),!wt(U,I)){const C=yield this.sdk.flow.start(l,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:ht},I),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:Pe(K),abTestingKey:Se,locale:Ce(T).locale,nativeOptions:pt,outboundAppId:ct,outboundAppScopes:dt}),ye,"",H.componentsVersion,ut,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),v?{exchangeCode:v,idpInitiated:!0}:{}),I.descopeIdpInitiated&&{idpInitiated:!0}),g?{token:g}:{}),I.oidcLoginHint?{externalId:I.oidcLoginHint}:{}));return r.__classPrivateFieldGet(this,V,"f").call(this,C),void(((o=C==null?void 0:C.data)===null||o===void 0?void 0:o.status)!=="completed"&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:_,code:v,exchangeError:y,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),_&&(s("code")&&v||s("exchangeError")&&y))return void r.__classPrivateFieldGet(this,b,"m",Oi).call(this,c,v,y);if(c&&(s("token")&&g||s("code")&&v||s("exchangeError")&&y)){const F=yield this.sdk.flow.next(c,u,ce.submit,k.version,H.componentsVersion,{token:g,exchangeCode:v,exchangeError:y});return r.__classPrivateFieldGet(this,V,"f").call(this,F),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(h===N.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some(F=>s(F))){if(!be||!L)return void this.loggerWrapper.error("Did not get saml idp params data to load");Qs(be,L,te||"",Xs)}if(h===N.redirect&&(s("redirectTo")||s("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if(m==="no-op")return;if(ee==="android"&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${S}`),S){this.loggerWrapper.debug("Opening redirect in popup");const F=rr(m,"?",598,700),C=this.shouldUsePopupPostMessage();C&&(F.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(C?"postMessage":"BroadcastChannel"));const G=Q=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(Q.data));const vt=C?this.popupOrigin:window.location.origin;if(Q.origin!==vt)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${Q.origin}", expected: "${vt}"`);const{action:Di,data:ft}=Q.data||{};Di==="code"&&this.flowState.update({code:ft.code,exchangeError:ft.exchangeError})};let A;this.loggerWrapper.debug("Starting popup closed detection");const Ni=setInterval(()=>{F.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(Ni),r.__classPrivateFieldGet(this,b,"m",B).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),A==null||A())},1e3);if(C)window.addEventListener("message",G),A=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",G)};else{this.loggerWrapper.debug("Creating broadcast channel");const Q=new BroadcastChannel(c);Q.onmessage=G,A=()=>{this.loggerWrapper.debug("Closing channel"),Q.close()}}}else this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),r.__classPrivateFieldGet(this,b,"m",B).call(this,"popupclosed",{});return}if(h===N.webauthnCreate||h===N.webauthnGet){if(!$||!O)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let F,C;(n=r.__classPrivateFieldGet(this,q,"f"))===null||n===void 0||n.abort(),r.__classPrivateFieldSet(this,q,null,"f");try{F=h===N.webauthnCreate?yield this.sdk.webauthn.helpers.create(O):yield this.sdk.webauthn.helpers.get(O)}catch(A){A.name==="InvalidStateError"?this.loggerWrapper.warn("WebAuthn operation failed",A.message):A.name!=="NotAllowedError"&&this.loggerWrapper.error(A.message),C=A.name}const G=yield this.sdk.flow.next(c,u,ce.submit,k.version,H.componentsVersion,{transactionId:$,response:F,failure:C});r.__classPrivateFieldGet(this,V,"f").call(this,G)}if(h===N.nativeBridge)return this.nativeCallbacks.complete=F=>r.__awaiter(this,void 0,void 0,function*(){const C=yield this.sdk.flow.next(c,u,ce.submit,k.version,H.componentsVersion,F);r.__classPrivateFieldGet(this,V,"f").call(this,C)}),r.__classPrivateFieldGet(this,b,"m",Ie).call(this,we,W),void setTimeout(()=>{this.dispatchEvent(new Event("popupclosed"))},500);if((s("action")||s("deferredPolling"))&&r.__classPrivateFieldGet(this,oe,"f").call(this,c,u,k.version,H.componentsVersion),!p&&!U)return void this.loggerWrapper.warn("No screen was found to show");const Le=U||p,Mi=yield this.getHtmlFilenameWithLocale(T,Le),{oidcLoginHint:Ui,oidcPrompt:ji,oidcErrorRedirectUri:Ri,oidcResource:Ti,samlIdpUsername:Li}=I,Y={direction:ds(u,t.stepId),screenState:Object.assign(Object.assign({},f),{form:Object.assign(Object.assign({},this.formConfigValues),f==null?void 0:f.form),lastAuth:{loginId:K,name:this.sdk.getLastUserDisplayName()||K},componentsConfig:Object.assign(Object.assign(Object.assign({},k.componentsConfig),gt),f==null?void 0:f.componentsConfig)}),htmlFilename:`${Le}.html`,htmlLocaleFilename:Mi,screenId:Le,stepName:e.stepName||Te,samlIdpUsername:Li,oidcLoginHint:Ui,oidcPrompt:ji,oidcErrorRedirectUri:Ri,oidcResource:Ti,action:h,locale:Ce(T).locale},Wi=Pe(K);wt(U,I)?Y.next=(F,C)=>r.__awaiter(this,void 0,void 0,function*(){const G=(k==null?void 0:k.clientScripts)||[];yield r.__classPrivateFieldGet(this,b,"m",Xe).call(this,G);const A=yield this.sdk.flow.start(l,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:ht},I),{lastAuth:Wi,preview:this.preview,abTestingKey:Se,client:this.client}),w&&{redirectUrl:w}),{locale:Ce(T).locale,nativeOptions:pt,outboundAppId:ct,outboundAppScopes:dt}),ye,F,H.componentsVersion,ut,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),St(C)),v&&{exchangeCode:v,idpInitiated:!0}),I.descopeIdpInitiated&&{idpInitiated:!0}),g&&{token:g}),Y.next.isCustomScreen);return r.__classPrivateFieldGet(this,V,"f").call(this,A),A}):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(Y.next=(F,C)=>r.__awaiter(this,void 0,void 0,function*(){const G=(f==null?void 0:f.clientScripts)||[];yield r.__classPrivateFieldGet(this,b,"m",Xe).call(this,G);const A=yield this.sdk.flow.next(c,u,F,k.version,H.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),St(C)),Y.next.isCustomScreen);return r.__classPrivateFieldGet(this,V,"f").call(this,A),A})),this.loggerWrapper.debug("Got a screen with id",Y.screenId),yield r.__classPrivateFieldGet(this,b,"m",Pi).call(this,Y),this.stepState.update(Y)})}onStepChange(e,t){return r.__awaiter(this,void 0,void 0,function*(){var s,o,n;const{htmlFilename:a,htmlLocaleFilename:l,direction:d,next:u,screenState:c}=e;this.loggerWrapper.debug("Rendering a flow screen");const h=document.createElement("template");h.innerHTML=yield this.getPageContent(a,l);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield r.__classPrivateFieldGet(this,b,"m",Fi).call(this,p,u):mr(p),!e.samlIdpUsername||!((s=c.form)===null||s===void 0)&&s.loginId||!((o=c.form)===null||o===void 0)&&o.email||(c.form||(c.form={}),c.form.loginId=e.samlIdpUsername,c.form.email=e.samlIdpUsername),ur(p,c,this.formConfig,this.loggerWrapper);const{geo:m}=(n=yield this.getExecutionContext())!==null&&n!==void 0?n:{};vr(p,m),fr(p,e.locale);const S=()=>r.__awaiter(this,void 0,void 0,function*(){var w,g;yield f;const v=this.contentRootElement;pr(v,(w=c==null?void 0:c.totp)===null||w===void 0?void 0:w.image),gr(v,(g=c==null?void 0:c.notp)===null||g===void 0?void 0:g.image),dr(v,p,c.cssVars,this.loggerWrapper),v.replaceChildren(p);const _=!t.htmlFilename;setTimeout(()=>{r.__classPrivateFieldGet(this,b,"m",Ii).call(this),this.validateOnBlur&&zs(v),hr(v,c),r.__classPrivateFieldGet(this,b,"m",Qe).call(this,{isFirstScreen:_,isCustomScreen:!1,stepName:e.stepName}),ai(v,this.autoFocus,_)}),r.__classPrivateFieldGet(this,b,"m",$i).call(this,u),v.querySelector(`[${Ue}="polling"]`)&&u(ce.polling,{})});d?r.__classPrivateFieldGet(this,b,"m",Je).call(this,S):S()})}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${st}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch{return!1}return!0}}ue=new WeakMap,q=new WeakMap,le=new WeakMap,xe=new WeakMap,$e=new WeakMap,He=new WeakMap,oe=new WeakMap,he=new WeakMap,ze=new WeakMap,V=new WeakMap,Ye=new WeakMap,pe=new WeakMap,Oe=new WeakMap,b=new WeakSet,Si=function(){document.hidden||setTimeout(()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})},300)},Mt=function(i,e,t){return r.__awaiter(this,void 0,void 0,function*(){var s;return((s=this.nativeOptions)===null||s===void 0?void 0:s.bridgeVersion)>=2&&new Promise(o=>{this.nativeCallbacks.screenNext=t,this.nativeCallbacks.screenResolve=o,r.__classPrivateFieldGet(this,b,"m",Ie).call(this,"beforeScreen",{screen:i,context:e})})})},Ut=function(i){var e;((e=this.nativeOptions)===null||e===void 0?void 0:e.bridgeVersion)>=2&&r.__classPrivateFieldGet(this,b,"m",Ie).call(this,"afterScreen",{screen:i})},Ie=function(i,e){r.__classPrivateFieldGet(this,b,"m",B).call(this,"bridge",{type:i,payload:e})},jt=function({errorText:i,errorType:e}){const t=()=>{var s;let o=i;try{o=((s=this.errorTransformer)===null||s===void 0?void 0:s.call(this,{text:i,type:e}))||i}catch(n){this.loggerWrapper.error("Error transforming error message",n.message)}cr(this.contentRootElement,"error-message",o)};this.addEventListener("screen-updated",t,{once:!0}),t()},Ke=function(){var i,e,t;(i=this.stepState)===null||i===void 0||i.subscribe(this.onStepChange.bind(this),s=>{var o=s.screenState,n=r.__rest(o===void 0?{}:o,["errorText","errorType"]),a=r.__rest(s,["screenState"]);return Object.assign(Object.assign({},a),{screenState:n})}),(e=this.stepState)===null||e===void 0||e.subscribe(r.__classPrivateFieldGet(this,b,"m",jt).bind(this),s=>{var o,n;return{errorText:(o=s==null?void 0:s.screenState)===null||o===void 0?void 0:o.errorText,errorType:(n=s==null?void 0:s.screenState)===null||n===void 0?void 0:n.errorType}},{forceUpdate:!0}),(t=this.stepState)===null||t===void 0||t.subscribe(r.__classPrivateFieldGet(this,b,"m",Rt).bind(this),s=>{var o,n;return{errorText:(o=s==null?void 0:s.screenState)===null||o===void 0?void 0:o.errorText,errorType:(n=s==null?void 0:s.screenState)===null||n===void 0?void 0:n.errorType}},{forceUpdate:!0})},Rt=function({errorText:i,errorType:e}){(e||i)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach(t=>{t.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach(s=>{s.value=""})}),ai(this.contentRootElement,this.autoFocus,!1))},Ci=function(){return r.__awaiter(this,void 0,void 0,function*(){this.loggerWrapper.debug("Trying to restart the flow");const i=yield this.getComponentsVersion();this.reset(),i===(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")})},Pi=function(i){return r.__awaiter(this,void 0,void 0,function*(){var e;const t=Object.assign(Object.assign({},this.stepState.current),i),{next:s,stepName:o}=t,n=r.__rest(t,["next","stepName"]),a=ir(n);let l=yield r.__classPrivateFieldGet(this,b,"m",Mt).call(this,o,a,s);l||(l=!!(yield(e=this.onScreenUpdate)===null||e===void 0?void 0:e.call(this,o,a,s,this)));const d=!this.stepState.current.htmlFilename;if(r.__classPrivateFieldGet(this,He,"f").call(this,l),s&&(s.isCustomScreen=l),r.__classPrivateFieldGet(this,$e,"f")!==l){const[u,c]=["flow","custom"].sort(()=>l?-1:1);this.loggerWrapper.debug(`Switching from ${c} screen to ${u} screen`),r.__classPrivateFieldSet(this,$e,l,"f"),l?this.stepState.unsubscribeAll():r.__classPrivateFieldGet(this,b,"m",Ke).call(this)}l?(this.loggerWrapper.debug("Showing a custom screen"),r.__classPrivateFieldGet(this,b,"m",Qe).call(this,{isFirstScreen:d,isCustomScreen:l,stepName:i.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=l})},Je=function(i){this.contentRootElement.addEventListener("transitionend",()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),i()},{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},Tt=function(i){const e=i.getAttribute("name");if(!["email"].includes(e)){const t=`user-${e}`;i.setAttribute("name",t),i.addEventListener("input",()=>{i.setAttribute("name",i.value?e:t)})}},Fi=function(i,e){return r.__awaiter(this,void 0,void 0,function*(){var t;(t=r.__classPrivateFieldGet(this,q,"f"))===null||t===void 0||t.abort();const s=i.querySelector('*[autocomplete="webauthn"]');if(s&&(yield _r())){const{options:o,transactionId:n}=(yield r.__classPrivateFieldGet(this,Ye,"f").call(this))||{};o&&n&&(r.__classPrivateFieldGet(this,b,"m",Tt).call(this,s),r.__classPrivateFieldSet(this,q,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(o,r.__classPrivateFieldGet(this,q,"f")).then(a=>r.__awaiter(this,void 0,void 0,function*(){e(s.id,{transactionId:n,response:a})})).catch(a=>{a.name!=="AbortError"&&this.loggerWrapper.error("Conditional login failed",a.message)}))}})},Qe=function({isFirstScreen:i,isCustomScreen:e,stepName:t}){i&&r.__classPrivateFieldGet(this,b,"m",B).call(this,"ready",{}),e||r.__classPrivateFieldGet(this,b,"m",Ut).call(this,t),r.__classPrivateFieldGet(this,b,"m",B).call(this,"page-updated",{screenName:t}),r.__classPrivateFieldGet(this,b,"m",B).call(this,"screen-updated",{screenName:t})},ki=function(){let i=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach(e=>{var t,s;e.localName==="slot"||e.classList.contains("hidden")||((t=e.reportValidity)===null||t===void 0||t.call(e),i&&(i=(s=e.checkValidity)===null||s===void 0?void 0:s.call(e)))}),i},Ei=function(){return r.__awaiter(this,void 0,void 0,function*(){const i=this.getInputs();return(yield Promise.all(i.map(e=>r.__awaiter(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}),{})})},Ai=function(i){const e=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter(n=>n!==i),t=()=>r.__awaiter(this,void 0,void 0,function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",t),i.removeAttribute("loading"),e.forEach(l=>{l.removeAttribute("disabled")});const n=yield this.getFlowConfig(),a=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(a)}),s=()=>{var n;window.removeEventListener("pageshow",r.__classPrivateFieldGet(this,pe,"f")),r.__classPrivateFieldSet(this,pe,l=>{l.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),t())},"f"),window.addEventListener("pageshow",r.__classPrivateFieldGet(this,pe,"f"),{once:!0});const a=(n=this.stepState)===null||n===void 0?void 0:n.subscribe((l,d)=>{l===d&&t(),this.removeEventListener("popupclosed",t),this.stepState.unsubscribe(a)},l=>l.screenId,{forceUpdate:!0})},o=this.nextRequestStatus.subscribe(({isLoading:n})=>{n?(this.addEventListener("popupclosed",t,{once:!0}),i.setAttribute("loading","true"),e.forEach(a=>a.setAttribute("disabled","true"))):(this.nextRequestStatus.unsubscribe(o),s())})},xi=function(i={}){var e,t;const s=yt(i,["externalId","email","phone"]),o=yt(i,["newPassword","password"]);if(s&&o)try{if(!globalThis.PasswordCredential)return;const n=new globalThis.PasswordCredential({id:s,password:o});(t=(e=navigator==null?void 0:navigator.credentials)===null||e===void 0?void 0:e.store)===null||t===void 0||t.call(e,n)}catch(n){this.loggerWrapper.error("Could not store credentials",n.message)}},Ii=function(){er(),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach(i=>r.__classPrivateFieldGet(this,b,"m",Lt).call(this,i))},Lt=function(i){i&&i.querySelectorAll("input").forEach(e=>{const t=e.getAttribute("slot"),s=`input-${i.id}-${t}`,o=document.createElement("slot");o.setAttribute("name",s),o.setAttribute("slot",t),i.appendChild(o),e.setAttribute("slot",s),this.appendChild(e)})},Xe=function(i){return r.__awaiter(this,void 0,void 0,function*(){if(r.__classPrivateFieldGet(this,le,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const o=Date.now();yield r.__classPrivateFieldGet(this,le,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-o).toString())}const e=this.loadSdkScriptsModules(),t=i.map(o=>o.id);for(const o of e)if(t.includes(o.id))try{typeof o.present=="function"&&((yield o.present())||this.loggerWrapper.debug(`Sdk script ${o.id} was cancelled`))}catch(n){this.loggerWrapper.error(`Failed to present ${o.id} script module`,n.message)}const s=[];for(const o of e)typeof o.refresh=="function"&&s.push(o.refresh());if(s.length>0)try{yield rt(ii,Promise.all(s),null)}catch(o){this.loggerWrapper.error("Failed to refresh script module",o.message)}})},Wt=function(i){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach(e=>{e.addEventListener("input",()=>{var t;!((t=e.checkValidity)===null||t===void 0)&&t.call(e)&&r.__classPrivateFieldGet(this,Oe,"f").call(this,e,i)})})},$i=function(i){this.contentRootElement.querySelectorAll(`descope-button:not([${bt}]), [data-type="button"]:not([${bt}]`).forEach(e=>{e.onclick=()=>{r.__classPrivateFieldGet(this,Oe,"f").call(this,e,i)}}),r.__classPrivateFieldGet(this,b,"m",Wt).call(this,i),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${st}])`).forEach(e=>{e.addEventListener("input",()=>{this.stepState.update(t=>Object.assign(Object.assign({},t),{screenState:Object.assign(Object.assign({},t.screenState),{errorText:"",errorType:""})}))})})},B=function(i,e){this.dispatchEvent(new CustomEvent(i,{detail:e}))},Oi=function(i,e,t){var s;const[o,n]=((s=window.name)===null||s===void 0?void 0:s.split("|"))||[],a={data:{code:e,exchangeError:t},action:"code"};if(o==="descope-wc"&&n){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",n);try{window.opener.postMessage(a,n)}catch(l){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",l==null?void 0:l.message)}}else{this.loggerWrapper.debug("Creating popup channel",i);const l=new BroadcastChannel(i);l.postMessage(a),l.close()}try{window.close()}catch{}};customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Gi);const co=Object.freeze(Object.defineProperty({__proto__:null,default:Gi},Symbol.toStringTag,{value:"Module"}));exports.c=ne;exports.index=co;exports.injectStyleMixin=Re;
50
50
  //# sourceMappingURL=index.cjs3.js.map