@descope/user-profile-widget 0.9.2 → 0.9.4

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.9.2
3
+ * @descope/user-profile-widget v0.9.4
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"),a=require("@reduxjs/toolkit"),l=require("@descope/web-js-sdk"),r=require("reselect");require("@descope/core-js-sdk"),require("@descope/web-component");const o=(e={})=>{const i=t.createTemplate("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,s])=>{i.content.querySelector("descope-wc").setAttribute(t.kebabCase(e),(e=>"string"==typeof e?e:t.isPlainObject(e)?JSON.stringify(e):"")(s))})),i};function n(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)}))}))},c=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}}),h=a.createAsyncThunk("users/me",((e,{extra:{api:t}})=>t.user.me())),v=d(h)({onFulfilled:(e,t)=>{e.me.data=t.payload}},c((e=>e.me))),u={action:h,reducer:v},_=a.createAsyncThunk("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),f=d(_)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},c((e=>e.devices))),g={action:_,reducer:f},m=a.createAsyncThunk("users/logout",((e,{extra:{api:t}})=>t.user.logout())),p={action:m,reducer:d(m)({})},w=e=>{if(!e)return null;const i=t.decodeJWT(e);return(null==i?void 0:i.dct)||null},F=e=>e.me.data,P=r.createSelector(F,(e=>e.userId)),b=r.createSelector(F,(e=>e.picture)),G=r.createSelector(F,(e=>e.email)),y=r.createSelector(F,(e=>e.verifiedEmail)),M=r.createSelector(F,(e=>e.name)),C=r.createSelector(F,(e=>e.phone)),S=r.createSelector(F,(e=>e.verifiedPhone)),U=r.createSelector(F,(e=>e.webauthn));r.createSelector(F,(e=>e.password));const k=r.createSelector(F,(e=>e.TOTP)),I=r.createSelector(F,(e=>e.customAttributes)),x=r.createSelector(F,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),R=r.createSelector((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:i,lastLoginTime:s,isCurrentDevice:a})=>({id:e,name:t,deviceType:i,lastLoginDate:1e3*parseInt(s,10),isCurrent:a}))))),W=e=>e.notifications,A=r.createSelector(F,(e=>e.userTenants||[])),T=e=>e.tenant.currentTenantId,j=a.createAsyncThunk("tenant/select",((t,i)=>e.__awaiter(void 0,[t,i],void 0,(function*(e,{extra:{api:t},getState:i}){if(e===T(i()))return null;const s=yield t.user.setCurrentTenant(e),a=s.sessionJwt||s.sessionToken;try{return{tenantId:w(a)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),D={action:j,reducer:d(j)({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}},c((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"}`}}))},N={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},L={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",selectTenant:"/v1/auth/tenant/select"},E=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)})),q=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],O=()=>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",verifiedEmail:!0,verifiedPhone:!0,userTenants:q,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})}))})),$=()=>({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}]}),B=({httpClient:t,mock:i})=>({me:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i)return O();const e=yield t.get(L.me);return yield E(e),e.json()})),setCurrentTenant:i=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.post(L.selectTenant,{tenant:i});return yield E(e),e.json()}))}),V=({httpClient:t,mock:i})=>({devices:s=>e.__awaiter(void 0,[s],void 0,(function*({userId:e}){if(i)return $();const s=yield t.post(L.devices,{identifiers:[e]});return yield E(s),s.json()}))}),H=t.createSingletonMixin((s=>{var a,r,o,n;const d=t.compose(i.projectIdMixin,i.observeAttributesMixin,i.loggerMixin,i.baseUrlMixin,i.cookieConfigMixin)(s);return n=class extends d{constructor(){super(...arguments),a.add(this),r.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,r,"f")||e.__classPrivateFieldGet(this,a,"m",o).call(this),e.__classPrivateFieldGet(this,r,"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,r,"f")&&e.__classPrivateFieldGet(this,a,"m",o).call(this)}))}))}},r=new WeakMap,a=new WeakSet,o=function(){this.logger.debug("creating an sdk instance"),e.__classPrivateFieldSet(this,r,((t,i,s)=>{const a=l(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.9.2"}}));return{user:Object.assign(Object.assign({},B({httpClient:a.httpClient,mock:i})),{logout:i?()=>e.__awaiter(void 0,void 0,void 0,(function*(){})):a.logout}),device:Object.assign({},V({httpClient:a.httpClient,mock:i}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},n})),Z=t.createSingletonMixin((e=>{const s=t.compose(i.createStateManagementMixin({name:"widget",initialState:N,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{u.reducer(e),g.reducer(e),p.reducer(e),D.reducer(e)},asyncActions:{getMe:u.action,listDevices:g.action,logout:p.action,selectTenant:D.action}}),i.initLifecycleMixin,i.loggerMixin,H)(e);return class extends s{constructor(...e){super(...e),this.state=N,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),J="widget-flow",X=t.createSingletonMixin((a=>{var l,r,d;return d=class extends(t.compose(i.initLifecycleMixin,i.modalMixin,Z,i.cookieConfigMixin,i.loggerMixin,i.themeMixin)(a)){constructor(){super(...arguments),l.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=n(J);s&&(!function(e){if(window.history.replaceState&&n(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())}}(J),e.__classPrivateFieldGet(this,l,"m",r).call(this,s))}))}},l=new WeakSet,r=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(o({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId}));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()},d})),Y=t.createSingletonMixin((s=>{const a=t.compose(i.staticResourcesMixin,i.createValidateAttributesMixin({"widget-id":i.createValidateAttributesMixin.missingAttrValidator}))(s);return class extends a{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(t){return e.__awaiter(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${t}`,"text")).body}))}}})),z=t.createSingletonMixin((s=>{var a,l,r;return r=class extends(t.compose(i.loggerMixin,i.initLifecycleMixin,i.descopeUiMixin,i.initElementMixin,Y,Z)(s)){constructor(){super(...arguments),a.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,a,"m",l).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},a=new WeakSet,l=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))}))},r})),K=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}))}})),Q=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_;return _=class extends(t.compose(K,i.themeMixin,Z,i.loggerMixin,i.cookieConfigMixin,z,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.set(this,void 0),v.set(this,t.withMemCache((e=>{this.avatar.image=e}))),u.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,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",d).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,b(this.state)),e.__classPrivateFieldGet(this,u,"f").call(this,M(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),b),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),M)}))}},r=new WeakMap,n=new WeakMap,v=new WeakMap,u=new WeakMap,l=new WeakSet,d=function(){this.avatar.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"update-pic"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",c).bind(this),e.__classPrivateFieldGet(this,l,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},c=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},h=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,r,"f"))||void 0===t||t.open()}))},_})),ee=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g,m,p;return p=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),c.set(this,void 0),g.set(this,t.withMemCache((e=>{this.emailUserAttr.value=e}))),m.set(this,t.withMemCache((e=>{this.emailUserAttr.badgeLabel=e?"":"Unverified"})))}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,l,"m",f).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,G(this.state)),e.__classPrivateFieldGet(this,m,"f").call(this,y(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),G),this.subscribe(e.__classPrivateFieldGet(this,m,"f").bind(this),y)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,m=new WeakMap,l=new WeakSet,h=function(){this.emailUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-email"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this),e.__classPrivateFieldGet(this,l,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.emailUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"delete-email"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,d,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,d,"f").setContent(o({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getMe()}))},f=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,r,"f"))||void 0===t||t.open()})),this.emailUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.open()}))},p})),te=t.createSingletonMixin((a=>{var l,r,o;return o=class extends(t.compose(Z,i.loggerMixin,z,i.modalMixin)(a)){constructor(){super(...arguments),l.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,l,"m",r).call(this)}))}},l=new WeakSet,r=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"))}))))},o})),ie=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g,m;return m=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),c.set(this,void 0),g.set(this,t.withMemCache((e=>{this.nameUserAttr.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,l,"m",f).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,M(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),M)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,l=new WeakSet,h=function(){this.nameUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-name"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this),e.__classPrivateFieldGet(this,l,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.nameUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"delete-name"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,d,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,d,"f").setContent(o({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getMe()}))},f=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,r,"f"))||void 0===t||t.open()})),this.nameUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.open()}))},m})),se=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g,m;return m=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),c.set(this,void 0),g.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,l,"m",f).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,U(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),U)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,l=new WeakSet,h=function(){this.passkeyUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"add-passkey"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this),e.__classPrivateFieldGet(this,l,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"remove-passkey"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,d,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,d,"f").setContent(o({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getMe()}))},f=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,r,"f"))||void 0===t||t.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.open()}))},m})),ae=t.createSingletonMixin((a=>{var l,r,n,d,c,h;return h=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.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,r,"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,l,"m",d).call(this)}))}},r=new WeakMap,n=new WeakMap,l=new WeakSet,d=function(){this.passwordUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"password"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",c).bind(this),e.__classPrivateFieldGet(this,l,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},c=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close()}))},h})),le=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g,m,p;return p=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),c.set(this,void 0),g.set(this,t.withMemCache((e=>{this.phoneUserAttr.value=e}))),m.set(this,t.withMemCache((e=>{this.phoneUserAttr.badgeLabel=e?"":"Unverified"})))}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,l,"m",f).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,C(this.state)),e.__classPrivateFieldGet(this,m,"f").call(this,S(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),C),this.subscribe(e.__classPrivateFieldGet(this,m,"f").bind(this),S)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,m=new WeakMap,l=new WeakSet,h=function(){this.phoneUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-phone"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this),e.__classPrivateFieldGet(this,l,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.phoneUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"delete-phone"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,d,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,d,"f").setContent(o({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getMe()}))},f=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,r,"f"))||void 0===t||t.open()})),this.phoneUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.open()}))},p})),re=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g,m;return m=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),c.set(this,void 0),g.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,l,"m",f).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,k(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),k)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,l=new WeakSet,h=function(){this.totpUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"totp"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this),e.__classPrivateFieldGet(this,l,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.totpUserAuthMethod.fulfilledFlowId&&(e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"remove-totp"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,d,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,d,"f").setContent(o({projectId:this.projectId,flowId:this.totpUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getMe()}))},f=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,r,"f"))||void 0===t||t.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.open()}))},m})),oe=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,{}),n.set(this,{}),d.set(this,{}),c.set(this,{}),u.set(this,t.withMemCache((t=>{var i;const a=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(a).forEach((i=>{const a=i.getAttribute("data-id").replace("builtin.",""),r=t[a],o=new s.UserAttributeDriver(i,{logger:this.logger});o.value=(r||"").toString(),e.__classPrivateFieldGet(this,l,"m",_).call(this,i,a,o),e.__classPrivateFieldGet(this,l,"m",f).call(this,i,a,o)}))})))}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,x(this.state)),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),x)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,u=new WeakMap,l=new WeakSet,h=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.setContent(o({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),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(o({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),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,a){const o=t.getAttribute("edit-flow-id");o&&(e.__classPrivateFieldGet(this,r,"f")[o]=this.createModal({"data-id":`edit-${i}`}),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,l,"m",h).bind(this,o),a.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,l,"m",h).call(this,o),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")[o]))},f=function(t,i,a){const r=t.getAttribute("delete-flow-id");r&&(e.__classPrivateFieldGet(this,d,"f")[r]=this.createModal({"data-id":`delete-${i}`}),e.__classPrivateFieldGet(this,c,"f")[r]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f")[r])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,d,"f")[r].afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this,r),a.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t?void 0:t[r])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,l,"m",v).call(this,r),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")[r]))},g}));var ne;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(ne||(ne={}));const de=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g;return r=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),n.set(this,{}),d.set(this,{}),c.set(this,{}),h.set(this,{}),_.set(this,t.withMemCache((t=>{var i;const a=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(a).forEach((i=>{const a=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||ne.TEXT,n=t[a],d=new s.UserAttributeDriver(i,{logger:this.logger});d.value=r.getFormattedValue(o,n),e.__classPrivateFieldGet(this,l,"m",f).call(this,i,a,d),e.__classPrivateFieldGet(this,l,"m",g).call(this,i,a,d)}))})))}static getFormattedValue(e,t){return e===ne.DATE&&t?new Date(t).toLocaleString():e===ne.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,_,"f").call(this,I(this.state)),this.subscribe(e.__classPrivateFieldGet(this,_,"f").bind(this),I)}))}},n=new WeakMap,d=new WeakMap,c=new WeakMap,h=new WeakMap,_=new WeakMap,l=new WeakSet,v=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,n,"f")[t])||void 0===i||i.setContent(o({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(s=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,n,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},u=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===i||i.setContent(o({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(s=e.__classPrivateFieldGet(this,h,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},f=function(t,i,a){const r=t.getAttribute("edit-flow-id");r&&(e.__classPrivateFieldGet(this,n,"f")[r]=this.createModal({"data-id":`edit-${i}`}),e.__classPrivateFieldGet(this,d,"f")[r]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,n,"f")[r])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,n,"f")[r].afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this,r),a.onEditClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t?void 0:t[r])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,l,"m",v).call(this,r),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")[r]))},g=function(t,i,a){const r=t.getAttribute("delete-flow-id");r&&(e.__classPrivateFieldGet(this,c,"f")[r]=this.createModal({"data-id":`delete-${i}`}),e.__classPrivateFieldGet(this,h,"f")[r]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,c,"f")[r])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,c,"f")[r].afterClose=e.__classPrivateFieldGet(this,l,"m",u).bind(this,r),a.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,c,"f"))||void 0===t?void 0:t[r])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,l,"m",u).call(this,r),this.syncFlowTheme(e.__classPrivateFieldGet(this,h,"f")[r]))},r})),ce=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u;return u=class extends(t.compose(K,i.themeMixin,Z,i.loggerMixin,i.cookieConfigMixin,z,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.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,l,"m",v).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this,R(this.state)),e.__classPrivateFieldGet(this,l,"m",d).call(this),this.subscribe(this.updateDeviceList.bind(this),R))}))}},r=new WeakMap,n=new WeakMap,l=new WeakSet,d=function(){this.deviceList.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"untrust-device"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=()=>e.__classPrivateFieldGet(this,l,"m",c).call(this,""),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},c=function(t=""){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.deviceList.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:{deviceId:t}})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.listDevices({userId:P(this.state)})}))},h=function(t){this.deviceList.onRemoveDeviceClick((({id:t})=>{var i;e.__classPrivateFieldGet(this,l,"m",c).call(this,t),null===(i=e.__classPrivateFieldGet(this,r,"f"))||void 0===i||i.open()})),this.deviceList.data=t},v=function(){return e.__awaiter(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:P(this.state)})}))},u}));const he={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},ve=t.createSingletonMixin((s=>{var a,l,r,o,n;return n=class extends(t.compose(i.loggerMixin,Z,i.notificationsMixin,i.initLifecycleMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,t.withMemCache((t=>{t.length&&(t.forEach((({type:t,msg:i})=>{const s=e.__classPrivateFieldGet(this,a,"m",r).call(this,t);s.setContent(e.__classPrivateFieldGet(this,a,"m",l).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,o,"f").bind(this),W)}))}},o=new WeakMap,a=new WeakSet,l=function({type:e,msg:t}){const i=he[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}`},r=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},n})),ue=t.createSingletonMixin((a=>{var r,o,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(Z,i.loggerMixin,z)(a)){constructor(){super(...arguments),r.add(this),o.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=T(t);this.tenantSelector.value!==i&&e.__classPrivateFieldGet(this,r,"m",_).call(this,i);const{loading:s,error:a}=t.selectTenant,l=null!==t.tenant.previousTenantId,n=i!==e.__classPrivateFieldGet(this,o,"f");!i||s||a||l||!n||(e.__classPrivateFieldSet(this,o,i,"f"),e.__classPrivateFieldGet(this,r,"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=l.getSessionToken();return w(e)})()),e.__classPrivateFieldGet(this,r,"m",n).call(this),e.__classPrivateFieldGet(this,r,"m",f).call(this),e.__classPrivateFieldGet(this,r,"m",u).call(this,A(this.state)),this.subscribe(e.__classPrivateFieldGet(this,c,"f").bind(this))}))}},o=new WeakMap,d=new WeakMap,c=new WeakMap,r=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=T(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:t}})),this.tenantSelector.shouldReload&&e.__classPrivateFieldGet(this,r,"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,r,"m",_).call(this,T(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},g})),_e=t.createSingletonMixin((s=>class extends(t.compose(i.debuggerMixin,i.themeMixin,X,de,ee,Q,ie,le,se,ae,re,oe,te,ce,ve,ue)(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)}))}})),fe=t.compose((t=>class extends(_e(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.9.2"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",fe),module.exports=fe;
5
+ "use strict";var e=require("tslib"),t=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins"),s=require("@descope/sdk-component-drivers"),a=require("@reduxjs/toolkit"),l=require("@descope/web-js-sdk"),r=require("reselect");require("@descope/core-js-sdk"),require("@descope/web-component");const o=(e={})=>{const i=t.createTemplate("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,s])=>{i.content.querySelector("descope-wc").setAttribute(t.kebabCase(e),(e=>"string"==typeof e?e:t.isPlainObject(e)?JSON.stringify(e):"")(s))})),i};function n(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)}))}))},c=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}}),h=a.createAsyncThunk("users/me",((e,{extra:{api:t}})=>t.user.me())),v=d(h)({onFulfilled:(e,t)=>{e.me.data=t.payload}},c((e=>e.me))),u={action:h,reducer:v},_=a.createAsyncThunk("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),f=d(_)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},c((e=>e.devices))),g={action:_,reducer:f},m=a.createAsyncThunk("users/logout",((e,{extra:{api:t}})=>t.user.logout())),p={action:m,reducer:d(m)({})},w=e=>{if(!e)return null;const i=t.decodeJWT(e);return(null==i?void 0:i.dct)||null},F=e=>e.me.data,P=r.createSelector(F,(e=>e.userId)),b=r.createSelector(F,(e=>e.picture)),G=r.createSelector(F,(e=>e.email)),y=r.createSelector(F,(e=>e.verifiedEmail)),M=r.createSelector(F,(e=>e.name)),C=r.createSelector(F,(e=>e.phone)),S=r.createSelector(F,(e=>e.verifiedPhone)),U=r.createSelector(F,(e=>e.webauthn));r.createSelector(F,(e=>e.password));const k=r.createSelector(F,(e=>e.TOTP)),I=r.createSelector(F,(e=>e.customAttributes)),x=r.createSelector(F,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),R=r.createSelector((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:i,lastLoginTime:s,isCurrentDevice:a})=>({id:e,name:t,deviceType:i,lastLoginDate:1e3*parseInt(s,10),isCurrent:a}))))),W=e=>e.notifications,A=r.createSelector(F,(e=>e.userTenants||[])),T=e=>e.tenant.currentTenantId,j=a.createAsyncThunk("tenant/select",((t,i)=>e.__awaiter(void 0,[t,i],void 0,(function*(e,{extra:{api:t},getState:i}){if(e===T(i()))return null;const s=yield t.user.setCurrentTenant(e),a=s.sessionJwt||s.sessionToken;try{return{tenantId:w(a)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),D={action:j,reducer:d(j)({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}},c((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"}`}}))},N={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},L={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",selectTenant:"/v1/auth/tenant/select"},E=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)})),q=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],O=()=>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",verifiedEmail:!0,verifiedPhone:!0,userTenants:q,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})}))})),$=()=>({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}]}),B=({httpClient:t,mock:i})=>({me:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i)return O();const e=yield t.get(L.me);return yield E(e),e.json()})),setCurrentTenant:i=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.post(L.selectTenant,{tenant:i});return yield E(e),e.json()}))}),V=({httpClient:t,mock:i})=>({devices:s=>e.__awaiter(void 0,[s],void 0,(function*({userId:e}){if(i)return $();const s=yield t.post(L.devices,{identifiers:[e]});return yield E(s),s.json()}))}),H=t.createSingletonMixin((s=>{var a,r,o,n;const d=t.compose(i.projectIdMixin,i.observeAttributesMixin,i.loggerMixin,i.baseUrlMixin,i.cookieConfigMixin)(s);return n=class extends d{constructor(){super(...arguments),a.add(this),r.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,r,"f")||e.__classPrivateFieldGet(this,a,"m",o).call(this),e.__classPrivateFieldGet(this,r,"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,r,"f")&&e.__classPrivateFieldGet(this,a,"m",o).call(this)}))}))}},r=new WeakMap,a=new WeakSet,o=function(){this.logger.debug("creating an sdk instance"),e.__classPrivateFieldSet(this,r,((t,i,s)=>{const a=l(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.9.4"}}));return{user:Object.assign(Object.assign({},B({httpClient:a.httpClient,mock:i})),{logout:i?()=>e.__awaiter(void 0,void 0,void 0,(function*(){})):a.logout}),device:Object.assign({},V({httpClient:a.httpClient,mock:i}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},n})),Z=t.createSingletonMixin((e=>{const s=t.compose(i.createStateManagementMixin({name:"widget",initialState:N,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{u.reducer(e),g.reducer(e),p.reducer(e),D.reducer(e)},asyncActions:{getMe:u.action,listDevices:g.action,logout:p.action,selectTenant:D.action}}),i.initLifecycleMixin,i.loggerMixin,H)(e);return class extends s{constructor(...e){super(...e),this.state=N,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),J="widget-flow",X=t.createSingletonMixin((a=>{var l,r,d;return d=class extends(t.compose(i.initLifecycleMixin,i.modalMixin,Z,i.cookieConfigMixin,i.loggerMixin,i.themeMixin)(a)){constructor(){super(...arguments),l.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=n(J);s&&(!function(e){if(window.history.replaceState&&n(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())}}(J),e.__classPrivateFieldGet(this,l,"m",r).call(this,s))}))}},l=new WeakSet,r=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(o({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId}));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()},d})),Y=t.createSingletonMixin((s=>{const a=t.compose(i.staticResourcesMixin,i.createValidateAttributesMixin({"widget-id":i.createValidateAttributesMixin.missingAttrValidator}))(s);return class extends a{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(t){return e.__awaiter(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${t}`,"text")).body}))}}})),z=t.createSingletonMixin((s=>{var a,l,r;return r=class extends(t.compose(i.loggerMixin,i.initLifecycleMixin,i.descopeUiMixin,i.initElementMixin,Y,Z)(s)){constructor(){super(...arguments),a.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,a,"m",l).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},a=new WeakSet,l=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))}))},r})),K=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}))}})),Q=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_;return _=class extends(t.compose(K,i.themeMixin,Z,i.loggerMixin,i.cookieConfigMixin,z,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.set(this,void 0),v.set(this,t.withMemCache((e=>{this.avatar.image=e}))),u.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,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",d).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,b(this.state)),e.__classPrivateFieldGet(this,u,"f").call(this,M(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),b),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),M)}))}},r=new WeakMap,n=new WeakMap,v=new WeakMap,u=new WeakMap,l=new WeakSet,d=function(){this.avatar.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"update-pic"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",c).bind(this),e.__classPrivateFieldGet(this,l,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},c=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},h=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,r,"f"))||void 0===t||t.open()}))},_})),ee=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g,m,p;return p=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),c.set(this,void 0),g.set(this,t.withMemCache((e=>{this.emailUserAttr.value=e}))),m.set(this,t.withMemCache((e=>{this.emailUserAttr.badgeLabel=e?"":"Unverified"})))}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,l,"m",f).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,G(this.state)),e.__classPrivateFieldGet(this,m,"f").call(this,y(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),G),this.subscribe(e.__classPrivateFieldGet(this,m,"f").bind(this),y)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,m=new WeakMap,l=new WeakSet,h=function(){this.emailUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-email"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this),e.__classPrivateFieldGet(this,l,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.emailUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"delete-email"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,d,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,d,"f").setContent(o({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getMe()}))},f=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,r,"f"))||void 0===t||t.open()})),this.emailUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.open()}))},p})),te=t.createSingletonMixin((a=>{var l,r,o;return o=class extends(t.compose(Z,i.loggerMixin,z,i.modalMixin)(a)){constructor(){super(...arguments),l.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,l,"m",r).call(this)}))}},l=new WeakSet,r=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"))}))))},o})),ie=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g,m;return m=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),c.set(this,void 0),g.set(this,t.withMemCache((e=>{this.nameUserAttr.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,l,"m",f).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,M(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),M)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,l=new WeakSet,h=function(){this.nameUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-name"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this),e.__classPrivateFieldGet(this,l,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.nameUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"delete-name"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,d,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,d,"f").setContent(o({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getMe()}))},f=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,r,"f"))||void 0===t||t.open()})),this.nameUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.open()}))},m})),se=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g,m;return m=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),c.set(this,void 0),g.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,l,"m",f).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,U(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),U)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,l=new WeakSet,h=function(){this.passkeyUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"add-passkey"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this),e.__classPrivateFieldGet(this,l,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"remove-passkey"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,d,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,d,"f").setContent(o({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getMe()}))},f=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,r,"f"))||void 0===t||t.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.open()}))},m})),ae=t.createSingletonMixin((a=>{var l,r,n,d,c,h;return h=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.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,r,"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,l,"m",d).call(this)}))}},r=new WeakMap,n=new WeakMap,l=new WeakSet,d=function(){this.passwordUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"password"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",c).bind(this),e.__classPrivateFieldGet(this,l,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},c=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close()}))},h})),le=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g,m,p;return p=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),c.set(this,void 0),g.set(this,t.withMemCache((e=>{this.phoneUserAttr.value=e}))),m.set(this,t.withMemCache((e=>{this.phoneUserAttr.badgeLabel=e?"":"Unverified"})))}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,l,"m",f).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,C(this.state)),e.__classPrivateFieldGet(this,m,"f").call(this,S(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),C),this.subscribe(e.__classPrivateFieldGet(this,m,"f").bind(this),S)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,m=new WeakMap,l=new WeakSet,h=function(){this.phoneUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-phone"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this),e.__classPrivateFieldGet(this,l,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.phoneUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"delete-phone"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,d,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,d,"f").setContent(o({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getMe()}))},f=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,r,"f"))||void 0===t||t.open()})),this.phoneUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.open()}))},p})),re=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g,m;return m=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.set(this,void 0),d.set(this,void 0),c.set(this,void 0),g.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,l,"m",f).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,k(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),k)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,l=new WeakSet,h=function(){this.totpUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"totp"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this),e.__classPrivateFieldGet(this,l,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.totpUserAuthMethod.fulfilledFlowId&&(e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"remove-totp"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,d,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,d,"f").setContent(o({projectId:this.projectId,flowId:this.totpUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getMe()}))},f=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,r,"f"))||void 0===t||t.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.open()}))},m})),oe=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,{}),n.set(this,{}),d.set(this,{}),c.set(this,{}),u.set(this,t.withMemCache((t=>{var i;const a=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(a).forEach((i=>{const a=i.getAttribute("data-id").replace("builtin.",""),r=t[a],o=new s.UserAttributeDriver(i,{logger:this.logger});o.value=(r||"").toString(),e.__classPrivateFieldGet(this,l,"m",_).call(this,i,a,o),e.__classPrivateFieldGet(this,l,"m",f).call(this,i,a,o)}))})))}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,x(this.state)),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),x)}))}},r=new WeakMap,n=new WeakMap,d=new WeakMap,c=new WeakMap,u=new WeakMap,l=new WeakSet,h=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.setContent(o({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),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(o({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),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,a){const o=t.getAttribute("edit-flow-id");o&&(e.__classPrivateFieldGet(this,r,"f")[o]=this.createModal({"data-id":`edit-${i}`}),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,l,"m",h).bind(this,o),a.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,l,"m",h).call(this,o),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")[o]))},f=function(t,i,a){const r=t.getAttribute("delete-flow-id");r&&(e.__classPrivateFieldGet(this,d,"f")[r]=this.createModal({"data-id":`delete-${i}`}),e.__classPrivateFieldGet(this,c,"f")[r]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f")[r])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,d,"f")[r].afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this,r),a.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t?void 0:t[r])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,l,"m",v).call(this,r),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")[r]))},g}));var ne;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(ne||(ne={}));const de=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u,_,f,g;return r=class extends(t.compose(K,Z,i.loggerMixin,z,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),n.set(this,{}),d.set(this,{}),c.set(this,{}),h.set(this,{}),_.set(this,t.withMemCache((t=>{var i;const a=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(a).forEach((i=>{const a=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||ne.TEXT,n=t[a],d=new s.UserAttributeDriver(i,{logger:this.logger});d.value=r.getFormattedValue(o,n),e.__classPrivateFieldGet(this,l,"m",f).call(this,i,a,d),e.__classPrivateFieldGet(this,l,"m",g).call(this,i,a,d)}))})))}static getFormattedValue(e,t){return e===ne.DATE&&t?new Date(t).toLocaleString():e===ne.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,_,"f").call(this,I(this.state)),this.subscribe(e.__classPrivateFieldGet(this,_,"f").bind(this),I)}))}},n=new WeakMap,d=new WeakMap,c=new WeakMap,h=new WeakMap,_=new WeakMap,l=new WeakSet,v=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,n,"f")[t])||void 0===i||i.setContent(o({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(s=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,n,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},u=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===i||i.setContent(o({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(s=e.__classPrivateFieldGet(this,h,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},f=function(t,i,a){const r=t.getAttribute("edit-flow-id");r&&(e.__classPrivateFieldGet(this,n,"f")[r]=this.createModal({"data-id":`edit-${i}`}),e.__classPrivateFieldGet(this,d,"f")[r]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,n,"f")[r])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,n,"f")[r].afterClose=e.__classPrivateFieldGet(this,l,"m",v).bind(this,r),a.onEditClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t?void 0:t[r])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,l,"m",v).call(this,r),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")[r]))},g=function(t,i,a){const r=t.getAttribute("delete-flow-id");r&&(e.__classPrivateFieldGet(this,c,"f")[r]=this.createModal({"data-id":`delete-${i}`}),e.__classPrivateFieldGet(this,h,"f")[r]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,c,"f")[r])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,c,"f")[r].afterClose=e.__classPrivateFieldGet(this,l,"m",u).bind(this,r),a.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,c,"f"))||void 0===t?void 0:t[r])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,l,"m",u).call(this,r),this.syncFlowTheme(e.__classPrivateFieldGet(this,h,"f")[r]))},r})),ce=t.createSingletonMixin((a=>{var l,r,n,d,c,h,v,u;return u=class extends(t.compose(K,i.themeMixin,Z,i.loggerMixin,i.cookieConfigMixin,z,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),n.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,l,"m",v).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this,R(this.state)),e.__classPrivateFieldGet(this,l,"m",d).call(this),this.subscribe(this.updateDeviceList.bind(this),R))}))}},r=new WeakMap,n=new WeakMap,l=new WeakSet,d=function(){this.deviceList.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"untrust-device"}),"f"),e.__classPrivateFieldSet(this,n,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=()=>e.__classPrivateFieldGet(this,l,"m",c).call(this,""),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")))},c=function(t=""){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.deviceList.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:{deviceId:t}})),e.__classPrivateFieldGet(this,n,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.listDevices({userId:P(this.state)})}))},h=function(t){this.deviceList.onRemoveDeviceClick((({id:t})=>{var i;e.__classPrivateFieldGet(this,l,"m",c).call(this,t),null===(i=e.__classPrivateFieldGet(this,r,"f"))||void 0===i||i.open()})),this.deviceList.data=t},v=function(){return e.__awaiter(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:P(this.state)})}))},u}));const he={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},ve=t.createSingletonMixin((s=>{var a,l,r,o,n;return n=class extends(t.compose(i.loggerMixin,Z,i.notificationsMixin,i.initLifecycleMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,t.withMemCache((t=>{t.length&&(t.forEach((({type:t,msg:i})=>{const s=e.__classPrivateFieldGet(this,a,"m",r).call(this,t);s.setContent(e.__classPrivateFieldGet(this,a,"m",l).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,o,"f").bind(this),W)}))}},o=new WeakMap,a=new WeakSet,l=function({type:e,msg:t}){const i=he[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}`},r=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},n})),ue=t.createSingletonMixin((a=>{var r,o,n,d,c,h,v,u,_,f,g;return g=class extends(t.compose(Z,i.loggerMixin,z)(a)){constructor(){super(...arguments),r.add(this),o.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=T(t);this.tenantSelector.value!==i&&e.__classPrivateFieldGet(this,r,"m",_).call(this,i);const{loading:s,error:a}=t.selectTenant,l=null!==t.tenant.previousTenantId,n=i!==e.__classPrivateFieldGet(this,o,"f");!i||s||a||l||!n||(e.__classPrivateFieldSet(this,o,i,"f"),e.__classPrivateFieldGet(this,r,"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=l.getSessionToken();return w(e)})()),e.__classPrivateFieldGet(this,r,"m",n).call(this),e.__classPrivateFieldGet(this,r,"m",f).call(this),e.__classPrivateFieldGet(this,r,"m",u).call(this,A(this.state)),this.subscribe(e.__classPrivateFieldGet(this,c,"f").bind(this))}))}},o=new WeakMap,d=new WeakMap,c=new WeakMap,r=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=T(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:t}})),this.tenantSelector.shouldReload&&e.__classPrivateFieldGet(this,r,"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,r,"m",_).call(this,T(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},g})),_e=t.createSingletonMixin((s=>class extends(t.compose(i.debuggerMixin,i.themeMixin,X,de,ee,Q,ie,le,se,ae,re,oe,te,ce,ve,ue)(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)}))}})),fe=t.compose((t=>class extends(_e(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.9.4"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",fe),module.exports=fe;
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.9.2
3
+ * @descope/user-profile-widget v0.9.4
4
4
  */
5
- import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createTemplate as s,kebabCase as o,isPlainObject as n,decodeJWT as r,createSingletonMixin as a,compose as l,withMemCache as d}from"@descope/sdk-helpers";import{projectIdMixin as h,observeAttributesMixin as c,loggerMixin as u,baseUrlMixin as f,cookieConfigMixin as v,DEFAULT_STYLE_ID as g,createStateManagementMixin as m,initLifecycleMixin as p,modalMixin as w,themeMixin as b,staticResourcesMixin as y,createValidateAttributesMixin as C,descopeUiMixin as U,initElementMixin as k,notificationsMixin as I,debuggerMixin as S}from"@descope/sdk-mixins";import{FlowDriver as R,AvatarDriver as M,UserAttributeDriver as W,ButtonDriver as A,UserAuthMethodDriver as T,DeviceListDriver as j,TenantSelectorDriver as N}from"@descope/sdk-component-drivers";import{createAsyncThunk as x}from"@reduxjs/toolkit";import F,{getSessionToken as L}from"@descope/web-js-sdk";import{createSelector as E}from"reselect";import"@descope/core-js-sdk";import"@descope/web-component";const O=(t={})=>{const e=s("<descope-wc></descope-wc>");return Object.entries(t).forEach((([t,i])=>{e.content.querySelector("descope-wc").setAttribute(o(t),(t=>"string"==typeof t?t:n(t)?JSON.stringify(t):"")(i))})),e};function D(t){return new URLSearchParams(window.location.search).get(t)}const q=t=>(...e)=>i=>{i.addCase(t.pending,((t,i)=>{e.forEach((({onPending:e})=>{null==e||e(t,i)}))})),i.addCase(t.fulfilled,((t,i)=>{e.forEach((({onFulfilled:e})=>{null==e||e(t,i)}))})),i.addCase(t.rejected,((t,i)=>{e.forEach((({onRejected:e})=>{null==e||e(t,i)}))}))},P=t=>({onFulfilled:e=>{t(e).loading=!1},onPending:e=>{t(e).loading=!0,t(e).error=null},onRejected:(e,i)=>{t(e).loading=!1,t(e).error=i.error}}),$=x("users/me",((t,{extra:{api:e}})=>e.user.me())),B=q($)({onFulfilled:(t,e)=>{t.me.data=e.payload}},P((t=>t.me))),H={action:$,reducer:B},V=x("users/devices",((t,{extra:{api:e}})=>e.device.devices(t))),Z=q(V)({onFulfilled:(t,e)=>{t.devices.data=e.payload.devices}},P((t=>t.devices))),J={action:V,reducer:Z},X=x("users/logout",((t,{extra:{api:e}})=>e.user.logout())),z={action:X,reducer:q(X)({})},G=t=>{if(!t)return null;const e=r(t);return(null==e?void 0:e.dct)||null},Y=t=>t.me.data,_=E(Y,(t=>t.userId)),K=E(Y,(t=>t.picture)),Q=E(Y,(t=>t.email)),tt=E(Y,(t=>t.verifiedEmail)),et=E(Y,(t=>t.name)),it=E(Y,(t=>t.phone)),st=E(Y,(t=>t.verifiedPhone)),ot=E(Y,(t=>t.webauthn));E(Y,(t=>t.password));const nt=E(Y,(t=>t.TOTP)),rt=E(Y,(t=>t.customAttributes)),at=E(Y,(t=>({givenName:t.givenName,middleName:t.middleName,familyName:t.familyName}))),lt=E((t=>t.devices.data),(t=>t.map((({id:t,name:e,deviceType:i,lastLoginTime:s,isCurrentDevice:o})=>({id:t,name:e,deviceType:i,lastLoginDate:1e3*parseInt(s,10),isCurrent:o}))))),dt=t=>t.notifications,ht=E(Y,(t=>t.userTenants||[])),ct=t=>t.tenant.currentTenantId,ut=x("tenant/select",((e,i)=>t(void 0,[e,i],void 0,(function*(t,{extra:{api:e},getState:i}){if(t===ct(i()))return null;const s=yield e.user.setCurrentTenant(t),o=s.sessionJwt||s.sessionToken;try{return{tenantId:G(o)}}catch(t){return console.error("Failed to switch tenant:",t),null}})))),ft={action:ut,reducer:q(ut)({onPending:t=>{t.tenant.previousTenantId=t.tenant.currentTenantId},onFulfilled:(t,e)=>{var i;t.tenant.currentTenantId=null===(i=e.payload)||void 0===i?void 0:i.tenantId,t.tenant.previousTenantId=null},onRejected:t=>{t.tenant.currentTenantId=t.tenant.previousTenantId,t.tenant.previousTenantId=null}},P((t=>t.selectTenant)),(({getErrorMsg:t,getSuccessMsg:e})=>({onFulfilled:(t,i)=>{if(e){const s=e(i);s&&t.notifications.push({type:"success",msg:s})}},onRejected:(e,i)=>{if(t){const s=t(i);s&&e.notifications.push({type:"error",msg:s})}}}))({getErrorMsg:t=>{var e,i;const s=(null===(e=t.error)||void 0===e?void 0:e.message)||"";return"Error"===(null===(i=t.error)||void 0===i?void 0:i.name)?s:`${s||"Error"}`}}))},vt={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},gt={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",selectTenant:"/v1/auth/tenant/select"},mt=e=>t(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),pt=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],wt=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({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",verifiedEmail:!0,verifiedPhone:!0,userTenants:pt,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})}))})),bt=()=>({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}]}),yt=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return wt();const t=yield e.get(gt.me);return yield mt(t),t.json()})),setCurrentTenant:i=>t(void 0,void 0,void 0,(function*(){const t=yield e.post(gt.selectTenant,{tenant:i});return yield mt(t),t.json()}))}),Ct=({httpClient:e,mock:i})=>({devices:s=>t(void 0,[s],void 0,(function*({userId:t}){if(i)return bt();const s=yield e.post(gt.devices,{identifiers:[t]});return yield mt(s),s.json()}))}),Ut=a((s=>{var o,n,r,a;const d=l(h,c,u,f,v)(s);return a=class extends d{constructor(){super(...arguments),o.add(this),n.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||g}get api(){return e(this,n,"f")||e(this,o,"m",r).call(this),e(this,n,"f")}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url"],(()=>{e(this,n,"f")&&e(this,o,"m",r).call(this)}))}))}},n=new WeakMap,o=new WeakSet,r=function(){this.logger.debug("creating an sdk instance"),i(this,n,((e,i,s)=>{const o=F(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.9.2"}}));return{user:Object.assign(Object.assign({},yt({httpClient:o.httpClient,mock:i})),{logout:i?()=>t(void 0,void 0,void 0,(function*(){})):o.logout}),device:Object.assign({},Ct({httpClient:o.httpClient,mock:i}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},a})),kt=a((t=>{const e=l(m({name:"widget",initialState:vt,reducers:{clearNotifications:t=>{t.notifications=[]},setCurrentTenantId:(t,{payload:e})=>{t.tenant.currentTenantId=e}},extraReducers:t=>{H.reducer(t),J.reducer(t),z.reducer(t),ft.reducer(t)},asyncActions:{getMe:H.action,listDevices:J.action,logout:z.action,selectTenant:ft.action}}),p,u,Ut)(t);return class extends e{constructor(...t){super(...t),this.state=vt,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),It="widget-flow",St=a((i=>{var s,o,n;return n=class extends(l(p,w,kt,v,u,b)(i)){constructor(){super(...arguments),s.add(this)}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);const n=D(It);n&&(!function(t){if(window.history.replaceState&&D(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}(It),e(this,s,"m",o).call(this,n))}))}},s=new WeakSet,o=function(t){const e=this.createModal({"data-id":"redirect-flow"});e.setContent(O({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId}));new R((()=>{var t;return null===(t=e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{e.close(),this.actions.getMe()})),e.afterClose=()=>{e.remove()},e.open()},n})),Rt=a((e=>{const i=l(y,C({"widget-id":C.missingAttrValidator}))(e);return class extends i{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return t(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Mt=a((i=>{var o,n,r;return r=class extends(l(u,p,U,k,Rt,kt)(i)){constructor(){super(...arguments),o.add(this)}onWidgetRootReady(){return t(this,void 0,void 0,(function*(){}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),yield this.actions.getMe(),yield e(this,o,"m",n).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},o=new WeakSet,n=function(){return t(this,void 0,void 0,(function*(){const t=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(t),this.contentRootElement.append(t.content.cloneNode(!0))}))},r})),Wt=a((t=>class extends(l(b,c)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}})),At=a((s=>{var o,n,r,a,h,c,f,g,m;return m=class extends(l(Wt,b,kt,u,v,Mt,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),f.set(this,d((t=>{this.avatar.image=t}))),g.set(this,d((t=>{this.avatar.displayName=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",c).call(this),e(this,o,"m",a).call(this),e(this,f,"f").call(this,K(this.state)),e(this,g,"f").call(this,et(this.state)),this.subscribe(e(this,f,"f").bind(this),K),this.subscribe(e(this,g,"f").bind(this),et)}))}},n=new WeakMap,r=new WeakMap,f=new WeakMap,g=new WeakMap,o=new WeakSet,a=function(){this.avatar.flowId&&(i(this,n,this.createModal({"data-id":"update-pic"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",h).bind(this),e(this,o,"m",h).call(this),this.syncFlowTheme(e(this,r,"f")))},h=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.getMe()}))},c=function(){this.avatar=new M((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()}))},m})),Tt=a((s=>{var o,n,r,a,h,c,f,g,m,p,b,y,C;return C=class extends(l(Wt,kt,u,Mt,v,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),a.set(this,void 0),h.set(this,void 0),b.set(this,d((t=>{this.emailUserAttr.value=t}))),y.set(this,d((t=>{this.emailUserAttr.badgeLabel=t?"":"Unverified"})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",p).call(this),e(this,o,"m",c).call(this),e(this,o,"m",g).call(this),e(this,b,"f").call(this,Q(this.state)),e(this,y,"f").call(this,tt(this.state)),this.subscribe(e(this,b,"f").bind(this),Q),this.subscribe(e(this,y,"f").bind(this),tt)}))}},n=new WeakMap,r=new WeakMap,a=new WeakMap,h=new WeakMap,b=new WeakMap,y=new WeakMap,o=new WeakSet,c=function(){this.emailUserAttr.editFlowId&&(i(this,n,this.createModal({"data-id":"edit-email"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,r,"f")))},f=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr.deleteFlowId&&(i(this,a,this.createModal({"data-id":"delete-email"}),"f"),i(this,h,new R((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,h,"f")))},m=function(){e(this,a,"f").setContent(O({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,h,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr=new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()})),this.emailUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},C})),jt=a((i=>{var s,o,n;return n=class extends(l(kt,u,Mt,w)(i)){constructor(){super(...arguments),s.add(this)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,s,"m",o).call(this)}))}},s=new WeakSet,o=function(){this.logout=new A((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>t(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},n})),Nt=a((s=>{var o,n,r,a,h,c,f,g,m,p,b,y;return y=class extends(l(Wt,kt,u,Mt,v,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),a.set(this,void 0),h.set(this,void 0),b.set(this,d((t=>{this.nameUserAttr.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",p).call(this),e(this,o,"m",c).call(this),e(this,o,"m",g).call(this),e(this,b,"f").call(this,et(this.state)),this.subscribe(e(this,b,"f").bind(this),et)}))}},n=new WeakMap,r=new WeakMap,a=new WeakMap,h=new WeakMap,b=new WeakMap,o=new WeakSet,c=function(){this.nameUserAttr.editFlowId&&(i(this,n,this.createModal({"data-id":"edit-name"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,r,"f")))},f=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr.deleteFlowId&&(i(this,a,this.createModal({"data-id":"delete-name"}),"f"),i(this,h,new R((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,h,"f")))},m=function(){e(this,a,"f").setContent(O({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,h,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr=new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()})),this.nameUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},y})),xt=a((s=>{var o,n,r,a,h,c,f,g,m,p,b,y;return y=class extends(l(Wt,kt,u,Mt,v,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),a.set(this,void 0),h.set(this,void 0),b.set(this,d((t=>{this.passkeyUserAuthMethod.fulfilled=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",p).call(this),e(this,o,"m",c).call(this),e(this,o,"m",g).call(this),e(this,b,"f").call(this,ot(this.state)),this.subscribe(e(this,b,"f").bind(this),ot)}))}},n=new WeakMap,r=new WeakMap,a=new WeakMap,h=new WeakMap,b=new WeakMap,o=new WeakSet,c=function(){this.passkeyUserAuthMethod.flowId&&(i(this,n,this.createModal({"data-id":"add-passkey"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,r,"f")))},f=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.getMe()}))},g=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(i(this,a,this.createModal({"data-id":"remove-passkey"}),"f"),i(this,h,new R((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,h,"f")))},m=function(){e(this,a,"f").setContent(O({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,h,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getMe()}))},p=function(){this.passkeyUserAuthMethod=new T((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},y})),Ft=a((s=>{var o,n,r,a,d,h;return h=class extends(l(Wt,kt,u,Mt,v,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new T((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),this.initPasswordAuthMethod(),e(this,o,"m",a).call(this)}))}},n=new WeakMap,r=new WeakMap,o=new WeakSet,a=function(){this.passwordUserAuthMethod.flowId&&(i(this,n,this.createModal({"data-id":"password"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",d).bind(this),e(this,o,"m",d).call(this),this.syncFlowTheme(e(this,r,"f")))},d=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close()}))},h})),Lt=a((s=>{var o,n,r,a,h,c,f,g,m,p,b,y,C;return C=class extends(l(Wt,kt,u,Mt,v,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),a.set(this,void 0),h.set(this,void 0),b.set(this,d((t=>{this.phoneUserAttr.value=t}))),y.set(this,d((t=>{this.phoneUserAttr.badgeLabel=t?"":"Unverified"})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",p).call(this),e(this,o,"m",c).call(this),e(this,o,"m",g).call(this),e(this,b,"f").call(this,it(this.state)),e(this,y,"f").call(this,st(this.state)),this.subscribe(e(this,b,"f").bind(this),it),this.subscribe(e(this,y,"f").bind(this),st)}))}},n=new WeakMap,r=new WeakMap,a=new WeakMap,h=new WeakMap,b=new WeakMap,y=new WeakMap,o=new WeakSet,c=function(){this.phoneUserAttr.editFlowId&&(i(this,n,this.createModal({"data-id":"edit-phone"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,r,"f")))},f=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr.deleteFlowId&&(i(this,a,this.createModal({"data-id":"delete-phone"}),"f"),i(this,h,new R((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,h,"f")))},m=function(){e(this,a,"f").setContent(O({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,h,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr=new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()})),this.phoneUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},C})),Et=a((s=>{var o,n,r,a,h,c,f,g,m,p,b,y;return y=class extends(l(Wt,kt,u,Mt,v,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),a.set(this,void 0),h.set(this,void 0),b.set(this,d((t=>{this.totpUserAuthMethod.fulfilled=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",p).call(this),e(this,o,"m",c).call(this),e(this,o,"m",g).call(this),e(this,b,"f").call(this,nt(this.state)),this.subscribe(e(this,b,"f").bind(this),nt)}))}},n=new WeakMap,r=new WeakMap,a=new WeakMap,h=new WeakMap,b=new WeakMap,o=new WeakSet,c=function(){this.totpUserAuthMethod.flowId&&(i(this,n,this.createModal({"data-id":"totp"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,r,"f")))},f=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.getMe()}))},g=function(){this.totpUserAuthMethod.fulfilledFlowId&&(i(this,a,this.createModal({"data-id":"remove-totp"}),"f"),i(this,h,new R((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,h,"f")))},m=function(){e(this,a,"f").setContent(O({projectId:this.projectId,flowId:this.totpUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e(this,h,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getMe()}))},p=function(){this.totpUserAuthMethod=new T((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},y})),Ot=a((i=>{var s,o,n,r,a,h,c,f,g,m,p;return p=class extends(l(Wt,kt,u,Mt,v,w)(i)){constructor(){super(...arguments),s.add(this),o.set(this,{}),n.set(this,{}),r.set(this,{}),a.set(this,{}),f.set(this,d((t=>{var i;const o=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(o).forEach((i=>{const o=i.getAttribute("data-id").replace("builtin.",""),n=t[o],r=new W(i,{logger:this.logger});r.value=(n||"").toString(),e(this,s,"m",g).call(this,i,o,r),e(this,s,"m",m).call(this,i,o,r)}))})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,f,"f").call(this,at(this.state)),this.subscribe(e(this,f,"f").bind(this),at)}))}},o=new WeakMap,n=new WeakMap,r=new WeakMap,a=new WeakMap,f=new WeakMap,s=new WeakSet,h=function(t){var i,s;null===(i=e(this,o,"f")[t])||void 0===i||i.setContent(O({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(s=e(this,n,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,o,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},c=function(t){var i,s;null===(i=e(this,r,"f")[t])||void 0===i||i.setContent(O({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(s=e(this,a,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,r,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},g=function(t,i,r){const a=t.getAttribute("edit-flow-id");a&&(e(this,o,"f")[a]=this.createModal({"data-id":`edit-${i}`}),e(this,n,"f")[a]=new R((()=>{var t,i;return null===(i=null===(t=e(this,o,"f")[a])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,o,"f")[a].afterClose=e(this,s,"m",h).bind(this,a),r.onEditClick((()=>{var t,i;null===(i=null===(t=e(this,o,"f"))||void 0===t?void 0:t[a])||void 0===i||i.open()})),e(this,s,"m",h).call(this,a),this.syncFlowTheme(e(this,n,"f")[a]))},m=function(t,i,o){const n=t.getAttribute("delete-flow-id");n&&(e(this,r,"f")[n]=this.createModal({"data-id":`delete-${i}`}),e(this,a,"f")[n]=new R((()=>{var t,i;return null===(i=null===(t=e(this,r,"f")[n])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,r,"f")[n].afterClose=e(this,s,"m",c).bind(this,n),o.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,r,"f"))||void 0===t?void 0:t[n])||void 0===i||i.open()})),e(this,s,"m",c).call(this,n),this.syncFlowTheme(e(this,a,"f")[n]))},p}));var Dt;!function(t){t.TEXT="text",t.NUMBER="number",t.BOOLEAN="boolean",t.SINGLE_SELECT="singleSelect",t.ARRAY="array",t.DATE="date"}(Dt||(Dt={}));const qt=a((i=>{var s,o,n,r,a,h,c,f,g,m,p;return o=class extends(l(Wt,kt,u,Mt,v,w)(i)){constructor(){super(...arguments),s.add(this),n.set(this,{}),r.set(this,{}),a.set(this,{}),h.set(this,{}),g.set(this,d((t=>{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.",""),r=i.getAttribute("data-type")||Dt.TEXT,a=t[n],l=new W(i,{logger:this.logger});l.value=o.getFormattedValue(r,a),e(this,s,"m",m).call(this,i,n,l),e(this,s,"m",p).call(this,i,n,l)}))})))}static getFormattedValue(t,e){return t===Dt.DATE&&e?new Date(e).toLocaleString():t===Dt.BOOLEAN&&void 0!==e?e?"True":"False":(e||"").toString()}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,g,"f").call(this,rt(this.state)),this.subscribe(e(this,g,"f").bind(this),rt)}))}},n=new WeakMap,r=new WeakMap,a=new WeakMap,h=new WeakMap,g=new WeakMap,s=new WeakSet,c=function(t){var i,s;null===(i=e(this,n,"f")[t])||void 0===i||i.setContent(O({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(s=e(this,r,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,n,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},f=function(t){var i,s;null===(i=e(this,a,"f")[t])||void 0===i||i.setContent(O({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(s=e(this,h,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,a,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},m=function(t,i,o){const a=t.getAttribute("edit-flow-id");a&&(e(this,n,"f")[a]=this.createModal({"data-id":`edit-${i}`}),e(this,r,"f")[a]=new R((()=>{var t,i;return null===(i=null===(t=e(this,n,"f")[a])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,n,"f")[a].afterClose=e(this,s,"m",c).bind(this,a),o.onEditClick((()=>{var t,i;null===(i=null===(t=e(this,n,"f"))||void 0===t?void 0:t[a])||void 0===i||i.open()})),e(this,s,"m",c).call(this,a),this.syncFlowTheme(e(this,r,"f")[a]))},p=function(t,i,o){const n=t.getAttribute("delete-flow-id");n&&(e(this,a,"f")[n]=this.createModal({"data-id":`delete-${i}`}),e(this,h,"f")[n]=new R((()=>{var t,i;return null===(i=null===(t=e(this,a,"f")[n])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,a,"f")[n].afterClose=e(this,s,"m",f).bind(this,n),o.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,a,"f"))||void 0===t?void 0:t[n])||void 0===i||i.open()})),e(this,s,"m",f).call(this,n),this.syncFlowTheme(e(this,h,"f")[n]))},o})),Pt=a((s=>{var o,n,r,a,h,c,f,g;return g=class extends(l(Wt,b,kt,u,v,Mt,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),this.updateDeviceList=d((t=>{this.deviceList.data=t}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),this.deviceList=new j((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield e(this,o,"m",f).call(this),e(this,o,"m",c).call(this,lt(this.state)),e(this,o,"m",a).call(this),this.subscribe(this.updateDeviceList.bind(this),lt))}))}},n=new WeakMap,r=new WeakMap,o=new WeakSet,a=function(){this.deviceList.flowId&&(i(this,n,this.createModal({"data-id":"untrust-device"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=()=>e(this,o,"m",h).call(this,""),this.syncFlowTheme(e(this,r,"f")))},h=function(t=""){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.deviceList.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:{deviceId:t}})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.listDevices({userId:_(this.state)})}))},c=function(t){this.deviceList.onRemoveDeviceClick((({id:t})=>{var i;e(this,o,"m",h).call(this,t),null===(i=e(this,n,"f"))||void 0===i||i.open()})),this.deviceList.data=t},f=function(){return t(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:_(this.state)})}))},g}));const $t={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},Bt=a((i=>{var s,o,n,r,a;return a=class extends(l(u,kt,I,p)(i)){constructor(){super(...arguments),s.add(this),r.set(this,d((t=>{t.length&&(t.forEach((({type:t,msg:i})=>{const r=e(this,s,"m",n).call(this,t);r.setContent(e(this,s,"m",o).call(this,{type:t,msg:i})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),this.subscribe(e(this,r,"f").bind(this),dt)}))}},r=new WeakMap,s=new WeakSet,o=function({type:t,msg:e}){const i=$t[t],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)||""}${e}${s.outerHTML}`},n=function(t){return this.createNotification({mode:t,duration:"error"===t?0:3e3,position:"bottom-start",size:"sm"})},a})),Ht=a((s=>{var o,n,r,a,d,h,c,f,v,g,m;return m=class extends(l(kt,u,Mt)(s)){constructor(){super(...arguments),o.add(this),n.set(this,null),a.set(this,(e=>t(this,void 0,void 0,(function*(){const t=e.target.value;yield this.actions.selectTenant(t)})))),d.set(this,(t=>{const s=ct(t);this.tenantSelector.value!==s&&e(this,o,"m",v).call(this,s);const{loading:r,error:a}=t.selectTenant,l=null!==t.tenant.previousTenantId,d=s!==e(this,n,"f");!s||r||a||l||!d||(i(this,n,s,"f"),e(this,o,"m",h).call(this))}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),this.actions.setCurrentTenantId((()=>{const t=L();return G(t)})()),e(this,o,"m",r).call(this),e(this,o,"m",g).call(this),e(this,o,"m",f).call(this,ht(this.state)),this.subscribe(e(this,d,"f").bind(this))}))}},n=new WeakMap,a=new WeakMap,d=new WeakMap,o=new WeakSet,r=function(){this.tenantSelector=new N((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(e(this,a,"f"))},h=function(){const t=ct(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:t}})),this.tenantSelector.shouldReload&&e(this,o,"m",c).call(this)},c=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},f=function(e){return t(this,void 0,void 0,(function*(){const t=e.map((t=>({label:t.tenantName||t.tenantId,value:t.tenantId})));yield this.tenantSelector.setData(t)}))},v=function(t){t&&(this.tenantSelector.value=t)},g=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{e(this,o,"m",v).call(this,ct(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},m})),Vt=a((e=>class extends(l(S,b,St,qt,Tt,At,Nt,Lt,xt,Ft,Et,Ot,jt,Pt,Bt,Ht)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Zt=l((e=>class extends(Vt(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((t=>t.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.9.2"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",Zt);export{Zt as default};
5
+ import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createTemplate as s,kebabCase as o,isPlainObject as n,decodeJWT as r,createSingletonMixin as a,compose as l,withMemCache as d}from"@descope/sdk-helpers";import{projectIdMixin as h,observeAttributesMixin as c,loggerMixin as u,baseUrlMixin as f,cookieConfigMixin as v,DEFAULT_STYLE_ID as g,createStateManagementMixin as m,initLifecycleMixin as p,modalMixin as w,themeMixin as b,staticResourcesMixin as y,createValidateAttributesMixin as C,descopeUiMixin as U,initElementMixin as k,notificationsMixin as I,debuggerMixin as S}from"@descope/sdk-mixins";import{FlowDriver as R,AvatarDriver as M,UserAttributeDriver as W,ButtonDriver as A,UserAuthMethodDriver as T,DeviceListDriver as j,TenantSelectorDriver as N}from"@descope/sdk-component-drivers";import{createAsyncThunk as x}from"@reduxjs/toolkit";import F,{getSessionToken as L}from"@descope/web-js-sdk";import{createSelector as E}from"reselect";import"@descope/core-js-sdk";import"@descope/web-component";const O=(t={})=>{const e=s("<descope-wc></descope-wc>");return Object.entries(t).forEach((([t,i])=>{e.content.querySelector("descope-wc").setAttribute(o(t),(t=>"string"==typeof t?t:n(t)?JSON.stringify(t):"")(i))})),e};function D(t){return new URLSearchParams(window.location.search).get(t)}const q=t=>(...e)=>i=>{i.addCase(t.pending,((t,i)=>{e.forEach((({onPending:e})=>{null==e||e(t,i)}))})),i.addCase(t.fulfilled,((t,i)=>{e.forEach((({onFulfilled:e})=>{null==e||e(t,i)}))})),i.addCase(t.rejected,((t,i)=>{e.forEach((({onRejected:e})=>{null==e||e(t,i)}))}))},P=t=>({onFulfilled:e=>{t(e).loading=!1},onPending:e=>{t(e).loading=!0,t(e).error=null},onRejected:(e,i)=>{t(e).loading=!1,t(e).error=i.error}}),$=x("users/me",((t,{extra:{api:e}})=>e.user.me())),B=q($)({onFulfilled:(t,e)=>{t.me.data=e.payload}},P((t=>t.me))),H={action:$,reducer:B},V=x("users/devices",((t,{extra:{api:e}})=>e.device.devices(t))),Z=q(V)({onFulfilled:(t,e)=>{t.devices.data=e.payload.devices}},P((t=>t.devices))),J={action:V,reducer:Z},X=x("users/logout",((t,{extra:{api:e}})=>e.user.logout())),z={action:X,reducer:q(X)({})},G=t=>{if(!t)return null;const e=r(t);return(null==e?void 0:e.dct)||null},Y=t=>t.me.data,_=E(Y,(t=>t.userId)),K=E(Y,(t=>t.picture)),Q=E(Y,(t=>t.email)),tt=E(Y,(t=>t.verifiedEmail)),et=E(Y,(t=>t.name)),it=E(Y,(t=>t.phone)),st=E(Y,(t=>t.verifiedPhone)),ot=E(Y,(t=>t.webauthn));E(Y,(t=>t.password));const nt=E(Y,(t=>t.TOTP)),rt=E(Y,(t=>t.customAttributes)),at=E(Y,(t=>({givenName:t.givenName,middleName:t.middleName,familyName:t.familyName}))),lt=E((t=>t.devices.data),(t=>t.map((({id:t,name:e,deviceType:i,lastLoginTime:s,isCurrentDevice:o})=>({id:t,name:e,deviceType:i,lastLoginDate:1e3*parseInt(s,10),isCurrent:o}))))),dt=t=>t.notifications,ht=E(Y,(t=>t.userTenants||[])),ct=t=>t.tenant.currentTenantId,ut=x("tenant/select",((e,i)=>t(void 0,[e,i],void 0,(function*(t,{extra:{api:e},getState:i}){if(t===ct(i()))return null;const s=yield e.user.setCurrentTenant(t),o=s.sessionJwt||s.sessionToken;try{return{tenantId:G(o)}}catch(t){return console.error("Failed to switch tenant:",t),null}})))),ft={action:ut,reducer:q(ut)({onPending:t=>{t.tenant.previousTenantId=t.tenant.currentTenantId},onFulfilled:(t,e)=>{var i;t.tenant.currentTenantId=null===(i=e.payload)||void 0===i?void 0:i.tenantId,t.tenant.previousTenantId=null},onRejected:t=>{t.tenant.currentTenantId=t.tenant.previousTenantId,t.tenant.previousTenantId=null}},P((t=>t.selectTenant)),(({getErrorMsg:t,getSuccessMsg:e})=>({onFulfilled:(t,i)=>{if(e){const s=e(i);s&&t.notifications.push({type:"success",msg:s})}},onRejected:(e,i)=>{if(t){const s=t(i);s&&e.notifications.push({type:"error",msg:s})}}}))({getErrorMsg:t=>{var e,i;const s=(null===(e=t.error)||void 0===e?void 0:e.message)||"";return"Error"===(null===(i=t.error)||void 0===i?void 0:i.name)?s:`${s||"Error"}`}}))},vt={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},gt={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",selectTenant:"/v1/auth/tenant/select"},mt=e=>t(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),pt=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],wt=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({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",verifiedEmail:!0,verifiedPhone:!0,userTenants:pt,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})}))})),bt=()=>({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}]}),yt=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return wt();const t=yield e.get(gt.me);return yield mt(t),t.json()})),setCurrentTenant:i=>t(void 0,void 0,void 0,(function*(){const t=yield e.post(gt.selectTenant,{tenant:i});return yield mt(t),t.json()}))}),Ct=({httpClient:e,mock:i})=>({devices:s=>t(void 0,[s],void 0,(function*({userId:t}){if(i)return bt();const s=yield e.post(gt.devices,{identifiers:[t]});return yield mt(s),s.json()}))}),Ut=a((s=>{var o,n,r,a;const d=l(h,c,u,f,v)(s);return a=class extends d{constructor(){super(...arguments),o.add(this),n.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||g}get api(){return e(this,n,"f")||e(this,o,"m",r).call(this),e(this,n,"f")}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url"],(()=>{e(this,n,"f")&&e(this,o,"m",r).call(this)}))}))}},n=new WeakMap,o=new WeakSet,r=function(){this.logger.debug("creating an sdk instance"),i(this,n,((e,i,s)=>{const o=F(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.9.4"}}));return{user:Object.assign(Object.assign({},yt({httpClient:o.httpClient,mock:i})),{logout:i?()=>t(void 0,void 0,void 0,(function*(){})):o.logout}),device:Object.assign({},Ct({httpClient:o.httpClient,mock:i}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},a})),kt=a((t=>{const e=l(m({name:"widget",initialState:vt,reducers:{clearNotifications:t=>{t.notifications=[]},setCurrentTenantId:(t,{payload:e})=>{t.tenant.currentTenantId=e}},extraReducers:t=>{H.reducer(t),J.reducer(t),z.reducer(t),ft.reducer(t)},asyncActions:{getMe:H.action,listDevices:J.action,logout:z.action,selectTenant:ft.action}}),p,u,Ut)(t);return class extends e{constructor(...t){super(...t),this.state=vt,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),It="widget-flow",St=a((i=>{var s,o,n;return n=class extends(l(p,w,kt,v,u,b)(i)){constructor(){super(...arguments),s.add(this)}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);const n=D(It);n&&(!function(t){if(window.history.replaceState&&D(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}(It),e(this,s,"m",o).call(this,n))}))}},s=new WeakSet,o=function(t){const e=this.createModal({"data-id":"redirect-flow"});e.setContent(O({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId}));new R((()=>{var t;return null===(t=e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{e.close(),this.actions.getMe()})),e.afterClose=()=>{e.remove()},e.open()},n})),Rt=a((e=>{const i=l(y,C({"widget-id":C.missingAttrValidator}))(e);return class extends i{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return t(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Mt=a((i=>{var o,n,r;return r=class extends(l(u,p,U,k,Rt,kt)(i)){constructor(){super(...arguments),o.add(this)}onWidgetRootReady(){return t(this,void 0,void 0,(function*(){}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),yield this.actions.getMe(),yield e(this,o,"m",n).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},o=new WeakSet,n=function(){return t(this,void 0,void 0,(function*(){const t=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(t),this.contentRootElement.append(t.content.cloneNode(!0))}))},r})),Wt=a((t=>class extends(l(b,c)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}})),At=a((s=>{var o,n,r,a,h,c,f,g,m;return m=class extends(l(Wt,b,kt,u,v,Mt,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),f.set(this,d((t=>{this.avatar.image=t}))),g.set(this,d((t=>{this.avatar.displayName=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",c).call(this),e(this,o,"m",a).call(this),e(this,f,"f").call(this,K(this.state)),e(this,g,"f").call(this,et(this.state)),this.subscribe(e(this,f,"f").bind(this),K),this.subscribe(e(this,g,"f").bind(this),et)}))}},n=new WeakMap,r=new WeakMap,f=new WeakMap,g=new WeakMap,o=new WeakSet,a=function(){this.avatar.flowId&&(i(this,n,this.createModal({"data-id":"update-pic"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",h).bind(this),e(this,o,"m",h).call(this),this.syncFlowTheme(e(this,r,"f")))},h=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.getMe()}))},c=function(){this.avatar=new M((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()}))},m})),Tt=a((s=>{var o,n,r,a,h,c,f,g,m,p,b,y,C;return C=class extends(l(Wt,kt,u,Mt,v,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),a.set(this,void 0),h.set(this,void 0),b.set(this,d((t=>{this.emailUserAttr.value=t}))),y.set(this,d((t=>{this.emailUserAttr.badgeLabel=t?"":"Unverified"})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",p).call(this),e(this,o,"m",c).call(this),e(this,o,"m",g).call(this),e(this,b,"f").call(this,Q(this.state)),e(this,y,"f").call(this,tt(this.state)),this.subscribe(e(this,b,"f").bind(this),Q),this.subscribe(e(this,y,"f").bind(this),tt)}))}},n=new WeakMap,r=new WeakMap,a=new WeakMap,h=new WeakMap,b=new WeakMap,y=new WeakMap,o=new WeakSet,c=function(){this.emailUserAttr.editFlowId&&(i(this,n,this.createModal({"data-id":"edit-email"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,r,"f")))},f=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr.deleteFlowId&&(i(this,a,this.createModal({"data-id":"delete-email"}),"f"),i(this,h,new R((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,h,"f")))},m=function(){e(this,a,"f").setContent(O({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,h,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr=new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()})),this.emailUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},C})),jt=a((i=>{var s,o,n;return n=class extends(l(kt,u,Mt,w)(i)){constructor(){super(...arguments),s.add(this)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,s,"m",o).call(this)}))}},s=new WeakSet,o=function(){this.logout=new A((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>t(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},n})),Nt=a((s=>{var o,n,r,a,h,c,f,g,m,p,b,y;return y=class extends(l(Wt,kt,u,Mt,v,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),a.set(this,void 0),h.set(this,void 0),b.set(this,d((t=>{this.nameUserAttr.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",p).call(this),e(this,o,"m",c).call(this),e(this,o,"m",g).call(this),e(this,b,"f").call(this,et(this.state)),this.subscribe(e(this,b,"f").bind(this),et)}))}},n=new WeakMap,r=new WeakMap,a=new WeakMap,h=new WeakMap,b=new WeakMap,o=new WeakSet,c=function(){this.nameUserAttr.editFlowId&&(i(this,n,this.createModal({"data-id":"edit-name"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,r,"f")))},f=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr.deleteFlowId&&(i(this,a,this.createModal({"data-id":"delete-name"}),"f"),i(this,h,new R((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,h,"f")))},m=function(){e(this,a,"f").setContent(O({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,h,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr=new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()})),this.nameUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},y})),xt=a((s=>{var o,n,r,a,h,c,f,g,m,p,b,y;return y=class extends(l(Wt,kt,u,Mt,v,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),a.set(this,void 0),h.set(this,void 0),b.set(this,d((t=>{this.passkeyUserAuthMethod.fulfilled=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",p).call(this),e(this,o,"m",c).call(this),e(this,o,"m",g).call(this),e(this,b,"f").call(this,ot(this.state)),this.subscribe(e(this,b,"f").bind(this),ot)}))}},n=new WeakMap,r=new WeakMap,a=new WeakMap,h=new WeakMap,b=new WeakMap,o=new WeakSet,c=function(){this.passkeyUserAuthMethod.flowId&&(i(this,n,this.createModal({"data-id":"add-passkey"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,r,"f")))},f=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.getMe()}))},g=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(i(this,a,this.createModal({"data-id":"remove-passkey"}),"f"),i(this,h,new R((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,h,"f")))},m=function(){e(this,a,"f").setContent(O({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,h,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getMe()}))},p=function(){this.passkeyUserAuthMethod=new T((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},y})),Ft=a((s=>{var o,n,r,a,d,h;return h=class extends(l(Wt,kt,u,Mt,v,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new T((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),this.initPasswordAuthMethod(),e(this,o,"m",a).call(this)}))}},n=new WeakMap,r=new WeakMap,o=new WeakSet,a=function(){this.passwordUserAuthMethod.flowId&&(i(this,n,this.createModal({"data-id":"password"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",d).bind(this),e(this,o,"m",d).call(this),this.syncFlowTheme(e(this,r,"f")))},d=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close()}))},h})),Lt=a((s=>{var o,n,r,a,h,c,f,g,m,p,b,y,C;return C=class extends(l(Wt,kt,u,Mt,v,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),a.set(this,void 0),h.set(this,void 0),b.set(this,d((t=>{this.phoneUserAttr.value=t}))),y.set(this,d((t=>{this.phoneUserAttr.badgeLabel=t?"":"Unverified"})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",p).call(this),e(this,o,"m",c).call(this),e(this,o,"m",g).call(this),e(this,b,"f").call(this,it(this.state)),e(this,y,"f").call(this,st(this.state)),this.subscribe(e(this,b,"f").bind(this),it),this.subscribe(e(this,y,"f").bind(this),st)}))}},n=new WeakMap,r=new WeakMap,a=new WeakMap,h=new WeakMap,b=new WeakMap,y=new WeakMap,o=new WeakSet,c=function(){this.phoneUserAttr.editFlowId&&(i(this,n,this.createModal({"data-id":"edit-phone"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,r,"f")))},f=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr.deleteFlowId&&(i(this,a,this.createModal({"data-id":"delete-phone"}),"f"),i(this,h,new R((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,h,"f")))},m=function(){e(this,a,"f").setContent(O({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,h,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr=new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()})),this.phoneUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},C})),Et=a((s=>{var o,n,r,a,h,c,f,g,m,p,b,y;return y=class extends(l(Wt,kt,u,Mt,v,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),a.set(this,void 0),h.set(this,void 0),b.set(this,d((t=>{this.totpUserAuthMethod.fulfilled=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",p).call(this),e(this,o,"m",c).call(this),e(this,o,"m",g).call(this),e(this,b,"f").call(this,nt(this.state)),this.subscribe(e(this,b,"f").bind(this),nt)}))}},n=new WeakMap,r=new WeakMap,a=new WeakMap,h=new WeakMap,b=new WeakMap,o=new WeakSet,c=function(){this.totpUserAuthMethod.flowId&&(i(this,n,this.createModal({"data-id":"totp"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,r,"f")))},f=function(){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.getMe()}))},g=function(){this.totpUserAuthMethod.fulfilledFlowId&&(i(this,a,this.createModal({"data-id":"remove-totp"}),"f"),i(this,h,new R((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,h,"f")))},m=function(){e(this,a,"f").setContent(O({projectId:this.projectId,flowId:this.totpUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e(this,h,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getMe()}))},p=function(){this.totpUserAuthMethod=new T((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,n,"f"))||void 0===t||t.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},y})),Ot=a((i=>{var s,o,n,r,a,h,c,f,g,m,p;return p=class extends(l(Wt,kt,u,Mt,v,w)(i)){constructor(){super(...arguments),s.add(this),o.set(this,{}),n.set(this,{}),r.set(this,{}),a.set(this,{}),f.set(this,d((t=>{var i;const o=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(o).forEach((i=>{const o=i.getAttribute("data-id").replace("builtin.",""),n=t[o],r=new W(i,{logger:this.logger});r.value=(n||"").toString(),e(this,s,"m",g).call(this,i,o,r),e(this,s,"m",m).call(this,i,o,r)}))})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,f,"f").call(this,at(this.state)),this.subscribe(e(this,f,"f").bind(this),at)}))}},o=new WeakMap,n=new WeakMap,r=new WeakMap,a=new WeakMap,f=new WeakMap,s=new WeakSet,h=function(t){var i,s;null===(i=e(this,o,"f")[t])||void 0===i||i.setContent(O({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(s=e(this,n,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,o,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},c=function(t){var i,s;null===(i=e(this,r,"f")[t])||void 0===i||i.setContent(O({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(s=e(this,a,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,r,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},g=function(t,i,r){const a=t.getAttribute("edit-flow-id");a&&(e(this,o,"f")[a]=this.createModal({"data-id":`edit-${i}`}),e(this,n,"f")[a]=new R((()=>{var t,i;return null===(i=null===(t=e(this,o,"f")[a])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,o,"f")[a].afterClose=e(this,s,"m",h).bind(this,a),r.onEditClick((()=>{var t,i;null===(i=null===(t=e(this,o,"f"))||void 0===t?void 0:t[a])||void 0===i||i.open()})),e(this,s,"m",h).call(this,a),this.syncFlowTheme(e(this,n,"f")[a]))},m=function(t,i,o){const n=t.getAttribute("delete-flow-id");n&&(e(this,r,"f")[n]=this.createModal({"data-id":`delete-${i}`}),e(this,a,"f")[n]=new R((()=>{var t,i;return null===(i=null===(t=e(this,r,"f")[n])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,r,"f")[n].afterClose=e(this,s,"m",c).bind(this,n),o.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,r,"f"))||void 0===t?void 0:t[n])||void 0===i||i.open()})),e(this,s,"m",c).call(this,n),this.syncFlowTheme(e(this,a,"f")[n]))},p}));var Dt;!function(t){t.TEXT="text",t.NUMBER="number",t.BOOLEAN="boolean",t.SINGLE_SELECT="singleSelect",t.ARRAY="array",t.DATE="date"}(Dt||(Dt={}));const qt=a((i=>{var s,o,n,r,a,h,c,f,g,m,p;return o=class extends(l(Wt,kt,u,Mt,v,w)(i)){constructor(){super(...arguments),s.add(this),n.set(this,{}),r.set(this,{}),a.set(this,{}),h.set(this,{}),g.set(this,d((t=>{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.",""),r=i.getAttribute("data-type")||Dt.TEXT,a=t[n],l=new W(i,{logger:this.logger});l.value=o.getFormattedValue(r,a),e(this,s,"m",m).call(this,i,n,l),e(this,s,"m",p).call(this,i,n,l)}))})))}static getFormattedValue(t,e){return t===Dt.DATE&&e?new Date(e).toLocaleString():t===Dt.BOOLEAN&&void 0!==e?e?"True":"False":(e||"").toString()}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,g,"f").call(this,rt(this.state)),this.subscribe(e(this,g,"f").bind(this),rt)}))}},n=new WeakMap,r=new WeakMap,a=new WeakMap,h=new WeakMap,g=new WeakMap,s=new WeakSet,c=function(t){var i,s;null===(i=e(this,n,"f")[t])||void 0===i||i.setContent(O({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(s=e(this,r,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,n,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},f=function(t){var i,s;null===(i=e(this,a,"f")[t])||void 0===i||i.setContent(O({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(s=e(this,h,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,a,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},m=function(t,i,o){const a=t.getAttribute("edit-flow-id");a&&(e(this,n,"f")[a]=this.createModal({"data-id":`edit-${i}`}),e(this,r,"f")[a]=new R((()=>{var t,i;return null===(i=null===(t=e(this,n,"f")[a])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,n,"f")[a].afterClose=e(this,s,"m",c).bind(this,a),o.onEditClick((()=>{var t,i;null===(i=null===(t=e(this,n,"f"))||void 0===t?void 0:t[a])||void 0===i||i.open()})),e(this,s,"m",c).call(this,a),this.syncFlowTheme(e(this,r,"f")[a]))},p=function(t,i,o){const n=t.getAttribute("delete-flow-id");n&&(e(this,a,"f")[n]=this.createModal({"data-id":`delete-${i}`}),e(this,h,"f")[n]=new R((()=>{var t,i;return null===(i=null===(t=e(this,a,"f")[n])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,a,"f")[n].afterClose=e(this,s,"m",f).bind(this,n),o.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,a,"f"))||void 0===t?void 0:t[n])||void 0===i||i.open()})),e(this,s,"m",f).call(this,n),this.syncFlowTheme(e(this,h,"f")[n]))},o})),Pt=a((s=>{var o,n,r,a,h,c,f,g;return g=class extends(l(Wt,b,kt,u,v,Mt,w)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),r.set(this,void 0),this.updateDeviceList=d((t=>{this.deviceList.data=t}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),this.deviceList=new j((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield e(this,o,"m",f).call(this),e(this,o,"m",c).call(this,lt(this.state)),e(this,o,"m",a).call(this),this.subscribe(this.updateDeviceList.bind(this),lt))}))}},n=new WeakMap,r=new WeakMap,o=new WeakSet,a=function(){this.deviceList.flowId&&(i(this,n,this.createModal({"data-id":"untrust-device"}),"f"),i(this,r,new R((()=>{var t;return null===(t=e(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,n,"f").afterClose=()=>e(this,o,"m",h).call(this,""),this.syncFlowTheme(e(this,r,"f")))},h=function(t=""){e(this,n,"f").setContent(O({projectId:this.projectId,flowId:this.deviceList.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:{deviceId:t}})),e(this,r,"f").onSuccess((()=>{e(this,n,"f").close(),this.actions.listDevices({userId:_(this.state)})}))},c=function(t){this.deviceList.onRemoveDeviceClick((({id:t})=>{var i;e(this,o,"m",h).call(this,t),null===(i=e(this,n,"f"))||void 0===i||i.open()})),this.deviceList.data=t},f=function(){return t(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:_(this.state)})}))},g}));const $t={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},Bt=a((i=>{var s,o,n,r,a;return a=class extends(l(u,kt,I,p)(i)){constructor(){super(...arguments),s.add(this),r.set(this,d((t=>{t.length&&(t.forEach((({type:t,msg:i})=>{const r=e(this,s,"m",n).call(this,t);r.setContent(e(this,s,"m",o).call(this,{type:t,msg:i})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),this.subscribe(e(this,r,"f").bind(this),dt)}))}},r=new WeakMap,s=new WeakSet,o=function({type:t,msg:e}){const i=$t[t],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)||""}${e}${s.outerHTML}`},n=function(t){return this.createNotification({mode:t,duration:"error"===t?0:3e3,position:"bottom-start",size:"sm"})},a})),Ht=a((s=>{var o,n,r,a,d,h,c,f,v,g,m;return m=class extends(l(kt,u,Mt)(s)){constructor(){super(...arguments),o.add(this),n.set(this,null),a.set(this,(e=>t(this,void 0,void 0,(function*(){const t=e.target.value;yield this.actions.selectTenant(t)})))),d.set(this,(t=>{const s=ct(t);this.tenantSelector.value!==s&&e(this,o,"m",v).call(this,s);const{loading:r,error:a}=t.selectTenant,l=null!==t.tenant.previousTenantId,d=s!==e(this,n,"f");!s||r||a||l||!d||(i(this,n,s,"f"),e(this,o,"m",h).call(this))}))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),this.actions.setCurrentTenantId((()=>{const t=L();return G(t)})()),e(this,o,"m",r).call(this),e(this,o,"m",g).call(this),e(this,o,"m",f).call(this,ht(this.state)),this.subscribe(e(this,d,"f").bind(this))}))}},n=new WeakMap,a=new WeakMap,d=new WeakMap,o=new WeakSet,r=function(){this.tenantSelector=new N((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(e(this,a,"f"))},h=function(){const t=ct(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:t}})),this.tenantSelector.shouldReload&&e(this,o,"m",c).call(this)},c=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},f=function(e){return t(this,void 0,void 0,(function*(){const t=e.map((t=>({label:t.tenantName||t.tenantId,value:t.tenantId})));yield this.tenantSelector.setData(t)}))},v=function(t){t&&(this.tenantSelector.value=t)},g=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{e(this,o,"m",v).call(this,ct(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},m})),Vt=a((e=>class extends(l(S,b,St,qt,Tt,At,Nt,Lt,xt,Ft,Et,Ot,jt,Pt,Bt,Ht)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Zt=l((e=>class extends(Vt(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((t=>t.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.9.4"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",Zt);export{Zt as default};
6
6
  //# sourceMappingURL=index.js.map