@descope/tenant-profile-widget 0.8.2 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**
3
- * @descope/tenant-profile-widget v0.8.2
3
+ * @descope/tenant-profile-widget v0.8.4
4
4
  */
5
- "use strict";var e=require("tslib"),t=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins"),s=require("reselect"),n=require("@descope/sdk-component-drivers"),a=require("@reduxjs/toolkit");require("@descope/core-js-sdk");var o=require("@descope/web-js-sdk");require("@descope/web-component");const l=e=>e.tenant.data,r=e=>e.tenantAdminLinkSSO.data.defaultLink,d=s.createSelector(l,(e=>e.customAttributes||{})),c=s.createSelector(l,(e=>e.name||"")),h=s.createSelector(l,(e=>e.selfProvisioningDomains||[])),v=s.createSelector(l,(e=>e.enforceSSOExclusions||[])),u=s.createSelector(l,(e=>e.enforceSSO||!1)),_=s.createSelector(l,r,(e=>e.tenantAdminLinkSSO.data.ssoIdToLink),((e,t,i)=>[...e?[{id:"",name:"Default SSO Configuration",authType:e.authType,isDefault:!0,link:t}]:[],...((null==e?void 0:e.additionalSSOConfigs)||[]).map((({ssoId:e,name:t,authType:s})=>({id:e,name:t,authType:s,link:i[e]||""})))])),f=s.createSelector(l,(e=>((null==e?void 0:e.additionalSSOConfigs)||[]).map((({ssoId:e})=>e))));function g(e){return new URLSearchParams(window.location.search).get(e)}const m=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)}))}))},w=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}}),F=a.createAsyncThunk("users/me",((e,{extra:{api:t}})=>t.user.me())),p=m(F)({onFulfilled:(e,t)=>{e.me.data=t.payload}},w((e=>e.me))),P={action:F,reducer:p},S=a.createAsyncThunk("tenant/details",((e,{extra:{api:t}})=>t.tenant.details())),y=m(S)({onFulfilled:(e,t)=>{e.tenant.data=t.payload}},w((e=>e.tenant))),G={action:S,reducer:y},M=a.createAsyncThunk("tenant/adminLinkSso",(({ssoIds:e},{extra:{api:t}})=>t.tenant.adminLinkSso({ssoIds:e}))),x={action:M,reducer:m(M)({onFulfilled:(e,t)=>{var i;e.tenantAdminLinkSSO.data=null!==(i=t.payload)&&void 0!==i?i:{defaultLink:"",ssoIdToLink:{}}}},w((e=>e.tenantAdminLinkSSO)))},k={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:{defaultLink:"",ssoIdToLink:{}}}},b={me:"/v1/auth/me"},R={details:"/v1/mgmt/tenant",adminLinkSso:"/v1/mgmt/tenant/adminlinks/sso/authenticated/batch"},T=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)})),I=()=>e.__awaiter(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),D=()=>e.__awaiter(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({tenantId:"tenant-1",roleNames:["admin"],id:"tenant-1",name:"Test Tenant",selfProvisioningDomains:["example1.com","example2.com"],customAttributes:{},authType:"password",domains:[],createdTime:Date.now(),disabled:!1,enforceSSO:!0})}))})),W=()=>e.__awaiter(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({defaultLink:"_blank",ssoIdToLink:{"okta-prod":"_blank?ssoId=okta-prod","entra-eu":"_blank?ssoId=entra-eu"}})}))})),C=({httpClient:t,tenantId:i,mock:s})=>{const n=encodeURIComponent(i||""),a=`?tenant=${n}&id=${n}`;return{details:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(s)return D();if(!i)throw new Error("tenantId is not defined");const e=`${R.details}${a}`,n=yield t.get(e);yield T(n);return yield n.json()})),adminLinkSso:a=>e.__awaiter(void 0,[a],void 0,(function*({ssoIds:e}){if(s)return W();if(!i)throw new Error("tenantId is not defined");const a=yield t.post(`${R.adminLinkSso}?tenant=${n}`,{tenantId:n,ssoIds:e},{headers:{"Content-Type":"application/json"}});yield T(a);return yield a.json()}))}},O=({httpClient:t,mock:i})=>({me:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i)return I();const e=yield t.get(b.me);return yield T(e),e.json()}))}),A=t.createSingletonMixin((s=>{var n,a,l,r;const d=t.compose(i.projectIdMixin,i.observeAttributesMixin,i.loggerMixin,i.baseUrlMixin,i.cookieConfigMixin)(s);return r=class extends d{constructor(){super(...arguments),n.add(this),a.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||i.DEFAULT_STYLE_ID}get api(){return e.__classPrivateFieldGet(this,a,"f")||e.__classPrivateFieldGet(this,n,"m",l).call(this),e.__classPrivateFieldGet(this,a,"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","tenant","mock"],(()=>{e.__classPrivateFieldGet(this,a,"f")&&e.__classPrivateFieldGet(this,n,"m",l).call(this)}))}))}},a=new WeakMap,n=new WeakSet,l=function(){this.logger.debug("creating an sdk instance"),e.__classPrivateFieldSet(this,a,((e,t,i,s)=>{const n=o(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.8.2"}}));return{user:O({httpClient:n.httpClient,mock:i}),tenant:C({httpClient:n.httpClient,tenantId:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},r})),E=t.createSingletonMixin((e=>{const s=t.compose(i.createStateManagementMixin({name:"widget",initialState:k,reducers:{},extraReducers:e=>{P.reducer(e),G.reducer(e),x.reducer(e)},asyncActions:{getMe:P.action,getTenant:G.action,getTenantAdminLinkSSO:x.action}}),i.initLifecycleMixin,i.loggerMixin,A)(e);return class extends s{constructor(...e){super(...e),this.state=k,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),L="widget-flow",j=t.createSingletonMixin((s=>{var a,o,l;return l=class extends(t.compose(i.localeMixin,i.initLifecycleMixin,i.modalMixin,E,i.cookieConfigMixin,i.loggerMixin,i.themeMixin,i.flowInputMixin)(s)){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=g(L);s&&(!function(e){if(window.history.replaceState&&g(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())}}(L),e.__classPrivateFieldGet(this,a,"m",o).call(this,s))}))}},a=new WeakSet,o=function(t){const i=this.createModal({"data-id":"redirect-flow"});i.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId}));new n.FlowDriver((()=>{var e;return null===(e=i.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>e.__awaiter(this,void 0,void 0,(function*(){i.close(),this.actions.getMe(),yield this.actions.getTenant();const e=f(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:e})})))),i.afterClose=()=>{i.remove()},i.open()},l})),q=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}))}}));const U=t.createSingletonMixin((s=>{var n,a,o;return o=class extends(t.compose(i.loggerMixin,i.initLifecycleMixin,i.descopeUiMixin,i.initElementMixin,i.createFetchWidgetPagesMixin("tenant-profile-widget"),E)(s)){constructor(){super(...arguments),n.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 Promise.all([this.actions.getMe(),this.actions.getTenant()]);const e=f(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:e})}catch(e){}const s=this.state.me.error||(e=>e.tenant.error)(this.state)||(e=>e.tenantAdminLinkSSO.error)(this.state);if(s){this.contentRootElement.innerHTML="";const e="object"==typeof s&&null!==s&&"message"in s?s.message:String(s)||"An error occurred";this.contentRootElement.append(function({mainMessage:e="An error occurred"}){const t=document.createElement("div");t.setAttribute("data-id","widget-error"),t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="center",t.style.justifyContent="center",t.style.padding="72px 36px",t.style.background="#fff",t.style.borderRadius="12px",t.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",t.style.margin="32px auto",t.style.maxWidth="400px";const i=document.createElement("div");i.innerHTML='\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" stroke="#FF3B3B" stroke-width="3" fill="#fff"/>\n <text x="20" y="27" text-anchor="middle" font-size="24" font-family="Arial, sans-serif" fill="#FF3B3B">!</text>\n </svg>\n ',i.style.marginBottom="12px",t.appendChild(i);const s=document.createElement("div");return s.textContent=e,s.style.fontWeight="bold",s.style.fontSize="20px",s.style.color="#222",s.style.textAlign="center",s.style.marginTop="8px",t.appendChild(s),t}({mainMessage:e}))}else yield e.__classPrivateFieldGet(this,n,"m",a).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},n=new WeakSet,a=function(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.createTemplate(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},o})),N=t.createSingletonMixin((s=>{var a,o,l,r,d,c,h,v,u,g,m,w;return w=class extends(t.compose(q,E,i.modalMixin,i.loggerMixin,U,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),l.set(this,void 0),r.set(this,void 0),d.set(this,void 0),c.set(this,void 0)}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldSet(this,o,new n.MultiSsoConfigurationsDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-multi-sso")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").isExists&&(e.__classPrivateFieldGet(this,a,"m",m).call(this),e.__classPrivateFieldGet(this,o,"f").data=_(this.state),this.subscribe((t=>{e.__classPrivateFieldGet(this,o,"f").data=t}),_))}))}},o=new WeakMap,l=new WeakMap,r=new WeakMap,d=new WeakMap,c=new WeakMap,a=new WeakSet,h=function(){e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"multi-sso-create-modal"}),"f"),e.__classPrivateFieldSet(this,r,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f"))},v=function(){e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"multi-sso-delete-modal"}),"f"),e.__classPrivateFieldSet(this,c,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f"))},u=function(t){e.__classPrivateFieldGet(this,l,"f").setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId})),e.__classPrivateFieldGet(this,l,"f").open(),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>e.__awaiter(this,void 0,void 0,(function*(){e.__classPrivateFieldGet(this,l,"f").close(),yield this.actions.getTenant();const t=f(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})}))))},g=function(t,i){e.__classPrivateFieldGet(this,d,"f").setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId,form:{deleteSSOConfigurationId:i}})),e.__classPrivateFieldGet(this,d,"f").open(),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getTenant()}))},m=function(){const{createFlowId:t,deleteFlowId:i}=e.__classPrivateFieldGet(this,o,"f");i&&(e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,o,"f").onDeleteClicked((({id:t})=>e.__classPrivateFieldGet(this,a,"m",g).call(this,i,t)))),t&&(e.__classPrivateFieldGet(this,a,"m",h).call(this),e.__classPrivateFieldGet(this,o,"f").onCreateClicked((()=>e.__classPrivateFieldGet(this,a,"m",u).call(this,t))))},w})),$=t.createSingletonMixin((s=>{var a,o,l,d;return d=class extends(t.compose(q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin)(s)){constructor(){super(...arguments),a.add(this),l.set(this,t.withMemCache((e=>{this.tenantAdminLinkSSODriver.href=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",o).call(this),e.__classPrivateFieldGet(this,l,"f").call(this,r(this.state)),this.subscribe(e.__classPrivateFieldGet(this,l,"f").bind(this),r)}))}},l=new WeakMap,a=new WeakSet,o=function(){this.tenantAdminLinkSSODriver=new n.LinkDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},d}));var B;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(B||(B={}));const H=t.createSingletonMixin((s=>{var a,o,l,r,c,h,v,u,_,f,g;return g=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,{}),l.set(this,{}),r.set(this,{}),c.set(this,{}),u.set(this,t.withMemCache((t=>{var i;const s=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(s).forEach((i=>{const s=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||B.TEXT,l=t[s],r=new n.UserAttributeDriver(i,{logger:this.logger});r.value=((e,t)=>e===B.DATE&&t?new Date(t).toLocaleString():e===B.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString())(o,l),e.__classPrivateFieldGet(this,a,"m",_).call(this,i,s,r,o,s),e.__classPrivateFieldGet(this,a,"m",f).call(this,i,s,r)}))})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,u,"f").call(this,d(this.state)),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),d)}))}},o=new WeakMap,l=new WeakMap,r=new WeakMap,c=new WeakMap,u=new WeakMap,a=new WeakSet,h=function(t,i,s){var n,a;const r=d(this.state)[s],c=i===B.ARRAY?(r||[]).join(","):r;null===(n=e.__classPrivateFieldGet(this,o,"f")[t])||void 0===n||n.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId,form:{customAttributes:{[s]:c}}})),null===(a=e.__classPrivateFieldGet(this,l,"f")[t])||void 0===a||a.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,o,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},v=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId})),null===(s=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},_=function(t,i,s,r,d){const c=t.getAttribute("edit-flow-id");c&&(e.__classPrivateFieldGet(this,o,"f")[c]||(e.__classPrivateFieldGet(this,o,"f")[c]=this.createModal({"data-id":`edit-${i}`}),e.__classPrivateFieldGet(this,l,"f")[c]=new n.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,o,"f")[c])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,o,"f")[c].beforeOpen=e.__classPrivateFieldGet(this,a,"m",h).bind(this,c,r,d),s.onEditClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t?void 0:t[c])||void 0===i||i.open()})),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")[c])))},f=function(t,i,s){const o=t.getAttribute("delete-flow-id");o&&(e.__classPrivateFieldGet(this,r,"f")[o]||(e.__classPrivateFieldGet(this,r,"f")[o]=this.createModal({"data-id":`delete-${i}`}),e.__classPrivateFieldGet(this,c,"f")[o]=new n.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,r,"f")[o].beforeOpen=e.__classPrivateFieldGet(this,a,"m",v).bind(this,o),s.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")[o])))},g})),Y=t.createSingletonMixin((s=>{var a,o,l,r,d,c,v,u,_,f,g,m;return m=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),l.set(this,void 0),r.set(this,void 0),d.set(this,void 0),g.set(this,t.withMemCache((e=>{this.tenantEmailDomainsDriver.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",f).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,h(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),h)}))}},o=new WeakMap,l=new WeakMap,r=new WeakMap,d=new WeakMap,g=new WeakMap,a=new WeakSet,c=function(){this.tenantEmailDomainsDriver.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-tenant-email-domains"}),"f"),e.__classPrivateFieldSet(this,l,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",v).bind(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},v=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,form:{tenantEmailDomains:h(this.state)}})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getTenant()}))},u=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"delete-tenant-email-domains"}),"f"),e.__classPrivateFieldSet(this,d,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",_).bind(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},_=function(){e.__classPrivateFieldGet(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEmailDomainsDriver=new n.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()}))},m})),z=t.createSingletonMixin((s=>{var a,o,l,r,d,c,h,u,_,f,g,m;return m=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),l.set(this,void 0),r.set(this,void 0),d.set(this,void 0),g.set(this,t.withMemCache((e=>{this.tenantSSOExclusionsDriver.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",f).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,v(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),v)}))}},o=new WeakMap,l=new WeakMap,r=new WeakMap,d=new WeakMap,g=new WeakMap,a=new WeakSet,c=function(){this.tenantSSOExclusionsDriver.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),e.__classPrivateFieldSet(this,l,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,form:{enforceSSOExclusions:v(this.state)}})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getTenant()}))},u=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),e.__classPrivateFieldSet(this,d,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",_).bind(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},_=function(){e.__classPrivateFieldGet(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantSSOExclusionsDriver=new n.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()}))},m})),X=t.createSingletonMixin((s=>{var a,o,l,r,d,c,h,v,_,f,g,m;return m=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),l.set(this,void 0),r.set(this,void 0),d.set(this,void 0),g.set(this,t.withMemCache((e=>{this.tenantEnforceSSODriver.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",f).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,u(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),u)}))}},o=new WeakMap,l=new WeakMap,r=new WeakMap,d=new WeakMap,g=new WeakMap,a=new WeakSet,c=function(){this.tenantEnforceSSODriver.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-tenant-enforce-sso"}),"f"),e.__classPrivateFieldSet(this,l,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,form:{enforceSSO:u(this.state)}})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getTenant()}))},v=function(){this.tenantEnforceSSODriver.deleteFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"delete-tenant-enforce-sso"}),"f"),e.__classPrivateFieldSet(this,d,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",_).bind(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},_=function(){e.__classPrivateFieldGet(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEnforceSSODriver=new n.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()}))},m})),J=t.createSingletonMixin((s=>{var a,o,l,r,d,h,v,u;return u=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),l.set(this,void 0),v.set(this,t.withMemCache((e=>{this.tenantNameDriver.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",h).call(this),e.__classPrivateFieldGet(this,a,"m",r).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,c(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),c)}))}},o=new WeakMap,l=new WeakMap,v=new WeakMap,a=new WeakSet,r=function(){this.tenantNameDriver.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"tenant-profile-set-name"}),"f"),e.__classPrivateFieldSet(this,l,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",d).bind(this),e.__classPrivateFieldGet(this,a,"m",d).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},d=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,form:{tenantName:c(this.state)}})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getTenant()}))},h=function(){this.tenantNameDriver=new n.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()}))},u})),K=t.createSingletonMixin((s=>{var a,o,l,r,d,c,h;return h=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),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;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",r).call(this)}))}},o=new WeakMap,l=new WeakMap,a=new WeakSet,r=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"password-policy"}),"f"),e.__classPrivateFieldSet(this,l,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",d).bind(this),e.__classPrivateFieldGet(this,a,"m",d).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},d=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getTenant()}))},c=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new n.UserAuthMethodDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()}))},h})),Q=t.createSingletonMixin((s=>{var a,o,l,r,d,c,h;return h=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),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;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",r).call(this)}))}},o=new WeakMap,l=new WeakMap,a=new WeakSet,r=function(){this.TenantSessionSettingsUserAuthMethodDriver.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"session-settings"}),"f"),e.__classPrivateFieldSet(this,l,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",d).bind(this),e.__classPrivateFieldGet(this,a,"m",d).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},d=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.TenantSessionSettingsUserAuthMethodDriver.flowId,tenant:this.tenantId})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getTenant()}))},c=function(){this.TenantSessionSettingsUserAuthMethodDriver=new n.UserAuthMethodDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="session-settings"]')}),{logger:this.logger}),this.TenantSessionSettingsUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()}))},h})),V=t.createSingletonMixin((s=>class extends(t.compose(i.debuggerMixin,i.themeMixin,j,U,J,Y,z,X,H,$,K,Q,N)(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)}))}})),Z=t.compose((t=>class extends(V(t)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.8.2"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",Z),module.exports=Z;
5
+ "use strict";var e=require("tslib"),t=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins"),s=require("reselect"),n=require("@descope/sdk-component-drivers"),a=require("@reduxjs/toolkit");require("@descope/core-js-sdk");var o=require("@descope/web-js-sdk");require("@descope/web-component");const l=e=>e.tenant.data,r=e=>e.tenantAdminLinkSSO.data.defaultLink,d=s.createSelector(l,(e=>e.customAttributes||{})),c=s.createSelector(l,(e=>e.name||"")),h=s.createSelector(l,(e=>e.selfProvisioningDomains||[])),v=s.createSelector(l,(e=>e.enforceSSOExclusions||[])),u=s.createSelector(l,(e=>e.enforceSSO||!1)),_=s.createSelector(l,r,(e=>e.tenantAdminLinkSSO.data.ssoIdToLink),((e,t,i)=>[...e?[{id:"",name:"Default SSO Configuration",authType:e.authType,isDefault:!0,link:t}]:[],...((null==e?void 0:e.additionalSSOConfigs)||[]).map((({ssoId:e,name:t,authType:s})=>({id:e,name:t,authType:s,link:i[e]||""})))])),f=s.createSelector(l,(e=>((null==e?void 0:e.additionalSSOConfigs)||[]).map((({ssoId:e})=>e))));function g(e){return new URLSearchParams(window.location.search).get(e)}const m=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)}))}))},w=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}}),F=a.createAsyncThunk("users/me",((e,{extra:{api:t}})=>t.user.me())),p=m(F)({onFulfilled:(e,t)=>{e.me.data=t.payload}},w((e=>e.me))),P={action:F,reducer:p},S=a.createAsyncThunk("tenant/details",((e,{extra:{api:t}})=>t.tenant.details())),y=m(S)({onFulfilled:(e,t)=>{e.tenant.data=t.payload}},w((e=>e.tenant))),G={action:S,reducer:y},M=a.createAsyncThunk("tenant/adminLinkSso",(({ssoIds:e},{extra:{api:t}})=>t.tenant.adminLinkSso({ssoIds:e}))),x={action:M,reducer:m(M)({onFulfilled:(e,t)=>{var i;e.tenantAdminLinkSSO.data=null!==(i=t.payload)&&void 0!==i?i:{defaultLink:"",ssoIdToLink:{}}}},w((e=>e.tenantAdminLinkSSO)))},k={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:{defaultLink:"",ssoIdToLink:{}}}},b={me:"/v1/auth/me"},R={details:"/v1/mgmt/tenant",adminLinkSso:"/v1/mgmt/tenant/adminlinks/sso/authenticated/batch"},T=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)})),I=()=>e.__awaiter(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),D=()=>e.__awaiter(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({tenantId:"tenant-1",roleNames:["admin"],id:"tenant-1",name:"Test Tenant",selfProvisioningDomains:["example1.com","example2.com"],customAttributes:{},authType:"password",domains:[],createdTime:Date.now(),disabled:!1,enforceSSO:!0})}))})),W=()=>e.__awaiter(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({defaultLink:"_blank",ssoIdToLink:{"okta-prod":"_blank?ssoId=okta-prod","entra-eu":"_blank?ssoId=entra-eu"}})}))})),C=({httpClient:t,tenantId:i,mock:s})=>{const n=encodeURIComponent(i||""),a=`?tenant=${n}&id=${n}`;return{details:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(s)return D();if(!i)throw new Error("tenantId is not defined");const e=`${R.details}${a}`,n=yield t.get(e);yield T(n);return yield n.json()})),adminLinkSso:a=>e.__awaiter(void 0,[a],void 0,(function*({ssoIds:e}){if(s)return W();if(!i)throw new Error("tenantId is not defined");const a=yield t.post(`${R.adminLinkSso}?tenant=${n}`,{tenantId:n,ssoIds:e},{headers:{"Content-Type":"application/json"}});yield T(a);return yield a.json()}))}},O=({httpClient:t,mock:i})=>({me:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i)return I();const e=yield t.get(b.me);return yield T(e),e.json()}))}),A=t.createSingletonMixin((s=>{var n,a,l,r;const d=t.compose(i.projectIdMixin,i.observeAttributesMixin,i.loggerMixin,i.baseUrlMixin,i.cookieConfigMixin)(s);return r=class extends d{constructor(){super(...arguments),n.add(this),a.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||i.DEFAULT_STYLE_ID}get api(){return e.__classPrivateFieldGet(this,a,"f")||e.__classPrivateFieldGet(this,n,"m",l).call(this),e.__classPrivateFieldGet(this,a,"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","tenant","mock"],(()=>{e.__classPrivateFieldGet(this,a,"f")&&e.__classPrivateFieldGet(this,n,"m",l).call(this)}))}))}},a=new WeakMap,n=new WeakSet,l=function(){this.logger.debug("creating an sdk instance"),e.__classPrivateFieldSet(this,a,((e,t,i,s)=>{const n=o(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.8.4"}}));return{user:O({httpClient:n.httpClient,mock:i}),tenant:C({httpClient:n.httpClient,tenantId:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},r})),E=t.createSingletonMixin((e=>{const s=t.compose(i.createStateManagementMixin({name:"widget",initialState:k,reducers:{},extraReducers:e=>{P.reducer(e),G.reducer(e),x.reducer(e)},asyncActions:{getMe:P.action,getTenant:G.action,getTenantAdminLinkSSO:x.action}}),i.initLifecycleMixin,i.loggerMixin,A)(e);return class extends s{constructor(...e){super(...e),this.state=k,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),L="widget-flow",j=t.createSingletonMixin((s=>{var a,o,l;return l=class extends(t.compose(i.localeMixin,i.initLifecycleMixin,i.modalMixin,E,i.cookieConfigMixin,i.loggerMixin,i.themeMixin,i.flowInputMixin)(s)){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=g(L);s&&(!function(e){if(window.history.replaceState&&g(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())}}(L),e.__classPrivateFieldGet(this,a,"m",o).call(this,s))}))}},a=new WeakSet,o=function(t){const i=this.createModal({"data-id":"redirect-flow"});i.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId}));new n.FlowDriver((()=>{var e;return null===(e=i.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>e.__awaiter(this,void 0,void 0,(function*(){i.close(),this.actions.getMe(),yield this.actions.getTenant();const e=f(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:e})})))),i.afterClose=()=>{i.remove()},i.open()},l})),q=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}))}}));const U=t.createSingletonMixin((s=>{var n,a,o;return o=class extends(t.compose(i.loggerMixin,i.initLifecycleMixin,i.descopeUiMixin,i.initElementMixin,i.createFetchWidgetPagesMixin("tenant-profile-widget"),E)(s)){constructor(){super(...arguments),n.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 Promise.all([this.actions.getMe(),this.actions.getTenant()]);const e=f(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:e})}catch(e){}const s=this.state.me.error||(e=>e.tenant.error)(this.state)||(e=>e.tenantAdminLinkSSO.error)(this.state);if(s){this.contentRootElement.innerHTML="";const e="object"==typeof s&&null!==s&&"message"in s?s.message:String(s)||"An error occurred";this.contentRootElement.append(function({mainMessage:e="An error occurred"}){const t=document.createElement("div");t.setAttribute("data-id","widget-error"),t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="center",t.style.justifyContent="center",t.style.padding="72px 36px",t.style.background="#fff",t.style.borderRadius="12px",t.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",t.style.margin="32px auto",t.style.maxWidth="400px";const i=document.createElement("div");i.innerHTML='\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" stroke="#FF3B3B" stroke-width="3" fill="#fff"/>\n <text x="20" y="27" text-anchor="middle" font-size="24" font-family="Arial, sans-serif" fill="#FF3B3B">!</text>\n </svg>\n ',i.style.marginBottom="12px",t.appendChild(i);const s=document.createElement("div");return s.textContent=e,s.style.fontWeight="bold",s.style.fontSize="20px",s.style.color="#222",s.style.textAlign="center",s.style.marginTop="8px",t.appendChild(s),t}({mainMessage:e}))}else yield e.__classPrivateFieldGet(this,n,"m",a).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},n=new WeakSet,a=function(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.createTemplate(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},o})),N=t.createSingletonMixin((s=>{var a,o,l,r,d,c,h,v,u,g,m,w;return w=class extends(t.compose(q,E,i.modalMixin,i.loggerMixin,U,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),l.set(this,void 0),r.set(this,void 0),d.set(this,void 0),c.set(this,void 0)}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldSet(this,o,new n.MultiSsoConfigurationsDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-multi-sso")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").isExists&&(e.__classPrivateFieldGet(this,a,"m",m).call(this),e.__classPrivateFieldGet(this,o,"f").data=_(this.state),this.subscribe((t=>{e.__classPrivateFieldGet(this,o,"f").data=t}),_))}))}},o=new WeakMap,l=new WeakMap,r=new WeakMap,d=new WeakMap,c=new WeakMap,a=new WeakSet,h=function(){e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"multi-sso-create-modal"}),"f"),e.__classPrivateFieldSet(this,r,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e.__classPrivateFieldGet(this,r,"f"))},v=function(){e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"multi-sso-delete-modal"}),"f"),e.__classPrivateFieldSet(this,c,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f"))},u=function(t){e.__classPrivateFieldGet(this,l,"f").setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId})),e.__classPrivateFieldGet(this,l,"f").open(),e.__classPrivateFieldGet(this,r,"f").onSuccess((()=>e.__awaiter(this,void 0,void 0,(function*(){e.__classPrivateFieldGet(this,l,"f").close(),yield this.actions.getTenant();const t=f(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})}))))},g=function(t,i){e.__classPrivateFieldGet(this,d,"f").setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId,form:{deleteSSOConfigurationId:i}})),e.__classPrivateFieldGet(this,d,"f").open(),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getTenant()}))},m=function(){const{createFlowId:t,deleteFlowId:i}=e.__classPrivateFieldGet(this,o,"f");i&&(e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,o,"f").onDeleteClicked((({id:t})=>e.__classPrivateFieldGet(this,a,"m",g).call(this,i,t)))),t&&(e.__classPrivateFieldGet(this,a,"m",h).call(this),e.__classPrivateFieldGet(this,o,"f").onCreateClicked((()=>e.__classPrivateFieldGet(this,a,"m",u).call(this,t))))},w})),$=t.createSingletonMixin((s=>{var a,o,l,d;return d=class extends(t.compose(q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin)(s)){constructor(){super(...arguments),a.add(this),l.set(this,t.withMemCache((e=>{this.tenantAdminLinkSSODriver.href=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",o).call(this),e.__classPrivateFieldGet(this,l,"f").call(this,r(this.state)),this.subscribe(e.__classPrivateFieldGet(this,l,"f").bind(this),r)}))}},l=new WeakMap,a=new WeakSet,o=function(){this.tenantAdminLinkSSODriver=new n.LinkDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},d}));var B;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(B||(B={}));const H=t.createSingletonMixin((s=>{var a,o,l,r,c,h,v,u,_,f,g;return g=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,{}),l.set(this,{}),r.set(this,{}),c.set(this,{}),u.set(this,t.withMemCache((t=>{var i;const s=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(s).forEach((i=>{const s=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||B.TEXT,l=t[s],r=new n.UserAttributeDriver(i,{logger:this.logger});r.value=((e,t)=>e===B.DATE&&t?new Date(t).toLocaleString():e===B.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString())(o,l),e.__classPrivateFieldGet(this,a,"m",_).call(this,i,s,r,o,s),e.__classPrivateFieldGet(this,a,"m",f).call(this,i,s,r)}))})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,u,"f").call(this,d(this.state)),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),d)}))}},o=new WeakMap,l=new WeakMap,r=new WeakMap,c=new WeakMap,u=new WeakMap,a=new WeakSet,h=function(t,i,s){var n,a;const r=d(this.state)[s],c=i===B.ARRAY?(r||[]).join(","):r;null===(n=e.__classPrivateFieldGet(this,o,"f")[t])||void 0===n||n.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId,form:{customAttributes:{[s]:c}}})),null===(a=e.__classPrivateFieldGet(this,l,"f")[t])||void 0===a||a.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,o,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},v=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId})),null===(s=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},_=function(t,i,s,r,d){const c=t.getAttribute("edit-flow-id");c&&(e.__classPrivateFieldGet(this,o,"f")[c]||(e.__classPrivateFieldGet(this,o,"f")[c]=this.createModal({"data-id":`edit-${i}`}),e.__classPrivateFieldGet(this,l,"f")[c]=new n.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,o,"f")[c])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,o,"f")[c].beforeOpen=e.__classPrivateFieldGet(this,a,"m",h).bind(this,c,r,d),s.onEditClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t?void 0:t[c])||void 0===i||i.open()})),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")[c])))},f=function(t,i,s){const o=t.getAttribute("delete-flow-id");o&&(e.__classPrivateFieldGet(this,r,"f")[o]||(e.__classPrivateFieldGet(this,r,"f")[o]=this.createModal({"data-id":`delete-${i}`}),e.__classPrivateFieldGet(this,c,"f")[o]=new n.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,r,"f")[o].beforeOpen=e.__classPrivateFieldGet(this,a,"m",v).bind(this,o),s.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")[o])))},g})),Y=t.createSingletonMixin((s=>{var a,o,l,r,d,c,v,u,_,f,g,m;return m=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),l.set(this,void 0),r.set(this,void 0),d.set(this,void 0),g.set(this,t.withMemCache((e=>{this.tenantEmailDomainsDriver.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",f).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,h(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),h)}))}},o=new WeakMap,l=new WeakMap,r=new WeakMap,d=new WeakMap,g=new WeakMap,a=new WeakSet,c=function(){this.tenantEmailDomainsDriver.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-tenant-email-domains"}),"f"),e.__classPrivateFieldSet(this,l,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",v).bind(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},v=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,form:{tenantEmailDomains:h(this.state)}})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getTenant()}))},u=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"delete-tenant-email-domains"}),"f"),e.__classPrivateFieldSet(this,d,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",_).bind(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},_=function(){e.__classPrivateFieldGet(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEmailDomainsDriver=new n.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()}))},m})),z=t.createSingletonMixin((s=>{var a,o,l,r,d,c,h,u,_,f,g,m;return m=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),l.set(this,void 0),r.set(this,void 0),d.set(this,void 0),g.set(this,t.withMemCache((e=>{this.tenantSSOExclusionsDriver.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",f).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,v(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),v)}))}},o=new WeakMap,l=new WeakMap,r=new WeakMap,d=new WeakMap,g=new WeakMap,a=new WeakSet,c=function(){this.tenantSSOExclusionsDriver.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),e.__classPrivateFieldSet(this,l,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,form:{enforceSSOExclusions:v(this.state)}})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getTenant()}))},u=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),e.__classPrivateFieldSet(this,d,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",_).bind(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},_=function(){e.__classPrivateFieldGet(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantSSOExclusionsDriver=new n.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()}))},m})),X=t.createSingletonMixin((s=>{var a,o,l,r,d,c,h,v,_,f,g,m;return m=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),l.set(this,void 0),r.set(this,void 0),d.set(this,void 0),g.set(this,t.withMemCache((e=>{this.tenantEnforceSSODriver.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",f).call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,u(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),u)}))}},o=new WeakMap,l=new WeakMap,r=new WeakMap,d=new WeakMap,g=new WeakMap,a=new WeakSet,c=function(){this.tenantEnforceSSODriver.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"edit-tenant-enforce-sso"}),"f"),e.__classPrivateFieldSet(this,l,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",h).bind(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},h=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,form:{enforceSSO:u(this.state)}})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getTenant()}))},v=function(){this.tenantEnforceSSODriver.deleteFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"delete-tenant-enforce-sso"}),"f"),e.__classPrivateFieldSet(this,d,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",_).bind(this),e.__classPrivateFieldGet(this,a,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},_=function(){e.__classPrivateFieldGet(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEnforceSSODriver=new n.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()}))},m})),J=t.createSingletonMixin((s=>{var a,o,l,r,d,h,v,u;return u=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),l.set(this,void 0),v.set(this,t.withMemCache((e=>{this.tenantNameDriver.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",h).call(this),e.__classPrivateFieldGet(this,a,"m",r).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,c(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),c)}))}},o=new WeakMap,l=new WeakMap,v=new WeakMap,a=new WeakSet,r=function(){this.tenantNameDriver.editFlowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"tenant-profile-set-name"}),"f"),e.__classPrivateFieldSet(this,l,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").beforeOpen=e.__classPrivateFieldGet(this,a,"m",d).bind(this),e.__classPrivateFieldGet(this,a,"m",d).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},d=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,form:{tenantName:c(this.state)}})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getTenant()}))},h=function(){this.tenantNameDriver=new n.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()}))},u})),K=t.createSingletonMixin((s=>{var a,o,l,r,d,c,h;return h=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),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;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",r).call(this)}))}},o=new WeakMap,l=new WeakMap,a=new WeakSet,r=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"password-policy"}),"f"),e.__classPrivateFieldSet(this,l,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",d).bind(this),e.__classPrivateFieldGet(this,a,"m",d).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},d=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getTenant()}))},c=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new n.UserAuthMethodDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()}))},h})),Q=t.createSingletonMixin((s=>{var a,o,l,r,d,c,h;return h=class extends(t.compose(i.localeMixin,q,E,i.loggerMixin,U,i.cookieConfigMixin,i.modalMixin,i.flowInputMixin)(s)){constructor(){super(...arguments),a.add(this),o.set(this,void 0),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;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),e.__classPrivateFieldGet(this,a,"m",r).call(this)}))}},o=new WeakMap,l=new WeakMap,a=new WeakSet,r=function(){this.TenantSessionSettingsUserAuthMethodDriver.flowId&&(e.__classPrivateFieldSet(this,o,this.createModal({"data-id":"session-settings"}),"f"),e.__classPrivateFieldSet(this,l,new n.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,o,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",d).bind(this),e.__classPrivateFieldGet(this,a,"m",d).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},d=function(){e.__classPrivateFieldGet(this,o,"f").setContent(this.createFlowTemplate({flowId:this.TenantSessionSettingsUserAuthMethodDriver.flowId,tenant:this.tenantId})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,o,"f").close(),this.actions.getTenant()}))},c=function(){this.TenantSessionSettingsUserAuthMethodDriver=new n.UserAuthMethodDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="session-settings"]')}),{logger:this.logger}),this.TenantSessionSettingsUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,o,"f"))||void 0===t||t.open()}))},h})),V=t.createSingletonMixin((s=>class extends(t.compose(i.debuggerMixin,i.themeMixin,j,U,J,Y,z,X,H,$,K,Q,N)(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)}))}})),Z=t.compose((t=>class extends(V(t)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.8.4"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",Z),module.exports=Z;
6
6
  //# sourceMappingURL=index.js.map
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**
3
- * @descope/tenant-profile-widget v0.8.2
3
+ * @descope/tenant-profile-widget v0.8.4
4
4
  */
5
- import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createSingletonMixin as s,compose as n,createTemplate as o,withMemCache as a}from"@descope/sdk-helpers";import{projectIdMixin as r,observeAttributesMixin as d,loggerMixin as l,baseUrlMixin as h,cookieConfigMixin as c,DEFAULT_STYLE_ID as u,createStateManagementMixin as f,initLifecycleMixin as v,localeMixin as m,modalMixin as g,themeMixin as p,flowInputMixin as w,descopeUiMixin as y,initElementMixin as S,createFetchWidgetPagesMixin as k,debuggerMixin as b}from"@descope/sdk-mixins";import{createSelector as R}from"reselect";import{FlowDriver as T,MultiSsoConfigurationsDriver as W,LinkDriver as I,UserAttributeDriver as x,UserAuthMethodDriver as O}from"@descope/sdk-component-drivers";import{createAsyncThunk as M}from"@reduxjs/toolkit";import"@descope/core-js-sdk";import D from"@descope/web-js-sdk";import"@descope/web-component";const E=t=>t.tenant.data,C=t=>t.tenantAdminLinkSSO.data.defaultLink,A=R(E,(t=>t.customAttributes||{})),F=R(E,(t=>t.name||"")),L=R(E,(t=>t.selfProvisioningDomains||[])),j=R(E,(t=>t.enforceSSOExclusions||[])),q=R(E,(t=>t.enforceSSO||!1)),P=R(E,C,(t=>t.tenantAdminLinkSSO.data.ssoIdToLink),((t,e,i)=>[...t?[{id:"",name:"Default SSO Configuration",authType:t.authType,isDefault:!0,link:e}]:[],...((null==t?void 0:t.additionalSSOConfigs)||[]).map((({ssoId:t,name:e,authType:s})=>({id:t,name:e,authType:s,link:i[t]||""})))])),N=R(E,(t=>((null==t?void 0:t.additionalSSOConfigs)||[]).map((({ssoId:t})=>t))));function U(t){return new URLSearchParams(window.location.search).get(t)}const $=t=>(...e)=>i=>{i.addCase(t.pending,((t,i)=>{e.forEach((({onPending:e})=>{null==e||e(t,i)}))})),i.addCase(t.fulfilled,((t,i)=>{e.forEach((({onFulfilled:e})=>{null==e||e(t,i)}))})),i.addCase(t.rejected,((t,i)=>{e.forEach((({onRejected:e})=>{null==e||e(t,i)}))}))},B=t=>({onFulfilled:e=>{t(e).loading=!1},onPending:e=>{t(e).loading=!0,t(e).error=null},onRejected:(e,i)=>{t(e).loading=!1,t(e).error=i.error}}),H=M("users/me",((t,{extra:{api:e}})=>e.user.me())),_=$(H)({onFulfilled:(t,e)=>{t.me.data=e.payload}},B((t=>t.me))),z={action:H,reducer:_},X=M("tenant/details",((t,{extra:{api:e}})=>e.tenant.details())),Y=$(X)({onFulfilled:(t,e)=>{t.tenant.data=e.payload}},B((t=>t.tenant))),G={action:X,reducer:Y},J=M("tenant/adminLinkSso",(({ssoIds:t},{extra:{api:e}})=>e.tenant.adminLinkSso({ssoIds:t}))),K={action:J,reducer:$(J)({onFulfilled:(t,e)=>{var i;t.tenantAdminLinkSSO.data=null!==(i=e.payload)&&void 0!==i?i:{defaultLink:"",ssoIdToLink:{}}}},B((t=>t.tenantAdminLinkSSO)))},Q={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:{defaultLink:"",ssoIdToLink:{}}}},V={me:"/v1/auth/me"},Z={details:"/v1/mgmt/tenant",adminLinkSso:"/v1/mgmt/tenant/adminlinks/sso/authenticated/batch"},tt=e=>t(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),et=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),it=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({tenantId:"tenant-1",roleNames:["admin"],id:"tenant-1",name:"Test Tenant",selfProvisioningDomains:["example1.com","example2.com"],customAttributes:{},authType:"password",domains:[],createdTime:Date.now(),disabled:!1,enforceSSO:!0})}))})),st=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({defaultLink:"_blank",ssoIdToLink:{"okta-prod":"_blank?ssoId=okta-prod","entra-eu":"_blank?ssoId=entra-eu"}})}))})),nt=({httpClient:e,tenantId:i,mock:s})=>{const n=encodeURIComponent(i||""),o=`?tenant=${n}&id=${n}`;return{details:()=>t(void 0,void 0,void 0,(function*(){if(s)return it();if(!i)throw new Error("tenantId is not defined");const t=`${Z.details}${o}`,n=yield e.get(t);yield tt(n);return yield n.json()})),adminLinkSso:o=>t(void 0,[o],void 0,(function*({ssoIds:t}){if(s)return st();if(!i)throw new Error("tenantId is not defined");const o=yield e.post(`${Z.adminLinkSso}?tenant=${n}`,{tenantId:n,ssoIds:t},{headers:{"Content-Type":"application/json"}});yield tt(o);return yield o.json()}))}},ot=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return et();const t=yield e.get(V.me);return yield tt(t),t.json()}))}),at=s((s=>{var o,a,f,v;const m=n(r,d,l,h,c)(s);return v=class extends m{constructor(){super(...arguments),o.add(this),a.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||u}get api(){return e(this,a,"f")||e(this,o,"m",f).call(this),e(this,a,"f")}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url","tenant","mock"],(()=>{e(this,a,"f")&&e(this,o,"m",f).call(this)}))}))}},a=new WeakMap,o=new WeakSet,f=function(){this.logger.debug("creating an sdk instance"),i(this,a,((t,e,i,s)=>{const n=D(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.8.2"}}));return{user:ot({httpClient:n.httpClient,mock:i}),tenant:nt({httpClient:n.httpClient,tenantId:e,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},v})),rt=s((t=>{const e=n(f({name:"widget",initialState:Q,reducers:{},extraReducers:t=>{z.reducer(t),G.reducer(t),K.reducer(t)},asyncActions:{getMe:z.action,getTenant:G.action,getTenantAdminLinkSSO:K.action}}),v,l,at)(t);return class extends e{constructor(...t){super(...t),this.state=Q,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),dt="widget-flow",lt=s((i=>{var s,o,a;return a=class extends(n(m,v,g,rt,c,l,p,w)(i)){constructor(){super(...arguments),s.add(this)}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);const n=U(dt);n&&(!function(t){if(window.history.replaceState&&U(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}(dt),e(this,s,"m",o).call(this,n))}))}},s=new WeakSet,o=function(e){const i=this.createModal({"data-id":"redirect-flow"});i.setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId}));new T((()=>{var t;return null===(t=i.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>t(this,void 0,void 0,(function*(){i.close(),this.actions.getMe(),yield this.actions.getTenant();const t=N(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})})))),i.afterClose=()=>{i.remove()},i.open()},a})),ht=s((t=>class extends(n(p,d)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}}));const ct=s((i=>{var s,a,r;return r=class extends(n(l,v,y,S,k("tenant-profile-widget"),rt)(i)){constructor(){super(...arguments),s.add(this)}onWidgetRootReady(){return t(this,void 0,void 0,(function*(){}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant()]);const t=N(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})}catch(t){}const n=this.state.me.error||(t=>t.tenant.error)(this.state)||(t=>t.tenantAdminLinkSSO.error)(this.state);if(n){this.contentRootElement.innerHTML="";const t="object"==typeof n&&null!==n&&"message"in n?n.message:String(n)||"An error occurred";this.contentRootElement.append(function({mainMessage:t="An error occurred"}){const e=document.createElement("div");e.setAttribute("data-id","widget-error"),e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="center",e.style.justifyContent="center",e.style.padding="72px 36px",e.style.background="#fff",e.style.borderRadius="12px",e.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",e.style.margin="32px auto",e.style.maxWidth="400px";const i=document.createElement("div");i.innerHTML='\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" stroke="#FF3B3B" stroke-width="3" fill="#fff"/>\n <text x="20" y="27" text-anchor="middle" font-size="24" font-family="Arial, sans-serif" fill="#FF3B3B">!</text>\n </svg>\n ',i.style.marginBottom="12px",e.appendChild(i);const s=document.createElement("div");return s.textContent=t,s.style.fontWeight="bold",s.style.fontSize="20px",s.style.color="#222",s.style.textAlign="center",s.style.marginTop="8px",e.appendChild(s),e}({mainMessage:t}))}else yield e(this,s,"m",a).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},s=new WeakSet,a=function(){return t(this,void 0,void 0,(function*(){const t=o(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(t),this.contentRootElement.append(t.content.cloneNode(!0))}))},r})),ut=s((s=>{var o,a,r,d,h,c,u,f,v,m,p,y;return y=class extends(n(ht,rt,g,l,ct,w)(s)){constructor(){super(...arguments),o.add(this),a.set(this,void 0),r.set(this,void 0),d.set(this,void 0),h.set(this,void 0),c.set(this,void 0)}onWidgetRootReady(){const s=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=s.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,a,new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("descope-multi-sso")}),{logger:this.logger}),"f"),e(this,a,"f").isExists&&(e(this,o,"m",p).call(this),e(this,a,"f").data=P(this.state),this.subscribe((t=>{e(this,a,"f").data=t}),P))}))}},a=new WeakMap,r=new WeakMap,d=new WeakMap,h=new WeakMap,c=new WeakMap,o=new WeakSet,u=function(){i(this,r,this.createModal({"data-id":"multi-sso-create-modal"}),"f"),i(this,d,new T((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e(this,d,"f"))},f=function(){i(this,h,this.createModal({"data-id":"multi-sso-delete-modal"}),"f"),i(this,c,new T((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e(this,c,"f"))},v=function(i){e(this,r,"f").setContent(this.createFlowTemplate({flowId:i,tenant:this.tenantId})),e(this,r,"f").open(),e(this,d,"f").onSuccess((()=>t(this,void 0,void 0,(function*(){e(this,r,"f").close(),yield this.actions.getTenant();const t=N(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})}))))},m=function(t,i){e(this,h,"f").setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId,form:{deleteSSOConfigurationId:i}})),e(this,h,"f").open(),e(this,c,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},p=function(){const{createFlowId:t,deleteFlowId:i}=e(this,a,"f");i&&(e(this,o,"m",f).call(this),e(this,a,"f").onDeleteClicked((({id:t})=>e(this,o,"m",m).call(this,i,t)))),t&&(e(this,o,"m",u).call(this),e(this,a,"f").onCreateClicked((()=>e(this,o,"m",v).call(this,t))))},y})),ft=s((i=>{var s,o,r,d;return d=class extends(n(ht,rt,l,ct,c,g)(i)){constructor(){super(...arguments),s.add(this),r.set(this,a((t=>{this.tenantAdminLinkSSODriver.href=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,s,"m",o).call(this),e(this,r,"f").call(this,C(this.state)),this.subscribe(e(this,r,"f").bind(this),C)}))}},r=new WeakMap,s=new WeakSet,o=function(){this.tenantAdminLinkSSODriver=new I((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},d}));var vt;!function(t){t.TEXT="text",t.NUMBER="number",t.BOOLEAN="boolean",t.SINGLE_SELECT="singleSelect",t.ARRAY="array",t.DATE="date"}(vt||(vt={}));const mt=s((i=>{var s,o,r,d,h,u,f,v,p,y,S;return S=class extends(n(m,ht,rt,l,ct,c,g,w)(i)){constructor(){super(...arguments),s.add(this),o.set(this,{}),r.set(this,{}),d.set(this,{}),h.set(this,{}),v.set(this,a((t=>{var i;const n=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(n).forEach((i=>{const n=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||vt.TEXT,a=t[n],r=new x(i,{logger:this.logger});r.value=((t,e)=>t===vt.DATE&&e?new Date(e).toLocaleString():t===vt.BOOLEAN&&void 0!==e?e?"True":"False":(e||"").toString())(o,a),e(this,s,"m",p).call(this,i,n,r,o,n),e(this,s,"m",y).call(this,i,n,r)}))})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,v,"f").call(this,A(this.state)),this.subscribe(e(this,v,"f").bind(this),A)}))}},o=new WeakMap,r=new WeakMap,d=new WeakMap,h=new WeakMap,v=new WeakMap,s=new WeakSet,u=function(t,i,s){var n,a;const d=A(this.state)[s],l=i===vt.ARRAY?(d||[]).join(","):d;null===(n=e(this,o,"f")[t])||void 0===n||n.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId,form:{customAttributes:{[s]:l}}})),null===(a=e(this,r,"f")[t])||void 0===a||a.onSuccess((()=>{var i;null===(i=e(this,o,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},f=function(t){var i,s;null===(i=e(this,d,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId})),null===(s=e(this,h,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,d,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},p=function(t,i,n,a,d){const l=t.getAttribute("edit-flow-id");l&&(e(this,o,"f")[l]||(e(this,o,"f")[l]=this.createModal({"data-id":`edit-${i}`}),e(this,r,"f")[l]=new T((()=>{var t,i;return null===(i=null===(t=e(this,o,"f")[l])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,o,"f")[l].beforeOpen=e(this,s,"m",u).bind(this,l,a,d),n.onEditClick((()=>{var t,i;null===(i=null===(t=e(this,o,"f"))||void 0===t?void 0:t[l])||void 0===i||i.open()})),this.syncFlowTheme(e(this,r,"f")[l])))},y=function(t,i,n){const o=t.getAttribute("delete-flow-id");o&&(e(this,d,"f")[o]||(e(this,d,"f")[o]=this.createModal({"data-id":`delete-${i}`}),e(this,h,"f")[o]=new T((()=>{var t,i;return null===(i=null===(t=e(this,d,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,d,"f")[o].beforeOpen=e(this,s,"m",f).bind(this,o),n.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,d,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),this.syncFlowTheme(e(this,h,"f")[o])))},S})),gt=s((s=>{var o,r,d,h,u,f,v,p,y,S,k,b;return b=class extends(n(m,ht,rt,l,ct,c,g,w)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),h.set(this,void 0),u.set(this,void 0),k.set(this,a((t=>{this.tenantEmailDomainsDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",S).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,k,"f").call(this,L(this.state)),this.subscribe(e(this,k,"f").bind(this),L)}))}},r=new WeakMap,d=new WeakMap,h=new WeakMap,u=new WeakMap,k=new WeakMap,o=new WeakSet,f=function(){this.tenantEmailDomainsDriver.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-tenant-email-domains"}),"f"),i(this,d,new T((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").beforeOpen=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,form:{tenantEmailDomains:L(this.state)}})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(i(this,h,this.createModal({"data-id":"delete-tenant-email-domains"}),"f"),i(this,u,new T((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,h,"f").beforeOpen=e(this,o,"m",y).bind(this),e(this,o,"m",y).call(this),this.syncFlowTheme(e(this,u,"f")))},y=function(){e(this,h,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId})),e(this,u,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},S=function(){this.tenantEmailDomainsDriver=new x((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var t;null===(t=e(this,h,"f"))||void 0===t||t.open()}))},b})),pt=s((s=>{var o,r,d,h,u,f,v,p,y,S,k,b;return b=class extends(n(m,ht,rt,l,ct,c,g,w)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),h.set(this,void 0),u.set(this,void 0),k.set(this,a((t=>{this.tenantSSOExclusionsDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",S).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,k,"f").call(this,j(this.state)),this.subscribe(e(this,k,"f").bind(this),j)}))}},r=new WeakMap,d=new WeakMap,h=new WeakMap,u=new WeakMap,k=new WeakMap,o=new WeakSet,f=function(){this.tenantSSOExclusionsDriver.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),i(this,d,new T((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").beforeOpen=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,form:{enforceSSOExclusions:j(this.state)}})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(i(this,h,this.createModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),i(this,u,new T((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,h,"f").beforeOpen=e(this,o,"m",y).bind(this),e(this,o,"m",y).call(this),this.syncFlowTheme(e(this,u,"f")))},y=function(){e(this,h,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId})),e(this,u,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},S=function(){this.tenantSSOExclusionsDriver=new x((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var t;null===(t=e(this,h,"f"))||void 0===t||t.open()}))},b})),wt=s((s=>{var o,r,d,h,u,f,v,p,y,S,k,b;return b=class extends(n(m,ht,rt,l,ct,c,g,w)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),h.set(this,void 0),u.set(this,void 0),k.set(this,a((t=>{this.tenantEnforceSSODriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",S).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,k,"f").call(this,q(this.state)),this.subscribe(e(this,k,"f").bind(this),q)}))}},r=new WeakMap,d=new WeakMap,h=new WeakMap,u=new WeakMap,k=new WeakMap,o=new WeakSet,f=function(){this.tenantEnforceSSODriver.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-tenant-enforce-sso"}),"f"),i(this,d,new T((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").beforeOpen=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,form:{enforceSSO:q(this.state)}})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantEnforceSSODriver.deleteFlowId&&(i(this,h,this.createModal({"data-id":"delete-tenant-enforce-sso"}),"f"),i(this,u,new T((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,h,"f").beforeOpen=e(this,o,"m",y).bind(this),e(this,o,"m",y).call(this),this.syncFlowTheme(e(this,u,"f")))},y=function(){e(this,h,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId})),e(this,u,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},S=function(){this.tenantEnforceSSODriver=new x((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var t;null===(t=e(this,h,"f"))||void 0===t||t.open()}))},b})),yt=s((s=>{var o,r,d,h,u,f,v,p;return p=class extends(n(m,ht,rt,l,ct,c,g,w)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),v.set(this,a((t=>{this.tenantNameDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",f).call(this),e(this,o,"m",h).call(this),e(this,v,"f").call(this,F(this.state)),this.subscribe(e(this,v,"f").bind(this),F)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,o=new WeakSet,h=function(){this.tenantNameDriver.editFlowId&&(i(this,r,this.createModal({"data-id":"tenant-profile-set-name"}),"f"),i(this,d,new T((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").beforeOpen=e(this,o,"m",u).bind(this),e(this,o,"m",u).call(this),this.syncFlowTheme(e(this,d,"f")))},u=function(){e(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,form:{tenantName:F(this.state)}})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantNameDriver=new x((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},p})),St=s((s=>{var o,a,r,d,h,u,f;return f=class extends(n(m,ht,rt,l,ct,c,g,w)(s)){constructor(){super(...arguments),o.add(this),a.set(this,void 0),r.set(this,void 0)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",u).call(this),e(this,o,"m",d).call(this)}))}},a=new WeakMap,r=new WeakMap,o=new WeakSet,d=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(i(this,a,this.createModal({"data-id":"password-policy"}),"f"),i(this,r,new T((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",h).bind(this),e(this,o,"m",h).call(this),this.syncFlowTheme(e(this,r,"f")))},h=function(){e(this,a,"f").setContent(this.createFlowTemplate({flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId})),e(this,r,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getTenant()}))},u=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new O((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},f})),kt=s((s=>{var o,a,r,d,h,u,f;return f=class extends(n(m,ht,rt,l,ct,c,g,w)(s)){constructor(){super(...arguments),o.add(this),a.set(this,void 0),r.set(this,void 0)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",u).call(this),e(this,o,"m",d).call(this)}))}},a=new WeakMap,r=new WeakMap,o=new WeakSet,d=function(){this.TenantSessionSettingsUserAuthMethodDriver.flowId&&(i(this,a,this.createModal({"data-id":"session-settings"}),"f"),i(this,r,new T((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",h).bind(this),e(this,o,"m",h).call(this),this.syncFlowTheme(e(this,r,"f")))},h=function(){e(this,a,"f").setContent(this.createFlowTemplate({flowId:this.TenantSessionSettingsUserAuthMethodDriver.flowId,tenant:this.tenantId})),e(this,r,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getTenant()}))},u=function(){this.TenantSessionSettingsUserAuthMethodDriver=new O((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="session-settings"]')}),{logger:this.logger}),this.TenantSessionSettingsUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},f})),bt=s((e=>class extends(n(b,p,lt,ct,yt,gt,pt,wt,mt,ft,St,kt,ut)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Rt=n((e=>class extends(bt(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((t=>t.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.8.2"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",Rt);export{Rt as default};
5
+ import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createSingletonMixin as s,compose as n,createTemplate as o,withMemCache as a}from"@descope/sdk-helpers";import{projectIdMixin as r,observeAttributesMixin as d,loggerMixin as l,baseUrlMixin as h,cookieConfigMixin as c,DEFAULT_STYLE_ID as u,createStateManagementMixin as f,initLifecycleMixin as v,localeMixin as m,modalMixin as g,themeMixin as p,flowInputMixin as w,descopeUiMixin as y,initElementMixin as S,createFetchWidgetPagesMixin as k,debuggerMixin as b}from"@descope/sdk-mixins";import{createSelector as R}from"reselect";import{FlowDriver as T,MultiSsoConfigurationsDriver as W,LinkDriver as I,UserAttributeDriver as x,UserAuthMethodDriver as O}from"@descope/sdk-component-drivers";import{createAsyncThunk as M}from"@reduxjs/toolkit";import"@descope/core-js-sdk";import D from"@descope/web-js-sdk";import"@descope/web-component";const E=t=>t.tenant.data,C=t=>t.tenantAdminLinkSSO.data.defaultLink,A=R(E,(t=>t.customAttributes||{})),F=R(E,(t=>t.name||"")),L=R(E,(t=>t.selfProvisioningDomains||[])),j=R(E,(t=>t.enforceSSOExclusions||[])),q=R(E,(t=>t.enforceSSO||!1)),P=R(E,C,(t=>t.tenantAdminLinkSSO.data.ssoIdToLink),((t,e,i)=>[...t?[{id:"",name:"Default SSO Configuration",authType:t.authType,isDefault:!0,link:e}]:[],...((null==t?void 0:t.additionalSSOConfigs)||[]).map((({ssoId:t,name:e,authType:s})=>({id:t,name:e,authType:s,link:i[t]||""})))])),N=R(E,(t=>((null==t?void 0:t.additionalSSOConfigs)||[]).map((({ssoId:t})=>t))));function U(t){return new URLSearchParams(window.location.search).get(t)}const $=t=>(...e)=>i=>{i.addCase(t.pending,((t,i)=>{e.forEach((({onPending:e})=>{null==e||e(t,i)}))})),i.addCase(t.fulfilled,((t,i)=>{e.forEach((({onFulfilled:e})=>{null==e||e(t,i)}))})),i.addCase(t.rejected,((t,i)=>{e.forEach((({onRejected:e})=>{null==e||e(t,i)}))}))},B=t=>({onFulfilled:e=>{t(e).loading=!1},onPending:e=>{t(e).loading=!0,t(e).error=null},onRejected:(e,i)=>{t(e).loading=!1,t(e).error=i.error}}),H=M("users/me",((t,{extra:{api:e}})=>e.user.me())),_=$(H)({onFulfilled:(t,e)=>{t.me.data=e.payload}},B((t=>t.me))),z={action:H,reducer:_},X=M("tenant/details",((t,{extra:{api:e}})=>e.tenant.details())),Y=$(X)({onFulfilled:(t,e)=>{t.tenant.data=e.payload}},B((t=>t.tenant))),G={action:X,reducer:Y},J=M("tenant/adminLinkSso",(({ssoIds:t},{extra:{api:e}})=>e.tenant.adminLinkSso({ssoIds:t}))),K={action:J,reducer:$(J)({onFulfilled:(t,e)=>{var i;t.tenantAdminLinkSSO.data=null!==(i=e.payload)&&void 0!==i?i:{defaultLink:"",ssoIdToLink:{}}}},B((t=>t.tenantAdminLinkSSO)))},Q={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:{defaultLink:"",ssoIdToLink:{}}}},V={me:"/v1/auth/me"},Z={details:"/v1/mgmt/tenant",adminLinkSso:"/v1/mgmt/tenant/adminlinks/sso/authenticated/batch"},tt=e=>t(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),et=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),it=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({tenantId:"tenant-1",roleNames:["admin"],id:"tenant-1",name:"Test Tenant",selfProvisioningDomains:["example1.com","example2.com"],customAttributes:{},authType:"password",domains:[],createdTime:Date.now(),disabled:!1,enforceSSO:!0})}))})),st=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({defaultLink:"_blank",ssoIdToLink:{"okta-prod":"_blank?ssoId=okta-prod","entra-eu":"_blank?ssoId=entra-eu"}})}))})),nt=({httpClient:e,tenantId:i,mock:s})=>{const n=encodeURIComponent(i||""),o=`?tenant=${n}&id=${n}`;return{details:()=>t(void 0,void 0,void 0,(function*(){if(s)return it();if(!i)throw new Error("tenantId is not defined");const t=`${Z.details}${o}`,n=yield e.get(t);yield tt(n);return yield n.json()})),adminLinkSso:o=>t(void 0,[o],void 0,(function*({ssoIds:t}){if(s)return st();if(!i)throw new Error("tenantId is not defined");const o=yield e.post(`${Z.adminLinkSso}?tenant=${n}`,{tenantId:n,ssoIds:t},{headers:{"Content-Type":"application/json"}});yield tt(o);return yield o.json()}))}},ot=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return et();const t=yield e.get(V.me);return yield tt(t),t.json()}))}),at=s((s=>{var o,a,f,v;const m=n(r,d,l,h,c)(s);return v=class extends m{constructor(){super(...arguments),o.add(this),a.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||u}get api(){return e(this,a,"f")||e(this,o,"m",f).call(this),e(this,a,"f")}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url","tenant","mock"],(()=>{e(this,a,"f")&&e(this,o,"m",f).call(this)}))}))}},a=new WeakMap,o=new WeakSet,f=function(){this.logger.debug("creating an sdk instance"),i(this,a,((t,e,i,s)=>{const n=D(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.8.4"}}));return{user:ot({httpClient:n.httpClient,mock:i}),tenant:nt({httpClient:n.httpClient,tenantId:e,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},v})),rt=s((t=>{const e=n(f({name:"widget",initialState:Q,reducers:{},extraReducers:t=>{z.reducer(t),G.reducer(t),K.reducer(t)},asyncActions:{getMe:z.action,getTenant:G.action,getTenantAdminLinkSSO:K.action}}),v,l,at)(t);return class extends e{constructor(...t){super(...t),this.state=Q,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),dt="widget-flow",lt=s((i=>{var s,o,a;return a=class extends(n(m,v,g,rt,c,l,p,w)(i)){constructor(){super(...arguments),s.add(this)}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);const n=U(dt);n&&(!function(t){if(window.history.replaceState&&U(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}(dt),e(this,s,"m",o).call(this,n))}))}},s=new WeakSet,o=function(e){const i=this.createModal({"data-id":"redirect-flow"});i.setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId}));new T((()=>{var t;return null===(t=i.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>t(this,void 0,void 0,(function*(){i.close(),this.actions.getMe(),yield this.actions.getTenant();const t=N(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})})))),i.afterClose=()=>{i.remove()},i.open()},a})),ht=s((t=>class extends(n(p,d)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}}));const ct=s((i=>{var s,a,r;return r=class extends(n(l,v,y,S,k("tenant-profile-widget"),rt)(i)){constructor(){super(...arguments),s.add(this)}onWidgetRootReady(){return t(this,void 0,void 0,(function*(){}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant()]);const t=N(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})}catch(t){}const n=this.state.me.error||(t=>t.tenant.error)(this.state)||(t=>t.tenantAdminLinkSSO.error)(this.state);if(n){this.contentRootElement.innerHTML="";const t="object"==typeof n&&null!==n&&"message"in n?n.message:String(n)||"An error occurred";this.contentRootElement.append(function({mainMessage:t="An error occurred"}){const e=document.createElement("div");e.setAttribute("data-id","widget-error"),e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="center",e.style.justifyContent="center",e.style.padding="72px 36px",e.style.background="#fff",e.style.borderRadius="12px",e.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",e.style.margin="32px auto",e.style.maxWidth="400px";const i=document.createElement("div");i.innerHTML='\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" stroke="#FF3B3B" stroke-width="3" fill="#fff"/>\n <text x="20" y="27" text-anchor="middle" font-size="24" font-family="Arial, sans-serif" fill="#FF3B3B">!</text>\n </svg>\n ',i.style.marginBottom="12px",e.appendChild(i);const s=document.createElement("div");return s.textContent=t,s.style.fontWeight="bold",s.style.fontSize="20px",s.style.color="#222",s.style.textAlign="center",s.style.marginTop="8px",e.appendChild(s),e}({mainMessage:t}))}else yield e(this,s,"m",a).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},s=new WeakSet,a=function(){return t(this,void 0,void 0,(function*(){const t=o(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(t),this.contentRootElement.append(t.content.cloneNode(!0))}))},r})),ut=s((s=>{var o,a,r,d,h,c,u,f,v,m,p,y;return y=class extends(n(ht,rt,g,l,ct,w)(s)){constructor(){super(...arguments),o.add(this),a.set(this,void 0),r.set(this,void 0),d.set(this,void 0),h.set(this,void 0),c.set(this,void 0)}onWidgetRootReady(){const s=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=s.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,a,new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("descope-multi-sso")}),{logger:this.logger}),"f"),e(this,a,"f").isExists&&(e(this,o,"m",p).call(this),e(this,a,"f").data=P(this.state),this.subscribe((t=>{e(this,a,"f").data=t}),P))}))}},a=new WeakMap,r=new WeakMap,d=new WeakMap,h=new WeakMap,c=new WeakMap,o=new WeakSet,u=function(){i(this,r,this.createModal({"data-id":"multi-sso-create-modal"}),"f"),i(this,d,new T((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e(this,d,"f"))},f=function(){i(this,h,this.createModal({"data-id":"multi-sso-delete-modal"}),"f"),i(this,c,new T((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e(this,c,"f"))},v=function(i){e(this,r,"f").setContent(this.createFlowTemplate({flowId:i,tenant:this.tenantId})),e(this,r,"f").open(),e(this,d,"f").onSuccess((()=>t(this,void 0,void 0,(function*(){e(this,r,"f").close(),yield this.actions.getTenant();const t=N(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})}))))},m=function(t,i){e(this,h,"f").setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId,form:{deleteSSOConfigurationId:i}})),e(this,h,"f").open(),e(this,c,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},p=function(){const{createFlowId:t,deleteFlowId:i}=e(this,a,"f");i&&(e(this,o,"m",f).call(this),e(this,a,"f").onDeleteClicked((({id:t})=>e(this,o,"m",m).call(this,i,t)))),t&&(e(this,o,"m",u).call(this),e(this,a,"f").onCreateClicked((()=>e(this,o,"m",v).call(this,t))))},y})),ft=s((i=>{var s,o,r,d;return d=class extends(n(ht,rt,l,ct,c,g)(i)){constructor(){super(...arguments),s.add(this),r.set(this,a((t=>{this.tenantAdminLinkSSODriver.href=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,s,"m",o).call(this),e(this,r,"f").call(this,C(this.state)),this.subscribe(e(this,r,"f").bind(this),C)}))}},r=new WeakMap,s=new WeakSet,o=function(){this.tenantAdminLinkSSODriver=new I((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},d}));var vt;!function(t){t.TEXT="text",t.NUMBER="number",t.BOOLEAN="boolean",t.SINGLE_SELECT="singleSelect",t.ARRAY="array",t.DATE="date"}(vt||(vt={}));const mt=s((i=>{var s,o,r,d,h,u,f,v,p,y,S;return S=class extends(n(m,ht,rt,l,ct,c,g,w)(i)){constructor(){super(...arguments),s.add(this),o.set(this,{}),r.set(this,{}),d.set(this,{}),h.set(this,{}),v.set(this,a((t=>{var i;const n=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(n).forEach((i=>{const n=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||vt.TEXT,a=t[n],r=new x(i,{logger:this.logger});r.value=((t,e)=>t===vt.DATE&&e?new Date(e).toLocaleString():t===vt.BOOLEAN&&void 0!==e?e?"True":"False":(e||"").toString())(o,a),e(this,s,"m",p).call(this,i,n,r,o,n),e(this,s,"m",y).call(this,i,n,r)}))})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,v,"f").call(this,A(this.state)),this.subscribe(e(this,v,"f").bind(this),A)}))}},o=new WeakMap,r=new WeakMap,d=new WeakMap,h=new WeakMap,v=new WeakMap,s=new WeakSet,u=function(t,i,s){var n,a;const d=A(this.state)[s],l=i===vt.ARRAY?(d||[]).join(","):d;null===(n=e(this,o,"f")[t])||void 0===n||n.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId,form:{customAttributes:{[s]:l}}})),null===(a=e(this,r,"f")[t])||void 0===a||a.onSuccess((()=>{var i;null===(i=e(this,o,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},f=function(t){var i,s;null===(i=e(this,d,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId})),null===(s=e(this,h,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,d,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},p=function(t,i,n,a,d){const l=t.getAttribute("edit-flow-id");l&&(e(this,o,"f")[l]||(e(this,o,"f")[l]=this.createModal({"data-id":`edit-${i}`}),e(this,r,"f")[l]=new T((()=>{var t,i;return null===(i=null===(t=e(this,o,"f")[l])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,o,"f")[l].beforeOpen=e(this,s,"m",u).bind(this,l,a,d),n.onEditClick((()=>{var t,i;null===(i=null===(t=e(this,o,"f"))||void 0===t?void 0:t[l])||void 0===i||i.open()})),this.syncFlowTheme(e(this,r,"f")[l])))},y=function(t,i,n){const o=t.getAttribute("delete-flow-id");o&&(e(this,d,"f")[o]||(e(this,d,"f")[o]=this.createModal({"data-id":`delete-${i}`}),e(this,h,"f")[o]=new T((()=>{var t,i;return null===(i=null===(t=e(this,d,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,d,"f")[o].beforeOpen=e(this,s,"m",f).bind(this,o),n.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,d,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),this.syncFlowTheme(e(this,h,"f")[o])))},S})),gt=s((s=>{var o,r,d,h,u,f,v,p,y,S,k,b;return b=class extends(n(m,ht,rt,l,ct,c,g,w)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),h.set(this,void 0),u.set(this,void 0),k.set(this,a((t=>{this.tenantEmailDomainsDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",S).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,k,"f").call(this,L(this.state)),this.subscribe(e(this,k,"f").bind(this),L)}))}},r=new WeakMap,d=new WeakMap,h=new WeakMap,u=new WeakMap,k=new WeakMap,o=new WeakSet,f=function(){this.tenantEmailDomainsDriver.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-tenant-email-domains"}),"f"),i(this,d,new T((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").beforeOpen=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,form:{tenantEmailDomains:L(this.state)}})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(i(this,h,this.createModal({"data-id":"delete-tenant-email-domains"}),"f"),i(this,u,new T((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,h,"f").beforeOpen=e(this,o,"m",y).bind(this),e(this,o,"m",y).call(this),this.syncFlowTheme(e(this,u,"f")))},y=function(){e(this,h,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId})),e(this,u,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},S=function(){this.tenantEmailDomainsDriver=new x((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var t;null===(t=e(this,h,"f"))||void 0===t||t.open()}))},b})),pt=s((s=>{var o,r,d,h,u,f,v,p,y,S,k,b;return b=class extends(n(m,ht,rt,l,ct,c,g,w)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),h.set(this,void 0),u.set(this,void 0),k.set(this,a((t=>{this.tenantSSOExclusionsDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",S).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,k,"f").call(this,j(this.state)),this.subscribe(e(this,k,"f").bind(this),j)}))}},r=new WeakMap,d=new WeakMap,h=new WeakMap,u=new WeakMap,k=new WeakMap,o=new WeakSet,f=function(){this.tenantSSOExclusionsDriver.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),i(this,d,new T((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").beforeOpen=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,form:{enforceSSOExclusions:j(this.state)}})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(i(this,h,this.createModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),i(this,u,new T((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,h,"f").beforeOpen=e(this,o,"m",y).bind(this),e(this,o,"m",y).call(this),this.syncFlowTheme(e(this,u,"f")))},y=function(){e(this,h,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId})),e(this,u,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},S=function(){this.tenantSSOExclusionsDriver=new x((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var t;null===(t=e(this,h,"f"))||void 0===t||t.open()}))},b})),wt=s((s=>{var o,r,d,h,u,f,v,p,y,S,k,b;return b=class extends(n(m,ht,rt,l,ct,c,g,w)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),h.set(this,void 0),u.set(this,void 0),k.set(this,a((t=>{this.tenantEnforceSSODriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",S).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,k,"f").call(this,q(this.state)),this.subscribe(e(this,k,"f").bind(this),q)}))}},r=new WeakMap,d=new WeakMap,h=new WeakMap,u=new WeakMap,k=new WeakMap,o=new WeakSet,f=function(){this.tenantEnforceSSODriver.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-tenant-enforce-sso"}),"f"),i(this,d,new T((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").beforeOpen=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,form:{enforceSSO:q(this.state)}})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantEnforceSSODriver.deleteFlowId&&(i(this,h,this.createModal({"data-id":"delete-tenant-enforce-sso"}),"f"),i(this,u,new T((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,h,"f").beforeOpen=e(this,o,"m",y).bind(this),e(this,o,"m",y).call(this),this.syncFlowTheme(e(this,u,"f")))},y=function(){e(this,h,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId})),e(this,u,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},S=function(){this.tenantEnforceSSODriver=new x((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var t;null===(t=e(this,h,"f"))||void 0===t||t.open()}))},b})),yt=s((s=>{var o,r,d,h,u,f,v,p;return p=class extends(n(m,ht,rt,l,ct,c,g,w)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),v.set(this,a((t=>{this.tenantNameDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",f).call(this),e(this,o,"m",h).call(this),e(this,v,"f").call(this,F(this.state)),this.subscribe(e(this,v,"f").bind(this),F)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,o=new WeakSet,h=function(){this.tenantNameDriver.editFlowId&&(i(this,r,this.createModal({"data-id":"tenant-profile-set-name"}),"f"),i(this,d,new T((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").beforeOpen=e(this,o,"m",u).bind(this),e(this,o,"m",u).call(this),this.syncFlowTheme(e(this,d,"f")))},u=function(){e(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,form:{tenantName:F(this.state)}})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantNameDriver=new x((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},p})),St=s((s=>{var o,a,r,d,h,u,f;return f=class extends(n(m,ht,rt,l,ct,c,g,w)(s)){constructor(){super(...arguments),o.add(this),a.set(this,void 0),r.set(this,void 0)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",u).call(this),e(this,o,"m",d).call(this)}))}},a=new WeakMap,r=new WeakMap,o=new WeakSet,d=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(i(this,a,this.createModal({"data-id":"password-policy"}),"f"),i(this,r,new T((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",h).bind(this),e(this,o,"m",h).call(this),this.syncFlowTheme(e(this,r,"f")))},h=function(){e(this,a,"f").setContent(this.createFlowTemplate({flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId})),e(this,r,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getTenant()}))},u=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new O((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},f})),kt=s((s=>{var o,a,r,d,h,u,f;return f=class extends(n(m,ht,rt,l,ct,c,g,w)(s)){constructor(){super(...arguments),o.add(this),a.set(this,void 0),r.set(this,void 0)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",u).call(this),e(this,o,"m",d).call(this)}))}},a=new WeakMap,r=new WeakMap,o=new WeakSet,d=function(){this.TenantSessionSettingsUserAuthMethodDriver.flowId&&(i(this,a,this.createModal({"data-id":"session-settings"}),"f"),i(this,r,new T((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",h).bind(this),e(this,o,"m",h).call(this),this.syncFlowTheme(e(this,r,"f")))},h=function(){e(this,a,"f").setContent(this.createFlowTemplate({flowId:this.TenantSessionSettingsUserAuthMethodDriver.flowId,tenant:this.tenantId})),e(this,r,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getTenant()}))},u=function(){this.TenantSessionSettingsUserAuthMethodDriver=new O((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="session-settings"]')}),{logger:this.logger}),this.TenantSessionSettingsUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},f})),bt=s((e=>class extends(n(b,p,lt,ct,yt,gt,pt,wt,mt,ft,St,kt,ut)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Rt=n((e=>class extends(bt(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((t=>t.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.8.4"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",Rt);export{Rt as default};
6
6
  //# sourceMappingURL=index.js.map