chordia-ui 3.3.8 → 3.3.9

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 (159) hide show
  1. package/dist/AgentLiftCard.cjs.js.map +1 -1
  2. package/dist/AgentLiftCard.es.js +5 -3
  3. package/dist/AgentLiftCard.es.js.map +1 -1
  4. package/dist/CustomFilterChips.cjs.js.map +1 -1
  5. package/dist/CustomFilterChips.es.js +2 -1
  6. package/dist/CustomFilterChips.es.js.map +1 -1
  7. package/dist/FileUploadingState.cjs.js.map +1 -1
  8. package/dist/FileUploadingState.es.js +16 -10
  9. package/dist/FileUploadingState.es.js.map +1 -1
  10. package/dist/IntegrationCard.cjs.js.map +1 -1
  11. package/dist/IntegrationCard.es.js +3 -3
  12. package/dist/IntegrationCard.es.js.map +1 -1
  13. package/dist/SectionLabel.cjs.js.map +1 -1
  14. package/dist/SectionLabel.es.js.map +1 -1
  15. package/dist/SmallButton.cjs.js.map +1 -1
  16. package/dist/SmallButton.es.js +16 -16
  17. package/dist/SmallButton.es.js.map +1 -1
  18. package/dist/SummarySection.cjs.js.map +1 -1
  19. package/dist/SummarySection.es.js +11 -9
  20. package/dist/SummarySection.es.js.map +1 -1
  21. package/dist/TextInput.cjs.js.map +1 -1
  22. package/dist/TextInput.es.js.map +1 -1
  23. package/dist/Timeline.cjs.js.map +1 -1
  24. package/dist/Timeline.es.js +14 -8
  25. package/dist/Timeline.es.js.map +1 -1
  26. package/dist/Tooltip.cjs.js +1 -1
  27. package/dist/Tooltip.cjs.js.map +1 -1
  28. package/dist/Tooltip.es.js +31 -20
  29. package/dist/Tooltip.es.js.map +1 -1
  30. package/dist/TourGuideTooltip.cjs.js.map +1 -1
  31. package/dist/TourGuideTooltip.es.js +2 -1
  32. package/dist/TourGuideTooltip.es.js.map +1 -1
  33. package/dist/UpdatedInteractionRecording.cjs.js +1 -1
  34. package/dist/UpdatedInteractionRecording.cjs.js.map +1 -1
  35. package/dist/UpdatedInteractionRecording.es.js +79 -97
  36. package/dist/UpdatedInteractionRecording.es.js.map +1 -1
  37. package/dist/UploadInteraction.cjs.js.map +1 -1
  38. package/dist/UploadInteraction.es.js.map +1 -1
  39. package/dist/colors.cjs.js +2 -0
  40. package/dist/colors.cjs.js.map +1 -0
  41. package/dist/colors.es.js +2 -0
  42. package/dist/colors.es.js.map +1 -0
  43. package/dist/components/UpdatedInteractionDetails.cjs.js +10 -1
  44. package/dist/components/UpdatedInteractionDetails.cjs.js.map +1 -1
  45. package/dist/components/UpdatedInteractionDetails.es.js +1531 -9
  46. package/dist/components/UpdatedInteractionDetails.es.js.map +1 -1
  47. package/dist/components/chat.cjs.js +30 -1
  48. package/dist/components/chat.cjs.js.map +1 -1
  49. package/dist/components/chat.es.js +2222 -7
  50. package/dist/components/chat.es.js.map +1 -1
  51. package/dist/components/common.cjs.js +1 -1
  52. package/dist/components/common.es.js +32 -25
  53. package/dist/components/common.es.js.map +1 -1
  54. package/dist/components/data.cjs.js +1 -1
  55. package/dist/components/data.cjs.js.map +1 -1
  56. package/dist/components/data.es.js +1033 -4
  57. package/dist/components/data.es.js.map +1 -1
  58. package/dist/components/layout.cjs.js +3 -1
  59. package/dist/components/layout.cjs.js.map +1 -1
  60. package/dist/components/layout.es.js +1533 -8
  61. package/dist/components/layout.es.js.map +1 -1
  62. package/dist/components/login.cjs.js +1 -1
  63. package/dist/components/login.es.js +6 -2
  64. package/dist/components/login.es.js.map +1 -1
  65. package/dist/components/media.cjs.js +1 -1
  66. package/dist/components/media.cjs.js.map +1 -1
  67. package/dist/components/media.es.js +220 -6
  68. package/dist/components/media.es.js.map +1 -1
  69. package/dist/components/models.cjs.js +1 -1
  70. package/dist/components/models.cjs.js.map +1 -1
  71. package/dist/components/models.es.js +91 -2
  72. package/dist/components/models.es.js.map +1 -1
  73. package/dist/components/navigation.cjs.js +1 -1
  74. package/dist/components/navigation.cjs.js.map +1 -1
  75. package/dist/components/navigation.es.js +766 -7
  76. package/dist/components/navigation.es.js.map +1 -1
  77. package/dist/components/notifications.cjs.js +1 -1
  78. package/dist/components/notifications.cjs.js.map +1 -1
  79. package/dist/components/notifications.es.js +368 -3
  80. package/dist/components/notifications.es.js.map +1 -1
  81. package/dist/components/onboarding.cjs.js +1 -1
  82. package/dist/components/onboarding.cjs.js.map +1 -1
  83. package/dist/components/onboarding.es.js +985 -7
  84. package/dist/components/onboarding.es.js.map +1 -1
  85. package/dist/components/primitives.cjs.js +1 -1
  86. package/dist/components/primitives.cjs.js.map +1 -1
  87. package/dist/components/primitives.es.js +635 -25
  88. package/dist/components/primitives.es.js.map +1 -1
  89. package/dist/debugger-wc.cjs.js +4 -4
  90. package/dist/debugger-wc.cjs.js.map +1 -1
  91. package/dist/debugger-wc.es.js +15 -11
  92. package/dist/debugger-wc.es.js.map +1 -1
  93. package/dist/index.cjs.js +1 -1
  94. package/dist/index.cjs2.js +2 -49
  95. package/dist/index.cjs2.js.map +1 -1
  96. package/dist/index.cjs3.js +50 -0
  97. package/dist/index.cjs3.js.map +1 -0
  98. package/dist/index.es.js +104 -99
  99. package/dist/index.es.js.map +1 -1
  100. package/dist/index.es2.js +2632 -1776
  101. package/dist/index.es2.js.map +1 -1
  102. package/dist/index.es3.js +1944 -0
  103. package/dist/index.es3.js.map +1 -0
  104. package/dist/pages/interactionDetails.cjs.js +1 -1
  105. package/dist/pages/interactionDetails.cjs.js.map +1 -1
  106. package/dist/pages/interactionDetails.es.js +70 -47
  107. package/dist/pages/interactionDetails.es.js.map +1 -1
  108. package/dist/sortable.esm.cjs.js +1 -1
  109. package/dist/sortable.esm.cjs.js.map +1 -1
  110. package/dist/sortable.esm.es.js +55 -53
  111. package/dist/sortable.esm.es.js.map +1 -1
  112. package/dist/{chordia-ui.css → style.css} +1 -1
  113. package/package.json +1 -1
  114. package/src/components/UpdatedInteractionDetails/UpdatedInteractionDetails.jsx +318 -77
  115. package/src/components/UpdatedInteractionDetails/UpdatedInteractionRecording.jsx +7 -17
  116. package/dist/ChartRenderer.cjs.js +0 -31
  117. package/dist/ChartRenderer.cjs.js.map +0 -1
  118. package/dist/ChartRenderer.es.js +0 -2210
  119. package/dist/ChartRenderer.es.js.map +0 -1
  120. package/dist/GettingStarted.cjs.js +0 -2
  121. package/dist/GettingStarted.cjs.js.map +0 -1
  122. package/dist/GettingStarted.es.js +0 -983
  123. package/dist/GettingStarted.es.js.map +0 -1
  124. package/dist/InlineConfirm.cjs.js +0 -2
  125. package/dist/InlineConfirm.cjs.js.map +0 -1
  126. package/dist/InlineConfirm.es.js +0 -618
  127. package/dist/InlineConfirm.es.js.map +0 -1
  128. package/dist/InteractionSummaryCard.cjs.js +0 -2
  129. package/dist/InteractionSummaryCard.cjs.js.map +0 -1
  130. package/dist/InteractionSummaryCard.es.js +0 -216
  131. package/dist/InteractionSummaryCard.es.js.map +0 -1
  132. package/dist/LoginPage.cjs.js +0 -3
  133. package/dist/LoginPage.cjs.js.map +0 -1
  134. package/dist/LoginPage.es.js +0 -2618
  135. package/dist/LoginPage.es.js.map +0 -1
  136. package/dist/NavigationBar.cjs.js +0 -2
  137. package/dist/NavigationBar.cjs.js.map +0 -1
  138. package/dist/NavigationBar.es.js +0 -762
  139. package/dist/NavigationBar.es.js.map +0 -1
  140. package/dist/NotificationPanel.cjs.js +0 -2
  141. package/dist/NotificationPanel.cjs.js.map +0 -1
  142. package/dist/NotificationPanel.es.js +0 -371
  143. package/dist/NotificationPanel.es.js.map +0 -1
  144. package/dist/OverlayPanel.cjs.js +0 -2
  145. package/dist/OverlayPanel.cjs.js.map +0 -1
  146. package/dist/OverlayPanel.es.js +0 -93
  147. package/dist/OverlayPanel.es.js.map +0 -1
  148. package/dist/SplitPane.cjs.js +0 -4
  149. package/dist/SplitPane.cjs.js.map +0 -1
  150. package/dist/SplitPane.es.js +0 -1531
  151. package/dist/SplitPane.es.js.map +0 -1
  152. package/dist/SummaryStatsPanel.cjs.js +0 -2
  153. package/dist/SummaryStatsPanel.cjs.js.map +0 -1
  154. package/dist/SummaryStatsPanel.es.js +0 -1027
  155. package/dist/SummaryStatsPanel.es.js.map +0 -1
  156. package/dist/UpdatedInteractionDetails.cjs.js +0 -11
  157. package/dist/UpdatedInteractionDetails.cjs.js.map +0 -1
  158. package/dist/UpdatedInteractionDetails.es.js +0 -1310
  159. package/dist/UpdatedInteractionDetails.es.js.map +0 -1
@@ -0,0 +1,50 @@
1
+ "use strict";const r=require("./index.cjs2.js"),De=typeof localStorage<"u",Nt="J151000",Vi="J151001",mt="E103205",qi="E102004",Bi="E103202",Ki=De&&localStorage.getItem("base.content.url")||"",Hi="https://static.descope.com/pages",Ji="v2-beta",zi="v2-alpha",Yi="config.json",_t="base.ui.components.url";De&&localStorage.getItem(_t),De&&localStorage.getItem(_t);const Ze="descope-login-flow",et="t",tt="code",Dt="redirect_mode",it="err",Qi="ra-challenge",Xi="ra-callback",Zi="ra-backup-callback",es="ra-initiator",ts="data-descope-",st="data-exclude-field",bt="data-exclude-next",Vt="dls_last_auth",qt="state_id",Bt="saml_idp_state_id",Kt="saml_idp_username",Ht="descope_idp_initiated",Jt="sso_app_id",zt="third_party_app_id",Yt="third_party_app_state_id",Qt="oidc_login_hint",Xt="oidc_prompt",Zt="oidc_resource",ei="oidc_error_redirect_uri",ti="application_scopes",Ue="data-type",is="sdkScriptsResults",N={redirect:"redirect",poll:"poll",webauthnCreate:"webauthnCreate",webauthnGet:"webauthnGet",nativeBridge:"nativeBridge",loadForm:"loadForm"},ce={submit:"submit",polling:"polling"},ss="data-has-dynamic-attr-values",rs=["descope-multi-select-combo-box","descope-text-area"],ii=5e3,os=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Ge;(function(i){i.backward="backward",i.forward="forward"})(Ge||(Ge={}));const ns=["descope-enriched-text"];function as(i,e,t){return(...s)=>r.__awaiter(this,void 0,void 0,function*(){let o;const n=t+1;for(let a=0;a<n;a++)try{return yield i(...s)}catch(l){o=l,a<t&&(yield new Promise(d=>{setTimeout(d,e*Math.pow(2,a+1))}))}throw o})}function P(i){return new URLSearchParams(window.location.search).get(i)}function E(i){if(window.history.replaceState&&P(i)){const e=new URL(window.location.href),t=new URLSearchParams(e.search);t.delete(i),e.search=t.toString(),window.history.replaceState({},"",e.toString())}}function ls(i,e){return r.__awaiter(this,void 0,void 0,function*(){const t=yield fetch(i,{cache:"default"});if(!t.ok)throw Error(`Error fetching URL ${i} [${t.status}]`);return{body:yield t[e](),headers:Object.fromEntries(t.headers.entries())}})}function cs({projectId:i,filename:e,assetsFolder:t=Ji,baseUrl:s}){const o=new URL(Ki||s||Hi);return o.pathname=((...n)=>n.join("/").replace(/\/+/g,"/"))(o.pathname,i,t,e),o.toString()}function ds(i,e){if(!e)return;const t=+i,s=+e;return Number.isNaN(t)||Number.isNaN(s)?void 0:t>s?Ge.forward:t<s?Ge.backward:void 0}const si=i=>{let[e="",t=""]=(P(Ze)||"").split("_");const s=(o=>{var n;return((n=/(.*)\|#\|.*/.exec(o))===null||n===void 0?void 0:n[1])||""})(e);return(!i||s&&s!==i)&&(e="",t=""),{executionId:e,stepId:t,executionFlowId:s}};function us(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}function ri(){E(Ze)}function hs(){return P(et)||void 0}function ps(){E(et)}function gs(){return P(tt)||void 0}function vs(){return P(Dt)==="popup"}function fs(){return P(it)||void 0}function ms(){E(tt)}function _s(){E(Dt)}function bs(){E(it)}function ws(){return{redirectAuthCodeChallenge:P(Qi),redirectAuthCallbackUrl:P(Xi),redirectAuthBackupCallbackUri:P(Zi),redirectAuthInitiator:P(es)}}function ys(){return P(qt)}function Ss(){E(qt)}function Cs(){return P(Bt)}function Ps(){E(Bt)}function Fs(){return P(Kt)}function ks(){E(Kt)}function Es(){return P(Ht)}function As(){E(Ht)}function xs(){return P(Jt)}function Is(){return P(zt)}function $s(){E(Jt)}function Os(){E(zt)}function Gs(){return P(Yt)}function Ms(){E(Yt)}function Us(){return P(ti)}function js(){E(ti)}function Rs(){return P(Qt)}function Ts(){E(Qt)}function Ls(){return P(Xt)}function Ws(){E(Xt)}function Ns(){return P(ei)}function Ds(){E(ei)}function Vs(){return P(Zt)}function qs(){E(Zt)}const oi=i=>i.replace(/-./g,e=>e[1].toUpperCase()),Bs=(i,e)=>t=>i[t]!==e[t],Ks=i=>Array.from((i==null?void 0:i.attributes)||[]).reduce((e,t)=>{var s;const o=(s=new RegExp(`^${ts}(\\S+)$`).exec(t.name))===null||s===void 0?void 0:s[1];return o?Object.assign(e,{[o]:t.value}):e},{}),Hs=(i,e)=>{const{executionId:t,stepId:s,executionFlowId:o}=si(i);if(o&&i!==o)return e.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(t||s)&&ri();const n=hs();n&&ps();const a=gs();a&&ms();const l=vs();l&&_s();const d=fs();d&&bs();const{redirectAuthCodeChallenge:u,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p}=ws(),f=ys();f&&Ss();const m=Cs();m&&Ps();const S=Fs();m&&ks();const w=Es();w&&As();const g=xs();g&&$s();const v=Is();v&&Os();const _=Gs();_&&Ms();const y=Us();y&&js();const $=Rs();$&&Ts();const O=Ls();O&&Ws();const M=Ns();M&&Ds();const j=Vs();return j&&qs(),{executionId:t,stepId:s,token:n,code:a,isPopup:l,exchangeError:d,redirectAuthCodeChallenge:u,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p,ssoQueryParams:{oidcIdpStateId:f,samlIdpStateId:m,samlIdpUsername:S,descopeIdpInitiated:w==="true",ssoAppId:g,oidcLoginHint:$,oidcPrompt:O,oidcErrorRedirectUri:M,oidcResource:j,thirdPartyAppId:v,thirdPartyAppStateId:_,applicationScopes:y}}},ni=i=>{let e,t;return Object.assign((...s)=>{return e&&(n=s,(o=e).length===n.length&&o.every((a,l)=>a===n[l]))||(e=s,t=i(...s)),t;var o,n},{reset:()=>{e=void 0,t=void 0}})},Js='*[name]:not([auto-focus="false"]):not([aria-hidden="true"])',ai=(i,e,t)=>{if(e===!0||e==="skipFirstScreen"&&!t){const s=i.querySelector(Js);setTimeout(()=>{s==null||s.focus()})}},zs=i=>{i.querySelectorAll("*[name]").forEach(e=>{e.addEventListener("blur",()=>{var t;const s=()=>{var a;const l=e.focus;e.focus=()=>{},(a=e.reportValidity)===null||a===void 0||a.call(e),setTimeout(()=>{e.focus=l})};if(e.getAttribute("invalid")==="true"||!((t=e.value)===null||t===void 0)&&t.length)return void s();const o={timer:void 0},n=a=>{a.target.getAttribute("formnovalidate")==="true"&&(clearTimeout(o.timer),o.timer=void 0)};o.timer=setTimeout(()=>{i.removeEventListener("click",n),s(),o.timer=void 0},150),i.addEventListener("click",n,{once:!0})})})};function rt(i,e,t){return new Promise((s,o)=>{let n=!1;const a=setTimeout(()=>{n=!0,t!==void 0?s(t):o(new Error(`Promise timed out after ${i} ms`))},i);e.then(l=>{n||(clearTimeout(a),s(l))}).catch(l=>{n||(clearTimeout(a),o(l))})})}const Ys=()=>{var i;const e=(i=navigator==null?void 0:navigator.userAgentData)===null||i===void 0?void 0:i.brands,t=e==null?void 0:e.find(({brand:s,version:o})=>s==="Chromium"&&parseFloat(o));return t?t.version:0},wt=(i,{oidcIdpStateId:e,samlIdpStateId:t,samlIdpUsername:s,ssoAppId:o,oidcLoginHint:n,oidcPrompt:a,oidcErrorRedirectUri:l,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:c,applicationScopes:h})=>!(!i||e||t||s||o||n||a||l||d||u||c||h),Qs=(i,e,t,s)=>{const o=document.createElement("form");o.method="POST",o.action=i,o.innerHTML=`
2
+ <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />
3
+ <input type="hidden" role="saml-relay-state" name="RelayState" value="${t}" />
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=`
6
+ <div id="${Fe}">
7
+ <div id="${Ne}"></div>
8
+ </div>
9
+ `,this.injectStyle(`
10
+ #${Fe}, #${Ne} {
11
+ height: 100%;
12
+ }
13
+ #${Fe} {
14
+ position: relative;
15
+ height: fit-content;
16
+ }
17
+ `),this.contentRootElement=(o=this.shadowRoot)===null||o===void 0?void 0:o.getElementById(Ne),this.rootElement=(n=this.shadowRoot)===null||n===void 0?void 0:n.getElementById(Fe)}}}),eo="theme",to=i=>{const e=document.createElement("link");e.href=i,e.rel="stylesheet",document.head.appendChild(e)},io=async()=>{const i=localStorage.getItem(lt),e=i==null?void 0:i.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",e);const t=document.createElement("script");if(t.src=e,document.body.appendChild(t),await new Promise((s,o)=>{t.onload=s,t.onerror=o}),globalThis.DescopeDev){const{themeToStyle:s,defaultTheme:o,darkTheme:n}=globalThis.DescopeDev;return{light:s(o),dark:s(n)}}},so=(i,e)=>(e||!1)&&e!=="light"&&e!=="dark"&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ro=r.h(i=>{var e,t,s,o,n,a,l,d,u,c,h,p,f,m;const S=r.r(je({theme:so}),at,_e,Yr,gi,Zr,nt,Re)(i);return m=class extends S{constructor(){super(...arguments),e.add(this),t.set(this,void 0),s.set(this,void 0),h.set(this,()=>{r.__classPrivateFieldGet(this,e,"m",p).call(this),r.__classPrivateFieldGet(this,f,"f").call(this,this.getAttribute("theme")==="os")}),f.set(this,g=>{var v,_,y;const $=g?"addEventListener":"removeEventListener";(y=(_=(v=window.matchMedia)===null||v===void 0?void 0:v.call(window,"(prefers-color-scheme: dark)"))===null||_===void 0?void 0:_[$])===null||y===void 0||y.call(_,"change",()=>r.__classPrivateFieldGet(this,e,"m",p).call(this))})}get theme(){var g,v;const _=this.getAttribute("theme");return _==="os"?window.matchMedia&&((v=(g=window.matchMedia)===null||g===void 0?void 0:g.call(window,"(prefers-color-scheme: dark)"))===null||v===void 0?void 0:v.matches)?"dark":"light":_||"light"}get styleId(){return this.getAttribute("style-id")||eo}async init(){var g;await((g=super.init)===null||g===void 0?void 0:g.call(this)),r.__classPrivateFieldGet(this,h,"f").call(this),await Promise.all([r.__classPrivateFieldGet(this,e,"m",a).call(this),r.__classPrivateFieldGet(this,e,"m",l).call(this)]),this.observeAttributes(["theme"],r.__classPrivateFieldGet(this,h,"f")),this.observeAttributes(["style-id"],()=>{r.__classPrivateFieldSet(this,s,null,"f"),r.__classPrivateFieldGet(this,e,"m",u).call(this),r.__classPrivateFieldGet(this,e,"m",a).call(this),r.__classPrivateFieldGet(this,e,"m",l).call(this)})}},t=new WeakMap,s=new WeakMap,h=new WeakMap,f=new WeakMap,e=new WeakSet,o=async function(){try{const{body:g}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(process.env.NODE_ENV==="development"&&localStorage!=null&&localStorage.getItem(lt))try{this.logger.warn(`You are in DEV mode, and UI components override URL was found
18
+ trying to merge project theme with the default theme of the UI components`);const v=await io();v&&(g.light.components=Object.assign(Object.assign({},g.light.components),v.light.components),g.dark.components=Object.assign(Object.assign({},g.dark.components),v.dark.components),this.logger.warn("Theme was merged successfully"),console.log(`%cNOTICE! This is not the theme that will be used in production!
19
+
20
+ Make sure to test it without the override UI components URL!`,"color: black; background-color:yellow; font-size: x-large"))}catch(v){this.logger.error(`Failed to merge UI components theme
21
+ `,v)}return g}catch{this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},n=function(){return r.__classPrivateFieldGet(this,s,"f")||(r.__classPrivateFieldSet(this,s,r.__classPrivateFieldGet(this,e,"m",o).call(this),"f"),r.__classPrivateFieldGet(this,s,"f").then(g=>this.logger.debug("Fetched theme",g))),r.__classPrivateFieldGet(this,s,"f")},a=async function(){var g,v;const _=await r.__classPrivateFieldGet(this,e,"a",n);_&&(r.__classPrivateFieldGet(this,t,"f")||r.__classPrivateFieldSet(this,t,this.injectStyle(""),"f"),r.__classPrivateFieldGet(this,t,"f").replaceSync((((g=_==null?void 0:_.light)===null||g===void 0?void 0:g.globals)||"")+(((v=_==null?void 0:_.dark)===null||v===void 0?void 0:v.globals)||"")))},l=async function(){var g,v;const _=await r.__classPrivateFieldGet(this,e,"a",n);if(!_)return;const y=await this.descopeUi;y!=null&&y.componentsThemeManager&&(y.componentsThemeManager.themes={light:(g=_==null?void 0:_.light)===null||g===void 0?void 0:g.components,dark:(v=_==null?void 0:_.dark)===null||v===void 0?void 0:v.components})},d=async function(){var g,v;const{projectConfig:_}=await this.config||{},y=(g=_==null?void 0:_.styles)===null||g===void 0?void 0:g[this.styleId],$=_==null?void 0:_.cssTemplate,O=y||$;return(v=O==null?void 0:O[this.theme])===null||v===void 0?void 0:v.fonts},u=async function(){const g=await r.__classPrivateFieldGet(this,e,"m",d).call(this);g?Object.values(g).forEach(v=>{v.url&&(this.logger.debug(`Loading font from URL "${v.url}"`),to(v.url))}):this.logger.debug("No fonts to load")},c=async function(){this.rootElement.setAttribute("data-theme",this.theme);const g=await this.descopeUi;g!=null&&g.componentsThemeManager&&(g.componentsThemeManager.currentThemeName=this.theme)},p=function(){r.__classPrivateFieldGet(this,e,"m",u).call(this),r.__classPrivateFieldGet(this,e,"m",c).call(this)},m}),Ve=(i,e="")=>Object.keys(i).reduce((t,s)=>{var o;if(Array.isArray(i[s]))return Object.assign(Object.assign({},t),{[s]:{value:i[s].map(l=>typeof l=="object"&&l!==null?Ve(l):l)}});if(typeof i[s]=="object"&&i[s]!==null&&!(!((o=i[s])===null||o===void 0)&&o.value))return Object.assign(Object.assign({},t),Ve(i[s],`${e+s}.`));const n=typeof i[s]=="object"?i[s]:{value:i[s]},a=Object.assign(Object.assign({},t),{[e+s]:n,[`form.${e}${s}`]:n});return s==="displayName"?Object.assign(Object.assign({},a),{[`${e}fullName`]:n,[`form.${e}fullName`]:n}):a},[]),oo=i=>{try{return Ve(JSON.parse(i))}catch{return{}}},no=(i,e)=>Object.fromEntries(Object.entries(i).map(([t,s])=>[t,s[e]])),ao=r.h(i=>{var e,t,s,o;return o=class extends i{constructor(){super(...arguments),e.add(this)}connectedCallback(){var n;r.__classPrivateFieldGet(this,e,"m",t).call(this)&&r.__classPrivateFieldGet(this,e,"m",s).call(this),(n=super.connectedCallback)===null||n===void 0||n.call(this)}},e=new WeakSet,t=function(){return!this.shadowRoot.host.closest("form")&&us()},s=function(){const n=this.shadowRoot.host,a=document.createElement("form");a.style.width="100%",a.style.height="100%",n.parentElement.appendChild(a),a.appendChild(n)},o});var x,Ee,Ae,ae,Z,se,ge,J,re,Me,$t,vi,qe,fi,Ot,mi,_i,Gt,bi,Be,wi,yi;const lo=r.r(ro,at,ao,Re)(HTMLElement);class ve extends lo{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),x.add(this),Ae.set(this,!1),ae.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(t,s="")=>{this.logger.error(t,s,new Error),r.__classPrivateFieldGet(this,x,"m",yi).call(this,t,s)},warn:(t,s="")=>{this.logger.warn(t,s)},info:(t,s="",o={})=>{this.logger.info(t,s,o)},debug:(t,s="")=>{this.logger.debug(t,s)}},Z.set(this,new ne),se.set(this,new ne),ge.set(this,{}),this.getComponentsContext=()=>r.__classPrivateFieldGet(this,ge,"f"),this.nextRequestStatus=new ne({isLoading:!1}),J.set(this,void 0),re.set(this,{popstate:r.__classPrivateFieldGet(this,x,"m",fi).bind(this),componentsContext:r.__classPrivateFieldGet(this,x,"m",bi).bind(this)}),Me.set(this,void 0),this.getConfig=()=>r.__awaiter(this,void 0,void 0,function*(){return(yield this.config)||{isMissingConfig:!0}}),r.__classPrivateFieldSet(this,Me,e,"f"),r.__classPrivateFieldGet(this,x,"m",vi).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch{return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return this.getAttribute("debug")==="true"}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var e;const t=(e=this.getAttribute("auto-focus"))!==null&&e!==void 0?e:"true";return t==="skipFirstScreen"?t:t==="true"}get validateOnBlur(){return this.getAttribute("validate-on-blur")==="true"}get storeLastAuthenticatedUser(){var e;return((e=this.getAttribute("store-last-authenticated-user"))!==null&&e!==void 0?e:"true")==="true"}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return this.getAttribute("keep-last-authenticated-user-after-logout")==="true"}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return oo(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return no(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch{return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return r.__classPrivateFieldGet(this,ae,"f")}set customStorage(e){if(e&&typeof e.getItem!="function")throw new Error("Custom storage must have a getItem method");if(e&&typeof e.setItem!="function")throw new Error("Custom storage must have a setItem method");if(e&&typeof e.removeItem!="function")throw new Error("Custom storage must have a removeItem method");r.__classPrivateFieldSet(this,ae,e,"f"),br(e)}get isRestartOnError(){return this.getAttribute("restart-on-error")==="true"}getExecutionContext(){return r.__awaiter(this,void 0,void 0,function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0})}getProjectConfig(){return r.__awaiter(this,void 0,void 0,function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0})}getFlowConfig(){return r.__awaiter(this,void 0,void 0,function*(){var e,t;const s=yield this.getProjectConfig(),o=((e=s==null?void 0:s.flows)===null||e===void 0?void 0:e[this.flowId])||{};return(t=o.version)!==null&&t!==void 0||(o.version=0),o})}getTargetLocales(){return r.__awaiter(this,void 0,void 0,function*(){const e=yield this.getFlowConfig();return((e==null?void 0:e.targetLocales)||[]).map(t=>t.toLowerCase())})}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,s,o;const n=!!(!((t=this.shadowRoot.activeElement)===null||t===void 0)&&t.getAttribute("href")),a=rs.includes((o=(s=this.shadowRoot.activeElement)===null||s===void 0?void 0:s.localName)!==null&&o!==void 0?o:"");if(e.key!=="Enter"||n||a)return;e.preventDefault();const l=this.rootElement.querySelectorAll("descope-button");if(l.length===1&&l[0].getAttribute("auto-submit")!=="false")return void l[0].click();const d=Array.from(l).filter(c=>c.getAttribute("auto-submit")==="true");if(d.length===1)return void d[0].click();const u=Array.from(l).filter(c=>c.getAttribute("data-type")==="button");if(u.length===1)u[0].getAttribute("auto-submit")!=="false"&&u[0].click();else if(u.length===0){const c=Array.from(l).filter(h=>h.getAttribute("data-type")==="sso");c.length===1&&c[0].getAttribute("auto-submit")!=="false"&&c[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return r.__awaiter(this,void 0,void 0,function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?(e=t.projectConfig)===null||e===void 0?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")})}init(){const e=Object.create(null,{init:{get:()=>super.init}});return r.__awaiter(this,void 0,void 0,function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach(S=>this.addEventListener(S,()=>{this.flowStatus=S})),yield(t=e.init)===null||t===void 0?void 0:t.call(this),r.__classPrivateFieldGet(this,se,"f").subscribe(r.__classPrivateFieldGet(this,x,"m",wi).bind(this)),r.__classPrivateFieldGet(this,se,"f").update({isDebug:this.debug}),r.__classPrivateFieldGet(this,x,"m",qe).call(this),yield r.__classPrivateFieldGet(this,x,"m",_i).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const s=yield this.getConfig();if("isMissingConfig"in s&&s.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:o,stepId:n,token:a,code:l,isPopup:d,exchangeError:u,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f,ssoQueryParams:m}=Hs(this.flowId,this.loggerWrapper);window.addEventListener("popstate",r.__classPrivateFieldGet(this,re,"f").popstate),window.addEventListener("components-context",r.__classPrivateFieldGet(this,re,"f").componentsContext),r.__classPrivateFieldGet(this,Z,"f").subscribe(r.__classPrivateFieldGet(this,x,"m",mi).bind(this)),r.__classPrivateFieldGet(this,Z,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:o,token:a,code:l,isPopup:d,exchangeError:u,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f},m)),r.__classPrivateFieldSet(this,Ae,!0,"f")})}disconnectedCallback(){r.__classPrivateFieldGet(this,Z,"f").unsubscribeAll(),r.__classPrivateFieldGet(this,se,"f").unsubscribeAll(),r.__classPrivateFieldGet(this,x,"m",Be).call(this),window.removeEventListener("popstate",r.__classPrivateFieldGet(this,re,"f").popstate),window.removeEventListener("components-context",r.__classPrivateFieldGet(this,re,"f").componentsContext)}attributeChangedCallback(e,t,s){if(this.shadowRoot.isConnected&&r.__classPrivateFieldGet(this,Ae,"f")&&t!==s&&Ee.observedAttributes.includes(e)){r.__classPrivateFieldGet(this,x,"m",qe).call(this);const o=t===null;r.__classPrivateFieldGet(this,Z,"f").update(({stepId:n,executionId:a})=>{let l=n,d=a;return o||(d=null,l=null,ri()),{[oi(e)]:s,stepId:l,executionId:d}}),r.__classPrivateFieldGet(this,se,"f").update({isDebug:this.debug})}}}Ee=ve,Ae=new WeakMap,ae=new WeakMap,Z=new WeakMap,se=new WeakMap,ge=new WeakMap,J=new WeakMap,re=new WeakMap,Me=new WeakMap,x=new WeakSet,$t=function(){this.injectStyle(`
22
+ :host {
23
+ width: 100%;
24
+ display: block;
25
+ }
26
+
27
+ #root {
28
+ height: 100%;
29
+ display: flex;
30
+ flex-direction: column;
31
+ }
32
+
33
+ #content-root {
34
+ all: initial;
35
+ transition: opacity 200ms ease-in-out;
36
+ }
37
+
38
+ #root[data-theme] {
39
+ background-color: transparent;
40
+ }
41
+
42
+ .fade-out {
43
+ opacity: 0.1!important;
44
+ }
45
+
46
+ .hidden {
47
+ display: none;
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;
50
+ //# sourceMappingURL=index.cjs3.js.map