@descope/user-profile-widget 0.15.0 → 0.15.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.
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**
3
- * @descope/user-profile-widget v0.15.0
3
+ * @descope/user-profile-widget v0.15.2
4
4
  */
5
- "use strict";var e=require("tslib"),t=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins"),s=require("@descope/sdk-component-drivers"),l=require("@reduxjs/toolkit"),a=require("@descope/web-js-sdk"),o=require("reselect");function r(e){return new URLSearchParams(window.location.search).get(e)}require("@descope/core-js-sdk"),require("@descope/web-component");const n=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},d=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),c=l.createAsyncThunk("users/me",((e,{extra:{api:t}})=>t.user.me())),h=n(c)({onFulfilled:(e,t)=>{e.me.data=t.payload}},d((e=>e.me))),v={action:c,reducer:h},u=l.createAsyncThunk("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),_=n(u)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},d((e=>e.devices))),f={action:u,reducer:_},g=l.createAsyncThunk("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),F=n(g)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},d((e=>e.passkeys))),w={action:g,reducer:F},p=l.createAsyncThunk("users/logout",((e,{extra:{api:t}})=>t.user.logout())),m={action:p,reducer:n(p)({})},P=e=>{if(!e)return null;const i=t.decodeJWT(e);return(null==i?void 0:i.dct)||null},G=e=>e.me.data,y=o.createSelector(G,(e=>e.userId)),M=o.createSelector(G,(e=>e.picture)),k=o.createSelector(G,(e=>e.email)),S=o.createSelector(G,(e=>e.verifiedEmail)),x=o.createSelector(G,(e=>e.name)),b=o.createSelector(G,(e=>e.phone)),C=o.createSelector(G,(e=>e.verifiedPhone)),R=o.createSelector(k,S,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),W=o.createSelector(b,C,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),I=o.createSelector(G,(e=>e.recoveryEmail)),T=o.createSelector(G,(e=>e.verifiedRecoveryEmail)),A=o.createSelector(G,(e=>e.recoveryPhone)),U=o.createSelector(G,(e=>e.verifiedRecoveryPhone)),D=o.createSelector(I,T,((e,t)=>t?e:"")),E=o.createSelector(A,U,((e,t)=>t?e:"")),L=o.createSelector(G,(e=>e.webauthn));o.createSelector(G,(e=>e.password));const q=o.createSelector(G,(e=>e.TOTP)),j=o.createSelector(G,(e=>e.customAttributes)),O=o.createSelector(G,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),N=o.createSelector((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:i,lastLoginTime:s,isCurrentDevice:l})=>({id:e,name:t,deviceType:i,lastLoginDate:1e3*parseInt(s,10),isCurrent:l}))))),B=o.createSelector((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:i,createdTime:s})=>({id:e,name:t,passkeyType:i,createdAt:1e3*s}))))),$=e=>e.notifications,H=o.createSelector(G,(e=>e.userTenants||[])),V=e=>e.tenant.currentTenantId,Z=l.createAsyncThunk("tenant/select",((t,i)=>e.__awaiter(void 0,[t,i],void 0,(function*(e,{extra:{api:t},getState:i}){if(e===V(i()))return null;const s=yield t.user.setCurrentTenant(e),l=s.sessionJwt||s.sessionToken;try{return{tenantId:P(l)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),J={action:Z,reducer:n(Z)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var i;e.tenant.currentTenantId=null===(i=t.payload)||void 0===i?void 0:i.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},d((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{if(t){const s=t(i);s&&e.notifications.push({type:"success",msg:s})}},onRejected:(t,i)=>{if(e){const s=e(i);s&&t.notifications.push({type:"error",msg:s})}}}))({getErrorMsg:e=>{var t,i;const s=(null===(t=e.error)||void 0===t?void 0:t.message)||"";return"Error"===(null===(i=e.error)||void 0===i?void 0:i.name)?s:`${s||"Error"}`}}))},X={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},passkeys:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},Y={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",passkeys:"/v1/mgmt/user/passkeys/list",selectTenant:"/v1/auth/tenant/select"},z=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.text(),i=JSON.parse(e);if(!t.ok){const e=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(e||`${t.status} ${t.statusText}`)}t.json=()=>Promise.resolve(i),t.text=()=>Promise.resolve(e)})),K=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],Q=()=>e.__awaiter(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",recoveryEmail:"recovery@company.com",recoveryPhone:"+1-202-555-020",verifiedEmail:!0,verifiedPhone:!0,verifiedRecoveryEmail:!0,verifiedRecoveryPhone:!0,userTenants:K,status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),ee=()=>({devices:[{id:"device-id-1",name:"Device 1",deviceType:"desktop",lastLoginDate:17359776e5,isCurrent:!1},{id:"device-id-2",name:"Device 2",deviceType:"mobile",lastLoginDate:17387505e5,isCurrentDevice:!0},{id:"device-id-3",name:"Device 3",deviceType:"tablet",lastLoginDate:17412642e5,isCurrent:!1},{id:"device-id-4",name:"Device 4",deviceType:"unknown",lastLoginDate:17440371e5,isCurrent:!1},{id:"device-id-5",name:"Device 5",deviceType:"desktop",lastLoginDate:174672e7,isCurrent:!1}]}),te=()=>({passkeys:[{id:"vendor-id-1",displayName:"Device 1",kind:"google",createdTime:1735977600,rpId:"example.com"},{id:"vendor-id-2",displayName:"Device 2",kind:"edge",createdTime:1738750500,rpId:"example.com"},{id:"vendor-id-3",displayName:"Device 3",kind:"apple",createdTime:1741264200,rpId:"example.com"}]}),ie=({httpClient:t,mock:i})=>({me:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i)return Q();const e=yield t.get(Y.me);return yield z(e),e.json()})),setCurrentTenant:i=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.post(Y.selectTenant,{tenant:i});return yield z(e),e.json()}))}),se=({httpClient:t,mock:i})=>({devices:s=>e.__awaiter(void 0,[s],void 0,(function*({userId:e}){if(i)return ee();const s=yield t.post(Y.devices,{identifiers:[e]});return yield z(s),s.json()}))}),le=({httpClient:t,mock:i})=>({listPasskeys:s=>e.__awaiter(void 0,[s],void 0,(function*({userId:e}){if(i)return te();const s=yield t.post(Y.passkeys,{loginId:e});return yield z(s),s.json()}))}),ae=t.createSingletonMixin((s=>{var l,o,r,n;const d=t.compose(i.projectIdMixin,i.observeAttributesMixin,i.loggerMixin,i.baseUrlMixin,i.cookieConfigMixin)(s);return n=class extends d{constructor(){super(...arguments),l.add(this),o.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||i.DEFAULT_STYLE_ID}get api(){return e.__classPrivateFieldGet(this,o,"f")||e.__classPrivateFieldGet(this,l,"m",r).call(this),e.__classPrivateFieldGet(this,o,"f")}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this),this.observeAttributes(["project-id","base-url"],(()=>{e.__classPrivateFieldGet(this,o,"f")&&e.__classPrivateFieldGet(this,l,"m",r).call(this)}))}))}},o=new WeakMap,l=new WeakSet,r=function(){this.logger.debug("creating an sdk instance"),e.__classPrivateFieldSet(this,o,((t,i,s)=>{const l=a(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.15.0"}}));return{user:Object.assign(Object.assign({},ie({httpClient:l.httpClient,mock:i})),{logout:i?()=>e.__awaiter(void 0,void 0,void 0,(function*(){})):l.logout}),device:Object.assign({},se({httpClient:l.httpClient,mock:i})),passkey:Object.assign({},le({httpClient:l.httpClient,mock:i}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},n})),oe=t.createSingletonMixin((e=>{const s=t.compose(i.createStateManagementMixin({name:"widget",initialState:X,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{v.reducer(e),f.reducer(e),w.reducer(e),m.reducer(e),J.reducer(e)},asyncActions:{getMe:v.action,listDevices:f.action,listPasskeys:w.action,logout:m.action,selectTenant:J.action}}),i.initLifecycleMixin,i.loggerMixin,ae)(e);return class extends s{constructor(...e){super(...e),this.state=X,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),re="widget-flow",ne=t.createSingletonMixin((l=>{var a,o,n;return n=class extends(t.compose(i.localeMixin,i.initLifecycleMixin,i.modalMixin,oe,i.cookieConfigMixin,i.loggerMixin,i.themeMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this)}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this);const s=r(re);s&&(!function(e){if(window.history.replaceState&&r(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(re),e.__classPrivateFieldGet(this,a,"m",o).call(this,s))}))}},a=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e}));new s.FlowDriver((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},n})),de=t.createSingletonMixin((s=>{var l,a,o;return o=class extends(t.compose(i.loggerMixin,i.initLifecycleMixin,i.descopeUiMixin,i.initElementMixin,i.createFetchWidgetPagesMixin("user-profile-widget"),oe)(s)){constructor(){super(...arguments),l.add(this)}onWidgetRootReady(){return e.__awaiter(this,void 0,void 0,(function*(){}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this),yield this.actions.getMe(),yield e.__classPrivateFieldGet(this,l,"m",a).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},l=new WeakSet,a=function(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.createTemplate(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},o})),ce=t.createSingletonMixin((e=>class extends(t.compose(i.themeMixin,i.observeAttributesMixin)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),he=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u;return u=class extends(t.compose(i.localeMixin,ce,i.themeMixin,oe,i.loggerMixin,i.cookieConfigMixin,de,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),h.set(this,t.withMemCache((e=>{this.avatar.image=e}))),v.set(this,t.withMemCache((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",n).call(this),e.__classPrivateFieldGet(this,h,"f").call(this,M(this.state)),e.__classPrivateFieldGet(this,v,"f").call(this,x(this.state)),this.subscribe(e.__classPrivateFieldGet(this,h,"f").bind(this),M),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),x)}))}},o=new WeakMap,r=new WeakMap,h=new WeakMap,v=new WeakMap,a=new WeakSet,n=function(){this.avatar.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"update-pic","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",d).bind(this),e.__classPrivateFieldGet(this,a,"m",d).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},d=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.avatar.flowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},c=function(){this.avatar=new s.AvatarDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()}))},u})),ve=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g,F,w;return w=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),g.set(this,t.withMemCache((t=>{this.emailUserAttr.value=t,e.__classPrivateFieldGet(this,a,"m",f).call(this)}))),F.set(this,t.withMemCache((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,k(this.state)),e.__classPrivateFieldGet(this,F,"f").call(this,R(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),k),this.subscribe(e.__classPrivateFieldGet(this,F,"f").bind(this),R)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,g=new WeakMap,F=new WeakMap,a=new WeakSet,c=function(){this.emailUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-email","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.editFlowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.emailUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-email","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.deleteFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.emailUserAttr=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.emailUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},f=function(){var t,i;(null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t?void 0:t.isClosed)&&e.__classPrivateFieldGet(this,a,"m",h).call(this),(null===(i=e.__classPrivateFieldGet(this,n,"f"))||void 0===i?void 0:i.isClosed)&&e.__classPrivateFieldGet(this,a,"m",u).call(this)},w})),ue=t.createSingletonMixin((l=>{var a,o,r;return r=class extends(t.compose(oe,i.loggerMixin,de,i.modalMixin)(l)){constructor(){super(...arguments),a.add(this)}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",o).call(this)}))}},a=new WeakSet,o=function(){this.logout=new s.ButtonDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>e.__awaiter(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},r})),_e=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g,F;return F=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),g.set(this,t.withMemCache((t=>{this.nameUserAttr.value=t,e.__classPrivateFieldGet(this,a,"m",f).call(this)})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,x(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),x)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,g=new WeakMap,a=new WeakSet,c=function(){this.nameUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-name","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.editFlowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.nameUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-name","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.deleteFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.nameUserAttr=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.nameUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},f=function(){var t,i;(null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t?void 0:t.isClosed)&&e.__classPrivateFieldGet(this,a,"m",h).call(this),(null===(i=e.__classPrivateFieldGet(this,n,"f"))||void 0===i?void 0:i.isClosed)&&e.__classPrivateFieldGet(this,a,"m",u).call(this)},F})),fe=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),f.set(this,t.withMemCache((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,L(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),L)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,f=new WeakMap,a=new WeakSet,c=function(){this.passkeyUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"add-passkey","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.flowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"remove-passkey","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.fulfilledFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.passkeyUserAuthMethod=new s.UserAuthMethodDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},g})),ge=t.createSingletonMixin((l=>{var a,o,r,n,d,c;return c=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new s.UserAuthMethodDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()}))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.initPasswordAuthMethod(),e.__classPrivateFieldGet(this,a,"m",n).call(this)}))}},o=new WeakMap,r=new WeakMap,a=new WeakSet,n=function(){this.passwordUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"password","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",d).bind(this),e.__classPrivateFieldGet(this,a,"m",d).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},d=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.passwordUserAuthMethod.flowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close()}))},c})),Fe=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g,F,w;return w=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),g.set(this,t.withMemCache((t=>{this.phoneUserAttr.value=t,e.__classPrivateFieldGet(this,a,"m",f).call(this)}))),F.set(this,t.withMemCache((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,b(this.state)),e.__classPrivateFieldGet(this,F,"f").call(this,W(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),b),this.subscribe(e.__classPrivateFieldGet(this,F,"f").bind(this),W)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,g=new WeakMap,F=new WeakMap,a=new WeakSet,c=function(){this.phoneUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-phone","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.editFlowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.phoneUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-phone","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.deleteFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.phoneUserAttr=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.phoneUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},f=function(){var t,i;(null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t?void 0:t.isClosed)&&e.__classPrivateFieldGet(this,a,"m",h).call(this),(null===(i=e.__classPrivateFieldGet(this,n,"f"))||void 0===i?void 0:i.isClosed)&&e.__classPrivateFieldGet(this,a,"m",u).call(this)},w})),we=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),f.set(this,t.withMemCache((e=>{this.recoveryEmailUserAttr.value=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,D(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),D)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,f=new WeakMap,a=new WeakSet,c=function(){this.recoveryEmailUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-recovery-email","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.recoveryEmailUserAttr.editFlowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.recoveryEmailUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-recovery-email","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.recoveryEmailUserAttr.deleteFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.recoveryEmailUserAttr=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryEmail"]')}),{logger:this.logger}),this.recoveryEmailUserAttr.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.recoveryEmailUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},g})),pe=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),f.set(this,t.withMemCache((e=>{this.recoveryPhoneUserAttr.value=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,E(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),E)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,f=new WeakMap,a=new WeakSet,c=function(){this.recoveryPhoneUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-recovery-phone","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.recoveryPhoneUserAttr.editFlowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.recoveryPhoneUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-recovery-phone","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.recoveryPhoneUserAttr.deleteFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.recoveryPhoneUserAttr=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryPhone"]')}),{logger:this.logger}),this.recoveryPhoneUserAttr.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.recoveryPhoneUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},g})),me=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),f.set(this,t.withMemCache((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,q(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),q)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,f=new WeakMap,a=new WeakSet,c=function(){this.totpUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"totp","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.flowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.totpUserAuthMethod.fulfilledFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"remove-totp","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.fulfilledFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.totpUserAuthMethod=new s.UserAuthMethodDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},g})),Pe=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g,F,w;return w=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,{}),r.set(this,{}),n.set(this,{}),d.set(this,{}),c.set(this,{}),F.set(this,t.withMemCache((t=>{Object.keys(e.__classPrivateFieldGet(this,o,"f")).forEach((i=>{e.__classPrivateFieldGet(this,o,"f")[i].value=(t[i]||"").toString()})),e.__classPrivateFieldGet(this,a,"m",g).call(this)})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",f).call(this),e.__classPrivateFieldGet(this,F,"f").call(this,O(this.state)),this.subscribe(e.__classPrivateFieldGet(this,F,"f").bind(this),O)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,F=new WeakMap,a=new WeakSet,h=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t})),null===(s=e.__classPrivateFieldGet(this,n,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},v=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t})),null===(s=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},u=function(t,i,l){const o=t.getAttribute("edit-flow-id");o&&(e.__classPrivateFieldGet(this,r,"f")[o]=this.createModal({"data-id":`edit-${i}`,"close-on-outside-click":"true"}),e.__classPrivateFieldGet(this,n,"f")[o]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,r,"f")[o].afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this,o),l.onEditClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")[o]))},_=function(t,i,l){const o=t.getAttribute("delete-flow-id");o&&(e.__classPrivateFieldGet(this,d,"f")[o]=this.createModal({"data-id":`delete-${i}`,"close-on-outside-click":"true"}),e.__classPrivateFieldGet(this,c,"f")[o]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,d,"f")[o].afterClose=e.__classPrivateFieldGet(this,a,"m",v).bind(this,o),l.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")[o]))},f=function(){var t;const i=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(i||[]).forEach((t=>{const i=t.getAttribute("data-id").replace("builtin.",""),l=new s.UserAttributeDriver(t,{logger:this.logger});e.__classPrivateFieldGet(this,o,"f")[i]=l,e.__classPrivateFieldGet(this,a,"m",u).call(this,t,i,l),e.__classPrivateFieldGet(this,a,"m",_).call(this,t,i,l)}))},g=function(){Object.entries(e.__classPrivateFieldGet(this,r,"f")).forEach((([t,i])=>{i.isClosed&&e.__classPrivateFieldGet(this,a,"m",h).call(this,t)})),Object.entries(e.__classPrivateFieldGet(this,d,"f")).forEach((([t,i])=>{i.isClosed&&e.__classPrivateFieldGet(this,a,"m",v).call(this,t)}))},w}));var Ge;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Ge||(Ge={}));const ye=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f;return o=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),r.set(this,{}),n.set(this,{}),d.set(this,{}),c.set(this,{}),u.set(this,t.withMemCache((t=>{var i;const l=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(l).forEach((i=>{const l=i.getAttribute("data-id").replace("customAttributes.",""),r=i.getAttribute("data-type")||Ge.TEXT,n=t[l],d=new s.UserAttributeDriver(i,{logger:this.logger});d.value=o.getFormattedValue(r,n),e.__classPrivateFieldGet(this,a,"m",_).call(this,i,l,d),e.__classPrivateFieldGet(this,a,"m",f).call(this,i,l,d)}))})))}static getFormattedValue(e,t){return e===Ge.DATE&&t?new Date(t).toLocaleString():e===Ge.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,u,"f").call(this,j(this.state)),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),j)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,u=new WeakMap,a=new WeakSet,h=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t})),null===(s=e.__classPrivateFieldGet(this,n,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},v=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t})),null===(s=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},_=function(t,i,l){const o=t.getAttribute("edit-flow-id");o&&(e.__classPrivateFieldGet(this,r,"f")[o]=this.createModal({"data-id":`edit-${i}`,"close-on-outside-click":"true"}),e.__classPrivateFieldGet(this,n,"f")[o]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,r,"f")[o].afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this,o),l.onEditClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,a,"m",h).call(this,o),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")[o]))},f=function(t,i,l){const o=t.getAttribute("delete-flow-id");o&&(e.__classPrivateFieldGet(this,d,"f")[o]=this.createModal({"data-id":`delete-${i}`,"close-on-outside-click":"true"}),e.__classPrivateFieldGet(this,c,"f")[o]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,d,"f")[o].afterClose=e.__classPrivateFieldGet(this,a,"m",v).bind(this,o),l.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,a,"m",v).call(this,o),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")[o]))},o})),Me=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v;return v=class extends(t.compose(i.localeMixin,ce,i.themeMixin,oe,i.loggerMixin,i.cookieConfigMixin,de,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),this.updateDeviceList=t.withMemCache((e=>{this.deviceList.data=e}))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.deviceList=new s.DeviceListDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield e.__classPrivateFieldGet(this,a,"m",h).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this,N(this.state)),e.__classPrivateFieldGet(this,a,"m",n).call(this),this.subscribe(this.updateDeviceList.bind(this),N))}))}},o=new WeakMap,r=new WeakMap,a=new WeakSet,n=function(){this.deviceList.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"untrust-device","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=()=>e.__classPrivateFieldGet(this,a,"m",d).call(this,""),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},d=function(t=""){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.deviceList.flowId,form:{deviceId:t}})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.listDevices({userId:y(this.state)})}))},c=function(t){this.deviceList.onRemoveDeviceClick((({id:t})=>{var i;e.__classPrivateFieldGet(this,a,"m",d).call(this,t),null===(i=e.__classPrivateFieldGet(this,o,"f"))||void 0===i||i.open()})),this.deviceList.data=t},h=function(){return e.__awaiter(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:y(this.state)})}))},v})),ke=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),_.set(this,t.withMemCache((e=>{this.actions.listPasskeys({userId:e})}))),this.updatePasskeyList=t.withMemCache((e=>{this.userPasskeys.data=e}))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.userPasskeys=new s.UserPasskeysDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-user-passkeys")}),{logger:this.logger}),this.userPasskeys.isExists&&(e.__classPrivateFieldGet(this,a,"m",f).call(this,B(this.state)),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),this.subscribe(e.__classPrivateFieldGet(this,_,"f").bind(this),y),this.subscribe(this.updatePasskeyList.bind(this),B))}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,_=new WeakMap,a=new WeakSet,c=function(){this.userPasskeys.addPasskeyFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"add-user-passkey","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.addPasskeyFlowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:y(this.state)})}))},v=function(){this.userPasskeys.removePasskeyFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"remove-user-passkey","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function({externalId:t,credentialId:i}){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.removePasskeyFlowId,form:{externalId:t,credentialId:i}})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:y(this.state)})}))},f=function(t){this.updatePasskeyList(t),this.userPasskeys.onAddPasskeyClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.userPasskeys.onRemovePasskeyClick((({id:t})=>{var i;const s=y(this.state);e.__classPrivateFieldGet(this,a,"m",u).call(this,{externalId:s,credentialId:t}),null===(i=e.__classPrivateFieldGet(this,n,"f"))||void 0===i||i.open()}))},g}));const Se={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},xe=t.createSingletonMixin((s=>{var l,a,o,r,n;return n=class extends(t.compose(i.loggerMixin,oe,i.notificationsMixin,i.initLifecycleMixin)(s)){constructor(){super(...arguments),l.add(this),r.set(this,t.withMemCache((t=>{t.length&&(t.forEach((({type:t,msg:i})=>{const s=e.__classPrivateFieldGet(this,l,"m",o).call(this,t);s.setContent(e.__classPrivateFieldGet(this,l,"m",a).call(this,{type:t,msg:i})),s.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this),this.subscribe(e.__classPrivateFieldGet(this,r,"f").bind(this),$)}))}},r=new WeakMap,l=new WeakSet,a=function({type:e,msg:t}){const i=Se[e],s=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${s.outerHTML}`},o=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},n})),be=t.createSingletonMixin((l=>{var o,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(oe,i.loggerMixin,de)(l)){constructor(){super(...arguments),o.add(this),r.set(this,null),d.set(this,(t=>e.__awaiter(this,void 0,void 0,(function*(){const e=t.target.value;yield this.actions.selectTenant(e)})))),c.set(this,(t=>{const i=V(t);this.tenantSelector.value!==i&&e.__classPrivateFieldGet(this,o,"m",_).call(this,i);const{loading:s,error:l}=t.selectTenant,a=null!==t.tenant.previousTenantId,n=i!==e.__classPrivateFieldGet(this,r,"f");!i||s||l||a||!n||(e.__classPrivateFieldSet(this,r,i,"f"),e.__classPrivateFieldGet(this,o,"m",h).call(this))}))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.actions.setCurrentTenantId((()=>{const e=a.getSessionToken();return P(e)})()),e.__classPrivateFieldGet(this,o,"m",n).call(this),e.__classPrivateFieldGet(this,o,"m",f).call(this),e.__classPrivateFieldGet(this,o,"m",u).call(this,H(this.state)),this.subscribe(e.__classPrivateFieldGet(this,c,"f").bind(this))}))}},r=new WeakMap,d=new WeakMap,c=new WeakMap,o=new WeakSet,n=function(){this.tenantSelector=new s.TenantSelectorDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(e.__classPrivateFieldGet(this,d,"f"))},h=function(){const t=V(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:t}})),this.tenantSelector.shouldReload&&e.__classPrivateFieldGet(this,o,"m",v).call(this)},v=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},u=function(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.map((e=>({label:e.tenantName||e.tenantId,value:e.tenantId})));yield this.tenantSelector.setData(e)}))},_=function(e){e&&(this.tenantSelector.value=e)},f=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{e.__classPrivateFieldGet(this,o,"m",_).call(this,V(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},g})),Ce=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f;return f=class extends(t.compose(i.localeMixin,ce,oe,i.modalMixin,i.loggerMixin,de,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,[]),d.set(this,null)}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),e.__classPrivateFieldGet(this,n,"f").forEach((e=>e.enable()))}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,a=new WeakSet,c=function(t){const i=new s.GenericFlowButtonDriver(t,{logger:this.logger});i.onClick((()=>{e.__classPrivateFieldGet(this,a,"m",_).call(this,i.flowId,y(this.state))})),e.__classPrivateFieldGet(this,n,"f").push(i)},h=function(){var t;const i=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelectorAll("[data-generic-flow-button-id]");Array.from(i).forEach((t=>{e.__classPrivateFieldGet(this,a,"m",c).call(this,t)}))},v=function(){e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"generic-flow-modal","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.call(this),e.__classPrivateFieldSet(this,d,null,"f")},e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f"))},u=function(){var t;e.__classPrivateFieldGet(this,o,"f").open(),null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.call(this)},_=function(t,i){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:t,client:{userId:i}}));e.__classPrivateFieldSet(this,d,e.__classPrivateFieldGet(this,r,"f").onPageUpdated((()=>e.__classPrivateFieldGet(this,a,"m",u).call(this))),"f"),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},f})),Re=t.createSingletonMixin((s=>class extends(t.compose(i.debuggerMixin,i.themeMixin,ne,ye,ve,he,_e,Fe,we,pe,fe,ge,me,Pe,ue,Me,ke,xe,be,Ce)(s)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this)}))}})),We=t.compose((t=>class extends(Re(t)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.15.0"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",We),module.exports=We;
5
+ "use strict";var e=require("tslib"),t=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins"),s=require("@descope/sdk-component-drivers"),l=require("@reduxjs/toolkit"),a=require("@descope/web-js-sdk"),o=require("reselect");function r(e){return new URLSearchParams(window.location.search).get(e)}require("@descope/core-js-sdk"),require("@descope/web-component");const n=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},d=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),c=l.createAsyncThunk("users/me",((e,{extra:{api:t}})=>t.user.me())),h=n(c)({onFulfilled:(e,t)=>{e.me.data=t.payload}},d((e=>e.me))),v={action:c,reducer:h},u=l.createAsyncThunk("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),_=n(u)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},d((e=>e.devices))),f={action:u,reducer:_},g=l.createAsyncThunk("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),F=n(g)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},d((e=>e.passkeys))),w={action:g,reducer:F},p=l.createAsyncThunk("users/logout",((e,{extra:{api:t}})=>t.user.logout())),m={action:p,reducer:n(p)({})},P=e=>{if(!e)return null;const i=t.decodeJWT(e);return(null==i?void 0:i.dct)||null},G=e=>e.me.data,y=o.createSelector(G,(e=>e.userId)),M=o.createSelector(G,(e=>e.picture)),k=o.createSelector(G,(e=>e.email)),S=o.createSelector(G,(e=>e.verifiedEmail)),x=o.createSelector(G,(e=>e.name)),b=o.createSelector(G,(e=>e.phone)),C=o.createSelector(G,(e=>e.verifiedPhone)),R=o.createSelector(k,S,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),W=o.createSelector(b,C,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),I=o.createSelector(G,(e=>e.recoveryEmail)),T=o.createSelector(G,(e=>e.verifiedRecoveryEmail)),A=o.createSelector(G,(e=>e.recoveryPhone)),U=o.createSelector(G,(e=>e.verifiedRecoveryPhone)),D=o.createSelector(I,T,((e,t)=>t?e:"")),E=o.createSelector(A,U,((e,t)=>t?e:"")),L=o.createSelector(G,(e=>e.webauthn));o.createSelector(G,(e=>e.password));const q=o.createSelector(G,(e=>e.TOTP)),j=o.createSelector(G,(e=>e.customAttributes)),O=o.createSelector(G,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),N=o.createSelector((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:i,lastLoginTime:s,isCurrentDevice:l})=>({id:e,name:t,deviceType:i,lastLoginDate:1e3*parseInt(s,10),isCurrent:l}))))),B=o.createSelector((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:i,createdTime:s})=>({id:e,name:t,passkeyType:i,createdAt:1e3*s}))))),$=e=>e.notifications,H=o.createSelector(G,(e=>e.userTenants||[])),V=e=>e.tenant.currentTenantId,Z=l.createAsyncThunk("tenant/select",((t,i)=>e.__awaiter(void 0,[t,i],void 0,(function*(e,{extra:{api:t},getState:i}){if(e===V(i()))return null;const s=yield t.user.setCurrentTenant(e),l=s.sessionJwt||s.sessionToken;try{return{tenantId:P(l)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),J={action:Z,reducer:n(Z)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var i;e.tenant.currentTenantId=null===(i=t.payload)||void 0===i?void 0:i.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},d((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{if(t){const s=t(i);s&&e.notifications.push({type:"success",msg:s})}},onRejected:(t,i)=>{if(e){const s=e(i);s&&t.notifications.push({type:"error",msg:s})}}}))({getErrorMsg:e=>{var t,i;const s=(null===(t=e.error)||void 0===t?void 0:t.message)||"";return"Error"===(null===(i=e.error)||void 0===i?void 0:i.name)?s:`${s||"Error"}`}}))},X={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},passkeys:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},Y={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",passkeys:"/v1/mgmt/user/passkeys/list",selectTenant:"/v1/auth/tenant/select"},z=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.text(),i=JSON.parse(e);if(!t.ok){const e=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(e||`${t.status} ${t.statusText}`)}t.json=()=>Promise.resolve(i),t.text=()=>Promise.resolve(e)})),K=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],Q=()=>e.__awaiter(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",recoveryEmail:"recovery@company.com",recoveryPhone:"+1-202-555-020",verifiedEmail:!0,verifiedPhone:!0,verifiedRecoveryEmail:!0,verifiedRecoveryPhone:!0,userTenants:K,status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),ee=()=>({devices:[{id:"device-id-1",name:"Device 1",deviceType:"desktop",lastLoginDate:17359776e5,isCurrent:!1},{id:"device-id-2",name:"Device 2",deviceType:"mobile",lastLoginDate:17387505e5,isCurrentDevice:!0},{id:"device-id-3",name:"Device 3",deviceType:"tablet",lastLoginDate:17412642e5,isCurrent:!1},{id:"device-id-4",name:"Device 4",deviceType:"unknown",lastLoginDate:17440371e5,isCurrent:!1},{id:"device-id-5",name:"Device 5",deviceType:"desktop",lastLoginDate:174672e7,isCurrent:!1}]}),te=()=>({passkeys:[{id:"vendor-id-1",displayName:"Device 1",kind:"google",createdTime:1735977600,rpId:"example.com"},{id:"vendor-id-2",displayName:"Device 2",kind:"edge",createdTime:1738750500,rpId:"example.com"},{id:"vendor-id-3",displayName:"Device 3",kind:"apple",createdTime:1741264200,rpId:"example.com"}]}),ie=({httpClient:t,mock:i})=>({me:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i)return Q();const e=yield t.get(Y.me);return yield z(e),e.json()})),setCurrentTenant:i=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.post(Y.selectTenant,{tenant:i});return yield z(e),e.json()}))}),se=({httpClient:t,mock:i})=>({devices:s=>e.__awaiter(void 0,[s],void 0,(function*({userId:e}){if(i)return ee();const s=yield t.post(Y.devices,{identifiers:[e]});return yield z(s),s.json()}))}),le=({httpClient:t,mock:i})=>({listPasskeys:s=>e.__awaiter(void 0,[s],void 0,(function*({userId:e}){if(i)return te();const s=yield t.post(Y.passkeys,{loginId:e});return yield z(s),s.json()}))}),ae=t.createSingletonMixin((s=>{var l,o,r,n;const d=t.compose(i.projectIdMixin,i.observeAttributesMixin,i.loggerMixin,i.baseUrlMixin,i.cookieConfigMixin)(s);return n=class extends d{constructor(){super(...arguments),l.add(this),o.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||i.DEFAULT_STYLE_ID}get api(){return e.__classPrivateFieldGet(this,o,"f")||e.__classPrivateFieldGet(this,l,"m",r).call(this),e.__classPrivateFieldGet(this,o,"f")}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this),this.observeAttributes(["project-id","base-url"],(()=>{e.__classPrivateFieldGet(this,o,"f")&&e.__classPrivateFieldGet(this,l,"m",r).call(this)}))}))}},o=new WeakMap,l=new WeakSet,r=function(){this.logger.debug("creating an sdk instance"),e.__classPrivateFieldSet(this,o,((t,i,s)=>{const l=a(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.15.2"}}));return{user:Object.assign(Object.assign({},ie({httpClient:l.httpClient,mock:i})),{logout:i?()=>e.__awaiter(void 0,void 0,void 0,(function*(){})):l.logout}),device:Object.assign({},se({httpClient:l.httpClient,mock:i})),passkey:Object.assign({},le({httpClient:l.httpClient,mock:i}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},n})),oe=t.createSingletonMixin((e=>{const s=t.compose(i.createStateManagementMixin({name:"widget",initialState:X,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{v.reducer(e),f.reducer(e),w.reducer(e),m.reducer(e),J.reducer(e)},asyncActions:{getMe:v.action,listDevices:f.action,listPasskeys:w.action,logout:m.action,selectTenant:J.action}}),i.initLifecycleMixin,i.loggerMixin,ae)(e);return class extends s{constructor(...e){super(...e),this.state=X,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),re="widget-flow",ne=t.createSingletonMixin((l=>{var a,o,n;return n=class extends(t.compose(i.localeMixin,i.initLifecycleMixin,i.modalMixin,oe,i.cookieConfigMixin,i.loggerMixin,i.themeMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this)}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this);const s=r(re);s&&(!function(e){if(window.history.replaceState&&r(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(re),e.__classPrivateFieldGet(this,a,"m",o).call(this,s))}))}},a=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e}));new s.FlowDriver((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},n})),de=t.createSingletonMixin((s=>{var l,a,o;return o=class extends(t.compose(i.loggerMixin,i.initLifecycleMixin,i.descopeUiMixin,i.initElementMixin,i.createFetchWidgetPagesMixin("user-profile-widget"),oe)(s)){constructor(){super(...arguments),l.add(this)}onWidgetRootReady(){return e.__awaiter(this,void 0,void 0,(function*(){}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this),yield this.actions.getMe(),yield e.__classPrivateFieldGet(this,l,"m",a).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},l=new WeakSet,a=function(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.createTemplate(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},o})),ce=t.createSingletonMixin((e=>class extends(t.compose(i.themeMixin,i.observeAttributesMixin)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),he=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u;return u=class extends(t.compose(i.localeMixin,ce,i.themeMixin,oe,i.loggerMixin,i.cookieConfigMixin,de,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),h.set(this,t.withMemCache((e=>{this.avatar.image=e}))),v.set(this,t.withMemCache((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",n).call(this),e.__classPrivateFieldGet(this,h,"f").call(this,M(this.state)),e.__classPrivateFieldGet(this,v,"f").call(this,x(this.state)),this.subscribe(e.__classPrivateFieldGet(this,h,"f").bind(this),M),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),x)}))}},o=new WeakMap,r=new WeakMap,h=new WeakMap,v=new WeakMap,a=new WeakSet,n=function(){this.avatar.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"update-pic","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",d).bind(this),e.__classPrivateFieldGet(this,a,"m",d).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},d=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.avatar.flowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},c=function(){this.avatar=new s.AvatarDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()}))},u})),ve=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g,F,w;return w=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),g.set(this,t.withMemCache((t=>{this.emailUserAttr.value=t,e.__classPrivateFieldGet(this,a,"m",f).call(this)}))),F.set(this,t.withMemCache((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,k(this.state)),e.__classPrivateFieldGet(this,F,"f").call(this,R(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),k),this.subscribe(e.__classPrivateFieldGet(this,F,"f").bind(this),R)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,g=new WeakMap,F=new WeakMap,a=new WeakSet,c=function(){this.emailUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-email","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.editFlowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.emailUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-email","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.deleteFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.emailUserAttr=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.emailUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},f=function(){var t,i;(null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t?void 0:t.isClosed)&&e.__classPrivateFieldGet(this,a,"m",h).call(this),(null===(i=e.__classPrivateFieldGet(this,n,"f"))||void 0===i?void 0:i.isClosed)&&e.__classPrivateFieldGet(this,a,"m",u).call(this)},w})),ue=t.createSingletonMixin((l=>{var a,o,r;return r=class extends(t.compose(oe,i.loggerMixin,de,i.modalMixin)(l)){constructor(){super(...arguments),a.add(this)}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",o).call(this)}))}},a=new WeakSet,o=function(){this.logout=new s.ButtonDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>e.__awaiter(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},r})),_e=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g,F;return F=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),g.set(this,t.withMemCache((t=>{this.nameUserAttr.value=t,e.__classPrivateFieldGet(this,a,"m",f).call(this)})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,x(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),x)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,g=new WeakMap,a=new WeakSet,c=function(){this.nameUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-name","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.editFlowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.nameUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-name","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.deleteFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.nameUserAttr=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.nameUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},f=function(){var t,i;(null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t?void 0:t.isClosed)&&e.__classPrivateFieldGet(this,a,"m",h).call(this),(null===(i=e.__classPrivateFieldGet(this,n,"f"))||void 0===i?void 0:i.isClosed)&&e.__classPrivateFieldGet(this,a,"m",u).call(this)},F})),fe=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),f.set(this,t.withMemCache((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,L(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),L)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,f=new WeakMap,a=new WeakSet,c=function(){this.passkeyUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"add-passkey","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.flowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"remove-passkey","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.fulfilledFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.passkeyUserAuthMethod=new s.UserAuthMethodDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},g})),ge=t.createSingletonMixin((l=>{var a,o,r,n,d,c;return c=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new s.UserAuthMethodDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()}))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.initPasswordAuthMethod(),e.__classPrivateFieldGet(this,a,"m",n).call(this)}))}},o=new WeakMap,r=new WeakMap,a=new WeakSet,n=function(){this.passwordUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"password","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",d).bind(this),e.__classPrivateFieldGet(this,a,"m",d).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},d=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.passwordUserAuthMethod.flowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close()}))},c})),Fe=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g,F,w;return w=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),g.set(this,t.withMemCache((t=>{this.phoneUserAttr.value=t,e.__classPrivateFieldGet(this,a,"m",f).call(this)}))),F.set(this,t.withMemCache((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,b(this.state)),e.__classPrivateFieldGet(this,F,"f").call(this,W(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),b),this.subscribe(e.__classPrivateFieldGet(this,F,"f").bind(this),W)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,g=new WeakMap,F=new WeakMap,a=new WeakSet,c=function(){this.phoneUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-phone","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.editFlowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.phoneUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-phone","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.deleteFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.phoneUserAttr=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.phoneUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},f=function(){var t,i;(null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t?void 0:t.isClosed)&&e.__classPrivateFieldGet(this,a,"m",h).call(this),(null===(i=e.__classPrivateFieldGet(this,n,"f"))||void 0===i?void 0:i.isClosed)&&e.__classPrivateFieldGet(this,a,"m",u).call(this)},w})),we=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),f.set(this,t.withMemCache((e=>{this.recoveryEmailUserAttr.value=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,D(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),D)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,f=new WeakMap,a=new WeakSet,c=function(){this.recoveryEmailUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-recovery-email","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.recoveryEmailUserAttr.editFlowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.recoveryEmailUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-recovery-email","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.recoveryEmailUserAttr.deleteFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.recoveryEmailUserAttr=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryEmail"]')}),{logger:this.logger}),this.recoveryEmailUserAttr.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.recoveryEmailUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},g})),pe=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),f.set(this,t.withMemCache((e=>{this.recoveryPhoneUserAttr.value=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,E(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),E)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,f=new WeakMap,a=new WeakSet,c=function(){this.recoveryPhoneUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-recovery-phone","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.recoveryPhoneUserAttr.editFlowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.recoveryPhoneUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-recovery-phone","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.recoveryPhoneUserAttr.deleteFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.recoveryPhoneUserAttr=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryPhone"]')}),{logger:this.logger}),this.recoveryPhoneUserAttr.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.recoveryPhoneUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},g})),me=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),f.set(this,t.withMemCache((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,q(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),q)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,f=new WeakMap,a=new WeakSet,c=function(){this.totpUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"totp","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.flowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},v=function(){this.totpUserAuthMethod.fulfilledFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"remove-totp","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",u).bind(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function(){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.fulfilledFlowId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},_=function(){this.totpUserAuthMethod=new s.UserAuthMethodDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},g})),Pe=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g,F,w;return w=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,{}),r.set(this,{}),n.set(this,{}),d.set(this,{}),c.set(this,{}),F.set(this,t.withMemCache((t=>{Object.keys(e.__classPrivateFieldGet(this,o,"f")).forEach((i=>{e.__classPrivateFieldGet(this,o,"f")[i].value=(t[i]||"").toString()})),e.__classPrivateFieldGet(this,a,"m",g).call(this)})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",f).call(this),e.__classPrivateFieldGet(this,F,"f").call(this,O(this.state)),this.subscribe(e.__classPrivateFieldGet(this,F,"f").bind(this),O)}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,F=new WeakMap,a=new WeakSet,h=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t})),null===(s=e.__classPrivateFieldGet(this,n,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},v=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t})),null===(s=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},u=function(t,i,l){const o=t.getAttribute("edit-flow-id");o&&(e.__classPrivateFieldGet(this,r,"f")[o]=this.createModal({"data-id":`edit-${i}`,"close-on-outside-click":"true"}),e.__classPrivateFieldGet(this,n,"f")[o]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,r,"f")[o].afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this,o),l.onEditClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")[o]))},_=function(t,i,l){const o=t.getAttribute("delete-flow-id");o&&(e.__classPrivateFieldGet(this,d,"f")[o]=this.createModal({"data-id":`delete-${i}`,"close-on-outside-click":"true"}),e.__classPrivateFieldGet(this,c,"f")[o]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,d,"f")[o].afterClose=e.__classPrivateFieldGet(this,a,"m",v).bind(this,o),l.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")[o]))},f=function(){var t;const i=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(i||[]).forEach((t=>{const i=t.getAttribute("data-id").replace("builtin.",""),l=new s.UserAttributeDriver(t,{logger:this.logger});e.__classPrivateFieldGet(this,o,"f")[i]=l,e.__classPrivateFieldGet(this,a,"m",u).call(this,t,i,l),e.__classPrivateFieldGet(this,a,"m",_).call(this,t,i,l)}))},g=function(){Object.entries(e.__classPrivateFieldGet(this,r,"f")).forEach((([t,i])=>{i.isClosed&&e.__classPrivateFieldGet(this,a,"m",h).call(this,t)})),Object.entries(e.__classPrivateFieldGet(this,d,"f")).forEach((([t,i])=>{i.isClosed&&e.__classPrivateFieldGet(this,a,"m",v).call(this,t)}))},w}));var Ge;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Ge||(Ge={}));const ye=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f;return o=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),r.set(this,{}),n.set(this,{}),d.set(this,{}),c.set(this,{}),u.set(this,t.withMemCache((t=>{var i;const l=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(l).forEach((i=>{const l=i.getAttribute("data-id").replace("customAttributes.",""),r=i.getAttribute("data-type")||Ge.TEXT,n=t[l],d=new s.UserAttributeDriver(i,{logger:this.logger});d.value=o.getFormattedValue(r,n),e.__classPrivateFieldGet(this,a,"m",_).call(this,i,l,d),e.__classPrivateFieldGet(this,a,"m",f).call(this,i,l,d)}))})))}static getFormattedValue(e,t){return e===Ge.DATE&&t?new Date(t).toLocaleString():e===Ge.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,u,"f").call(this,j(this.state)),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),j)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,u=new WeakMap,a=new WeakSet,h=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t})),null===(s=e.__classPrivateFieldGet(this,n,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},v=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t})),null===(s=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},_=function(t,i,l){const o=t.getAttribute("edit-flow-id");o&&(e.__classPrivateFieldGet(this,r,"f")[o]=this.createModal({"data-id":`edit-${i}`,"close-on-outside-click":"true"}),e.__classPrivateFieldGet(this,n,"f")[o]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,r,"f")[o].afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this,o),l.onEditClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,a,"m",h).call(this,o),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")[o]))},f=function(t,i,l){const o=t.getAttribute("delete-flow-id");o&&(e.__classPrivateFieldGet(this,d,"f")[o]=this.createModal({"data-id":`delete-${i}`,"close-on-outside-click":"true"}),e.__classPrivateFieldGet(this,c,"f")[o]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,d,"f")[o].afterClose=e.__classPrivateFieldGet(this,a,"m",v).bind(this,o),l.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,a,"m",v).call(this,o),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")[o]))},o})),Me=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v;return v=class extends(t.compose(i.localeMixin,ce,i.themeMixin,oe,i.loggerMixin,i.cookieConfigMixin,de,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),this.updateDeviceList=t.withMemCache((e=>{this.deviceList.data=e}))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.deviceList=new s.DeviceListDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield e.__classPrivateFieldGet(this,a,"m",h).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this,N(this.state)),e.__classPrivateFieldGet(this,a,"m",n).call(this),this.subscribe(this.updateDeviceList.bind(this),N))}))}},o=new WeakMap,r=new WeakMap,a=new WeakSet,n=function(){this.deviceList.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"untrust-device","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=()=>e.__classPrivateFieldGet(this,a,"m",d).call(this,""),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},d=function(t=""){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.deviceList.flowId,form:{deviceId:t}})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.listDevices({userId:y(this.state)})}))},c=function(t){this.deviceList.onRemoveDeviceClick((({id:t})=>{var i;e.__classPrivateFieldGet(this,a,"m",d).call(this,t),null===(i=e.__classPrivateFieldGet(this,o,"f"))||void 0===i||i.open()})),this.deviceList.data=t},h=function(){return e.__awaiter(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:y(this.state)})}))},v})),ke=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(i.localeMixin,ce,oe,i.loggerMixin,de,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),_.set(this,t.withMemCache((e=>{this.actions.listPasskeys({userId:e})}))),this.updatePasskeyList=t.withMemCache((e=>{this.userPasskeys.data=e}))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.userPasskeys=new s.UserPasskeysDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-user-passkeys")}),{logger:this.logger}),this.userPasskeys.isExists&&(e.__classPrivateFieldGet(this,a,"m",f).call(this,B(this.state)),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),this.subscribe(e.__classPrivateFieldGet(this,_,"f").bind(this),y),this.subscribe(this.updatePasskeyList.bind(this),B))}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,_=new WeakMap,a=new WeakSet,c=function(){this.userPasskeys.addPasskeyFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"add-user-passkey","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.addPasskeyFlowId})),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:y(this.state)})}))},v=function(){this.userPasskeys.removePasskeyFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"remove-user-passkey","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},u=function({externalId:t,credentialId:i}){e.__classPrivateFieldGet(this,n,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.removePasskeyFlowId,form:{externalId:t,credentialId:i}})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:y(this.state)})}))},f=function(t){this.updatePasskeyList(t),this.userPasskeys.onAddPasskeyClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.userPasskeys.onRemovePasskeyClick((({id:t})=>{var i;const s=y(this.state);e.__classPrivateFieldGet(this,a,"m",u).call(this,{externalId:s,credentialId:t}),null===(i=e.__classPrivateFieldGet(this,n,"f"))||void 0===i||i.open()}))},g}));const Se={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},xe=t.createSingletonMixin((s=>{var l,a,o,r,n;return n=class extends(t.compose(i.loggerMixin,oe,i.notificationsMixin,i.initLifecycleMixin)(s)){constructor(){super(...arguments),l.add(this),r.set(this,t.withMemCache((t=>{t.length&&(t.forEach((({type:t,msg:i})=>{const s=e.__classPrivateFieldGet(this,l,"m",o).call(this,t);s.setContent(e.__classPrivateFieldGet(this,l,"m",a).call(this,{type:t,msg:i})),s.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this),this.subscribe(e.__classPrivateFieldGet(this,r,"f").bind(this),$)}))}},r=new WeakMap,l=new WeakSet,a=function({type:e,msg:t}){const i=Se[e],s=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${s.outerHTML}`},o=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},n})),be=t.createSingletonMixin((l=>{var o,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(oe,i.loggerMixin,de)(l)){constructor(){super(...arguments),o.add(this),r.set(this,null),d.set(this,(t=>e.__awaiter(this,void 0,void 0,(function*(){const e=t.target.value;yield this.actions.selectTenant(e)})))),c.set(this,(t=>{const i=V(t);this.tenantSelector.value!==i&&e.__classPrivateFieldGet(this,o,"m",_).call(this,i);const{loading:s,error:l}=t.selectTenant,a=null!==t.tenant.previousTenantId,n=i!==e.__classPrivateFieldGet(this,r,"f");!i||s||l||a||!n||(e.__classPrivateFieldSet(this,r,i,"f"),e.__classPrivateFieldGet(this,o,"m",h).call(this))}))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.actions.setCurrentTenantId((()=>{const e=a.getSessionToken();return P(e)})()),e.__classPrivateFieldGet(this,o,"m",n).call(this),e.__classPrivateFieldGet(this,o,"m",f).call(this),e.__classPrivateFieldGet(this,o,"m",u).call(this,H(this.state)),this.subscribe(e.__classPrivateFieldGet(this,c,"f").bind(this))}))}},r=new WeakMap,d=new WeakMap,c=new WeakMap,o=new WeakSet,n=function(){this.tenantSelector=new s.TenantSelectorDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(e.__classPrivateFieldGet(this,d,"f"))},h=function(){const t=V(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:t}})),this.tenantSelector.shouldReload&&e.__classPrivateFieldGet(this,o,"m",v).call(this)},v=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},u=function(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.map((e=>({label:e.tenantName||e.tenantId,value:e.tenantId})));yield this.tenantSelector.setData(e)}))},_=function(e){e&&(this.tenantSelector.value=e)},f=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{e.__classPrivateFieldGet(this,o,"m",_).call(this,V(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},g})),Ce=t.createSingletonMixin((l=>{var a,o,r,n,d,c,h,v,u,_,f;return f=class extends(t.compose(i.localeMixin,ce,oe,i.modalMixin,i.loggerMixin,de,i.flowInputMixin)(l)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),r.set(this,void 0),n.set(this,[]),d.set(this,null)}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),e.__classPrivateFieldGet(this,n,"f").forEach((e=>e.enable()))}))}},o=new WeakMap,r=new WeakMap,n=new WeakMap,d=new WeakMap,a=new WeakSet,c=function(t){const i=new s.GenericFlowButtonDriver(t,{logger:this.logger});i.onClick((()=>{e.__classPrivateFieldGet(this,a,"m",_).call(this,i.flowId,y(this.state))})),e.__classPrivateFieldGet(this,n,"f").push(i)},h=function(){var t;const i=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelectorAll("[data-generic-flow-button-id]");Array.from(i).forEach((t=>{e.__classPrivateFieldGet(this,a,"m",c).call(this,t)}))},v=function(){e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"generic-flow-modal","close-on-outside-click":"true"}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.call(this),e.__classPrivateFieldSet(this,d,null,"f")},e.__classPrivateFieldSet(this,r,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f"))},u=function(){var t;e.__classPrivateFieldGet(this,o,"f").open(),null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.call(this)},_=function(t,i){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:t,client:{userId:i}}));e.__classPrivateFieldSet(this,d,e.__classPrivateFieldGet(this,r,"f").onPageUpdated((()=>e.__classPrivateFieldGet(this,a,"m",u).call(this))),"f"),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getMe()}))},f})),Re=t.createSingletonMixin((s=>class extends(t.compose(i.debuggerMixin,i.themeMixin,ne,ye,ve,he,_e,Fe,we,pe,fe,ge,me,Pe,ue,Me,ke,xe,be,Ce)(s)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this)}))}})),We=t.compose((t=>class extends(Re(t)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.15.2"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",We),module.exports=We;
6
6
  //# sourceMappingURL=index.js.map
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**
3
- * @descope/user-profile-widget v0.15.0
3
+ * @descope/user-profile-widget v0.15.2
4
4
  */
5
- import{__awaiter as e,__classPrivateFieldGet as t,__classPrivateFieldSet as i}from"tslib";import{decodeJWT as s,createSingletonMixin as o,compose as n,createTemplate as l,withMemCache as r}from"@descope/sdk-helpers";import{projectIdMixin as a,observeAttributesMixin as d,loggerMixin as h,baseUrlMixin as c,cookieConfigMixin as u,DEFAULT_STYLE_ID as v,createStateManagementMixin as f,initLifecycleMixin as g,localeMixin as p,modalMixin as m,themeMixin as w,flowInputMixin as y,descopeUiMixin as k,initElementMixin as b,createFetchWidgetPagesMixin as R,notificationsMixin as M,debuggerMixin as W}from"@descope/sdk-mixins";import{FlowDriver as C,AvatarDriver as S,UserAttributeDriver as I,ButtonDriver as T,UserAuthMethodDriver as A,DeviceListDriver as F,UserPasskeysDriver as U,TenantSelectorDriver as x,GenericFlowButtonDriver as E}from"@descope/sdk-component-drivers";import{createAsyncThunk as P}from"@reduxjs/toolkit";import j,{getSessionToken as L}from"@descope/web-js-sdk";import{createSelector as O}from"reselect";import"@descope/core-js-sdk";import"@descope/web-component";function q(e){return new URLSearchParams(window.location.search).get(e)}const D=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},N=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),$=P("users/me",((e,{extra:{api:t}})=>t.user.me())),B=D($)({onFulfilled:(e,t)=>{e.me.data=t.payload}},N((e=>e.me))),H={action:$,reducer:B},V=P("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),Z=D(V)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},N((e=>e.devices))),J={action:V,reducer:Z},X=P("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),z=D(X)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},N((e=>e.passkeys))),G={action:X,reducer:z},Y=P("users/logout",((e,{extra:{api:t}})=>t.user.logout())),_={action:Y,reducer:D(Y)({})},K=e=>{if(!e)return null;const t=s(e);return(null==t?void 0:t.dct)||null},Q=e=>e.me.data,ee=O(Q,(e=>e.userId)),te=O(Q,(e=>e.picture)),ie=O(Q,(e=>e.email)),se=O(Q,(e=>e.verifiedEmail)),oe=O(Q,(e=>e.name)),ne=O(Q,(e=>e.phone)),le=O(Q,(e=>e.verifiedPhone)),re=O(ie,se,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),ae=O(ne,le,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),de=O(Q,(e=>e.recoveryEmail)),he=O(Q,(e=>e.verifiedRecoveryEmail)),ce=O(Q,(e=>e.recoveryPhone)),ue=O(Q,(e=>e.verifiedRecoveryPhone)),ve=O(de,he,((e,t)=>t?e:"")),fe=O(ce,ue,((e,t)=>t?e:"")),ge=O(Q,(e=>e.webauthn));O(Q,(e=>e.password));const pe=O(Q,(e=>e.TOTP)),me=O(Q,(e=>e.customAttributes)),we=O(Q,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),ye=O((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:i,lastLoginTime:s,isCurrentDevice:o})=>({id:e,name:t,deviceType:i,lastLoginDate:1e3*parseInt(s,10),isCurrent:o}))))),ke=O((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:i,createdTime:s})=>({id:e,name:t,passkeyType:i,createdAt:1e3*s}))))),be=e=>e.notifications,Re=O(Q,(e=>e.userTenants||[])),Me=e=>e.tenant.currentTenantId,We=P("tenant/select",((t,i)=>e(void 0,[t,i],void 0,(function*(e,{extra:{api:t},getState:i}){if(e===Me(i()))return null;const s=yield t.user.setCurrentTenant(e),o=s.sessionJwt||s.sessionToken;try{return{tenantId:K(o)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),Ce={action:We,reducer:D(We)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var i;e.tenant.currentTenantId=null===(i=t.payload)||void 0===i?void 0:i.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},N((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{if(t){const s=t(i);s&&e.notifications.push({type:"success",msg:s})}},onRejected:(t,i)=>{if(e){const s=e(i);s&&t.notifications.push({type:"error",msg:s})}}}))({getErrorMsg:e=>{var t,i;const s=(null===(t=e.error)||void 0===t?void 0:t.message)||"";return"Error"===(null===(i=e.error)||void 0===i?void 0:i.name)?s:`${s||"Error"}`}}))},Se={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},passkeys:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},Ie={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",passkeys:"/v1/mgmt/user/passkeys/list",selectTenant:"/v1/auth/tenant/select"},Te=t=>e(void 0,void 0,void 0,(function*(){const e=yield t.text(),i=JSON.parse(e);if(!t.ok){const e=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(e||`${t.status} ${t.statusText}`)}t.json=()=>Promise.resolve(i),t.text=()=>Promise.resolve(e)})),Ae=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],Fe=()=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",recoveryEmail:"recovery@company.com",recoveryPhone:"+1-202-555-020",verifiedEmail:!0,verifiedPhone:!0,verifiedRecoveryEmail:!0,verifiedRecoveryPhone:!0,userTenants:Ae,status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),Ue=()=>({devices:[{id:"device-id-1",name:"Device 1",deviceType:"desktop",lastLoginDate:17359776e5,isCurrent:!1},{id:"device-id-2",name:"Device 2",deviceType:"mobile",lastLoginDate:17387505e5,isCurrentDevice:!0},{id:"device-id-3",name:"Device 3",deviceType:"tablet",lastLoginDate:17412642e5,isCurrent:!1},{id:"device-id-4",name:"Device 4",deviceType:"unknown",lastLoginDate:17440371e5,isCurrent:!1},{id:"device-id-5",name:"Device 5",deviceType:"desktop",lastLoginDate:174672e7,isCurrent:!1}]}),xe=()=>({passkeys:[{id:"vendor-id-1",displayName:"Device 1",kind:"google",createdTime:1735977600,rpId:"example.com"},{id:"vendor-id-2",displayName:"Device 2",kind:"edge",createdTime:1738750500,rpId:"example.com"},{id:"vendor-id-3",displayName:"Device 3",kind:"apple",createdTime:1741264200,rpId:"example.com"}]}),Ee=({httpClient:t,mock:i})=>({me:()=>e(void 0,void 0,void 0,(function*(){if(i)return Fe();const e=yield t.get(Ie.me);return yield Te(e),e.json()})),setCurrentTenant:i=>e(void 0,void 0,void 0,(function*(){const e=yield t.post(Ie.selectTenant,{tenant:i});return yield Te(e),e.json()}))}),Pe=({httpClient:t,mock:i})=>({devices:s=>e(void 0,[s],void 0,(function*({userId:e}){if(i)return Ue();const s=yield t.post(Ie.devices,{identifiers:[e]});return yield Te(s),s.json()}))}),je=({httpClient:t,mock:i})=>({listPasskeys:s=>e(void 0,[s],void 0,(function*({userId:e}){if(i)return xe();const s=yield t.post(Ie.passkeys,{loginId:e});return yield Te(s),s.json()}))}),Le=o((s=>{var o,l,r,f;const g=n(a,d,h,c,u)(s);return f=class extends g{constructor(){super(...arguments),o.add(this),l.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||v}get api(){return t(this,l,"f")||t(this,o,"m",r).call(this),t(this,l,"f")}init(){const i=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.init)||void 0===e?void 0:e.call(this),this.observeAttributes(["project-id","base-url"],(()=>{t(this,l,"f")&&t(this,o,"m",r).call(this)}))}))}},l=new WeakMap,o=new WeakSet,r=function(){this.logger.debug("creating an sdk instance"),i(this,l,((t,i,s)=>{const o=j(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.15.0"}}));return{user:Object.assign(Object.assign({},Ee({httpClient:o.httpClient,mock:i})),{logout:i?()=>e(void 0,void 0,void 0,(function*(){})):o.logout}),device:Object.assign({},Pe({httpClient:o.httpClient,mock:i})),passkey:Object.assign({},je({httpClient:o.httpClient,mock:i}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},f})),Oe=o((e=>{const t=n(f({name:"widget",initialState:Se,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{H.reducer(e),J.reducer(e),G.reducer(e),_.reducer(e),Ce.reducer(e)},asyncActions:{getMe:H.action,listDevices:J.action,listPasskeys:G.action,logout:_.action,selectTenant:Ce.action}}),g,h,Le)(e);return class extends t{constructor(...e){super(...e),this.state=Se,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),qe="widget-flow",De=o((i=>{var s,o,l;return l=class extends(n(p,g,m,Oe,u,h,w,y)(i)){constructor(){super(...arguments),s.add(this)}init(){const i=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.init)||void 0===e?void 0:e.call(this);const n=q(qe);n&&(!function(e){if(window.history.replaceState&&q(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(qe),t(this,s,"m",o).call(this,n))}))}},s=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e}));new C((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},l})),Ne=o((i=>{var s,o,r;return r=class extends(n(h,g,k,b,R("user-profile-widget"),Oe)(i)){constructor(){super(...arguments),s.add(this)}onWidgetRootReady(){return e(this,void 0,void 0,(function*(){}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.init)||void 0===e?void 0:e.call(this),yield this.actions.getMe(),yield t(this,s,"m",o).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},s=new WeakSet,o=function(){return e(this,void 0,void 0,(function*(){const e=l(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},r})),$e=o((e=>class extends(n(w,d)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),Be=o((s=>{var o,l,a,d,c,v,f,g,k;return k=class extends(n(p,$e,w,Oe,h,u,Ne,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),f.set(this,r((e=>{this.avatar.image=e}))),g.set(this,r((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",v).call(this),t(this,o,"m",d).call(this),t(this,f,"f").call(this,te(this.state)),t(this,g,"f").call(this,oe(this.state)),this.subscribe(t(this,f,"f").bind(this),te),this.subscribe(t(this,g,"f").bind(this),oe)}))}},l=new WeakMap,a=new WeakMap,f=new WeakMap,g=new WeakMap,o=new WeakSet,d=function(){this.avatar.flowId&&(i(this,l,this.createModal({"data-id":"update-pic","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",c).bind(this),t(this,o,"m",c).call(this),this.syncFlowTheme(t(this,a,"f")))},c=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.avatar.flowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},v=function(){this.avatar=new S((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()}))},k})),He=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R,M,W;return W=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),R.set(this,r((e=>{this.emailUserAttr.value=e,t(this,o,"m",b).call(this)}))),M.set(this,r((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,R,"f").call(this,ie(this.state)),t(this,M,"f").call(this,re(this.state)),this.subscribe(t(this,R,"f").bind(this),ie),this.subscribe(t(this,M,"f").bind(this),re)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,R=new WeakMap,M=new WeakMap,o=new WeakSet,v=function(){this.emailUserAttr.editFlowId&&(i(this,l,this.createModal({"data-id":"edit-email","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.editFlowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-email","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.deleteFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.emailUserAttr=new I((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},b=function(){var e,i;(null===(e=t(this,l,"f"))||void 0===e?void 0:e.isClosed)&&t(this,o,"m",f).call(this),(null===(i=t(this,d,"f"))||void 0===i?void 0:i.isClosed)&&t(this,o,"m",w).call(this)},W})),Ve=o((i=>{var s,o,l;return l=class extends(n(Oe,h,Ne,m)(i)){constructor(){super(...arguments),s.add(this)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,s,"m",o).call(this)}))}},s=new WeakSet,o=function(){this.logout=new T((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>e(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},l})),Ze=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R,M;return M=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),R.set(this,r((e=>{this.nameUserAttr.value=e,t(this,o,"m",b).call(this)})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,R,"f").call(this,oe(this.state)),this.subscribe(t(this,R,"f").bind(this),oe)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,R=new WeakMap,o=new WeakSet,v=function(){this.nameUserAttr.editFlowId&&(i(this,l,this.createModal({"data-id":"edit-name","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.editFlowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-name","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.deleteFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.nameUserAttr=new I((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},b=function(){var e,i;(null===(e=t(this,l,"f"))||void 0===e?void 0:e.isClosed)&&t(this,o,"m",f).call(this),(null===(i=t(this,d,"f"))||void 0===i?void 0:i.isClosed)&&t(this,o,"m",w).call(this)},M})),Je=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R;return R=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),b.set(this,r((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,b,"f").call(this,ge(this.state)),this.subscribe(t(this,b,"f").bind(this),ge)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,b=new WeakMap,o=new WeakSet,v=function(){this.passkeyUserAuthMethod.flowId&&(i(this,l,this.createModal({"data-id":"add-passkey","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),t(this,o,"m",f).call(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.flowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(i(this,d,this.createModal({"data-id":"remove-passkey","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),t(this,o,"m",w).call(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.fulfilledFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.passkeyUserAuthMethod=new A((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},R})),Xe=o((s=>{var o,l,r,a,d,c;return c=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),r.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new A((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),this.initPasswordAuthMethod(),t(this,o,"m",a).call(this)}))}},l=new WeakMap,r=new WeakMap,o=new WeakSet,a=function(){this.passwordUserAuthMethod.flowId&&(i(this,l,this.createModal({"data-id":"password","close-on-outside-click":"true"}),"f"),i(this,r,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",d).bind(this),t(this,o,"m",d).call(this),this.syncFlowTheme(t(this,r,"f")))},d=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.passwordUserAuthMethod.flowId})),t(this,r,"f").onSuccess((()=>{t(this,l,"f").close()}))},c})),ze=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R,M,W;return W=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),R.set(this,r((e=>{this.phoneUserAttr.value=e,t(this,o,"m",b).call(this)}))),M.set(this,r((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,R,"f").call(this,ne(this.state)),t(this,M,"f").call(this,ae(this.state)),this.subscribe(t(this,R,"f").bind(this),ne),this.subscribe(t(this,M,"f").bind(this),ae)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,R=new WeakMap,M=new WeakMap,o=new WeakSet,v=function(){this.phoneUserAttr.editFlowId&&(i(this,l,this.createModal({"data-id":"edit-phone","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.editFlowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-phone","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.deleteFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.phoneUserAttr=new I((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},b=function(){var e,i;(null===(e=t(this,l,"f"))||void 0===e?void 0:e.isClosed)&&t(this,o,"m",f).call(this),(null===(i=t(this,d,"f"))||void 0===i?void 0:i.isClosed)&&t(this,o,"m",w).call(this)},W})),Ge=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R;return R=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),b.set(this,r((e=>{this.recoveryEmailUserAttr.value=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,b,"f").call(this,ve(this.state)),this.subscribe(t(this,b,"f").bind(this),ve)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,b=new WeakMap,o=new WeakSet,v=function(){this.recoveryEmailUserAttr.editFlowId&&(i(this,l,this.createModal({"data-id":"edit-recovery-email","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),t(this,o,"m",f).call(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.recoveryEmailUserAttr.editFlowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.recoveryEmailUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-recovery-email","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),t(this,o,"m",w).call(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.recoveryEmailUserAttr.deleteFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.recoveryEmailUserAttr=new I((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryEmail"]')}),{logger:this.logger}),this.recoveryEmailUserAttr.onEditClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.recoveryEmailUserAttr.onDeleteClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},R})),Ye=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R;return R=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),b.set(this,r((e=>{this.recoveryPhoneUserAttr.value=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,b,"f").call(this,fe(this.state)),this.subscribe(t(this,b,"f").bind(this),fe)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,b=new WeakMap,o=new WeakSet,v=function(){this.recoveryPhoneUserAttr.editFlowId&&(i(this,l,this.createModal({"data-id":"edit-recovery-phone","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),t(this,o,"m",f).call(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.recoveryPhoneUserAttr.editFlowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.recoveryPhoneUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-recovery-phone","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),t(this,o,"m",w).call(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.recoveryPhoneUserAttr.deleteFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.recoveryPhoneUserAttr=new I((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryPhone"]')}),{logger:this.logger}),this.recoveryPhoneUserAttr.onEditClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.recoveryPhoneUserAttr.onDeleteClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},R})),_e=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R;return R=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),b.set(this,r((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,b,"f").call(this,pe(this.state)),this.subscribe(t(this,b,"f").bind(this),pe)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,b=new WeakMap,o=new WeakSet,v=function(){this.totpUserAuthMethod.flowId&&(i(this,l,this.createModal({"data-id":"totp","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),t(this,o,"m",f).call(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.flowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.totpUserAuthMethod.fulfilledFlowId&&(i(this,d,this.createModal({"data-id":"remove-totp","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),t(this,o,"m",w).call(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.fulfilledFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.totpUserAuthMethod=new A((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},R})),Ke=o((i=>{var s,o,l,a,d,c,v,f,g,w,k,b,R,M;return M=class extends(n(p,$e,Oe,h,Ne,u,m,y)(i)){constructor(){super(...arguments),s.add(this),o.set(this,{}),l.set(this,{}),a.set(this,{}),d.set(this,{}),c.set(this,{}),R.set(this,r((e=>{Object.keys(t(this,o,"f")).forEach((i=>{t(this,o,"f")[i].value=(e[i]||"").toString()})),t(this,s,"m",b).call(this)})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,s,"m",k).call(this),t(this,R,"f").call(this,we(this.state)),this.subscribe(t(this,R,"f").bind(this),we)}))}},o=new WeakMap,l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,R=new WeakMap,s=new WeakSet,v=function(e){var i,s;null===(i=t(this,l,"f")[e])||void 0===i||i.setContent(this.createFlowTemplate({flowId:e})),null===(s=t(this,a,"f")[e])||void 0===s||s.onSuccess((()=>{var i;null===(i=t(this,l,"f")[e])||void 0===i||i.close(),this.actions.getMe()}))},f=function(e){var i,s;null===(i=t(this,d,"f")[e])||void 0===i||i.setContent(this.createFlowTemplate({flowId:e})),null===(s=t(this,c,"f")[e])||void 0===s||s.onSuccess((()=>{var i;null===(i=t(this,d,"f")[e])||void 0===i||i.close(),this.actions.getMe()}))},g=function(e,i,o){const n=e.getAttribute("edit-flow-id");n&&(t(this,l,"f")[n]=this.createModal({"data-id":`edit-${i}`,"close-on-outside-click":"true"}),t(this,a,"f")[n]=new C((()=>{var e,i;return null===(i=null===(e=t(this,l,"f")[n])||void 0===e?void 0:e.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),t(this,l,"f")[n].afterClose=t(this,s,"m",v).bind(this,n),o.onEditClick((()=>{var e,i;null===(i=null===(e=t(this,l,"f"))||void 0===e?void 0:e[n])||void 0===i||i.open()})),this.syncFlowTheme(t(this,a,"f")[n]))},w=function(e,i,o){const n=e.getAttribute("delete-flow-id");n&&(t(this,d,"f")[n]=this.createModal({"data-id":`delete-${i}`,"close-on-outside-click":"true"}),t(this,c,"f")[n]=new C((()=>{var e,i;return null===(i=null===(e=t(this,d,"f")[n])||void 0===e?void 0:e.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),t(this,d,"f")[n].afterClose=t(this,s,"m",f).bind(this,n),o.onDeleteClick((()=>{var e,i;null===(i=null===(e=t(this,d,"f"))||void 0===e?void 0:e[n])||void 0===i||i.open()})),this.syncFlowTheme(t(this,c,"f")[n]))},k=function(){var e;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(i||[]).forEach((e=>{const i=e.getAttribute("data-id").replace("builtin.",""),n=new I(e,{logger:this.logger});t(this,o,"f")[i]=n,t(this,s,"m",g).call(this,e,i,n),t(this,s,"m",w).call(this,e,i,n)}))},b=function(){Object.entries(t(this,l,"f")).forEach((([e,i])=>{i.isClosed&&t(this,s,"m",v).call(this,e)})),Object.entries(t(this,d,"f")).forEach((([e,i])=>{i.isClosed&&t(this,s,"m",f).call(this,e)}))},M}));var Qe;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Qe||(Qe={}));const et=o((i=>{var s,o,l,a,d,c,v,f,g,w,k;return o=class extends(n(p,$e,Oe,h,Ne,u,m,y)(i)){constructor(){super(...arguments),s.add(this),l.set(this,{}),a.set(this,{}),d.set(this,{}),c.set(this,{}),g.set(this,r((e=>{var i;const n=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(n).forEach((i=>{const n=i.getAttribute("data-id").replace("customAttributes.",""),l=i.getAttribute("data-type")||Qe.TEXT,r=e[n],a=new I(i,{logger:this.logger});a.value=o.getFormattedValue(l,r),t(this,s,"m",w).call(this,i,n,a),t(this,s,"m",k).call(this,i,n,a)}))})))}static getFormattedValue(e,t){return e===Qe.DATE&&t?new Date(t).toLocaleString():e===Qe.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,g,"f").call(this,me(this.state)),this.subscribe(t(this,g,"f").bind(this),me)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,s=new WeakSet,v=function(e){var i,s;null===(i=t(this,l,"f")[e])||void 0===i||i.setContent(this.createFlowTemplate({flowId:e})),null===(s=t(this,a,"f")[e])||void 0===s||s.onSuccess((()=>{var i;null===(i=t(this,l,"f")[e])||void 0===i||i.close(),this.actions.getMe()}))},f=function(e){var i,s;null===(i=t(this,d,"f")[e])||void 0===i||i.setContent(this.createFlowTemplate({flowId:e})),null===(s=t(this,c,"f")[e])||void 0===s||s.onSuccess((()=>{var i;null===(i=t(this,d,"f")[e])||void 0===i||i.close(),this.actions.getMe()}))},w=function(e,i,o){const n=e.getAttribute("edit-flow-id");n&&(t(this,l,"f")[n]=this.createModal({"data-id":`edit-${i}`,"close-on-outside-click":"true"}),t(this,a,"f")[n]=new C((()=>{var e,i;return null===(i=null===(e=t(this,l,"f")[n])||void 0===e?void 0:e.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),t(this,l,"f")[n].afterClose=t(this,s,"m",v).bind(this,n),o.onEditClick((()=>{var e,i;null===(i=null===(e=t(this,l,"f"))||void 0===e?void 0:e[n])||void 0===i||i.open()})),t(this,s,"m",v).call(this,n),this.syncFlowTheme(t(this,a,"f")[n]))},k=function(e,i,o){const n=e.getAttribute("delete-flow-id");n&&(t(this,d,"f")[n]=this.createModal({"data-id":`delete-${i}`,"close-on-outside-click":"true"}),t(this,c,"f")[n]=new C((()=>{var e,i;return null===(i=null===(e=t(this,d,"f")[n])||void 0===e?void 0:e.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),t(this,d,"f")[n].afterClose=t(this,s,"m",f).bind(this,n),o.onDeleteClick((()=>{var e,i;null===(i=null===(e=t(this,d,"f"))||void 0===e?void 0:e[n])||void 0===i||i.open()})),t(this,s,"m",f).call(this,n),this.syncFlowTheme(t(this,c,"f")[n]))},o})),tt=o((s=>{var o,l,a,d,c,v,f,g;return g=class extends(n(p,$e,w,Oe,h,u,Ne,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),this.updateDeviceList=r((e=>{this.deviceList.data=e}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),this.deviceList=new F((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield t(this,o,"m",f).call(this),t(this,o,"m",v).call(this,ye(this.state)),t(this,o,"m",d).call(this),this.subscribe(this.updateDeviceList.bind(this),ye))}))}},l=new WeakMap,a=new WeakMap,o=new WeakSet,d=function(){this.deviceList.flowId&&(i(this,l,this.createModal({"data-id":"untrust-device","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=()=>t(this,o,"m",c).call(this,""),this.syncFlowTheme(t(this,a,"f")))},c=function(e=""){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.deviceList.flowId,form:{deviceId:e}})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.listDevices({userId:ee(this.state)})}))},v=function(e){this.deviceList.onRemoveDeviceClick((({id:e})=>{var i;t(this,o,"m",c).call(this,e),null===(i=t(this,l,"f"))||void 0===i||i.open()})),this.deviceList.data=e},f=function(){return e(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:ee(this.state)})}))},g})),it=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R;return R=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),k.set(this,r((e=>{this.actions.listPasskeys({userId:e})}))),this.updatePasskeyList=r((e=>{this.userPasskeys.data=e}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),this.userPasskeys=new U((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-user-passkeys")}),{logger:this.logger}),this.userPasskeys.isExists&&(t(this,o,"m",b).call(this,ke(this.state)),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),this.subscribe(t(this,k,"f").bind(this),ee),this.subscribe(this.updatePasskeyList.bind(this),ke))}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,k=new WeakMap,o=new WeakSet,v=function(){this.userPasskeys.addPasskeyFlowId&&(i(this,l,this.createModal({"data-id":"add-user-passkey","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),t(this,o,"m",f).call(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.addPasskeyFlowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:ee(this.state)})}))},g=function(){this.userPasskeys.removePasskeyFlowId&&(i(this,d,this.createModal({"data-id":"remove-user-passkey","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(t(this,c,"f")))},w=function({externalId:e,credentialId:i}){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.removePasskeyFlowId,form:{externalId:e,credentialId:i}})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:ee(this.state)})}))},b=function(e){this.updatePasskeyList(e),this.userPasskeys.onAddPasskeyClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.userPasskeys.onRemovePasskeyClick((({id:e})=>{var i;const s=ee(this.state);t(this,o,"m",w).call(this,{externalId:s,credentialId:e}),null===(i=t(this,d,"f"))||void 0===i||i.open()}))},R}));const st={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},ot=o((i=>{var s,o,l,a,d;return d=class extends(n(h,Oe,M,g)(i)){constructor(){super(...arguments),s.add(this),a.set(this,r((e=>{e.length&&(e.forEach((({type:e,msg:i})=>{const n=t(this,s,"m",l).call(this,e);n.setContent(t(this,s,"m",o).call(this,{type:e,msg:i})),n.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.init)||void 0===e?void 0:e.call(this),this.subscribe(t(this,a,"f").bind(this),be)}))}},a=new WeakMap,s=new WeakSet,o=function({type:e,msg:t}){const i=st[e],s=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${s.outerHTML}`},l=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},d})),nt=o((s=>{var o,l,r,a,d,c,u,v,f,g,p;return p=class extends(n(Oe,h,Ne)(s)){constructor(){super(...arguments),o.add(this),l.set(this,null),a.set(this,(t=>e(this,void 0,void 0,(function*(){const e=t.target.value;yield this.actions.selectTenant(e)})))),d.set(this,(e=>{const s=Me(e);this.tenantSelector.value!==s&&t(this,o,"m",f).call(this,s);const{loading:n,error:r}=e.selectTenant,a=null!==e.tenant.previousTenantId,d=s!==t(this,l,"f");!s||n||r||a||!d||(i(this,l,s,"f"),t(this,o,"m",c).call(this))}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),this.actions.setCurrentTenantId((()=>{const e=L();return K(e)})()),t(this,o,"m",r).call(this),t(this,o,"m",g).call(this),t(this,o,"m",v).call(this,Re(this.state)),this.subscribe(t(this,d,"f").bind(this))}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,o=new WeakSet,r=function(){this.tenantSelector=new x((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(t(this,a,"f"))},c=function(){const e=Me(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:e}})),this.tenantSelector.shouldReload&&t(this,o,"m",u).call(this)},u=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},v=function(t){return e(this,void 0,void 0,(function*(){const e=t.map((e=>({label:e.tenantName||e.tenantId,value:e.tenantId})));yield this.tenantSelector.setData(e)}))},f=function(e){e&&(this.tenantSelector.value=e)},g=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{t(this,o,"m",f).call(this,Me(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},p})),lt=o((s=>{var o,l,r,a,d,c,u,v,f,g,w;return w=class extends(n(p,$e,Oe,m,h,Ne,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),r.set(this,void 0),a.set(this,[]),d.set(this,null)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",v).call(this),t(this,o,"m",u).call(this),t(this,a,"f").forEach((e=>e.enable()))}))}},l=new WeakMap,r=new WeakMap,a=new WeakMap,d=new WeakMap,o=new WeakSet,c=function(e){const i=new E(e,{logger:this.logger});i.onClick((()=>{t(this,o,"m",g).call(this,i.flowId,ee(this.state))})),t(this,a,"f").push(i)},u=function(){var e;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(i).forEach((e=>{t(this,o,"m",c).call(this,e)}))},v=function(){i(this,l,this.createModal({"data-id":"generic-flow-modal","close-on-outside-click":"true"}),"f"),t(this,l,"f").afterClose=()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.call(this),i(this,d,null,"f")},i(this,r,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(t(this,r,"f"))},f=function(){var e;t(this,l,"f").open(),null===(e=t(this,d,"f"))||void 0===e||e.call(this)},g=function(e,s){t(this,l,"f").setContent(this.createFlowTemplate({flowId:e,client:{userId:s}}));i(this,d,t(this,r,"f").onPageUpdated((()=>t(this,o,"m",f).call(this))),"f"),t(this,r,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},w})),rt=o((t=>class extends(n(W,w,De,et,He,Be,Ze,ze,Ge,Ye,Je,Xe,_e,Ke,Ve,tt,it,ot,nt,lt)(t)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this)}))}})),at=n((t=>class extends(rt(t)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.15.0"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",at);export{at as default};
5
+ import{__awaiter as e,__classPrivateFieldGet as t,__classPrivateFieldSet as i}from"tslib";import{decodeJWT as s,createSingletonMixin as o,compose as n,createTemplate as l,withMemCache as r}from"@descope/sdk-helpers";import{projectIdMixin as a,observeAttributesMixin as d,loggerMixin as h,baseUrlMixin as c,cookieConfigMixin as u,DEFAULT_STYLE_ID as v,createStateManagementMixin as f,initLifecycleMixin as g,localeMixin as p,modalMixin as m,themeMixin as w,flowInputMixin as y,descopeUiMixin as k,initElementMixin as b,createFetchWidgetPagesMixin as R,notificationsMixin as M,debuggerMixin as W}from"@descope/sdk-mixins";import{FlowDriver as C,AvatarDriver as S,UserAttributeDriver as I,ButtonDriver as T,UserAuthMethodDriver as A,DeviceListDriver as F,UserPasskeysDriver as U,TenantSelectorDriver as x,GenericFlowButtonDriver as E}from"@descope/sdk-component-drivers";import{createAsyncThunk as P}from"@reduxjs/toolkit";import j,{getSessionToken as L}from"@descope/web-js-sdk";import{createSelector as O}from"reselect";import"@descope/core-js-sdk";import"@descope/web-component";function q(e){return new URLSearchParams(window.location.search).get(e)}const D=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},N=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),$=P("users/me",((e,{extra:{api:t}})=>t.user.me())),B=D($)({onFulfilled:(e,t)=>{e.me.data=t.payload}},N((e=>e.me))),H={action:$,reducer:B},V=P("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),Z=D(V)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},N((e=>e.devices))),J={action:V,reducer:Z},X=P("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),z=D(X)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},N((e=>e.passkeys))),G={action:X,reducer:z},Y=P("users/logout",((e,{extra:{api:t}})=>t.user.logout())),_={action:Y,reducer:D(Y)({})},K=e=>{if(!e)return null;const t=s(e);return(null==t?void 0:t.dct)||null},Q=e=>e.me.data,ee=O(Q,(e=>e.userId)),te=O(Q,(e=>e.picture)),ie=O(Q,(e=>e.email)),se=O(Q,(e=>e.verifiedEmail)),oe=O(Q,(e=>e.name)),ne=O(Q,(e=>e.phone)),le=O(Q,(e=>e.verifiedPhone)),re=O(ie,se,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),ae=O(ne,le,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),de=O(Q,(e=>e.recoveryEmail)),he=O(Q,(e=>e.verifiedRecoveryEmail)),ce=O(Q,(e=>e.recoveryPhone)),ue=O(Q,(e=>e.verifiedRecoveryPhone)),ve=O(de,he,((e,t)=>t?e:"")),fe=O(ce,ue,((e,t)=>t?e:"")),ge=O(Q,(e=>e.webauthn));O(Q,(e=>e.password));const pe=O(Q,(e=>e.TOTP)),me=O(Q,(e=>e.customAttributes)),we=O(Q,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),ye=O((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:i,lastLoginTime:s,isCurrentDevice:o})=>({id:e,name:t,deviceType:i,lastLoginDate:1e3*parseInt(s,10),isCurrent:o}))))),ke=O((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:i,createdTime:s})=>({id:e,name:t,passkeyType:i,createdAt:1e3*s}))))),be=e=>e.notifications,Re=O(Q,(e=>e.userTenants||[])),Me=e=>e.tenant.currentTenantId,We=P("tenant/select",((t,i)=>e(void 0,[t,i],void 0,(function*(e,{extra:{api:t},getState:i}){if(e===Me(i()))return null;const s=yield t.user.setCurrentTenant(e),o=s.sessionJwt||s.sessionToken;try{return{tenantId:K(o)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),Ce={action:We,reducer:D(We)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var i;e.tenant.currentTenantId=null===(i=t.payload)||void 0===i?void 0:i.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},N((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{if(t){const s=t(i);s&&e.notifications.push({type:"success",msg:s})}},onRejected:(t,i)=>{if(e){const s=e(i);s&&t.notifications.push({type:"error",msg:s})}}}))({getErrorMsg:e=>{var t,i;const s=(null===(t=e.error)||void 0===t?void 0:t.message)||"";return"Error"===(null===(i=e.error)||void 0===i?void 0:i.name)?s:`${s||"Error"}`}}))},Se={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},passkeys:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},Ie={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",passkeys:"/v1/mgmt/user/passkeys/list",selectTenant:"/v1/auth/tenant/select"},Te=t=>e(void 0,void 0,void 0,(function*(){const e=yield t.text(),i=JSON.parse(e);if(!t.ok){const e=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(e||`${t.status} ${t.statusText}`)}t.json=()=>Promise.resolve(i),t.text=()=>Promise.resolve(e)})),Ae=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],Fe=()=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",recoveryEmail:"recovery@company.com",recoveryPhone:"+1-202-555-020",verifiedEmail:!0,verifiedPhone:!0,verifiedRecoveryEmail:!0,verifiedRecoveryPhone:!0,userTenants:Ae,status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),Ue=()=>({devices:[{id:"device-id-1",name:"Device 1",deviceType:"desktop",lastLoginDate:17359776e5,isCurrent:!1},{id:"device-id-2",name:"Device 2",deviceType:"mobile",lastLoginDate:17387505e5,isCurrentDevice:!0},{id:"device-id-3",name:"Device 3",deviceType:"tablet",lastLoginDate:17412642e5,isCurrent:!1},{id:"device-id-4",name:"Device 4",deviceType:"unknown",lastLoginDate:17440371e5,isCurrent:!1},{id:"device-id-5",name:"Device 5",deviceType:"desktop",lastLoginDate:174672e7,isCurrent:!1}]}),xe=()=>({passkeys:[{id:"vendor-id-1",displayName:"Device 1",kind:"google",createdTime:1735977600,rpId:"example.com"},{id:"vendor-id-2",displayName:"Device 2",kind:"edge",createdTime:1738750500,rpId:"example.com"},{id:"vendor-id-3",displayName:"Device 3",kind:"apple",createdTime:1741264200,rpId:"example.com"}]}),Ee=({httpClient:t,mock:i})=>({me:()=>e(void 0,void 0,void 0,(function*(){if(i)return Fe();const e=yield t.get(Ie.me);return yield Te(e),e.json()})),setCurrentTenant:i=>e(void 0,void 0,void 0,(function*(){const e=yield t.post(Ie.selectTenant,{tenant:i});return yield Te(e),e.json()}))}),Pe=({httpClient:t,mock:i})=>({devices:s=>e(void 0,[s],void 0,(function*({userId:e}){if(i)return Ue();const s=yield t.post(Ie.devices,{identifiers:[e]});return yield Te(s),s.json()}))}),je=({httpClient:t,mock:i})=>({listPasskeys:s=>e(void 0,[s],void 0,(function*({userId:e}){if(i)return xe();const s=yield t.post(Ie.passkeys,{loginId:e});return yield Te(s),s.json()}))}),Le=o((s=>{var o,l,r,f;const g=n(a,d,h,c,u)(s);return f=class extends g{constructor(){super(...arguments),o.add(this),l.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||v}get api(){return t(this,l,"f")||t(this,o,"m",r).call(this),t(this,l,"f")}init(){const i=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.init)||void 0===e?void 0:e.call(this),this.observeAttributes(["project-id","base-url"],(()=>{t(this,l,"f")&&t(this,o,"m",r).call(this)}))}))}},l=new WeakMap,o=new WeakSet,r=function(){this.logger.debug("creating an sdk instance"),i(this,l,((t,i,s)=>{const o=j(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.15.2"}}));return{user:Object.assign(Object.assign({},Ee({httpClient:o.httpClient,mock:i})),{logout:i?()=>e(void 0,void 0,void 0,(function*(){})):o.logout}),device:Object.assign({},Pe({httpClient:o.httpClient,mock:i})),passkey:Object.assign({},je({httpClient:o.httpClient,mock:i}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},f})),Oe=o((e=>{const t=n(f({name:"widget",initialState:Se,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{H.reducer(e),J.reducer(e),G.reducer(e),_.reducer(e),Ce.reducer(e)},asyncActions:{getMe:H.action,listDevices:J.action,listPasskeys:G.action,logout:_.action,selectTenant:Ce.action}}),g,h,Le)(e);return class extends t{constructor(...e){super(...e),this.state=Se,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),qe="widget-flow",De=o((i=>{var s,o,l;return l=class extends(n(p,g,m,Oe,u,h,w,y)(i)){constructor(){super(...arguments),s.add(this)}init(){const i=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.init)||void 0===e?void 0:e.call(this);const n=q(qe);n&&(!function(e){if(window.history.replaceState&&q(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(qe),t(this,s,"m",o).call(this,n))}))}},s=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e}));new C((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},l})),Ne=o((i=>{var s,o,r;return r=class extends(n(h,g,k,b,R("user-profile-widget"),Oe)(i)){constructor(){super(...arguments),s.add(this)}onWidgetRootReady(){return e(this,void 0,void 0,(function*(){}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.init)||void 0===e?void 0:e.call(this),yield this.actions.getMe(),yield t(this,s,"m",o).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},s=new WeakSet,o=function(){return e(this,void 0,void 0,(function*(){const e=l(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},r})),$e=o((e=>class extends(n(w,d)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),Be=o((s=>{var o,l,a,d,c,v,f,g,k;return k=class extends(n(p,$e,w,Oe,h,u,Ne,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),f.set(this,r((e=>{this.avatar.image=e}))),g.set(this,r((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",v).call(this),t(this,o,"m",d).call(this),t(this,f,"f").call(this,te(this.state)),t(this,g,"f").call(this,oe(this.state)),this.subscribe(t(this,f,"f").bind(this),te),this.subscribe(t(this,g,"f").bind(this),oe)}))}},l=new WeakMap,a=new WeakMap,f=new WeakMap,g=new WeakMap,o=new WeakSet,d=function(){this.avatar.flowId&&(i(this,l,this.createModal({"data-id":"update-pic","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",c).bind(this),t(this,o,"m",c).call(this),this.syncFlowTheme(t(this,a,"f")))},c=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.avatar.flowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},v=function(){this.avatar=new S((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()}))},k})),He=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R,M,W;return W=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),R.set(this,r((e=>{this.emailUserAttr.value=e,t(this,o,"m",b).call(this)}))),M.set(this,r((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,R,"f").call(this,ie(this.state)),t(this,M,"f").call(this,re(this.state)),this.subscribe(t(this,R,"f").bind(this),ie),this.subscribe(t(this,M,"f").bind(this),re)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,R=new WeakMap,M=new WeakMap,o=new WeakSet,v=function(){this.emailUserAttr.editFlowId&&(i(this,l,this.createModal({"data-id":"edit-email","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.editFlowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-email","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.deleteFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.emailUserAttr=new I((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},b=function(){var e,i;(null===(e=t(this,l,"f"))||void 0===e?void 0:e.isClosed)&&t(this,o,"m",f).call(this),(null===(i=t(this,d,"f"))||void 0===i?void 0:i.isClosed)&&t(this,o,"m",w).call(this)},W})),Ve=o((i=>{var s,o,l;return l=class extends(n(Oe,h,Ne,m)(i)){constructor(){super(...arguments),s.add(this)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,s,"m",o).call(this)}))}},s=new WeakSet,o=function(){this.logout=new T((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>e(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},l})),Ze=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R,M;return M=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),R.set(this,r((e=>{this.nameUserAttr.value=e,t(this,o,"m",b).call(this)})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,R,"f").call(this,oe(this.state)),this.subscribe(t(this,R,"f").bind(this),oe)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,R=new WeakMap,o=new WeakSet,v=function(){this.nameUserAttr.editFlowId&&(i(this,l,this.createModal({"data-id":"edit-name","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.editFlowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-name","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.deleteFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.nameUserAttr=new I((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},b=function(){var e,i;(null===(e=t(this,l,"f"))||void 0===e?void 0:e.isClosed)&&t(this,o,"m",f).call(this),(null===(i=t(this,d,"f"))||void 0===i?void 0:i.isClosed)&&t(this,o,"m",w).call(this)},M})),Je=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R;return R=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),b.set(this,r((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,b,"f").call(this,ge(this.state)),this.subscribe(t(this,b,"f").bind(this),ge)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,b=new WeakMap,o=new WeakSet,v=function(){this.passkeyUserAuthMethod.flowId&&(i(this,l,this.createModal({"data-id":"add-passkey","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),t(this,o,"m",f).call(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.flowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(i(this,d,this.createModal({"data-id":"remove-passkey","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),t(this,o,"m",w).call(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.fulfilledFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.passkeyUserAuthMethod=new A((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},R})),Xe=o((s=>{var o,l,r,a,d,c;return c=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),r.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new A((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),this.initPasswordAuthMethod(),t(this,o,"m",a).call(this)}))}},l=new WeakMap,r=new WeakMap,o=new WeakSet,a=function(){this.passwordUserAuthMethod.flowId&&(i(this,l,this.createModal({"data-id":"password","close-on-outside-click":"true"}),"f"),i(this,r,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",d).bind(this),t(this,o,"m",d).call(this),this.syncFlowTheme(t(this,r,"f")))},d=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.passwordUserAuthMethod.flowId})),t(this,r,"f").onSuccess((()=>{t(this,l,"f").close()}))},c})),ze=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R,M,W;return W=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),R.set(this,r((e=>{this.phoneUserAttr.value=e,t(this,o,"m",b).call(this)}))),M.set(this,r((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,R,"f").call(this,ne(this.state)),t(this,M,"f").call(this,ae(this.state)),this.subscribe(t(this,R,"f").bind(this),ne),this.subscribe(t(this,M,"f").bind(this),ae)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,R=new WeakMap,M=new WeakMap,o=new WeakSet,v=function(){this.phoneUserAttr.editFlowId&&(i(this,l,this.createModal({"data-id":"edit-phone","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.editFlowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-phone","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.deleteFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.phoneUserAttr=new I((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},b=function(){var e,i;(null===(e=t(this,l,"f"))||void 0===e?void 0:e.isClosed)&&t(this,o,"m",f).call(this),(null===(i=t(this,d,"f"))||void 0===i?void 0:i.isClosed)&&t(this,o,"m",w).call(this)},W})),Ge=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R;return R=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),b.set(this,r((e=>{this.recoveryEmailUserAttr.value=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,b,"f").call(this,ve(this.state)),this.subscribe(t(this,b,"f").bind(this),ve)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,b=new WeakMap,o=new WeakSet,v=function(){this.recoveryEmailUserAttr.editFlowId&&(i(this,l,this.createModal({"data-id":"edit-recovery-email","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),t(this,o,"m",f).call(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.recoveryEmailUserAttr.editFlowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.recoveryEmailUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-recovery-email","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),t(this,o,"m",w).call(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.recoveryEmailUserAttr.deleteFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.recoveryEmailUserAttr=new I((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryEmail"]')}),{logger:this.logger}),this.recoveryEmailUserAttr.onEditClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.recoveryEmailUserAttr.onDeleteClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},R})),Ye=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R;return R=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),b.set(this,r((e=>{this.recoveryPhoneUserAttr.value=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,b,"f").call(this,fe(this.state)),this.subscribe(t(this,b,"f").bind(this),fe)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,b=new WeakMap,o=new WeakSet,v=function(){this.recoveryPhoneUserAttr.editFlowId&&(i(this,l,this.createModal({"data-id":"edit-recovery-phone","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),t(this,o,"m",f).call(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.recoveryPhoneUserAttr.editFlowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.recoveryPhoneUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-recovery-phone","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),t(this,o,"m",w).call(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.recoveryPhoneUserAttr.deleteFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.recoveryPhoneUserAttr=new I((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryPhone"]')}),{logger:this.logger}),this.recoveryPhoneUserAttr.onEditClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.recoveryPhoneUserAttr.onDeleteClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},R})),_e=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R;return R=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),b.set(this,r((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",k).call(this),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),t(this,b,"f").call(this,pe(this.state)),this.subscribe(t(this,b,"f").bind(this),pe)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,b=new WeakMap,o=new WeakSet,v=function(){this.totpUserAuthMethod.flowId&&(i(this,l,this.createModal({"data-id":"totp","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),t(this,o,"m",f).call(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.flowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.totpUserAuthMethod.fulfilledFlowId&&(i(this,d,this.createModal({"data-id":"remove-totp","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,d,"f").afterClose=t(this,o,"m",w).bind(this),t(this,o,"m",w).call(this),this.syncFlowTheme(t(this,c,"f")))},w=function(){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.fulfilledFlowId})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe()}))},k=function(){this.totpUserAuthMethod=new A((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.open()}))},R})),Ke=o((i=>{var s,o,l,a,d,c,v,f,g,w,k,b,R,M;return M=class extends(n(p,$e,Oe,h,Ne,u,m,y)(i)){constructor(){super(...arguments),s.add(this),o.set(this,{}),l.set(this,{}),a.set(this,{}),d.set(this,{}),c.set(this,{}),R.set(this,r((e=>{Object.keys(t(this,o,"f")).forEach((i=>{t(this,o,"f")[i].value=(e[i]||"").toString()})),t(this,s,"m",b).call(this)})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,s,"m",k).call(this),t(this,R,"f").call(this,we(this.state)),this.subscribe(t(this,R,"f").bind(this),we)}))}},o=new WeakMap,l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,R=new WeakMap,s=new WeakSet,v=function(e){var i,s;null===(i=t(this,l,"f")[e])||void 0===i||i.setContent(this.createFlowTemplate({flowId:e})),null===(s=t(this,a,"f")[e])||void 0===s||s.onSuccess((()=>{var i;null===(i=t(this,l,"f")[e])||void 0===i||i.close(),this.actions.getMe()}))},f=function(e){var i,s;null===(i=t(this,d,"f")[e])||void 0===i||i.setContent(this.createFlowTemplate({flowId:e})),null===(s=t(this,c,"f")[e])||void 0===s||s.onSuccess((()=>{var i;null===(i=t(this,d,"f")[e])||void 0===i||i.close(),this.actions.getMe()}))},g=function(e,i,o){const n=e.getAttribute("edit-flow-id");n&&(t(this,l,"f")[n]=this.createModal({"data-id":`edit-${i}`,"close-on-outside-click":"true"}),t(this,a,"f")[n]=new C((()=>{var e,i;return null===(i=null===(e=t(this,l,"f")[n])||void 0===e?void 0:e.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),t(this,l,"f")[n].afterClose=t(this,s,"m",v).bind(this,n),o.onEditClick((()=>{var e,i;null===(i=null===(e=t(this,l,"f"))||void 0===e?void 0:e[n])||void 0===i||i.open()})),this.syncFlowTheme(t(this,a,"f")[n]))},w=function(e,i,o){const n=e.getAttribute("delete-flow-id");n&&(t(this,d,"f")[n]=this.createModal({"data-id":`delete-${i}`,"close-on-outside-click":"true"}),t(this,c,"f")[n]=new C((()=>{var e,i;return null===(i=null===(e=t(this,d,"f")[n])||void 0===e?void 0:e.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),t(this,d,"f")[n].afterClose=t(this,s,"m",f).bind(this,n),o.onDeleteClick((()=>{var e,i;null===(i=null===(e=t(this,d,"f"))||void 0===e?void 0:e[n])||void 0===i||i.open()})),this.syncFlowTheme(t(this,c,"f")[n]))},k=function(){var e;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(i||[]).forEach((e=>{const i=e.getAttribute("data-id").replace("builtin.",""),n=new I(e,{logger:this.logger});t(this,o,"f")[i]=n,t(this,s,"m",g).call(this,e,i,n),t(this,s,"m",w).call(this,e,i,n)}))},b=function(){Object.entries(t(this,l,"f")).forEach((([e,i])=>{i.isClosed&&t(this,s,"m",v).call(this,e)})),Object.entries(t(this,d,"f")).forEach((([e,i])=>{i.isClosed&&t(this,s,"m",f).call(this,e)}))},M}));var Qe;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Qe||(Qe={}));const et=o((i=>{var s,o,l,a,d,c,v,f,g,w,k;return o=class extends(n(p,$e,Oe,h,Ne,u,m,y)(i)){constructor(){super(...arguments),s.add(this),l.set(this,{}),a.set(this,{}),d.set(this,{}),c.set(this,{}),g.set(this,r((e=>{var i;const n=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(n).forEach((i=>{const n=i.getAttribute("data-id").replace("customAttributes.",""),l=i.getAttribute("data-type")||Qe.TEXT,r=e[n],a=new I(i,{logger:this.logger});a.value=o.getFormattedValue(l,r),t(this,s,"m",w).call(this,i,n,a),t(this,s,"m",k).call(this,i,n,a)}))})))}static getFormattedValue(e,t){return e===Qe.DATE&&t?new Date(t).toLocaleString():e===Qe.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,g,"f").call(this,me(this.state)),this.subscribe(t(this,g,"f").bind(this),me)}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,s=new WeakSet,v=function(e){var i,s;null===(i=t(this,l,"f")[e])||void 0===i||i.setContent(this.createFlowTemplate({flowId:e})),null===(s=t(this,a,"f")[e])||void 0===s||s.onSuccess((()=>{var i;null===(i=t(this,l,"f")[e])||void 0===i||i.close(),this.actions.getMe()}))},f=function(e){var i,s;null===(i=t(this,d,"f")[e])||void 0===i||i.setContent(this.createFlowTemplate({flowId:e})),null===(s=t(this,c,"f")[e])||void 0===s||s.onSuccess((()=>{var i;null===(i=t(this,d,"f")[e])||void 0===i||i.close(),this.actions.getMe()}))},w=function(e,i,o){const n=e.getAttribute("edit-flow-id");n&&(t(this,l,"f")[n]=this.createModal({"data-id":`edit-${i}`,"close-on-outside-click":"true"}),t(this,a,"f")[n]=new C((()=>{var e,i;return null===(i=null===(e=t(this,l,"f")[n])||void 0===e?void 0:e.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),t(this,l,"f")[n].afterClose=t(this,s,"m",v).bind(this,n),o.onEditClick((()=>{var e,i;null===(i=null===(e=t(this,l,"f"))||void 0===e?void 0:e[n])||void 0===i||i.open()})),t(this,s,"m",v).call(this,n),this.syncFlowTheme(t(this,a,"f")[n]))},k=function(e,i,o){const n=e.getAttribute("delete-flow-id");n&&(t(this,d,"f")[n]=this.createModal({"data-id":`delete-${i}`,"close-on-outside-click":"true"}),t(this,c,"f")[n]=new C((()=>{var e,i;return null===(i=null===(e=t(this,d,"f")[n])||void 0===e?void 0:e.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),t(this,d,"f")[n].afterClose=t(this,s,"m",f).bind(this,n),o.onDeleteClick((()=>{var e,i;null===(i=null===(e=t(this,d,"f"))||void 0===e?void 0:e[n])||void 0===i||i.open()})),t(this,s,"m",f).call(this,n),this.syncFlowTheme(t(this,c,"f")[n]))},o})),tt=o((s=>{var o,l,a,d,c,v,f,g;return g=class extends(n(p,$e,w,Oe,h,u,Ne,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),this.updateDeviceList=r((e=>{this.deviceList.data=e}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),this.deviceList=new F((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield t(this,o,"m",f).call(this),t(this,o,"m",v).call(this,ye(this.state)),t(this,o,"m",d).call(this),this.subscribe(this.updateDeviceList.bind(this),ye))}))}},l=new WeakMap,a=new WeakMap,o=new WeakSet,d=function(){this.deviceList.flowId&&(i(this,l,this.createModal({"data-id":"untrust-device","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=()=>t(this,o,"m",c).call(this,""),this.syncFlowTheme(t(this,a,"f")))},c=function(e=""){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.deviceList.flowId,form:{deviceId:e}})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.listDevices({userId:ee(this.state)})}))},v=function(e){this.deviceList.onRemoveDeviceClick((({id:e})=>{var i;t(this,o,"m",c).call(this,e),null===(i=t(this,l,"f"))||void 0===i||i.open()})),this.deviceList.data=e},f=function(){return e(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:ee(this.state)})}))},g})),it=o((s=>{var o,l,a,d,c,v,f,g,w,k,b,R;return R=class extends(n(p,$e,Oe,h,Ne,u,m,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),a.set(this,void 0),d.set(this,void 0),c.set(this,void 0),k.set(this,r((e=>{this.actions.listPasskeys({userId:e})}))),this.updatePasskeyList=r((e=>{this.userPasskeys.data=e}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),this.userPasskeys=new U((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-user-passkeys")}),{logger:this.logger}),this.userPasskeys.isExists&&(t(this,o,"m",b).call(this,ke(this.state)),t(this,o,"m",v).call(this),t(this,o,"m",g).call(this),this.subscribe(t(this,k,"f").bind(this),ee),this.subscribe(this.updatePasskeyList.bind(this),ke))}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,c=new WeakMap,k=new WeakMap,o=new WeakSet,v=function(){this.userPasskeys.addPasskeyFlowId&&(i(this,l,this.createModal({"data-id":"add-user-passkey","close-on-outside-click":"true"}),"f"),i(this,a,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),t(this,l,"f").afterClose=t(this,o,"m",f).bind(this),t(this,o,"m",f).call(this),this.syncFlowTheme(t(this,a,"f")))},f=function(){t(this,l,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.addPasskeyFlowId})),t(this,a,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:ee(this.state)})}))},g=function(){this.userPasskeys.removePasskeyFlowId&&(i(this,d,this.createModal({"data-id":"remove-user-passkey","close-on-outside-click":"true"}),"f"),i(this,c,new C((()=>{var e;return null===(e=t(this,d,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(t(this,c,"f")))},w=function({externalId:e,credentialId:i}){t(this,d,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.removePasskeyFlowId,form:{externalId:e,credentialId:i}})),t(this,c,"f").onSuccess((()=>{t(this,d,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:ee(this.state)})}))},b=function(e){this.updatePasskeyList(e),this.userPasskeys.onAddPasskeyClick((()=>{var e;null===(e=t(this,l,"f"))||void 0===e||e.open()})),this.userPasskeys.onRemovePasskeyClick((({id:e})=>{var i;const s=ee(this.state);t(this,o,"m",w).call(this,{externalId:s,credentialId:e}),null===(i=t(this,d,"f"))||void 0===i||i.open()}))},R}));const st={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},ot=o((i=>{var s,o,l,a,d;return d=class extends(n(h,Oe,M,g)(i)){constructor(){super(...arguments),s.add(this),a.set(this,r((e=>{e.length&&(e.forEach((({type:e,msg:i})=>{const n=t(this,s,"m",l).call(this,e);n.setContent(t(this,s,"m",o).call(this,{type:e,msg:i})),n.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.init)||void 0===e?void 0:e.call(this),this.subscribe(t(this,a,"f").bind(this),be)}))}},a=new WeakMap,s=new WeakSet,o=function({type:e,msg:t}){const i=st[e],s=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${s.outerHTML}`},l=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},d})),nt=o((s=>{var o,l,r,a,d,c,u,v,f,g,p;return p=class extends(n(Oe,h,Ne)(s)){constructor(){super(...arguments),o.add(this),l.set(this,null),a.set(this,(t=>e(this,void 0,void 0,(function*(){const e=t.target.value;yield this.actions.selectTenant(e)})))),d.set(this,(e=>{const s=Me(e);this.tenantSelector.value!==s&&t(this,o,"m",f).call(this,s);const{loading:n,error:r}=e.selectTenant,a=null!==e.tenant.previousTenantId,d=s!==t(this,l,"f");!s||n||r||a||!d||(i(this,l,s,"f"),t(this,o,"m",c).call(this))}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),this.actions.setCurrentTenantId((()=>{const e=L();return K(e)})()),t(this,o,"m",r).call(this),t(this,o,"m",g).call(this),t(this,o,"m",v).call(this,Re(this.state)),this.subscribe(t(this,d,"f").bind(this))}))}},l=new WeakMap,a=new WeakMap,d=new WeakMap,o=new WeakSet,r=function(){this.tenantSelector=new x((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(t(this,a,"f"))},c=function(){const e=Me(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:e}})),this.tenantSelector.shouldReload&&t(this,o,"m",u).call(this)},u=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},v=function(t){return e(this,void 0,void 0,(function*(){const e=t.map((e=>({label:e.tenantName||e.tenantId,value:e.tenantId})));yield this.tenantSelector.setData(e)}))},f=function(e){e&&(this.tenantSelector.value=e)},g=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{t(this,o,"m",f).call(this,Me(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},p})),lt=o((s=>{var o,l,r,a,d,c,u,v,f,g,w;return w=class extends(n(p,$e,Oe,m,h,Ne,y)(s)){constructor(){super(...arguments),o.add(this),l.set(this,void 0),r.set(this,void 0),a.set(this,[]),d.set(this,null)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=i.onWidgetRootReady)||void 0===e?void 0:e.call(this),t(this,o,"m",v).call(this),t(this,o,"m",u).call(this),t(this,a,"f").forEach((e=>e.enable()))}))}},l=new WeakMap,r=new WeakMap,a=new WeakMap,d=new WeakMap,o=new WeakSet,c=function(e){const i=new E(e,{logger:this.logger});i.onClick((()=>{t(this,o,"m",g).call(this,i.flowId,ee(this.state))})),t(this,a,"f").push(i)},u=function(){var e;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(i).forEach((e=>{t(this,o,"m",c).call(this,e)}))},v=function(){i(this,l,this.createModal({"data-id":"generic-flow-modal","close-on-outside-click":"true"}),"f"),t(this,l,"f").afterClose=()=>{var e;null===(e=t(this,d,"f"))||void 0===e||e.call(this),i(this,d,null,"f")},i(this,r,new C((()=>{var e;return null===(e=t(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(t(this,r,"f"))},f=function(){var e;t(this,l,"f").open(),null===(e=t(this,d,"f"))||void 0===e||e.call(this)},g=function(e,s){t(this,l,"f").setContent(this.createFlowTemplate({flowId:e,client:{userId:s}}));i(this,d,t(this,r,"f").onPageUpdated((()=>t(this,o,"m",f).call(this))),"f"),t(this,r,"f").onSuccess((()=>{t(this,l,"f").close(),this.actions.getMe()}))},w})),rt=o((t=>class extends(n(W,w,De,et,He,Be,Ze,ze,Ge,Ye,Je,Xe,_e,Ke,Ve,tt,it,ot,nt,lt)(t)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this)}))}})),at=n((t=>class extends(rt(t)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.15.2"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",at);export{at as default};
6
6
  //# sourceMappingURL=index.js.map