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