New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@descope/user-profile-widget

Package Overview
Dependencies
Maintainers
4
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@descope/user-profile-widget - npm Package Compare versions

Comparing version 0.2.10 to 0.2.11

4

dist/cjs/index.js
/**
* @descope/user-profile-widget v0.2.10
* @descope/user-profile-widget v0.2.11
*/
"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");require("@descope/core-js-sdk");var l=require("@descope/web-js-sdk"),r=require("reselect");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),s)})),i};function d(e){return new URLSearchParams(window.location.search).get(e)}const n=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},c=a.createAsyncThunk("users/me",((e,{extra:{api:t}})=>t.user.me())),h=n(c)({onFulfilled:(e,t)=>{e.me.data=t.payload}},(v=e=>e.me,{onFulfilled:e=>{v(e).loading=!1},onPending:e=>{v(e).loading=!0,v(e).error=null},onRejected:(e,t)=>{v(e).loading=!1,v(e).error=t.error}}));var v;const u={action:c,reducer:h},_=a.createAsyncThunk("users/logout",((e,{extra:{api:t}})=>t.user.logout())),g={action:_,reducer:n(_)({})},f={me:{loading:!1,error:null,data:{}}},p={me:"/v1/auth/me"},w=()=>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:[],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})}))})),F=({httpClient:t,mock:i})=>({me:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i)return w();const s=yield t.get(p.me);return yield(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)})))(s),s.json()}))}),m=t.createSingletonMixin((s=>{var a,r,o,d;const n=t.compose(i.projectIdMixin,i.observeAttributesMixin,i.loggerMixin,i.baseUrlMixin)(s);return d=class extends n{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 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.2.10"}}));return{user:Object.assign(Object.assign({},F({httpClient:a.httpClient,mock:i})),{logout:i?()=>e.__awaiter(void 0,void 0,void 0,(function*(){})):a.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl},"true"===this.mock,this.widgetId),"f")},d})),P=t.createSingletonMixin((e=>{const s=t.compose(i.createStateManagementMixin({name:"widget",initialState:f,reducers:{},extraReducers:e=>{u.reducer(e),g.reducer(e)},asyncActions:{getMe:u.action,logout:g.action}}),i.initLifecycleMixin,i.loggerMixin,m)(e);return class extends s{constructor(...e){super(...e),this.state=f,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),b="widget-flow",G=t.createSingletonMixin((a=>{var l,r,n;return n=class extends(t.compose(i.initLifecycleMixin,i.modalMixin,P,i.loggerMixin)(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=d(b);s&&(!function(e){if(window.history.replaceState&&d(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())}}(b),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}));new s.FlowDriver((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},n})),M=e=>e.me.data,S=r.createSelector(M,(e=>e.picture)),y=r.createSelector(M,(e=>e.email)),U=r.createSelector(M,(e=>e.verifiedEmail)),R=r.createSelector(M,(e=>e.name)),x=r.createSelector(M,(e=>e.phone)),k=r.createSelector(M,(e=>e.verifiedPhone)),W=r.createSelector(M,(e=>e.webauthn));r.createSelector(M,(e=>e.password));const A=r.createSelector(M,(e=>e.customAttributes)),I=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}))}}})),C=t.createSingletonMixin((s=>{var a,l,r;return r=class extends(t.compose(i.loggerMixin,i.initLifecycleMixin,i.descopeUiMixin,i.initElementMixin,I,P)(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 Promise.all([this.actions.getMe(),e.__classPrivateFieldGet(this,a,"m",l).call(this)]),this.onWidgetRootReady()}))}},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})),j=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}))}})),T=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v,u,_;return _=class extends(t.compose(j,i.themeMixin,P,i.loggerMixin,C,i.modalMixin,i.baseStaticUrlMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),d.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",n).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,S(this.state)),e.__classPrivateFieldGet(this,u,"f").call(this,R(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),S),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),R)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,u=new WeakMap,l=new WeakSet,n=function(){this.avatar.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"update-pic"}),"f"),e.__classPrivateFieldSet(this,d,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,d,"f")))},c=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,d,"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()}))},_})),q=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v,u,_,g,f,p,w;return w=class extends(t.compose(j,P,i.loggerMixin,C,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),d.set(this,void 0),n.set(this,void 0),c.set(this,void 0),f.set(this,t.withMemCache((e=>{this.emailUserAttr.value=e}))),p.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",g).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,y(this.state)),e.__classPrivateFieldGet(this,p,"f").call(this,U(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),y),this.subscribe(e.__classPrivateFieldGet(this,p,"f").bind(this),U)}))}},r=new WeakMap,d=new WeakMap,n=new WeakMap,c=new WeakMap,f=new WeakMap,p=new WeakMap,l=new WeakSet,h=function(){this.emailUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-email"}),"f"),e.__classPrivateFieldSet(this,d,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,d,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.emailUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-email"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,n,"f").setContent(o({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},g=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,n,"f"))||void 0===t||t.open()}))},w})),D=t.createSingletonMixin((a=>{var l,r,o;return o=class extends(t.compose(P,i.loggerMixin,C,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})),E=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v,u,_,g,f,p;return p=class extends(t.compose(j,P,i.loggerMixin,C,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),d.set(this,void 0),n.set(this,void 0),c.set(this,void 0),f.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",g).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,R(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),R)}))}},r=new WeakMap,d=new WeakMap,n=new WeakMap,c=new WeakMap,f=new WeakMap,l=new WeakSet,h=function(){this.nameUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-name"}),"f"),e.__classPrivateFieldSet(this,d,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,d,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.nameUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-name"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,n,"f").setContent(o({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},g=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,n,"f"))||void 0===t||t.open()}))},p})),O=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v,u;return u=class extends(t.compose(j,P,i.loggerMixin,C,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),d.set(this,void 0),v.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",h).call(this),e.__classPrivateFieldGet(this,l,"m",n).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,W(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),W)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,l=new WeakSet,n=function(){this.passkeyUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"passkey"}),"f"),e.__classPrivateFieldSet(this,d,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,d,"f")))},c=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},h=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.onButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()}))},u})),L=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v;return v=class extends(t.compose(j,P,i.loggerMixin,C,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),d.set(this,void 0)}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",n).call(this)}))}},r=new WeakMap,d=new WeakMap,l=new WeakSet,n=function(){this.passwordUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"password"}),"f"),e.__classPrivateFieldSet(this,d,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,d,"f")))},c=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close()}))},h=function(){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.onButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()}))},v})),N=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v,u,_,g,f,p,w;return w=class extends(t.compose(j,P,i.loggerMixin,C,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),d.set(this,void 0),n.set(this,void 0),c.set(this,void 0),f.set(this,t.withMemCache((e=>{this.phoneUserAttr.value=e}))),p.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",g).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,x(this.state)),e.__classPrivateFieldGet(this,p,"f").call(this,k(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),x),this.subscribe(e.__classPrivateFieldGet(this,p,"f").bind(this),k)}))}},r=new WeakMap,d=new WeakMap,n=new WeakMap,c=new WeakMap,f=new WeakMap,p=new WeakMap,l=new WeakSet,h=function(){this.phoneUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-phone"}),"f"),e.__classPrivateFieldSet(this,d,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,d,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.phoneUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-phone"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,n,"f").setContent(o({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},g=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,n,"f"))||void 0===t||t.open()}))},w}));var $;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}($||($={}));const B=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v,u,_,g,f;return r=class extends(t.compose(j,P,i.loggerMixin,C,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),d.set(this,{}),n.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")||$.TEXT,d=t[a],n=new s.UserAttributeDriver(i,{logger:this.logger});n.value=r.getFormattedValue(o,d),e.__classPrivateFieldGet(this,l,"m",g).call(this,i,a,n),e.__classPrivateFieldGet(this,l,"m",f).call(this,i,a,n)}))})))}static getFormattedValue(e,t){return e===$.DATE&&t?new Date(t).toLocaleString():e===$.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,A(this.state)),this.subscribe(e.__classPrivateFieldGet(this,_,"f").bind(this),A)}))}},d=new WeakMap,n=new WeakMap,c=new WeakMap,h=new WeakMap,_=new WeakMap,l=new WeakSet,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})),null===(s=e.__classPrivateFieldGet(this,n,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},u=function(t){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})),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()}))},g=function(t,i,a){const r=t.getAttribute("edit-flow-id");r&&(e.__classPrivateFieldGet(this,d,"f")[r]=this.createModal({"data-id":`edit-${i}`}),e.__classPrivateFieldGet(this,n,"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.onEditClick((()=>{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,n,"f")[r]))},f=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})),V=t.createSingletonMixin((s=>class extends(t.compose(i.debuggerMixin,i.themeMixin,G,B,q,T,E,N,O,L,D)(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)}))}})),H=t.compose((t=>class extends(V(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.2.10"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",H),module.exports=H;
"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");require("@descope/core-js-sdk");var l=require("@descope/web-js-sdk"),r=require("reselect");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),s)})),i};function d(e){return new URLSearchParams(window.location.search).get(e)}const n=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},c=a.createAsyncThunk("users/me",((e,{extra:{api:t}})=>t.user.me())),h=n(c)({onFulfilled:(e,t)=>{e.me.data=t.payload}},(v=e=>e.me,{onFulfilled:e=>{v(e).loading=!1},onPending:e=>{v(e).loading=!0,v(e).error=null},onRejected:(e,t)=>{v(e).loading=!1,v(e).error=t.error}}));var v;const u={action:c,reducer:h},_=a.createAsyncThunk("users/logout",((e,{extra:{api:t}})=>t.user.logout())),g={action:_,reducer:n(_)({})},f={me:{loading:!1,error:null,data:{}}},p={me:"/v1/auth/me"},w=()=>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:[],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})}))})),F=({httpClient:t,mock:i})=>({me:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i)return w();const s=yield t.get(p.me);return yield(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)})))(s),s.json()}))}),m=t.createSingletonMixin((s=>{var a,r,o,d;const n=t.compose(i.projectIdMixin,i.observeAttributesMixin,i.loggerMixin,i.baseUrlMixin)(s);return d=class extends n{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 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.2.11"}}));return{user:Object.assign(Object.assign({},F({httpClient:a.httpClient,mock:i})),{logout:i?()=>e.__awaiter(void 0,void 0,void 0,(function*(){})):a.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl},"true"===this.mock,this.widgetId),"f")},d})),P=t.createSingletonMixin((e=>{const s=t.compose(i.createStateManagementMixin({name:"widget",initialState:f,reducers:{},extraReducers:e=>{u.reducer(e),g.reducer(e)},asyncActions:{getMe:u.action,logout:g.action}}),i.initLifecycleMixin,i.loggerMixin,m)(e);return class extends s{constructor(...e){super(...e),this.state=f,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),b="widget-flow",G=t.createSingletonMixin((a=>{var l,r,n;return n=class extends(t.compose(i.initLifecycleMixin,i.modalMixin,P,i.loggerMixin)(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=d(b);s&&(!function(e){if(window.history.replaceState&&d(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())}}(b),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}));new s.FlowDriver((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},n})),M=e=>e.me.data,S=r.createSelector(M,(e=>e.picture)),y=r.createSelector(M,(e=>e.email)),U=r.createSelector(M,(e=>e.verifiedEmail)),R=r.createSelector(M,(e=>e.name)),x=r.createSelector(M,(e=>e.phone)),k=r.createSelector(M,(e=>e.verifiedPhone)),W=r.createSelector(M,(e=>e.webauthn));r.createSelector(M,(e=>e.password));const A=r.createSelector(M,(e=>e.customAttributes)),I=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}))}}})),C=t.createSingletonMixin((s=>{var a,l,r;return r=class extends(t.compose(i.loggerMixin,i.initLifecycleMixin,i.descopeUiMixin,i.initElementMixin,I,P)(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 Promise.all([this.actions.getMe(),e.__classPrivateFieldGet(this,a,"m",l).call(this)]),this.onWidgetRootReady()}))}},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})),j=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}))}})),T=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v,u,_;return _=class extends(t.compose(j,i.themeMixin,P,i.loggerMixin,C,i.modalMixin,i.baseStaticUrlMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),d.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",n).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,S(this.state)),e.__classPrivateFieldGet(this,u,"f").call(this,R(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),S),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),R)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,u=new WeakMap,l=new WeakSet,n=function(){this.avatar.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"update-pic"}),"f"),e.__classPrivateFieldSet(this,d,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,d,"f")))},c=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,d,"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()}))},_})),q=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v,u,_,g,f,p,w;return w=class extends(t.compose(j,P,i.loggerMixin,C,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),d.set(this,void 0),n.set(this,void 0),c.set(this,void 0),f.set(this,t.withMemCache((e=>{this.emailUserAttr.value=e}))),p.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",g).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,y(this.state)),e.__classPrivateFieldGet(this,p,"f").call(this,U(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),y),this.subscribe(e.__classPrivateFieldGet(this,p,"f").bind(this),U)}))}},r=new WeakMap,d=new WeakMap,n=new WeakMap,c=new WeakMap,f=new WeakMap,p=new WeakMap,l=new WeakSet,h=function(){this.emailUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-email"}),"f"),e.__classPrivateFieldSet(this,d,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,d,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.emailUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-email"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,n,"f").setContent(o({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},g=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,n,"f"))||void 0===t||t.open()}))},w})),D=t.createSingletonMixin((a=>{var l,r,o;return o=class extends(t.compose(P,i.loggerMixin,C,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})),E=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v,u,_,g,f,p;return p=class extends(t.compose(j,P,i.loggerMixin,C,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),d.set(this,void 0),n.set(this,void 0),c.set(this,void 0),f.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",g).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,R(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),R)}))}},r=new WeakMap,d=new WeakMap,n=new WeakMap,c=new WeakMap,f=new WeakMap,l=new WeakSet,h=function(){this.nameUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-name"}),"f"),e.__classPrivateFieldSet(this,d,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,d,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.nameUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-name"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,n,"f").setContent(o({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},g=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,n,"f"))||void 0===t||t.open()}))},p})),O=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v,u;return u=class extends(t.compose(j,P,i.loggerMixin,C,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),d.set(this,void 0),v.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",h).call(this),e.__classPrivateFieldGet(this,l,"m",n).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,W(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),W)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,l=new WeakSet,n=function(){this.passkeyUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"passkey"}),"f"),e.__classPrivateFieldSet(this,d,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,d,"f")))},c=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},h=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.onButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()}))},u})),L=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v;return v=class extends(t.compose(j,P,i.loggerMixin,C,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),d.set(this,void 0)}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",n).call(this)}))}},r=new WeakMap,d=new WeakMap,l=new WeakSet,n=function(){this.passwordUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"password"}),"f"),e.__classPrivateFieldSet(this,d,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,d,"f")))},c=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close()}))},h=function(){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.onButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()}))},v})),N=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v,u,_,g,f,p,w;return w=class extends(t.compose(j,P,i.loggerMixin,C,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),r.set(this,void 0),d.set(this,void 0),n.set(this,void 0),c.set(this,void 0),f.set(this,t.withMemCache((e=>{this.phoneUserAttr.value=e}))),p.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",g).call(this),e.__classPrivateFieldGet(this,l,"m",h).call(this),e.__classPrivateFieldGet(this,l,"m",u).call(this),e.__classPrivateFieldGet(this,f,"f").call(this,x(this.state)),e.__classPrivateFieldGet(this,p,"f").call(this,k(this.state)),this.subscribe(e.__classPrivateFieldGet(this,f,"f").bind(this),x),this.subscribe(e.__classPrivateFieldGet(this,p,"f").bind(this),k)}))}},r=new WeakMap,d=new WeakMap,n=new WeakMap,c=new WeakMap,f=new WeakMap,p=new WeakMap,l=new WeakSet,h=function(){this.phoneUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-phone"}),"f"),e.__classPrivateFieldSet(this,d,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,d,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.phoneUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-phone"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,l,"m",_).bind(this),e.__classPrivateFieldGet(this,l,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,n,"f").setContent(o({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},g=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,n,"f"))||void 0===t||t.open()}))},w}));var $;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}($||($={}));const B=t.createSingletonMixin((a=>{var l,r,d,n,c,h,v,u,_,g,f;return r=class extends(t.compose(j,P,i.loggerMixin,C,i.modalMixin)(a)){constructor(){super(...arguments),l.add(this),d.set(this,{}),n.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")||$.TEXT,d=t[a],n=new s.UserAttributeDriver(i,{logger:this.logger});n.value=r.getFormattedValue(o,d),e.__classPrivateFieldGet(this,l,"m",g).call(this,i,a,n),e.__classPrivateFieldGet(this,l,"m",f).call(this,i,a,n)}))})))}static getFormattedValue(e,t){return e===$.DATE&&t?new Date(t).toLocaleString():e===$.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,A(this.state)),this.subscribe(e.__classPrivateFieldGet(this,_,"f").bind(this),A)}))}},d=new WeakMap,n=new WeakMap,c=new WeakMap,h=new WeakMap,_=new WeakMap,l=new WeakSet,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})),null===(s=e.__classPrivateFieldGet(this,n,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},u=function(t){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})),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()}))},g=function(t,i,a){const r=t.getAttribute("edit-flow-id");r&&(e.__classPrivateFieldGet(this,d,"f")[r]=this.createModal({"data-id":`edit-${i}`}),e.__classPrivateFieldGet(this,n,"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.onEditClick((()=>{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,n,"f")[r]))},f=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})),V=t.createSingletonMixin((s=>class extends(t.compose(i.debuggerMixin,i.themeMixin,G,B,q,T,E,N,O,L,D)(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)}))}})),H=t.compose((t=>class extends(V(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.2.11"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",H),module.exports=H;
//# sourceMappingURL=index.js.map
/**
* @descope/user-profile-widget v0.2.10
* @descope/user-profile-widget v0.2.11
*/
import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createTemplate as s,kebabCase as o,createSingletonMixin as r,compose as n,withMemCache as a}from"@descope/sdk-helpers";import{projectIdMixin as l,observeAttributesMixin as d,loggerMixin as h,baseUrlMixin as c,createStateManagementMixin as u,initLifecycleMixin as f,modalMixin as v,staticResourcesMixin as g,createValidateAttributesMixin as p,descopeUiMixin as w,initElementMixin as m,themeMixin as b,baseStaticUrlMixin as y,debuggerMixin as U}from"@descope/sdk-mixins";import{FlowDriver as R,AvatarDriver as S,UserAttributeDriver as W,ButtonDriver as k,UserAuthMethodDriver as M}from"@descope/sdk-component-drivers";import{createAsyncThunk as I}from"@reduxjs/toolkit";import"@descope/core-js-sdk";import A from"@descope/web-js-sdk";import{createSelector as j}from"reselect";import"@descope/web-component";const C=(t={})=>{const e=s("<descope-wc></descope-wc>");return Object.entries(t).forEach((([t,i])=>{e.content.querySelector("descope-wc").setAttribute(o(t),i)})),e};function x(t){return new URLSearchParams(window.location.search).get(t)}const F=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)}))}))},T=I("users/me",((t,{extra:{api:e}})=>e.user.me())),E=F(T)({onFulfilled:(t,e)=>{t.me.data=e.payload}},(O=t=>t.me,{onFulfilled:t=>{O(t).loading=!1},onPending:t=>{O(t).loading=!0,O(t).error=null},onRejected:(t,e)=>{O(t).loading=!1,O(t).error=e.error}}));var O;const q={action:T,reducer:E},P=I("users/logout",((t,{extra:{api:e}})=>e.user.logout())),L={action:P,reducer:F(P)({})},N={me:{loading:!1,error:null,data:{}}},D={me:"/v1/auth/me"},$=()=>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:[],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})}))})),B=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return $();const s=yield e.get(D.me);return yield(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)})))(s),s.json()}))}),H=r((s=>{var o,r,a,u;const f=n(l,d,h,c)(s);return u=class extends f{constructor(){super(...arguments),o.add(this),r.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return e(this,r,"f")||e(this,o,"m",a).call(this),e(this,r,"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,r,"f")&&e(this,o,"m",a).call(this)}))}))}},r=new WeakMap,o=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,r,((e,i,s)=>{const o=A(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.2.10"}}));return{user:Object.assign(Object.assign({},B({httpClient:o.httpClient,mock:i})),{logout:i?()=>t(void 0,void 0,void 0,(function*(){})):o.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl},"true"===this.mock,this.widgetId),"f")},u})),V=r((t=>{const e=n(u({name:"widget",initialState:N,reducers:{},extraReducers:t=>{q.reducer(t),L.reducer(t)},asyncActions:{getMe:q.action,logout:L.action}}),f,h,H)(t);return class extends e{constructor(...t){super(...t),this.state=N,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),X="widget-flow",G=r((i=>{var s,o,r;return r=class extends(n(f,v,V,h)(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 r=x(X);r&&(!function(t){if(window.history.replaceState&&x(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())}}(X),e(this,s,"m",o).call(this,r))}))}},s=new WeakSet,o=function(t){const e=this.createModal({"data-id":"redirect-flow"});e.setContent(C({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl}));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()},r})),J=t=>t.me.data,Y=j(J,(t=>t.picture)),_=j(J,(t=>t.email)),z=j(J,(t=>t.verifiedEmail)),K=j(J,(t=>t.name)),Q=j(J,(t=>t.phone)),Z=j(J,(t=>t.verifiedPhone)),tt=j(J,(t=>t.webauthn));j(J,(t=>t.password));const et=j(J,(t=>t.customAttributes)),it=r((e=>{const i=n(g,p({"widget-id":p.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}))}}})),st=r((i=>{var o,r,a;return a=class extends(n(h,f,w,m,it,V)(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 Promise.all([this.actions.getMe(),e(this,o,"m",r).call(this)]),this.onWidgetRootReady()}))}},o=new WeakSet,r=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))}))},a})),ot=r((t=>class extends(n(b,d)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}})),rt=r((s=>{var o,r,l,d,c,u,f,g,p;return p=class extends(n(ot,b,V,h,st,v,y)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),l.set(this,void 0),f.set(this,a((t=>{this.avatar.image=t}))),g.set(this,a((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",u).call(this),e(this,o,"m",d).call(this),e(this,f,"f").call(this,Y(this.state)),e(this,g,"f").call(this,K(this.state)),this.subscribe(e(this,f,"f").bind(this),Y),this.subscribe(e(this,g,"f").bind(this),K)}))}},r=new WeakMap,l=new WeakMap,f=new WeakMap,g=new WeakMap,o=new WeakSet,d=function(){this.avatar.flowId&&(i(this,r,this.createModal({"data-id":"update-pic"}),"f"),i(this,l,new R((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",c).bind(this),e(this,o,"m",c).call(this),this.syncFlowTheme(e(this,l,"f")))},c=function(){e(this,r,"f").setContent(C({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,l,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new S((()=>{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,r,"f"))||void 0===t||t.open()}))},p})),nt=r((s=>{var o,r,l,d,c,u,f,g,p,w,m,b,y;return y=class extends(n(ot,V,h,st,v)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),l.set(this,void 0),d.set(this,void 0),c.set(this,void 0),m.set(this,a((t=>{this.emailUserAttr.value=t}))),b.set(this,a((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",w).call(this),e(this,o,"m",u).call(this),e(this,o,"m",g).call(this),e(this,m,"f").call(this,_(this.state)),e(this,b,"f").call(this,z(this.state)),this.subscribe(e(this,m,"f").bind(this),_),this.subscribe(e(this,b,"f").bind(this),z)}))}},r=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakMap,m=new WeakMap,b=new WeakMap,o=new WeakSet,u=function(){this.emailUserAttr.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-email"}),"f"),i(this,l,new R((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,l,"f")))},f=function(){e(this,r,"f").setContent(C({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,l,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-email"}),"f"),i(this,c,new R((()=>{var t;return null===(t=e(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,d,"f").afterClose=e(this,o,"m",p).bind(this),e(this,o,"m",p).call(this),this.syncFlowTheme(e(this,c,"f")))},p=function(){e(this,d,"f").setContent(C({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,c,"f").onSuccess((()=>{e(this,d,"f").close(),this.actions.getMe()}))},w=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,r,"f"))||void 0===t||t.open()})),this.emailUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,d,"f"))||void 0===t||t.open()}))},y})),at=r((i=>{var s,o,r;return r=class extends(n(V,h,st,v)(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 k((()=>{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"))}))))},r})),lt=r((s=>{var o,r,l,d,c,u,f,g,p,w,m,b;return b=class extends(n(ot,V,h,st,v)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),l.set(this,void 0),d.set(this,void 0),c.set(this,void 0),m.set(this,a((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",w).call(this),e(this,o,"m",u).call(this),e(this,o,"m",g).call(this),e(this,m,"f").call(this,K(this.state)),this.subscribe(e(this,m,"f").bind(this),K)}))}},r=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakMap,m=new WeakMap,o=new WeakSet,u=function(){this.nameUserAttr.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-name"}),"f"),i(this,l,new R((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,l,"f")))},f=function(){e(this,r,"f").setContent(C({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,l,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-name"}),"f"),i(this,c,new R((()=>{var t;return null===(t=e(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,d,"f").afterClose=e(this,o,"m",p).bind(this),e(this,o,"m",p).call(this),this.syncFlowTheme(e(this,c,"f")))},p=function(){e(this,d,"f").setContent(C({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,c,"f").onSuccess((()=>{e(this,d,"f").close(),this.actions.getMe()}))},w=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,r,"f"))||void 0===t||t.open()})),this.nameUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,d,"f"))||void 0===t||t.open()}))},b})),dt=r((s=>{var o,r,l,d,c,u,f,g;return g=class extends(n(ot,V,h,st,v)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),l.set(this,void 0),f.set(this,a((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",u).call(this),e(this,o,"m",d).call(this),e(this,f,"f").call(this,tt(this.state)),this.subscribe(e(this,f,"f").bind(this),tt)}))}},r=new WeakMap,l=new WeakMap,f=new WeakMap,o=new WeakSet,d=function(){this.passkeyUserAuthMethod.flowId&&(i(this,r,this.createModal({"data-id":"passkey"}),"f"),i(this,l,new R((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",c).bind(this),e(this,o,"m",c).call(this),this.syncFlowTheme(e(this,l,"f")))},c=function(){e(this,r,"f").setContent(C({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,l,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.passkeyUserAuthMethod=new M((()=>{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.onButtonClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},g})),ht=r((s=>{var o,r,a,l,d,c,u;return u=class extends(n(ot,V,h,st,v)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),a.set(this,void 0)}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",l).call(this)}))}},r=new WeakMap,a=new WeakMap,o=new WeakSet,l=function(){this.passwordUserAuthMethod.flowId&&(i(this,r,this.createModal({"data-id":"password"}),"f"),i(this,a,new R((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",d).bind(this),e(this,o,"m",d).call(this),this.syncFlowTheme(e(this,a,"f")))},d=function(){e(this,r,"f").setContent(C({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,a,"f").onSuccess((()=>{e(this,r,"f").close()}))},c=function(){this.passwordUserAuthMethod=new M((()=>{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.onButtonClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},u})),ct=r((s=>{var o,r,l,d,c,u,f,g,p,w,m,b,y;return y=class extends(n(ot,V,h,st,v)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),l.set(this,void 0),d.set(this,void 0),c.set(this,void 0),m.set(this,a((t=>{this.phoneUserAttr.value=t}))),b.set(this,a((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",w).call(this),e(this,o,"m",u).call(this),e(this,o,"m",g).call(this),e(this,m,"f").call(this,Q(this.state)),e(this,b,"f").call(this,Z(this.state)),this.subscribe(e(this,m,"f").bind(this),Q),this.subscribe(e(this,b,"f").bind(this),Z)}))}},r=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakMap,m=new WeakMap,b=new WeakMap,o=new WeakSet,u=function(){this.phoneUserAttr.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-phone"}),"f"),i(this,l,new R((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,l,"f")))},f=function(){e(this,r,"f").setContent(C({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,l,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-phone"}),"f"),i(this,c,new R((()=>{var t;return null===(t=e(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,d,"f").afterClose=e(this,o,"m",p).bind(this),e(this,o,"m",p).call(this),this.syncFlowTheme(e(this,c,"f")))},p=function(){e(this,d,"f").setContent(C({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,c,"f").onSuccess((()=>{e(this,d,"f").close(),this.actions.getMe()}))},w=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,r,"f"))||void 0===t||t.open()})),this.phoneUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,d,"f"))||void 0===t||t.open()}))},y}));var ut;!function(t){t.TEXT="text",t.NUMBER="number",t.BOOLEAN="boolean",t.SINGLE_SELECT="singleSelect",t.ARRAY="array",t.DATE="date"}(ut||(ut={}));const ft=r((i=>{var s,o,r,l,d,c,u,f,g,p,w;return o=class extends(n(ot,V,h,st,v)(i)){constructor(){super(...arguments),s.add(this),r.set(this,{}),l.set(this,{}),d.set(this,{}),c.set(this,{}),g.set(this,a((t=>{var i;const r=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(r).forEach((i=>{const r=i.getAttribute("data-id").replace("customAttributes.",""),n=i.getAttribute("data-type")||ut.TEXT,a=t[r],l=new W(i,{logger:this.logger});l.value=o.getFormattedValue(n,a),e(this,s,"m",p).call(this,i,r,l),e(this,s,"m",w).call(this,i,r,l)}))})))}static getFormattedValue(t,e){return t===ut.DATE&&e?new Date(e).toLocaleString():t===ut.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,et(this.state)),this.subscribe(e(this,g,"f").bind(this),et)}))}},r=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,s=new WeakSet,u=function(t){var i,s;null===(i=e(this,r,"f")[t])||void 0===i||i.setContent(C({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),null===(s=e(this,l,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,r,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},f=function(t){var i,s;null===(i=e(this,d,"f")[t])||void 0===i||i.setContent(C({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),null===(s=e(this,c,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,d,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},p=function(t,i,o){const n=t.getAttribute("edit-flow-id");n&&(e(this,r,"f")[n]=this.createModal({"data-id":`edit-${i}`}),e(this,l,"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",u).bind(this,n),o.onEditClick((()=>{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",u).call(this,n),this.syncFlowTheme(e(this,l,"f")[n]))},w=function(t,i,o){const r=t.getAttribute("delete-flow-id");r&&(e(this,d,"f")[r]=this.createModal({"data-id":`delete-${i}`}),e(this,c,"f")[r]=new R((()=>{var t,i;return null===(i=null===(t=e(this,d,"f")[r])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,d,"f")[r].afterClose=e(this,s,"m",f).bind(this,r),o.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,d,"f"))||void 0===t?void 0:t[r])||void 0===i||i.open()})),e(this,s,"m",f).call(this,r),this.syncFlowTheme(e(this,c,"f")[r]))},o})),vt=r((e=>class extends(n(U,b,G,ft,nt,rt,lt,ct,dt,ht,at)(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)}))}})),gt=n((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.2.10"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",gt);export{gt as default};
import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createTemplate as s,kebabCase as o,createSingletonMixin as r,compose as n,withMemCache as a}from"@descope/sdk-helpers";import{projectIdMixin as l,observeAttributesMixin as d,loggerMixin as h,baseUrlMixin as c,createStateManagementMixin as u,initLifecycleMixin as f,modalMixin as v,staticResourcesMixin as g,createValidateAttributesMixin as p,descopeUiMixin as w,initElementMixin as m,themeMixin as b,baseStaticUrlMixin as y,debuggerMixin as U}from"@descope/sdk-mixins";import{FlowDriver as R,AvatarDriver as S,UserAttributeDriver as W,ButtonDriver as k,UserAuthMethodDriver as M}from"@descope/sdk-component-drivers";import{createAsyncThunk as I}from"@reduxjs/toolkit";import"@descope/core-js-sdk";import A from"@descope/web-js-sdk";import{createSelector as j}from"reselect";import"@descope/web-component";const C=(t={})=>{const e=s("<descope-wc></descope-wc>");return Object.entries(t).forEach((([t,i])=>{e.content.querySelector("descope-wc").setAttribute(o(t),i)})),e};function x(t){return new URLSearchParams(window.location.search).get(t)}const F=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)}))}))},T=I("users/me",((t,{extra:{api:e}})=>e.user.me())),E=F(T)({onFulfilled:(t,e)=>{t.me.data=e.payload}},(O=t=>t.me,{onFulfilled:t=>{O(t).loading=!1},onPending:t=>{O(t).loading=!0,O(t).error=null},onRejected:(t,e)=>{O(t).loading=!1,O(t).error=e.error}}));var O;const q={action:T,reducer:E},P=I("users/logout",((t,{extra:{api:e}})=>e.user.logout())),L={action:P,reducer:F(P)({})},N={me:{loading:!1,error:null,data:{}}},D={me:"/v1/auth/me"},$=()=>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:[],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})}))})),B=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return $();const s=yield e.get(D.me);return yield(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)})))(s),s.json()}))}),H=r((s=>{var o,r,a,u;const f=n(l,d,h,c)(s);return u=class extends f{constructor(){super(...arguments),o.add(this),r.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return e(this,r,"f")||e(this,o,"m",a).call(this),e(this,r,"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,r,"f")&&e(this,o,"m",a).call(this)}))}))}},r=new WeakMap,o=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,r,((e,i,s)=>{const o=A(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.2.11"}}));return{user:Object.assign(Object.assign({},B({httpClient:o.httpClient,mock:i})),{logout:i?()=>t(void 0,void 0,void 0,(function*(){})):o.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl},"true"===this.mock,this.widgetId),"f")},u})),V=r((t=>{const e=n(u({name:"widget",initialState:N,reducers:{},extraReducers:t=>{q.reducer(t),L.reducer(t)},asyncActions:{getMe:q.action,logout:L.action}}),f,h,H)(t);return class extends e{constructor(...t){super(...t),this.state=N,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),X="widget-flow",G=r((i=>{var s,o,r;return r=class extends(n(f,v,V,h)(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 r=x(X);r&&(!function(t){if(window.history.replaceState&&x(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())}}(X),e(this,s,"m",o).call(this,r))}))}},s=new WeakSet,o=function(t){const e=this.createModal({"data-id":"redirect-flow"});e.setContent(C({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl}));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()},r})),J=t=>t.me.data,Y=j(J,(t=>t.picture)),_=j(J,(t=>t.email)),z=j(J,(t=>t.verifiedEmail)),K=j(J,(t=>t.name)),Q=j(J,(t=>t.phone)),Z=j(J,(t=>t.verifiedPhone)),tt=j(J,(t=>t.webauthn));j(J,(t=>t.password));const et=j(J,(t=>t.customAttributes)),it=r((e=>{const i=n(g,p({"widget-id":p.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}))}}})),st=r((i=>{var o,r,a;return a=class extends(n(h,f,w,m,it,V)(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 Promise.all([this.actions.getMe(),e(this,o,"m",r).call(this)]),this.onWidgetRootReady()}))}},o=new WeakSet,r=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))}))},a})),ot=r((t=>class extends(n(b,d)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}})),rt=r((s=>{var o,r,l,d,c,u,f,g,p;return p=class extends(n(ot,b,V,h,st,v,y)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),l.set(this,void 0),f.set(this,a((t=>{this.avatar.image=t}))),g.set(this,a((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",u).call(this),e(this,o,"m",d).call(this),e(this,f,"f").call(this,Y(this.state)),e(this,g,"f").call(this,K(this.state)),this.subscribe(e(this,f,"f").bind(this),Y),this.subscribe(e(this,g,"f").bind(this),K)}))}},r=new WeakMap,l=new WeakMap,f=new WeakMap,g=new WeakMap,o=new WeakSet,d=function(){this.avatar.flowId&&(i(this,r,this.createModal({"data-id":"update-pic"}),"f"),i(this,l,new R((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",c).bind(this),e(this,o,"m",c).call(this),this.syncFlowTheme(e(this,l,"f")))},c=function(){e(this,r,"f").setContent(C({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,l,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new S((()=>{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,r,"f"))||void 0===t||t.open()}))},p})),nt=r((s=>{var o,r,l,d,c,u,f,g,p,w,m,b,y;return y=class extends(n(ot,V,h,st,v)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),l.set(this,void 0),d.set(this,void 0),c.set(this,void 0),m.set(this,a((t=>{this.emailUserAttr.value=t}))),b.set(this,a((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",w).call(this),e(this,o,"m",u).call(this),e(this,o,"m",g).call(this),e(this,m,"f").call(this,_(this.state)),e(this,b,"f").call(this,z(this.state)),this.subscribe(e(this,m,"f").bind(this),_),this.subscribe(e(this,b,"f").bind(this),z)}))}},r=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakMap,m=new WeakMap,b=new WeakMap,o=new WeakSet,u=function(){this.emailUserAttr.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-email"}),"f"),i(this,l,new R((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,l,"f")))},f=function(){e(this,r,"f").setContent(C({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,l,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-email"}),"f"),i(this,c,new R((()=>{var t;return null===(t=e(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,d,"f").afterClose=e(this,o,"m",p).bind(this),e(this,o,"m",p).call(this),this.syncFlowTheme(e(this,c,"f")))},p=function(){e(this,d,"f").setContent(C({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,c,"f").onSuccess((()=>{e(this,d,"f").close(),this.actions.getMe()}))},w=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,r,"f"))||void 0===t||t.open()})),this.emailUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,d,"f"))||void 0===t||t.open()}))},y})),at=r((i=>{var s,o,r;return r=class extends(n(V,h,st,v)(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 k((()=>{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"))}))))},r})),lt=r((s=>{var o,r,l,d,c,u,f,g,p,w,m,b;return b=class extends(n(ot,V,h,st,v)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),l.set(this,void 0),d.set(this,void 0),c.set(this,void 0),m.set(this,a((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",w).call(this),e(this,o,"m",u).call(this),e(this,o,"m",g).call(this),e(this,m,"f").call(this,K(this.state)),this.subscribe(e(this,m,"f").bind(this),K)}))}},r=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakMap,m=new WeakMap,o=new WeakSet,u=function(){this.nameUserAttr.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-name"}),"f"),i(this,l,new R((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,l,"f")))},f=function(){e(this,r,"f").setContent(C({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,l,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-name"}),"f"),i(this,c,new R((()=>{var t;return null===(t=e(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,d,"f").afterClose=e(this,o,"m",p).bind(this),e(this,o,"m",p).call(this),this.syncFlowTheme(e(this,c,"f")))},p=function(){e(this,d,"f").setContent(C({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,c,"f").onSuccess((()=>{e(this,d,"f").close(),this.actions.getMe()}))},w=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,r,"f"))||void 0===t||t.open()})),this.nameUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,d,"f"))||void 0===t||t.open()}))},b})),dt=r((s=>{var o,r,l,d,c,u,f,g;return g=class extends(n(ot,V,h,st,v)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),l.set(this,void 0),f.set(this,a((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",u).call(this),e(this,o,"m",d).call(this),e(this,f,"f").call(this,tt(this.state)),this.subscribe(e(this,f,"f").bind(this),tt)}))}},r=new WeakMap,l=new WeakMap,f=new WeakMap,o=new WeakSet,d=function(){this.passkeyUserAuthMethod.flowId&&(i(this,r,this.createModal({"data-id":"passkey"}),"f"),i(this,l,new R((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",c).bind(this),e(this,o,"m",c).call(this),this.syncFlowTheme(e(this,l,"f")))},c=function(){e(this,r,"f").setContent(C({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,l,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.passkeyUserAuthMethod=new M((()=>{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.onButtonClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},g})),ht=r((s=>{var o,r,a,l,d,c,u;return u=class extends(n(ot,V,h,st,v)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),a.set(this,void 0)}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",l).call(this)}))}},r=new WeakMap,a=new WeakMap,o=new WeakSet,l=function(){this.passwordUserAuthMethod.flowId&&(i(this,r,this.createModal({"data-id":"password"}),"f"),i(this,a,new R((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",d).bind(this),e(this,o,"m",d).call(this),this.syncFlowTheme(e(this,a,"f")))},d=function(){e(this,r,"f").setContent(C({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,a,"f").onSuccess((()=>{e(this,r,"f").close()}))},c=function(){this.passwordUserAuthMethod=new M((()=>{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.onButtonClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},u})),ct=r((s=>{var o,r,l,d,c,u,f,g,p,w,m,b,y;return y=class extends(n(ot,V,h,st,v)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),l.set(this,void 0),d.set(this,void 0),c.set(this,void 0),m.set(this,a((t=>{this.phoneUserAttr.value=t}))),b.set(this,a((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",w).call(this),e(this,o,"m",u).call(this),e(this,o,"m",g).call(this),e(this,m,"f").call(this,Q(this.state)),e(this,b,"f").call(this,Z(this.state)),this.subscribe(e(this,m,"f").bind(this),Q),this.subscribe(e(this,b,"f").bind(this),Z)}))}},r=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakMap,m=new WeakMap,b=new WeakMap,o=new WeakSet,u=function(){this.phoneUserAttr.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-phone"}),"f"),i(this,l,new R((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",f).bind(this),e(this,o,"m",f).call(this),this.syncFlowTheme(e(this,l,"f")))},f=function(){e(this,r,"f").setContent(C({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,l,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr.deleteFlowId&&(i(this,d,this.createModal({"data-id":"delete-phone"}),"f"),i(this,c,new R((()=>{var t;return null===(t=e(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,d,"f").afterClose=e(this,o,"m",p).bind(this),e(this,o,"m",p).call(this),this.syncFlowTheme(e(this,c,"f")))},p=function(){e(this,d,"f").setContent(C({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,c,"f").onSuccess((()=>{e(this,d,"f").close(),this.actions.getMe()}))},w=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,r,"f"))||void 0===t||t.open()})),this.phoneUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,d,"f"))||void 0===t||t.open()}))},y}));var ut;!function(t){t.TEXT="text",t.NUMBER="number",t.BOOLEAN="boolean",t.SINGLE_SELECT="singleSelect",t.ARRAY="array",t.DATE="date"}(ut||(ut={}));const ft=r((i=>{var s,o,r,l,d,c,u,f,g,p,w;return o=class extends(n(ot,V,h,st,v)(i)){constructor(){super(...arguments),s.add(this),r.set(this,{}),l.set(this,{}),d.set(this,{}),c.set(this,{}),g.set(this,a((t=>{var i;const r=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(r).forEach((i=>{const r=i.getAttribute("data-id").replace("customAttributes.",""),n=i.getAttribute("data-type")||ut.TEXT,a=t[r],l=new W(i,{logger:this.logger});l.value=o.getFormattedValue(n,a),e(this,s,"m",p).call(this,i,r,l),e(this,s,"m",w).call(this,i,r,l)}))})))}static getFormattedValue(t,e){return t===ut.DATE&&e?new Date(e).toLocaleString():t===ut.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,et(this.state)),this.subscribe(e(this,g,"f").bind(this),et)}))}},r=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakMap,g=new WeakMap,s=new WeakSet,u=function(t){var i,s;null===(i=e(this,r,"f")[t])||void 0===i||i.setContent(C({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),null===(s=e(this,l,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,r,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},f=function(t){var i,s;null===(i=e(this,d,"f")[t])||void 0===i||i.setContent(C({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),null===(s=e(this,c,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,d,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},p=function(t,i,o){const n=t.getAttribute("edit-flow-id");n&&(e(this,r,"f")[n]=this.createModal({"data-id":`edit-${i}`}),e(this,l,"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",u).bind(this,n),o.onEditClick((()=>{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",u).call(this,n),this.syncFlowTheme(e(this,l,"f")[n]))},w=function(t,i,o){const r=t.getAttribute("delete-flow-id");r&&(e(this,d,"f")[r]=this.createModal({"data-id":`delete-${i}`}),e(this,c,"f")[r]=new R((()=>{var t,i;return null===(i=null===(t=e(this,d,"f")[r])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,d,"f")[r].afterClose=e(this,s,"m",f).bind(this,r),o.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,d,"f"))||void 0===t?void 0:t[r])||void 0===i||i.open()})),e(this,s,"m",f).call(this,r),this.syncFlowTheme(e(this,c,"f")[r]))},o})),vt=r((e=>class extends(n(U,b,G,ft,nt,rt,lt,ct,dt,ht,at)(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)}))}})),gt=n((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.2.11"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",gt);export{gt as default};
//# sourceMappingURL=index.js.map
{
"name": "@descope/user-profile-widget",
"version": "0.2.10",
"version": "0.2.11",
"author": "Descope Team <info@descope.com>",

@@ -73,3 +73,3 @@ "homepage": "https://github.com/descope/descope-js",

"dependencies": {
"tslib": "2.6.3",
"tslib": "2.8.1",
"reselect": "5.1.1",

@@ -80,7 +80,7 @@ "@reduxjs/toolkit": "^2.0.1",

"immer": "^10.0.3",
"@descope/web-js-sdk": "1.23.2",
"@descope/web-component": "3.32.4",
"@descope/sdk-component-drivers": "0.2.43",
"@descope/sdk-mixins": "0.6.1",
"@descope/sdk-helpers": "0.1.60"
"@descope/web-js-sdk": "1.23.3",
"@descope/web-component": "3.32.5",
"@descope/sdk-mixins": "0.6.2",
"@descope/sdk-helpers": "0.1.61",
"@descope/sdk-component-drivers": "0.2.44"
},

@@ -87,0 +87,0 @@ "optionalDependencies": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc