@digital-realty/ui-user-management 16.0.2 → 16.0.3-fix-1.558007
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/sw.js +1 -1
- package/dist/sw.js.map +1 -1
- package/dist/ui-user-management.js +1 -1
- package/package.json +1 -1
package/dist/sw.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
if(!self.define){let e,n={};const i=(i,r)=>(i=new URL(i+".js",r).href,n[i]||new Promise(n=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=n,document.head.appendChild(e)}else e=i,importScripts(i),n()}).then(()=>{let e=n[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(r,s)=>{const
|
|
1
|
+
if(!self.define){let e,n={};const i=(i,r)=>(i=new URL(i+".js",r).href,n[i]||new Promise(n=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=n,document.head.appendChild(e)}else e=i,importScripts(i),n()}).then(()=>{let e=n[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(r,s)=>{const f=e||("document"in self?document.currentScript.src:"")||location.href;if(n[f])return;let t={};const u=e=>i(e,f),o={module:{uri:f},exports:t,require:u};n[f]=Promise.all(r.map(e=>o[e]||u(e))).then(e=>(s(...e),t))}}define(["./workbox-b865b753"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"index.html",revision:"d89f572522c250fdce8f56d27a121caf"},{url:"ui-user-management.js",revision:"bc51f1567fd591464f6664611699e942"},{url:"ui-user-management2.js",revision:"5bb6f4d5bf81f289d7330abc60af3ad4"},{url:"ui-user-management3.js",revision:"0ec415bff7bce30bf75c5e1fb5630305"},{url:"ui-user-management4.js",revision:"699a2ed550f224f607559558f1c06027"},{url:"ui-user-management5.js",revision:"1d60f32bc9923e5f21c4651eb85a6913"},{url:"ui-user-management6.js",revision:"3d125f029ee5e6ee0d344905a48f9929"}],{}),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"))),e.registerRoute("polyfills/*.js",new e.CacheFirst,"GET")});
|
|
2
2
|
//# sourceMappingURL=sw.js.map
|
package/dist/sw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sw.js","sources":["../../../../../../tmp/
|
|
1
|
+
{"version":3,"file":"sw.js","sources":["../../../../../../tmp/e18f034147e737feb53b1e387a58d7ab/sw.js"],"sourcesContent":["import {registerRoute as workbox_routing_registerRoute} from '/home/vsts/work/1/s/ui-user-management/node_modules/.pnpm/workbox-routing@6.6.0/node_modules/workbox-routing/registerRoute.mjs';\nimport {CacheFirst as workbox_strategies_CacheFirst} from '/home/vsts/work/1/s/ui-user-management/node_modules/.pnpm/workbox-strategies@6.6.0/node_modules/workbox-strategies/CacheFirst.mjs';\nimport {clientsClaim as workbox_core_clientsClaim} from '/home/vsts/work/1/s/ui-user-management/node_modules/.pnpm/workbox-core@6.6.0/node_modules/workbox-core/clientsClaim.mjs';\nimport {precacheAndRoute as workbox_precaching_precacheAndRoute} from '/home/vsts/work/1/s/ui-user-management/node_modules/.pnpm/workbox-precaching@6.6.0/node_modules/workbox-precaching/precacheAndRoute.mjs';\nimport {NavigationRoute as workbox_routing_NavigationRoute} from '/home/vsts/work/1/s/ui-user-management/node_modules/.pnpm/workbox-routing@6.6.0/node_modules/workbox-routing/NavigationRoute.mjs';\nimport {createHandlerBoundToURL as workbox_precaching_createHandlerBoundToURL} from '/home/vsts/work/1/s/ui-user-management/node_modules/.pnpm/workbox-precaching@6.6.0/node_modules/workbox-precaching/createHandlerBoundToURL.mjs';/**\n * Welcome to your Workbox-powered service worker!\n *\n * You'll need to register this file in your web app.\n * See https://goo.gl/nhQhGp\n *\n * The rest of the code is auto-generated. Please don't update this file\n * directly; instead, make changes to your Workbox build configuration\n * and re-run your build process.\n * See https://goo.gl/2aRDsh\n */\n\n\n\n\n\n\n\n\nself.skipWaiting();\n\nworkbox_core_clientsClaim();\n\n\n/**\n * The precacheAndRoute() method efficiently caches and responds to\n * requests for URLs in the manifest.\n * See https://goo.gl/S9QRab\n */\nworkbox_precaching_precacheAndRoute([\n {\n \"url\": \"index.html\",\n \"revision\": \"d89f572522c250fdce8f56d27a121caf\"\n },\n {\n \"url\": \"ui-user-management.js\",\n \"revision\": \"bc51f1567fd591464f6664611699e942\"\n },\n {\n \"url\": \"ui-user-management2.js\",\n \"revision\": \"5bb6f4d5bf81f289d7330abc60af3ad4\"\n },\n {\n \"url\": \"ui-user-management3.js\",\n \"revision\": \"0ec415bff7bce30bf75c5e1fb5630305\"\n },\n {\n \"url\": \"ui-user-management4.js\",\n \"revision\": \"699a2ed550f224f607559558f1c06027\"\n },\n {\n \"url\": \"ui-user-management5.js\",\n \"revision\": \"1d60f32bc9923e5f21c4651eb85a6913\"\n },\n {\n \"url\": \"ui-user-management6.js\",\n \"revision\": \"3d125f029ee5e6ee0d344905a48f9929\"\n }\n], {});\n\nworkbox_routing_registerRoute(new workbox_routing_NavigationRoute(workbox_precaching_createHandlerBoundToURL(\"/index.html\")));\n\n\nworkbox_routing_registerRoute(\"polyfills/*.js\", new workbox_strategies_CacheFirst(), 'GET');\n\n\n\n\n"],"names":["self","skipWaiting","workbox_core_clientsClaim","workbox_precaching_precacheAndRoute","url","revision","workbox","registerRoute","workbox_routing_NavigationRoute","workbox_precaching_createHandlerBoundToURL","workbox_strategies_CacheFirst"],"mappings":"inBAwBAA,KAAKC,cAELC,EAAAA,eAQAC,EAAAA,iBAAoC,CAClC,CACEC,IAAO,aACPC,SAAY,oCAEd,CACED,IAAO,wBACPC,SAAY,oCAEd,CACED,IAAO,yBACPC,SAAY,oCAEd,CACED,IAAO,yBACPC,SAAY,oCAEd,CACED,IAAO,yBACPC,SAAY,oCAEd,CACED,IAAO,yBACPC,SAAY,oCAEd,CACED,IAAO,yBACPC,SAAY,qCAEb,CAAE,GAEwBC,EAAAC,cAAC,IAAIC,EAAAA,gBAAgCC,EAAAA,wBAA2C,iBAGhFH,EAAAC,cAAC,iBAAkB,IAAIG,aAAiC"}
|
|
@@ -2029,7 +2029,7 @@ video {
|
|
|
2029
2029
|
}
|
|
2030
2030
|
}
|
|
2031
2031
|
}
|
|
2032
|
-
`;class Na{constructor(t){this.config=t,this.gqlClient=new ji(this.config.url),this.config.accessToken&&this.gqlClient.setHeader("authorization",this.config.accessToken)}async GetRolesInventory(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Ra,{...t})}async GetFlagsInventory(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Sa,{...t})}async GetAccountInventory(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(ka,{...t})}async SaveAccountRoleAssignments(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Ua,{...t})}async SaveAccountFlagAssignments(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request($a,{...t})}}const Fa="http://localhost".replace(/\/+$/,"");class _o{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Fa}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||To}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Da=new _o;class pt{constructor(t=Da){this.configuration=t,this.fetchApi=async(o,i)=>{let n={url:o,init:i};for(const s of this.middleware)s.pre&&(n=await s.pre({fetch:this.fetchApi,...n})||n);let a;try{a=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(s){for(const l of this.middleware)l.onError&&(a=await l.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:s,response:a?a.clone():void 0})||a);if(a===void 0)throw s instanceof Error?new Ba(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(a=await s.post({fetch:this.fetchApi,url:n.url,init:n.init,response:a.clone()})||a);return a},this.middleware=t.middleware}withMiddleware(...t){const o=this.clone();return o.middleware=o.middleware.concat(...t),o}withPreMiddleware(...t){const o=t.map(i=>({pre:i}));return this.withMiddleware(...o)}withPostMiddleware(...t){const o=t.map(i=>({post:i}));return this.withMiddleware(...o)}isJsonMime(t){return t?pt.jsonRegex.test(t):!1}async request(t,o){const{url:i,init:n}=await this.createFetchParams(t,o),a=await this.fetchApi(i,n);if(a&&a.status>=200&&a.status<300)return a;throw new Oa(a,"Response returned an error code")}async createFetchParams(t,o){let i=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(i+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(u=>n[u]===void 0?delete n[u]:{});const a=typeof o=="function"?o:async()=>o,s={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},l={...s,...await a({init:s,context:t})};let p;Ma(l.body)||l.body instanceof URLSearchParams||Pa(l.body)?p=l.body:this.isJsonMime(n["Content-Type"])?p=JSON.stringify(l.body):p=l.body;const h={...l,body:p};return{url:i,init:h}}clone(){const t=this.constructor,o=new t(this.configuration);return o.middleware=this.middleware.slice(),o}}pt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Pa(e){return typeof Blob<"u"&&e instanceof Blob}function Ma(e){return typeof FormData<"u"&&e instanceof FormData}class Oa extends Error{constructor(t,o){super(o),this.response=t,this.name="ResponseError"}}class Ba extends Error{constructor(t,o){super(o),this.cause=t,this.name="FetchError"}}class La extends Error{constructor(t,o){super(o),this.field=t,this.name="RequiredError"}}function re(e,t){return e[t]!=null}function To(e,t=""){return Object.keys(e).map(o=>Io(o,e[o],t)).filter(o=>o.length>0).join("&")}function Io(e,t,o=""){const i=o+(o.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(a=>encodeURIComponent(String(a))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Io(e,n,o)}return t instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?To(t,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(t))}`}class Eo{constructor(t,o=i=>i){this.raw=t,this.transformer=o}async value(){return this.transformer(await this.raw.json())}}function Ro(e){return qa(e)}function qa(e,t){return e==null?e:{firstName:re(e,"firstName")?e.firstName:void 0,lastName:re(e,"lastName")?e.lastName:void 0,contactPhoneNumber:re(e,"contactPhoneNumber")?e.contactPhoneNumber:void 0,preferredLanguage:re(e,"preferredLanguage")?e.preferredLanguage:void 0,preferredTimezone:re(e,"preferredTimezone")?e.preferredTimezone:void 0,timezoneOverridden:re(e,"timezoneOverridden")?e.timezoneOverridden:void 0,preferredDateFormat:re(e,"preferredDateFormat")?e.preferredDateFormat:void 0,preferredTimeFormat:re(e,"preferredTimeFormat")?e.preferredTimeFormat:void 0,email:re(e,"email")?e.email:void 0}}function Ha(e){if(e!==void 0)return e===null?null:{firstName:e.firstName,lastName:e.lastName,contactPhoneNumber:e.contactPhoneNumber,preferredLanguage:e.preferredLanguage,preferredTimezone:e.preferredTimezone,timezoneOverridden:e.timezoneOverridden,preferredDateFormat:e.preferredDateFormat,preferredTimeFormat:e.preferredTimeFormat}}class za extends pt{async getUserSettingsRaw(t){const o={},i={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,s=await a("bearerToken",[]);s&&(i.Authorization=`Bearer ${s}`)}const n=await this.request({path:"/user-profile",method:"GET",headers:i,query:o},t);return new Eo(n,a=>Ro(a))}async getUserSettings(t){return await(await this.getUserSettingsRaw(t)).value()}async userProfilePatchRaw(t,o){if(t.profileSettingEditInput===null||t.profileSettingEditInput===void 0)throw new La("profileSettingEditInput","Required parameter requestParameters.profileSettingEditInput was null or undefined when calling userProfilePatch.");const i={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,l=await s("bearerToken",[]);l&&(n.Authorization=`Bearer ${l}`)}const a=await this.request({path:"/user-profile",method:"PATCH",headers:n,query:i,body:Ha(t.profileSettingEditInput)},o);return new Eo(a,s=>Ro(s))}async userProfilePatch(t,o){return await(await this.userProfilePatchRaw(t,o)).value()}}class Va{constructor(t){this.configuration=t}get InventoryApi(){return new Na({url:this.configuration.userManagementAggregationApiUrl,accessToken:this.getToken()})}get UsersApi(){return new Ia(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get AccountAssociationApi(){return new ya(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get AccountsApi(){return new ba(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get RolesApi(){return new _a(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get PermissionsApi(){return new Aa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get RoleAssignmentsApi(){return new Ca(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get UserFlagsApi(){return new Ta(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get VerificationApi(){return new Ea(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get ChangeHistoriesApi(){return new wa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get AuthorityDocumentsApi(){return new xa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get UserProfileSettingsApi(){var t;const o=((t=this.getToken())!==null&&t!==void 0?t:"").replace(/^Bearer\s+/i,""),i={};return new za(new _o({basePath:this.configuration.LoginAuthority,accessToken:o,headers:i}))}getToken(){return this.configuration.getTokenFn?this.configuration.getTokenFn():void 0}}class ja extends Gi{constructor(t,o){super({...t}),this.hashed_identifier="",this.email="",this.account_number="",this.hashed_identifier=o}get getEmail(){var t;return(t=this.email)!==null&&t!==void 0?t:this.profile.email}get getAccount(){var t;return(t=this.account_number)!==null&&t!==void 0?t:this.profile.account_number}}class Ve{constructor({loginAuthority:t,clientId:o,scope:i,postLogoutRedirectUri:n,userStorageKey:a=N().UserManagement.UI.UserManagementUIStorageKey,xauthStorageKey:s=N().UserManagement.UI.UserManagementXAuthUIStorageKey,redirectUrlKey:l="redirect-url",authPaths:p={authenticate:"authenticate",authCallback:"auth-callback",logout:"logout"}}){this.configuration={loginAuthority:t,clientId:o,scope:i,postLogoutRedirectUri:n,userStorageKey:a,xauthStorageKey:s,redirectUrlKey:l,authPaths:p};const{location:h}=window,u=`${h.protocol}//${h.hostname}${h.port?`:${h.port}`:""}`,b={authority:this.configuration.loginAuthority,client_id:this.configuration.clientId,redirect_uri:`${u}/${this.configuration.authPaths.authCallback}`,response_type:"code",scope:this.configuration.scope,post_logout_redirect_uri:this.configuration.postLogoutRedirectUri,loadUserInfo:!0};this.userManager=new Ji(b)}isLoggedIn(){const t=this.getUser();if(t===null)return!1;if(!t.expires_at)return!0;const o=new Date,i=new Date(t.expires_at*1e3);return o<i}redirectToAuth(t=!1){const o=this.isAuthenticating();(t||!o)&&(o||localStorage.setItem(this.configuration.redirectUrlKey,window.location.href),window.location.href=`/${this.configuration.authPaths.authenticate}`)}isAuthenticating(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authenticate?(this.userManager.signinRedirect(),!0):!1}isHandlingAuthCallback(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authCallback?(this.userManager.signinRedirectCallback().then(Ve.ensureValidUser).then(Ve.addHashedIdToUserProfile).then(o=>this.saveUser(o)).then(()=>this.authSuccessRedirect()).catch(()=>this.redirectToAuth()),!0):!1}authSuccessRedirect(){let t="/";const o=localStorage.getItem(this.configuration.redirectUrlKey);o&&(localStorage.removeItem(this.configuration.redirectUrlKey),t=o),window.location.href=t}redirectToLogout(){this.isHandlingLogout()||(window.location.href=`/${this.configuration.authPaths.logout}`)}isHandlingLogout(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.logout?(this.clearUser(),window.localStorage.clear(),this.userManager.signoutRedirect({id_token_hint:this.getIdToken()}),!0):!1}isProcessing(){return this.isAuthenticating()||this.isHandlingAuthCallback()||this.isHandlingLogout()}saveUser(t){localStorage.setItem(this.configuration.userStorageKey,JSON.stringify(t))}clearUser(){localStorage.removeItem(this.configuration.userStorageKey)}getXAuthUser(){const t=localStorage.getItem(this.configuration.xauthStorageKey);if(t){const o=JSON.parse(t);if(o!=null&&o.email&&o!=null&&o.account_number)return o}}getTokenUser(){const t=localStorage.getItem(this.configuration.userStorageKey);if(t)return JSON.parse(t)}getUser(){const t=this.getTokenUser();return t?(t.profile.email||(t.profile.email=this.getXAuthUser().email),t!=null?t:null):null}getUserDetails(){const t={accountNumber:"",email:""},o=this.getUser();return o&&(t.accountNumber=o.profile.account_number,t.email=o.profile.email),t}getUserProfileSub(){var t;const o=this.getUser();return(t=o==null?void 0:o.profile)===null||t===void 0?void 0:t.sub}getUserLocale(){var t;const o=this.getUser();return(t=o==null?void 0:o.profile)===null||t===void 0?void 0:t.locale}getIdToken(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.id_token}getAccessToken(){var t;return`Bearer ${(t=this.getUser())===null||t===void 0?void 0:t.access_token}`}static async hashValue(t){const o=new TextEncoder().encode(t),i=await crypto.subtle.digest("SHA-256",o);return Array.from(new Uint8Array(i)).map(n=>n.toString(16).padStart(2,"0")).join("")}static async addHashedIdToUserProfile(t){const o=`${t.profile.sub}-${t.profile.customer_id}`,i=await Ve.hashValue(o);return new ja(t,i)}static ensureValidUser(t){if(!t.id_token)throw new Error("Missing property:id_token");return t}}const we=N(),Ae=new Ve({loginAuthority:we.LoginAuthority,clientId:we.LoginService.UserManagementUIClientId,scope:we.LoginService.UserManagementUIScopes}),v=new Va({userManagementApiUrl:we.UserManagement.UI.UserManagementApiUrl,userManagementAggregationApiUrl:we.UserManagement.UI.UserManagementAggregationApiUrl,LoginAuthority:we.LoginAuthority,getTokenFn:()=>Ae.getAccessToken()});var Ga="Alerts",Ja="Content",Ka="DCIM",Za="Invoices",Wa="Marketplace",Qa="Release",Ya="Security",Xa={"Account Information":"Account Information",Alerts:Ga,"Cloud Connect":"Cloud Connect",Content:Ja,"Cross Connect":"Cross Connect","Custom Role":"Custom Role","Custom Roles":"Custom Roles","Customer Equipment Connection (CEC)":"Customer Equipment Connection (CEC)","Customer Support":"Customer Care","Customer Support Team":"Customer Support Team",DCIM:Ka,"DCIM-enabled location data":"DCIM-enabled location data","Default System Roles":"Default System Roles","EMEA MarketPlace":"EMEA MarketPlace","External User":"External User","Internal Roles":"Internal Roles","Internal User":"Internal User","Internet Exchange":"Internet Exchange","Intra-Customer Connectivity (ICC)":"Intra-Customer Connectivity (ICC)",Invoices:Za,"IP Bandwidth":"IP Bandwidth",Marketplace:Wa,"OSP Access":"OSP Access","Permanent Badge":"Permanent Badge","Planned Site Maintenance":"Maintenance & Incident Notifications","PoP/POE Room Access":"PoP/POE Room Access",Release:Qa,"Remote Hands":"Remote Hands","Remote Hands Package":"Remote Hands Package",Security:Ya,"Service Exchange Cloud Router":"Service Exchange Cloud Router","Service Exchange Port":"Service Exchange Port","Shipping & Receiving":"Deliveries & Removals","Space & Power":"Space & Power","Trouble Ticket":"Trouble Ticket","Visitor Access":"Visitor Access"};Xt.use(Ki).init({resources:{en:{translation:{...Xa}}},interpolation:{escapeValue:!1},lng:"en",debug:!1});const So=e=>Xt.t(e),es=e=>{const t=[];return e.forEach(o=>{t.push({id:o.id,name:So(o.name),isNonLocation:o.is_non_location,category:o.category,privileges:o.privileges,internalPrivileges:o.internal_privileges,isInternal:o.is_internal})}),t},ts=e=>{const t=[];return e.forEach(o=>{t.push({accountNumber:o.account_number,permissionName:So(o.permission_name),privilege:o.privilege})}),t};class os{async get(){try{const t=await v.PermissionsApi.getPermissions();return es(t)}catch(t){return g.handleError(t,"Could not get permissions."),[]}}async getMyPermissions(t){try{const o=await v.PermissionsApi.getUserPermissions(t);return ts(o)}catch(o){return g.handleError(o,"Could not retrieve current user's permissions."),[]}}}const Ze=new os,is=e=>{const t=[];return e.forEach(o=>{t.push({accountNumber:o.account_number,name:o.name,parentAccountNumber:o.parent_account_number,displayName:o.friendly_name})}),t};class ns{async get(){try{const t=await v.AccountsApi.getAccounts();return is(t)}catch(t){return g.handleError(t,"Failed to get accounts."),[]}}}const ko=new ns;class as{async getUserProfile(){try{return await v.UserProfileSettingsApi.getUserSettings()}catch(t){g.handleError(t,"Failed to get user profile.");return}}async updateUserProfile(t){try{return await v.UserProfileSettingsApi.userProfilePatch(t)}catch(o){g.handleError(o,"Failed to update user profile.");return}}}const bt=new as;class ss{constructor(){this.myPermissions=[]}isProfileOfLoggedInUser(t){var o;return((o=U==null?void 0:U.getEmail())===null||o===void 0?void 0:o.toLowerCase())===(t==null?void 0:t.toLowerCase())}hasUserRead(t){return this.hasPermission(T.user,x.read,t)}hasUserUpdate(t){return this.hasPermission(T.user,x.update,t)}hasExternalUserRead(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.read,t):this.hasPermission(T.externalUser,x.read,t)}hasExternalUserUpdate(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.update,t):this.hasPermission(T.externalUser,x.update,t)}hasExternalUserCreate(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.create,t):this.hasPermission(T.externalUser,x.create,t)}hasInternalUserRead(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.read,t):this.hasPermission(T.internalUser,x.read,t)}hasInternalUserUpdate(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.update,t):this.hasPermission(T.internalUser,x.update,t)}hasCustomRolesApprove(t){return this.hasPermission(T.customRoles,x.approve,t)}hasCustomRolesCreate(t){return this.hasPermission(T.customRoles,x.create,t)}hasCustomRolesUpdate(t){return this.hasPermission(T.customRoles,x.update,t)}hasCustomRolesRead(t){return this.hasPermission(T.customRoles,x.read,t)}hasInternalRolesCreate(t){return this.hasPermission(T.internalRoles,x.create,t)}hasInternalRolesUpdate(t){return this.hasPermission(T.internalRoles,x.update,t)}hasInternalRolesRead(t){return this.hasPermission(T.internalRoles,x.read,t)}hasDefaultSystemRolesCreate(t){return this.hasPermission(T.defaultRoles,x.create,t)}hasDefaultSystemRolesUpdate(t){return this.hasPermission(T.defaultRoles,x.update,t)}hasDefaultSystemRolesRead(t){return this.hasPermission(T.defaultRoles,x.read,t)}hasRoleManagementAccess(t){return this.hasPermission(T.defaultRoles,x.read,t)||this.hasPermission(T.customRoles,x.read,t)||this.hasPermission(T.internalRoles,x.read,t)||this.hasPermission(T.externalUser,x.read,t)}hasUserManagementAccess(){return N().UserManagement.InternalUserRetired?this.hasUserRead():this.hasExternalUserRead()||this.hasInternalUserRead()}hasAssignInternalRoleCreate(t){return this.hasPermission(T.assignInternalRole,x.create,t)}hasDLRDomain(){var t;const o=(t=U.getEmail())===null||t===void 0?void 0:t.toLowerCase().trim(),i=N();let n=!1;return i.InternalUserDomainWhitelist.split(",").forEach(a=>{const s=a.toLowerCase().trim();s&&o!=null&&o.endsWith(s)&&(n=!0)}),n}async refreshPermissions(){this.myPermissions=await Ze.getMyPermissions({excludeParents:!1,excludeSiblings:!0})}async refreshAccounts(){const t=await ko.get();U.setAccounts(t)}async getUserProfileSettings(){return bt.getUserProfile()}hasPrivilegeLevel(t,o){const i=[x.approve,x.create,x.update,x.read],n=i.findIndex(s=>s===t.toLowerCase()),a=i.findIndex(s=>s===o.toLowerCase());return n>=a}hasPermission(t,o,i){let{myPermissions:n}=this,a=!1;return i&&(n=n.filter(s=>s.accountNumber===i)),n.length&&o&&(a=n.some(s=>s.permissionName===t&&this.hasPrivilegeLevel(o,s.privilege))),a}}const B=new ss,Uo="uppercase font-bold tracking-wider",$o={LocalStorage:{},SessionStorage:{HasOutstandingChanges:"hasOutstandingChanges"}};let xt=class extends I{constructor(){super(...arguments),this.routeName=null}return(){window.sessionStorage.getItem($o.SessionStorage.HasOutstandingChanges)!=="true"&&this.routeName&&Qe(this.routeName)}render(){return c` <ix-button appearance="text" has-icon @click="${this.return}" data-testid="um-back-button"> <md-icon slot="icon">arrow_back</md-icon> <span class="${Uo}">Back</span> </ix-button>`}};r([d()],xt.prototype,"routeName",void 0),xt=r([A("um-back-button")],xt);const Pe=(e,t,o)=>{e.dispatchEvent(new CustomEvent(t,{detail:o,bubbles:!0,composed:!0}))};let No=class extends I{dispatchCreateUserEvent(){Pe(this,S.CreateUserClicked)}render(){return c` <ix-button @click="${this.dispatchCreateUserEvent}" has-icon> <md-icon slot="icon">add</md-icon> <span class="${Uo}">Create User</span> </ix-button>`}};No=r([A("um-create-user-button")],No);const G={Home:"Home",UserManagement:"User Management",RoleManagement:"Role Management",UserManagementDetails:"User Management Details"},Fo=[{name:G.Home,path:"(/?)",component:"home-view",action:()=>{import("./ui-user-management2.js")}},{name:G.UserManagement,path:"/user-management",component:"user-management-view",headerRight:c``,action:async()=>{B.hasUserManagementAccess()?import("./ui-user-management3.js"):ye.go("/")}},{name:G.RoleManagement,path:"/role-management",component:"role-management-view",action:async()=>{B.hasRoleManagementAccess()?import("./ui-user-management4.js"):ye.go("/")}},{name:G.UserManagementDetails,path:"/user-management-details",component:"user-management-details-view",hideAccountSwitcher:!0,headerLeft:c`<um-back-button routeName="${G.UserManagement}"></um-back-button>`,action:async()=>{B.hasUserManagementAccess()?import("./ui-user-management6.js"):ye.go("/")}}];let oe=null;function Do(){const{pathname:e,search:t,hash:o}=window.location;ye.go({pathname:e,search:t,hash:o})}function rs(e,t,o){const i=o.map(n=>({...n,path:`${t}${n.path}`,redirect:n.redirect?`${t}${n.redirect}`:null}));i.push({path:"(.*)",component:"no-elem"}),oe=new ye(e),oe.setRoutes(i),window.addEventListener("shell-after-navigate",Do)}function ls(){return oe}function cs(){oe==null||oe.unsubscribe(),oe==null||oe.removeRoutes(),oe=null,window.removeEventListener("shell-after-navigate",Do)}function We(e,t){return oe&&oe.urlForName(e,t)}function Qe(e,t){const o=We(e);o&&ye.go({pathname:o,hash:t})}const ds=e=>{var t,o,i,n,a,s;const l=Fo.find(h=>h.name===e),p=(s=(a=(n=(i=(o=(t=window.document.querySelector("gp-bootstrap"))===null||t===void 0?void 0:t.shadowRoot)===null||o===void 0?void 0:o.querySelector("global-portal-app"))===null||i===void 0?void 0:i.shadowRoot)===null||n===void 0?void 0:n.querySelector("ui-user-management"))===null||a===void 0?void 0:a.getAttribute("baseurl"))!==null&&s!==void 0?s:"";return window.location.pathname===`${p}${l==null?void 0:l.path}`};let wt=class extends Ue{constructor(){super(...arguments),this.setNavigationItemsBinding=this.setNavigationItems.bind(this),this.navigationItems=[],this.compact=!1}static get styles(){return[po,_]}connectedCallback(){super.connectedCallback(),window.addEventListener(S.RouteChanged,this.setNavigationItemsBinding)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(S.RouteChanged,this.setNavigationItemsBinding)}setNavigationItems(){this.requestUpdate(),!this.navigationItems.length&&(this.navigationItems=[{href:We(G.UserManagement),title:"User Management",icon:c`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="white"> ${Ke.userManagementIcon} </svg>`},{href:We(G.RoleManagement),title:"Role Management",icon:c`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="white"> ${Ke.roleManagementIcon} </svg>`}])}toggleCompact(){Pe(this,S.ToggleNavBar),setTimeout(()=>{window.dispatchEvent(new Event("resize"))},301)}renderNavigation(){return B.hasExternalUserRead()?c`${this.navigationItems.map(e=>c` <li class="relative m-1"> <div class="${e.href===window.location.pathname?"bg-white opacity-[.16] inset-0 rounded-md absolute":""}"></div> <a href="${e.href}" class="${e.href===window.location.pathname?"flex px-6 py-4 gap-4 rounded-md font-bold":"flex px-6 py-4 gap-4 rounded-md font-bold opacity-60"}"> <div class="w-6 shrink-0">${e.icon}</div> <div class="grow text-left"> <div class="${this.compact?"w-0":"w-full"} animate-width overflow-hidden"> ${e.title} </div> </div> </a> </li> `)}`:y}render(){return c` <ix-icon-button @click="${this.toggleCompact}" icon="chevron_right" class="drop-shadow-lg items-center expand-cta bg-white rounded-full text-slate-600 h-8 w-8 absolute z-20 lg:right-0 lg:top-[34px] hidden top-[27px] right-[-8px] sm:flex ${this.compact?"animate-spin-180-backwards":"animate-spin-180-forwards"}"> </ix-icon-button> <nav class="flex flex-col overflow-hidden min-h-full rounded-xl drop-shadow text-center nav-bar long text-white ${this.compact?"closed":""} whitespace-nowrap animate-width"> <div class="m-1 px-6 py-4 hidden sm:block"> <svg @click="${this.toggleCompact}" focusable="false" viewBox="0 0 178 27" fill="white" class="w-[200px]"> ${Ke.digitalRealtyLogoWithText} </svg> </div> <hr class="divider hidden sm:block"> <ul class="grow"> ${this.renderNavigation()} </ul> <dev-clear-storage-button class="white-icon self-start p-5"></dev-clear-storage-button> </nav> `}};r([d({type:Boolean})],wt.prototype,"compact",void 0),wt=r([A("navigation-bar")],wt);const us=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.header-container{display:flex;align-items:center;margin-bottom:16px}.header-container-back-btn{display:flex;flex-direction:row;justify-content:space-between;align-items:center}.back{padding-left:12px}.arrow-back-icon{font-size:22px;align-items:center;padding-right:1px}.header-rhs-actions{display:flex;flex-direction:row;justify-content:space-between;align-items:center}.profile{background-color:#092241;height:35px;margin-right:30px;margin-left:30px;border-radius:10px;color:#fff;padding-left:20px;padding-right:20px;display:flex;align-items:center}.logout{height:35px;border-radius:10px;border:none;background-color:#1456e0;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding-left:15px;padding-right:15px}.logout svg{width:1em;height:1em;font-size:20px;margin-right:5px}.add-icon{font-size:20px;align-items:center}`;let Ce=class extends Ue{constructor(){super(...arguments),this.updateLayoutBinding=this.updateLayout.bind(this),this.pageTitle="",this.showCreateUserButton=!1,this.showHeader=!0}connectedCallback(){super.connectedCallback(),window.addEventListener(S.RouteChanged,this.updateLayoutBinding)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(S.RouteChanged,this.updateLayoutBinding)}updateLayout(e){switch(this.pageTitle=e.detail.location.route.name||"",this.pageTitle){case"User Management":this.showCreateUserButton=B.hasExternalUserCreate(),this.showHeader=!0;break;case"Role Management":this.showCreateUserButton=!1,this.showHeader=!0;break;case"User Management Details":this.showCreateUserButton=!1,this.showHeader=!1;break}}getRoute(){return this.pageTitle==="User Management Details"?G.UserManagement:G.Home}dispatchCreateUserEvent(){Pe(this,S.CreateUser)}renderAppHeader(){return c` <div class="flex gap-2 items-center mt-4 mb-8 justify-between"> <div> ${this.showHeader?c`<h1 class="dlr-text-page-title">${this.pageTitle}</h1>`:c` <um-back-button .routeName="${this.getRoute()}"></um-back-button> `} </div> <div class="items-center flex gap-2 flex-wrap justify-end"> ${this.showCreateUserButton?c` <ix-button @click="${this.dispatchCreateUserEvent}" has-icon data-testid="create-user-button"> Create User <md-icon slot="icon">add</md-icon> </ix-button> `:y} </div> </div> `}render(){return c`${this.renderAppHeader()}`}};Ce.styles=[_,us],r([d({type:String})],Ce.prototype,"pageTitle",void 0),r([m()],Ce.prototype,"showCreateUserButton",void 0),r([m()],Ce.prototype,"showHeader",void 0),Ce=r([A("app-header")],Ce);const Po=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}:host{--md-outlined-text-field-label-text-color:black}.input-group{display:flex;flex-direction:row;gap:20px;margin-bottom:20px}.input-group ix-phone-input,.input-group ix-textbox{flex:1}.textfield{width:100%}ix-button{font-family:var(--root-secondary-font)}@media screen and (max-width:600px){.input-group{flex-direction:column}}`,J=e=>e?e.component.value:null,Ye=(e,t)=>{if(!e)return;const o=e.component;o.value=t},_e=e=>{if(!e)return null;const{input:t}=e;return t.value},At=(e,t)=>{if(!e)return;const{input:o}=e;o.value=t},hs=e=>e?e.component.checked:null,ps=(e,t)=>{if(!e)return;const o=e.component;o.checked=t};function Mo(e){const t=JSON.stringify(e);return JSON.parse(t)}const ms=(e,t,o)=>e.sort((i,n)=>(i[t]<n[t]?-1:1)*(o?1:-1));function gs(e){const t={};for(const[o,i]of Object.entries(e))for(const n of o.split(" "))t[n]=i;return Qi(t)}const fs=e=>{try{const t=e.startsWith("+")?eo(e):eo(`+${e}`),o=`+${t.countryCallingCode} ${new Zi(t.country||"US").input(t.nationalNumber)}`;return o.endsWith(")")||o.endsWith("(")?e:o}catch(t){return e}},vs=()=>window.matchMedia("(min-width: 1024px)").matches,Me={phone:"^[+]?[(]?[0-9]{3}[)]?[-s.]?[0-9]{3}[-s.]?[0-9]{4,6}$",name:N().UserManagement.UI.ValidationRegexPatterns.name,alphabetOnly:"^[A-Za-z]+$"},Oe=(e,t)=>{const o=e;return"component"in o&&o.component.reportValidity(),t?(o.error=!1,o.errorText="",!0):(o.error=!0,o.errorText="This field is mandatory",!1)},Oo=(e,t,o)=>{const i=e;return t!=null&&t.match(i.pattern)?(i.error=!1,i.errorText="",!0):(i.error=!0,i.errorText=o,!1)},Bo=(e,t,o)=>{if(!t)return!1;const i=e;return Yi.isEmail(t)?(i.error=!1,i.errorText="",!0):(i.error=!0,i.errorText=o,!1)},ys=e=>e.error,bs=(e,t)=>{const o=t;return J(e)===o},Ct=(e,t,o)=>{const i=J(e);return e.required&&!Oe(e,i)||e.pattern&&!Oo(e,i,o)||e.type==="email"&&!Bo(e,i,o)?!1:!(ys(e)||bs(e,t))},_t=(e,t)=>{const o=_e(e),i=e;return Wi(o)?(i.error=!1,!0):(i.error=!0,i.errorText=t,!1)},xs=(e,t)=>{t.length>0&&t.forEach(o=>{const i=e.find(n=>n.id===o.field);i&&(i.error=!0,i.errorText=o.error,i.focus())})},w={CancelCreateUser:"cancel-create-user",CloseDrawer:"close-drawer",CreateContact:"create-contact",CreateNewContact:"create-new-contact",EvacAssistanceRequired:"evac-assistance-required",NextButtonToggle:"next-button-toggle",NextStep:"next-step",ResetSuccess:"reset-success",SetStep:"set-step",ToggleDialog:"toggle-dialog",ToggleDraft:"toggle-draft",ToggleDrawer:"toggle-drawer",UpdateAccounts:"update-accounts",UpdateAttachments:"update-attachments",UpdateContact:"update-contact",UpdateDFA:"update-dfa",UpdateFlags:"update-flags",UpdateObofSelections:"update-obof-selections",ValidateStep:"validate-step"};let fe=class extends I{constructor(){super(...arguments),this.validatingForm=!1,this._newContact={firstName:"",lastName:"",email:"",phone:"",accounts:[],evacAssistance:!1},this._nextButtonEnabled=!1}firstUpdated(){this._newContact=this.newContact,this.validateStep(),this.dispatchValidateStepEvent()}get firstName(){return this.renderRoot.querySelector("#first-name")}get lastName(){return this.renderRoot.querySelector("#last-name")}get email(){return this.renderRoot.querySelector("#email")}get phone(){return this.renderRoot.querySelector("#phone-number")}validateStep(){this._nextButtonEnabled=!(this.isInvalid()||this.isEmpty())}validateInput(e,t){const o=J(e);if(this.updateContactDetails(),e.required&&!Oe(e,o)){this._nextButtonEnabled=!1;return}e.pattern&&!Oo(e,o,t)&&(this._nextButtonEnabled=!1),this.validateStep(),this.dispatchNextButtonToggleEvent()}async validateEmailInput(e,t){this._nextButtonEnabled=!1;const o=J(e);if(this.updateContactDetails(),e.required&&!Oe(e,o)){this._nextButtonEnabled=!1;return}if(!Bo(e,o,t)){this._nextButtonEnabled=!1;return}clearTimeout(this.debounceTimeout),this.debounceTimeout=window.setTimeout(async()=>{const i={emailVerificationInput:{email_address:o!=null?o:""}};try{(await v.VerificationApi.verifyEmail(i)).is_verified?(e.error=!1,e.errorText="",this._nextButtonEnabled=!(this.isInvalid()||this.isEmpty())):(e.error=!0,e.errorText=`${t}`,this._nextButtonEnabled=!1)}catch(n){e.error=!0,e.errorText="An error occurred during email verification. Please try again later.",this._nextButtonEnabled=!1}},500),this.validateStep(),this.dispatchNextButtonToggleEvent()}validatePhoneInput(e,t){const o=_e(e);if(At(e,o),this.updateContactDetails(),e.required&&!Oe(e,o)){this._nextButtonEnabled=!1;return}if(!_t(e,t)){this._nextButtonEnabled=!1;return}this.validateStep(),this.dispatchNextButtonToggleEvent()}updateContactDetails(){var e,t,o,i;this._newContact={firstName:(e=J(this.firstName))!==null&&e!==void 0?e:"",lastName:(t=J(this.lastName))!==null&&t!==void 0?t:"",email:(o=J(this.email))!==null&&o!==void 0?o:"",phone:(i=_e(this.phone))!==null&&i!==void 0?i:"",accounts:this._newContact.accounts,evacAssistance:this._newContact.evacAssistance},this.dispatchUpdateContactEvent()}clearTextFields(){this._newContact={firstName:"",lastName:"",email:"",phone:"",accounts:[],evacAssistance:!1},Ye(this.firstName,""),Ye(this.lastName,""),Ye(this.email,""),this.phone.reset(),At(this.phone,"")}resetErrorStates(){this.firstName.error=!1,this.lastName.error=!1,this.email.error=!1,this.phone.error=!1}isInvalid(){return this.firstName.error||this.lastName.error||this.email.error||this.phone.error}isEmpty(){return!this._newContact.firstName||!this._newContact.lastName||!this._newContact.email||!this._newContact.phone}dispatchNextStepEvent(){this.dispatchEvent(new CustomEvent(w.NextStep,{bubbles:!0,composed:!0}))}dispatchUpdateContactEvent(){const e=new CustomEvent(w.UpdateContact,{detail:{newContact:this._newContact},bubbles:!0,composed:!0});this.dispatchEvent(e)}dispatchNextButtonToggleEvent(){this.dispatchEvent(new CustomEvent(w.NextButtonToggle,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}dispatchValidateStepEvent(){this.dispatchEvent(new CustomEvent(w.ValidateStep,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}render(){return c` <div class="input-group"> <ix-textbox required id="first-name" label="First name" name="first-name" type="text" value="${this._newContact.firstName}" @input="${()=>this.validateInput(this.firstName,"Invalid first name")}" pattern="${Me.name}" maxLength="50" data-testid="step-one-first-name"></ix-textbox> <ix-textbox required id="last-name" label="Last name" name="last-name" type="text" value="${this._newContact.lastName}" @input="${()=>this.validateInput(this.lastName,"Invalid last name")}" pattern="${Me.name}" maxLength="50" data-testid="step-one-last-name"></ix-textbox> </div> <div class="input-group"> <ix-textbox required id="email" label="Email Address" name="email" type="email" value="${this._newContact.email}" @input="${()=>this.validateEmailInput(this.email,"Invalid email address")}" data-testid="step-one-email"></ix-textbox> <ix-phone-input required id="phone-number" label="Phone Number" name="phone" value="${this._newContact.phone}" @input="${()=>this.validatePhoneInput(this.phone,"Invalid phone number")}" @country-change="${()=>this.phone.value?this.validatePhoneInput(this.phone,"Invalid phone number"):null}" data-testid="step-one-phone-number"></ix-phone-input> </div> <div style="display:flex;justify-content:flex-end;padding-top:8px"> <ix-button type="submit" ?disabled="${!this._nextButtonEnabled||this.validatingForm}" has-icon trailing-icon @click="${this.dispatchNextStepEvent}" data-testid="step-one-next-button"> Next <md-icon slot="icon">east</md-icon> </ix-button> </div> `}};fe.styles=[Po,_],r([d({type:Object})],fe.prototype,"newContact",void 0),r([d({type:Boolean})],fe.prototype,"validatingForm",void 0),r([m()],fe.prototype,"_newContact",void 0),r([m()],fe.prototype,"_nextButtonEnabled",void 0),fe=r([A("create-user-step-one")],fe);function Tt(e){var t;for(const o of e)if(o.checked||!((t=o.children)===null||t===void 0)&&t.length&&Tt(o.children))return!0;return!1}function It(e){return e.some(t=>t.subaccounts.length)?"nested":"flat"}function Et(e,t){var o,i;if(t==="flat")return e.filter(a=>a.checked);const n=[];for(const a of e){a.checked&&n.push(a);const s=(o=a.children)===null||o===void 0?void 0:o.every(l=>l.checked);if(!((i=a.children)===null||i===void 0)&&i.length&&(a.indeterminate||!s)){const l=Et(a.children,t);n.push(...l)}}return n}function Rt(e){var t,o;const i=[];for(const n of e)n.checked||!((t=n.children)===null||t===void 0)&&t.length&&n.children.every(a=>a.checked)?i.push(n):!((o=n.children)===null||o===void 0)&&o.length&&i.push(...Rt(n.children));return i}function Lo(e){const t=[];function o(i){i.checked&&t.push(i.id),i.children&&i.children.forEach(n=>{o(n)})}return e.forEach(i=>{o(i)}),t}function St(e){var t;return[e.id||e.label,...Lo((t=e.children)!==null&&t!==void 0?t:[])]}const qo=e=>{var t;return{authorityDocumentId:e.authority_document_id,changeHistoryId:e.change_history_id,fileName:e.file_name,createdAt:(t=e.created_at)===null||t===void 0?void 0:t.toString(),createdBy:e.created_by}},ws=e=>({file:e.file,fileName:e.fileName}),As=e=>({id:e.id});class Cs{async create(t){try{const o=ws(t),i=await v.AuthorityDocumentsApi.postAuthorityDocuments(o);return qo(i)}catch(o){return g.handleError(o,"Failed to upload authority document."),{}}}async getById(t){try{const o=As(t),i=await v.AuthorityDocumentsApi.getAuthorityDocument(o);return qo(i)}catch(o){return g.handleError(o,"Failed to get authority document."),{}}}async download(t){try{return await v.AuthorityDocumentsApi.downloadAuthorityDocuments({id:t})}catch(o){g.handleError(o,"Failed to download authority document.");return}}}const Ho=new Cs,zo=()=>N().UserManagement.UI.AuthorityDocuments.MaxFileSizeMB,Vo=()=>N().UserManagement.UI.AuthorityDocuments.AcceptedExtensions,_s=e=>{const t={file:e,fileName:e.name};return Ho.create(t)},jo=128;function Go(){const e=N().UserManagement.UI.AuthorityDocuments;return{minAttachments:1,maxFileSizeMB:e.MaxFileSizeMB,acceptedExtensions:e.AcceptedExtensions,fileNamePattern:new RegExp(e.FileNamePattern)}}function Jo(e,t){var o;const i=[],n=t.maxFileSizeMB*1024*1024;e.size>n&&i.push({code:"SIZE_EXCEEDED",message:`File exceeds the maximum size of ${t.maxFileSizeMB}MB.`,fileName:e.name});const a=((o=e.name.split(".").pop())===null||o===void 0?void 0:o.toLowerCase())||"";a&&!t.acceptedExtensions.includes(a)&&i.push({code:"INVALID_EXTENSION",message:`File extension for '${e.name}' is not allowed.`,fileName:e.name});const s=/^[A-Za-z0-9._() -]+$/;return t.fileNamePattern.test(e.name)||s.test(e.name)||i.push({code:"INVALID_FILENAME",message:"Filename must not contain special characters. Allowed: A-Z a-z 0-9 _ - .",fileName:e.name}),e.name.length>jo&&i.push({code:"FILENAME_TOO_LONG",message:`Filename must not exceed ${jo} characters.`,fileName:e.name}),i}function Ko(e,t){return Jo(e,t)}function Zo(e,t){const o={isValid:!0,errors:[],fileErrors:new Map};if(!e||e.length===0)return o.isValid=!1,o.errors.push({code:"MIN_ATTACHMENTS_REQUIRED",message:"At least one document is required."}),o;for(const i of e){const n=Jo(i,t);n.length>0&&(o.isValid=!1,o.fileErrors.set(i.name,n))}return o}class Ts{constructor(t){this._attachments=[],this._validationResult=null,this._documentsRequired=!1,this._onStateChanged=null,this._config=t||Go()}get attachments(){return this._attachments}get validationResult(){return this._validationResult}get isValid(){return this._validationResult?this._validationResult.isValid:!0}get documentsRequired(){return this._documentsRequired}get canProceed(){return this._documentsRequired?this.isValid&&this._attachments.length>0:this.isValid}addFiles(t){const o=new Map;for(const i of t){const n=Ko(i,this._config);if(n.length>0)o.set(i.name,n);else{const a=Object.assign(i,{id:this.generateFileId(i)});this._attachments.some(s=>s.name===a.name&&s.size===a.size)||this._attachments.push(a)}}this.validateCurrent();for(const[i,n]of o)this._validationResult.fileErrors.set(i,n);this.notifyStateChanged()}removeFile(t){const o=this._attachments.length;this._attachments=this._attachments.filter(i=>!(i.name===t||i.id===t||this.getFileKey(i)===t)),this._attachments.length!==o&&(this.validateCurrent(),this.notifyStateChanged())}clearAll(){this._attachments=[],this.validateCurrent(),this.notifyStateChanged()}validateCurrent(){if(this._attachments.length===0){this._validationResult={isValid:!0,errors:[],fileErrors:new Map};return}const t=this._attachments.map(o=>new File([o],o.name,{type:o.type}));this._validationResult=Zo(t,this._config)}getFileErrors(t){return this._validationResult?this._validationResult.fileErrors.get(t)||[]:[]}setDocumentsRequired(t){this._documentsRequired!==t&&(this._documentsRequired=t,this.notifyStateChanged())}onStateChanged(t){this._onStateChanged=t}generateFileId(t){return`${Date.now()}-${t.name}-${t.size}`}getFileKey(t){return t.id||t.name}notifyStateChanged(){this._onStateChanged&&this._onStateChanged()}}function Wo(e){return new Ts(e)}const Is=e=>({id:e.id,firstName:e.first_name,lastName:e.last_name,email:e.email,accountPermissionGroup:e.account_permission_group,accountAssociations:e.account_associations}),Es=e=>{var t;return{items:((t=e.items)!==null&&t!==void 0?t:[]).map(Is)}};class Rs{async get(t={}){try{const o=await v.UsersApi.getMyAccountsAdminsAndApprovers({isMyAccountRequest:t.isMyAccountRequest});return Es(o).items}catch(o){return g.handleError(o,"Failed to get account admins and approvers."),[]}}}const Ss=new Rs,ks=()=>Ss.get({isMyAccountRequest:!1}),Qo=async e=>(await ks()).filter(t=>{var o;return(o=t.accountAssociations)===null||o===void 0?void 0:o.includes(e)}),z={RequestedByCustomer:"REQUESTED_BY_CUSTOMER",NoUserAvailable:"NO_USER_AVAILABLE",NewCustomer:"NEW_CUSTOMER"};class Xe{constructor(t="",o="",i=o,n=""){this.value=t,this.displayText=o,this.name=i,this.email=n}isValid(){return this.value!==""}}const Us=e=>({id:e.id,name:e.account_name,status:e.status,accountNumber:e.account_number,displayName:e.account_friendly_name,statusUpdateAt:e.updated_at,statusUpdateBy:e.updated_by}),kt=e=>{var t;const o=[];return(t=e.account_associations)===null||t===void 0||t.forEach(i=>{o.push(Us(i))}),{id:e.id,firstName:e.first_name,lastName:e.last_name,email:e.email,phone:e.phone,evacAssistance:e.evacuation_assistance_required,accounts:o,status:"Active"}},$s=e=>{var t;const o=[];return(t=e.accounts)===null||t===void 0||t.forEach(i=>{o.includes(i.accountNumber)||o.push(i.accountNumber)}),{first_name:e.firstName,last_name:e.lastName,email:e.email,phone:e.phone,account_numbers:o,evacuation_assistance_required:e.evacAssistance}},Ns=e=>({id:e.id,first_name:e.firstName,last_name:e.lastName,email:e.email,phone:e.phone,evacuation_assistance_required:e.evacAssistance}),Fs=e=>({accountNumber:e.accountNumber,includeChildAccounts:!0,page:e.page,size:e.size,firstName:e.firstName,lastName:e.lastName,email:e.email,sort:e.sort,order:e.order}),Ds=e=>{var t,o;const i=[];return(t=e.content)===null||t===void 0||t.forEach(n=>{i.push(kt(n))}),{contacts:i,recordCount:(o=e.pageable)===null||o===void 0?void 0:o.total_elements}},Ps=e=>({id:e.id}),Ms=e=>({id:e.id,userProfile:Ns(e.contactInput)}),Os=e=>({userInput:{...$s(e.contactInput),change_history_id:e.changeHistoryId}});class Bs{async update(t){try{const o=Ms(t);return v.UsersApi.updateUser(o)}catch(o){return g.handleError("Failed to update user.")}}async create(t){try{const o=Os(t),i=await v.UsersApi.createUser(o);return kt(i)}catch(o){return g.handleError(o,`Failed to create user for ${t.contactInput.email}`),{}}}async search(t){try{const o=Fs(t),i=await v.UsersApi.getUsers(o);return Ds(i)}catch(o){return g.handleError(o,"Failed to get users."),{}}}async get(t){try{const o=Ps(t),i=await v.UsersApi.getUser(o);return kt(i)}catch(o){return g.handleError(o,"Failed to get user."),{}}}async getUsersReport(t){try{const o={accountNumber:t.accountNumber,includeChildAccounts:t.includeChildAccounts,firstName:t.firstName,lastName:t.lastName,email:t.email};return await v.UsersApi.getUserReport(o)}catch(o){throw g.handleError(o,"Failed to download users report."),o}}}const et=new Bs,Yo=e=>{const t=[...e.entries()].map(([o,i])=>({accountNumber:o,value:i.value})).filter(o=>!!o.value);if(t.length)return t.map(o=>o.value===z.NoUserAvailable?{reason:z.NoUserAvailable,authoriserUserId:"",accountNumber:o.accountNumber}:o.value===z.NewCustomer?{reason:z.NewCustomer,authoriserUserId:"",accountNumber:o.accountNumber}:{reason:z.RequestedByCustomer,authoriserUserId:o.value,accountNumber:o.accountNumber})},Xo=async e=>{const t=(await Promise.all(e.map(o=>_s(o)))).map(o=>o.authorityDocumentId).filter(Boolean);if(t.length!==e.length)throw new Error("Failed to upload all authority documents.");return t},Ut={noUserAvailable:"No User with Proper Permissions Available",newCustomer:"New Customer"},ei=(e,t,o)=>e?"loading":t>0?"selectable":o?"no-user":"new-customer",ti=(e,t)=>{const o=new Map(e!=null?e:new Map);t.forEach(n=>{o.has(n)||o.set(n,new Xe)});const i=new Set(t);return[...o.keys()].forEach(n=>{i.has(n)||o.delete(n)}),o},oi=(e,t)=>e.every(o=>{var i,n;return(n=(i=t==null?void 0:t.get(o))===null||i===void 0?void 0:i.isValid())!==null&&n!==void 0?n:!1}),$t=(e,t,o,i=[])=>{if(!e||!t||!o||o.size===0)return!1;const n=new Set(i),a=[...o.entries()].filter(([s])=>!n.size||n.has(s)).map(([,s])=>s).filter(s=>!!(s!=null&&s.value));return a.length?a.some(s=>s.value!==z.NewCustomer):!1},ii="data-wrap-patch";function ni(e,t){if(e.querySelector(`style[${ii}]`))return;const o=document.createElement("style");o.setAttribute(ii,""),o.textContent=t,e.appendChild(o)}function Ls(e){const t=()=>{const i=e.shadowRoot;i&&ni(i,`
|
|
2032
|
+
`;class Na{constructor(t){this.config=t,this.gqlClient=new ji(this.config.url),this.config.accessToken&&this.gqlClient.setHeader("authorization",this.config.accessToken)}async GetRolesInventory(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Ra,{...t})}async GetFlagsInventory(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Sa,{...t})}async GetAccountInventory(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(ka,{...t})}async SaveAccountRoleAssignments(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Ua,{...t})}async SaveAccountFlagAssignments(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request($a,{...t})}}const Fa="http://localhost".replace(/\/+$/,"");class _o{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Fa}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||To}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Da=new _o;class pt{constructor(t=Da){this.configuration=t,this.fetchApi=async(o,i)=>{let n={url:o,init:i};for(const s of this.middleware)s.pre&&(n=await s.pre({fetch:this.fetchApi,...n})||n);let a;try{a=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(s){for(const l of this.middleware)l.onError&&(a=await l.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:s,response:a?a.clone():void 0})||a);if(a===void 0)throw s instanceof Error?new Ba(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(a=await s.post({fetch:this.fetchApi,url:n.url,init:n.init,response:a.clone()})||a);return a},this.middleware=t.middleware}withMiddleware(...t){const o=this.clone();return o.middleware=o.middleware.concat(...t),o}withPreMiddleware(...t){const o=t.map(i=>({pre:i}));return this.withMiddleware(...o)}withPostMiddleware(...t){const o=t.map(i=>({post:i}));return this.withMiddleware(...o)}isJsonMime(t){return t?pt.jsonRegex.test(t):!1}async request(t,o){const{url:i,init:n}=await this.createFetchParams(t,o),a=await this.fetchApi(i,n);if(a&&a.status>=200&&a.status<300)return a;throw new Oa(a,"Response returned an error code")}async createFetchParams(t,o){let i=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(i+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(u=>n[u]===void 0?delete n[u]:{});const a=typeof o=="function"?o:async()=>o,s={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},l={...s,...await a({init:s,context:t})};let p;Ma(l.body)||l.body instanceof URLSearchParams||Pa(l.body)?p=l.body:this.isJsonMime(n["Content-Type"])?p=JSON.stringify(l.body):p=l.body;const h={...l,body:p};return{url:i,init:h}}clone(){const t=this.constructor,o=new t(this.configuration);return o.middleware=this.middleware.slice(),o}}pt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Pa(e){return typeof Blob<"u"&&e instanceof Blob}function Ma(e){return typeof FormData<"u"&&e instanceof FormData}class Oa extends Error{constructor(t,o){super(o),this.response=t,this.name="ResponseError"}}class Ba extends Error{constructor(t,o){super(o),this.cause=t,this.name="FetchError"}}class La extends Error{constructor(t,o){super(o),this.field=t,this.name="RequiredError"}}function re(e,t){return e[t]!=null}function To(e,t=""){return Object.keys(e).map(o=>Io(o,e[o],t)).filter(o=>o.length>0).join("&")}function Io(e,t,o=""){const i=o+(o.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(a=>encodeURIComponent(String(a))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Io(e,n,o)}return t instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?To(t,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(t))}`}class Eo{constructor(t,o=i=>i){this.raw=t,this.transformer=o}async value(){return this.transformer(await this.raw.json())}}function Ro(e){return qa(e)}function qa(e,t){return e==null?e:{firstName:re(e,"firstName")?e.firstName:void 0,lastName:re(e,"lastName")?e.lastName:void 0,contactPhoneNumber:re(e,"contactPhoneNumber")?e.contactPhoneNumber:void 0,preferredLanguage:re(e,"preferredLanguage")?e.preferredLanguage:void 0,preferredTimezone:re(e,"preferredTimezone")?e.preferredTimezone:void 0,timezoneOverridden:re(e,"timezoneOverridden")?e.timezoneOverridden:void 0,preferredDateFormat:re(e,"preferredDateFormat")?e.preferredDateFormat:void 0,preferredTimeFormat:re(e,"preferredTimeFormat")?e.preferredTimeFormat:void 0,email:re(e,"email")?e.email:void 0}}function Ha(e){if(e!==void 0)return e===null?null:{firstName:e.firstName,lastName:e.lastName,contactPhoneNumber:e.contactPhoneNumber,preferredLanguage:e.preferredLanguage,preferredTimezone:e.preferredTimezone,timezoneOverridden:e.timezoneOverridden,preferredDateFormat:e.preferredDateFormat,preferredTimeFormat:e.preferredTimeFormat}}class za extends pt{async getUserSettingsRaw(t){const o={},i={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,s=await a("bearerToken",[]);s&&(i.Authorization=`Bearer ${s}`)}const n=await this.request({path:"/user-profile",method:"GET",headers:i,query:o},t);return new Eo(n,a=>Ro(a))}async getUserSettings(t){return await(await this.getUserSettingsRaw(t)).value()}async userProfilePatchRaw(t,o){if(t.profileSettingEditInput===null||t.profileSettingEditInput===void 0)throw new La("profileSettingEditInput","Required parameter requestParameters.profileSettingEditInput was null or undefined when calling userProfilePatch.");const i={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,l=await s("bearerToken",[]);l&&(n.Authorization=`Bearer ${l}`)}const a=await this.request({path:"/user-profile",method:"PATCH",headers:n,query:i,body:Ha(t.profileSettingEditInput)},o);return new Eo(a,s=>Ro(s))}async userProfilePatch(t,o){return await(await this.userProfilePatchRaw(t,o)).value()}}class Va{constructor(t){this.configuration=t}get InventoryApi(){return new Na({url:this.configuration.userManagementAggregationApiUrl,accessToken:this.getToken()})}get UsersApi(){return new Ia(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get AccountAssociationApi(){return new ya(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get AccountsApi(){return new ba(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get RolesApi(){return new _a(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get PermissionsApi(){return new Aa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get RoleAssignmentsApi(){return new Ca(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get UserFlagsApi(){return new Ta(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get VerificationApi(){return new Ea(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get ChangeHistoriesApi(){return new wa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get AuthorityDocumentsApi(){return new xa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get UserProfileSettingsApi(){var t;const o=((t=this.getToken())!==null&&t!==void 0?t:"").replace(/^Bearer\s+/i,""),i={};return new za(new _o({basePath:this.configuration.LoginAuthority,accessToken:o,headers:i}))}getToken(){return this.configuration.getTokenFn?this.configuration.getTokenFn():void 0}}class ja extends Gi{constructor(t,o){super({...t}),this.hashed_identifier="",this.email="",this.account_number="",this.hashed_identifier=o}get getEmail(){var t;return(t=this.email)!==null&&t!==void 0?t:this.profile.email}get getAccount(){var t;return(t=this.account_number)!==null&&t!==void 0?t:this.profile.account_number}}class Ve{constructor({loginAuthority:t,clientId:o,scope:i,postLogoutRedirectUri:n,userStorageKey:a=N().UserManagement.UI.UserManagementUIStorageKey,xauthStorageKey:s=N().UserManagement.UI.UserManagementXAuthUIStorageKey,redirectUrlKey:l="redirect-url",authPaths:p={authenticate:"authenticate",authCallback:"auth-callback",logout:"logout"}}){this.configuration={loginAuthority:t,clientId:o,scope:i,postLogoutRedirectUri:n,userStorageKey:a,xauthStorageKey:s,redirectUrlKey:l,authPaths:p};const{location:h}=window,u=`${h.protocol}//${h.hostname}${h.port?`:${h.port}`:""}`,b={authority:this.configuration.loginAuthority,client_id:this.configuration.clientId,redirect_uri:`${u}/${this.configuration.authPaths.authCallback}`,response_type:"code",scope:this.configuration.scope,post_logout_redirect_uri:this.configuration.postLogoutRedirectUri,loadUserInfo:!0};this.userManager=new Ji(b)}isLoggedIn(){const t=this.getUser();if(t===null)return!1;if(!t.expires_at)return!0;const o=new Date,i=new Date(t.expires_at*1e3);return o<i}redirectToAuth(t=!1){const o=this.isAuthenticating();(t||!o)&&(o||localStorage.setItem(this.configuration.redirectUrlKey,window.location.href),window.location.href=`/${this.configuration.authPaths.authenticate}`)}isAuthenticating(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authenticate?(this.userManager.signinRedirect(),!0):!1}isHandlingAuthCallback(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authCallback?(this.userManager.signinRedirectCallback().then(Ve.ensureValidUser).then(Ve.addHashedIdToUserProfile).then(o=>this.saveUser(o)).then(()=>this.authSuccessRedirect()).catch(()=>this.redirectToAuth()),!0):!1}authSuccessRedirect(){let t="/";const o=localStorage.getItem(this.configuration.redirectUrlKey);o&&(localStorage.removeItem(this.configuration.redirectUrlKey),t=o),window.location.href=t}redirectToLogout(){this.isHandlingLogout()||(window.location.href=`/${this.configuration.authPaths.logout}`)}isHandlingLogout(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.logout?(this.clearUser(),window.localStorage.clear(),this.userManager.signoutRedirect({id_token_hint:this.getIdToken()}),!0):!1}isProcessing(){return this.isAuthenticating()||this.isHandlingAuthCallback()||this.isHandlingLogout()}saveUser(t){localStorage.setItem(this.configuration.userStorageKey,JSON.stringify(t))}clearUser(){localStorage.removeItem(this.configuration.userStorageKey)}getXAuthUser(){const t=localStorage.getItem(this.configuration.xauthStorageKey);if(t){const o=JSON.parse(t);if(o!=null&&o.email&&o!=null&&o.account_number)return o}}getTokenUser(){const t=localStorage.getItem(this.configuration.userStorageKey);if(t)return JSON.parse(t)}getUser(){const t=this.getTokenUser();return t?(t.profile.email||(t.profile.email=this.getXAuthUser().email),t!=null?t:null):null}getUserDetails(){const t={accountNumber:"",email:""},o=this.getUser();return o&&(t.accountNumber=o.profile.account_number,t.email=o.profile.email),t}getUserProfileSub(){var t;const o=this.getUser();return(t=o==null?void 0:o.profile)===null||t===void 0?void 0:t.sub}getUserLocale(){var t;const o=this.getUser();return(t=o==null?void 0:o.profile)===null||t===void 0?void 0:t.locale}getIdToken(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.id_token}getAccessToken(){var t;return`Bearer ${(t=this.getUser())===null||t===void 0?void 0:t.access_token}`}static async hashValue(t){const o=new TextEncoder().encode(t),i=await crypto.subtle.digest("SHA-256",o);return Array.from(new Uint8Array(i)).map(n=>n.toString(16).padStart(2,"0")).join("")}static async addHashedIdToUserProfile(t){const o=`${t.profile.sub}-${t.profile.customer_id}`,i=await Ve.hashValue(o);return new ja(t,i)}static ensureValidUser(t){if(!t.id_token)throw new Error("Missing property:id_token");return t}}const we=N(),Ae=new Ve({loginAuthority:we.LoginAuthority,clientId:we.LoginService.UserManagementUIClientId,scope:we.LoginService.UserManagementUIScopes}),v=new Va({userManagementApiUrl:we.UserManagement.UI.UserManagementApiUrl,userManagementAggregationApiUrl:we.UserManagement.UI.UserManagementAggregationApiUrl,LoginAuthority:we.LoginAuthority,getTokenFn:()=>Ae.getAccessToken()});var Ga="Alerts",Ja="Content",Ka="DCIM",Za="Invoices",Wa="Marketplace",Qa="Release",Ya="Security",Xa={"Account Information":"Account Information",Alerts:Ga,"Cloud Connect":"Cloud Connect",Content:Ja,"Cross Connect":"Cross Connect","Custom Role":"Custom Role","Custom Roles":"Custom Roles","Customer Equipment Connection (CEC)":"Customer Equipment Connection (CEC)","Customer Support":"Customer Care","Customer Support Team":"Customer Support Team",DCIM:Ka,"DCIM-enabled location data":"DCIM-enabled location data","Default System Roles":"Default System Roles","EMEA MarketPlace":"EMEA MarketPlace","External User":"External User","Internal Roles":"Internal Roles","Internal User":"Internal User","Internet Exchange":"Internet Exchange","Intra-Customer Connectivity (ICC)":"Intra-Customer Connectivity (ICC)",Invoices:Za,"IP Bandwidth":"IP Bandwidth",Marketplace:Wa,"OSP Access":"OSP Access","Permanent Badge":"Permanent Badge","Planned Site Maintenance":"Maintenance & Incident Notifications","PoP/POE Room Access":"PoP/POE Room Access",Release:Qa,"Remote Hands":"Remote Hands","Remote Hands Package":"Remote Hands Package",Security:Ya,"Service Exchange Cloud Router":"Service Exchange Cloud Router","Service Exchange Port":"Service Exchange Port","Shipping & Receiving":"Deliveries & Removals","Space & Power":"Space & Power","Trouble Ticket":"Trouble Ticket","Visitor Access":"Visitor Access"};Xt.use(Ki).init({resources:{en:{translation:{...Xa}}},interpolation:{escapeValue:!1},lng:"en",debug:!1});const So=e=>Xt.t(e),es=e=>{const t=[];return e.forEach(o=>{t.push({id:o.id,name:So(o.name),isNonLocation:o.is_non_location,category:o.category,privileges:o.privileges,internalPrivileges:o.internal_privileges,isInternal:o.is_internal})}),t},ts=e=>{const t=[];return e.forEach(o=>{t.push({accountNumber:o.account_number,permissionName:So(o.permission_name),privilege:o.privilege})}),t};class os{async get(){try{const t=await v.PermissionsApi.getPermissions();return es(t)}catch(t){return g.handleError(t,"Could not get permissions."),[]}}async getMyPermissions(t){try{const o=await v.PermissionsApi.getUserPermissions(t);return ts(o)}catch(o){return g.handleError(o,"Could not retrieve current user's permissions."),[]}}}const Ze=new os,is=e=>{const t=[];return e.forEach(o=>{t.push({accountNumber:o.account_number,name:o.name,parentAccountNumber:o.parent_account_number,displayName:o.friendly_name})}),t};class ns{async get(){try{const t=await v.AccountsApi.getAccounts();return is(t)}catch(t){return g.handleError(t,"Failed to get accounts."),[]}}}const ko=new ns;class as{async getUserProfile(){try{return await v.UserProfileSettingsApi.getUserSettings()}catch(t){g.handleError(t,"Failed to get user profile.");return}}async updateUserProfile(t){try{return await v.UserProfileSettingsApi.userProfilePatch(t)}catch(o){g.handleError(o,"Failed to update user profile.");return}}}const bt=new as;class ss{constructor(){this.myPermissions=[]}isProfileOfLoggedInUser(t){var o;return((o=U==null?void 0:U.getEmail())===null||o===void 0?void 0:o.toLowerCase())===(t==null?void 0:t.toLowerCase())}hasUserRead(t){return this.hasPermission(T.user,x.read,t)}hasUserUpdate(t){return this.hasPermission(T.user,x.update,t)}hasExternalUserRead(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.read,t):this.hasPermission(T.externalUser,x.read,t)}hasExternalUserUpdate(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.update,t):this.hasPermission(T.externalUser,x.update,t)}hasExternalUserCreate(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.create,t):this.hasPermission(T.externalUser,x.create,t)}hasInternalUserRead(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.read,t):this.hasPermission(T.internalUser,x.read,t)}hasInternalUserUpdate(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.update,t):this.hasPermission(T.internalUser,x.update,t)}hasCustomRolesApprove(t){return this.hasPermission(T.customRoles,x.approve,t)}hasCustomRolesCreate(t){return this.hasPermission(T.customRoles,x.create,t)}hasCustomRolesUpdate(t){return this.hasPermission(T.customRoles,x.update,t)}hasCustomRolesRead(t){return this.hasPermission(T.customRoles,x.read,t)}hasInternalRolesCreate(t){return this.hasPermission(T.internalRoles,x.create,t)}hasInternalRolesUpdate(t){return this.hasPermission(T.internalRoles,x.update,t)}hasInternalRolesRead(t){return this.hasPermission(T.internalRoles,x.read,t)}hasDefaultSystemRolesCreate(t){return this.hasPermission(T.defaultRoles,x.create,t)}hasDefaultSystemRolesUpdate(t){return this.hasPermission(T.defaultRoles,x.update,t)}hasDefaultSystemRolesRead(t){return this.hasPermission(T.defaultRoles,x.read,t)}hasRoleManagementAccess(t){return this.hasPermission(T.defaultRoles,x.read,t)||this.hasPermission(T.customRoles,x.read,t)||this.hasPermission(T.internalRoles,x.read,t)||this.hasPermission(T.externalUser,x.read,t)}hasUserManagementAccess(){return N().UserManagement.InternalUserRetired?this.hasUserRead():this.hasExternalUserRead()||this.hasInternalUserRead()}hasAssignInternalRoleCreate(t){return this.hasPermission(T.assignInternalRole,x.create,t)}hasDLRDomain(){var t;const o=(t=U.getEmail())===null||t===void 0?void 0:t.toLowerCase().trim(),i=N();let n=!1;return i.InternalUserDomainWhitelist.split(",").forEach(a=>{const s=a.toLowerCase().trim();s&&o!=null&&o.endsWith(s)&&(n=!0)}),n}async refreshPermissions(){this.myPermissions=await Ze.getMyPermissions({excludeParents:!1,excludeSiblings:!0})}async refreshAccounts(){const t=await ko.get();U.setAccounts(t)}async getUserProfileSettings(){return bt.getUserProfile()}hasPrivilegeLevel(t,o){const i=[x.approve,x.create,x.update,x.read],n=i.findIndex(s=>s===t.toLowerCase()),a=i.findIndex(s=>s===o.toLowerCase());return n>=a}hasPermission(t,o,i){let{myPermissions:n}=this,a=!1;return i&&(n=n.filter(s=>s.accountNumber===i)),n.length&&o&&(a=n.some(s=>s.permissionName===t&&this.hasPrivilegeLevel(o,s.privilege))),a}}const B=new ss,Uo="uppercase font-bold tracking-wider",$o={LocalStorage:{},SessionStorage:{HasOutstandingChanges:"hasOutstandingChanges"}};let xt=class extends I{constructor(){super(...arguments),this.routeName=null}return(){window.sessionStorage.getItem($o.SessionStorage.HasOutstandingChanges)!=="true"&&this.routeName&&Qe(this.routeName)}render(){return c` <ix-button appearance="text" has-icon @click="${this.return}" data-testid="um-back-button"> <md-icon slot="icon">arrow_back</md-icon> <span class="${Uo}">Back</span> </ix-button>`}};r([d()],xt.prototype,"routeName",void 0),xt=r([A("um-back-button")],xt);const Pe=(e,t,o)=>{e.dispatchEvent(new CustomEvent(t,{detail:o,bubbles:!0,composed:!0}))};let No=class extends I{dispatchCreateUserEvent(){Pe(this,S.CreateUserClicked)}render(){return c` <ix-button @click="${this.dispatchCreateUserEvent}" has-icon> <md-icon slot="icon">add</md-icon> <span class="${Uo}">Create User</span> </ix-button>`}};No=r([A("um-create-user-button")],No);const G={Home:"Home",UserManagement:"User Management",RoleManagement:"Role Management",UserManagementDetails:"User Management Details"},Fo=[{name:G.Home,path:"(/?)",component:"home-view",action:()=>{import("./ui-user-management2.js")}},{name:G.UserManagement,path:"/user-management",component:"user-management-view",headerRight:c``,action:async()=>{B.hasUserManagementAccess()?import("./ui-user-management3.js"):ye.go("/")}},{name:G.RoleManagement,path:"/role-management",component:"role-management-view",action:async()=>{B.hasRoleManagementAccess()?import("./ui-user-management4.js"):ye.go("/")}},{name:G.UserManagementDetails,path:"/user-management-details",component:"user-management-details-view",hideAccountSwitcher:!0,headerLeft:c`<um-back-button routeName="${G.UserManagement}"></um-back-button>`,action:async()=>{B.hasUserManagementAccess()?import("./ui-user-management6.js"):ye.go("/")}}];let oe=null;function Do(){const{pathname:e,search:t,hash:o}=window.location;ye.go({pathname:e,search:t,hash:o})}function rs(e,t,o){const i=o.map(n=>({...n,path:`${t}${n.path}`,redirect:n.redirect?`${t}${n.redirect}`:null}));i.push({path:"(.*)",component:"no-elem"}),oe=new ye(e),oe.setRoutes(i),window.addEventListener("shell-after-navigate",Do)}function ls(){return oe}function cs(){oe==null||oe.unsubscribe(),oe==null||oe.removeRoutes(),oe=null,window.removeEventListener("shell-after-navigate",Do)}function We(e,t){return oe&&oe.urlForName(e,t)}function Qe(e,t){const o=We(e);o&&ye.go({pathname:o,hash:t})}const ds=e=>{var t,o,i,n,a,s;const l=Fo.find(h=>h.name===e),p=(s=(a=(n=(i=(o=(t=window.document.querySelector("gp-bootstrap"))===null||t===void 0?void 0:t.shadowRoot)===null||o===void 0?void 0:o.querySelector("global-portal-app"))===null||i===void 0?void 0:i.shadowRoot)===null||n===void 0?void 0:n.querySelector("ui-user-management"))===null||a===void 0?void 0:a.getAttribute("baseurl"))!==null&&s!==void 0?s:"";return window.location.pathname===`${p}${l==null?void 0:l.path}`};let wt=class extends Ue{constructor(){super(...arguments),this.setNavigationItemsBinding=this.setNavigationItems.bind(this),this.navigationItems=[],this.compact=!1}static get styles(){return[po,_]}connectedCallback(){super.connectedCallback(),window.addEventListener(S.RouteChanged,this.setNavigationItemsBinding)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(S.RouteChanged,this.setNavigationItemsBinding)}setNavigationItems(){this.requestUpdate(),!this.navigationItems.length&&(this.navigationItems=[{href:We(G.UserManagement),title:"User Management",icon:c`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="white"> ${Ke.userManagementIcon} </svg>`},{href:We(G.RoleManagement),title:"Role Management",icon:c`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="white"> ${Ke.roleManagementIcon} </svg>`}])}toggleCompact(){Pe(this,S.ToggleNavBar),setTimeout(()=>{window.dispatchEvent(new Event("resize"))},301)}renderNavigation(){return B.hasExternalUserRead()?c`${this.navigationItems.map(e=>c` <li class="relative m-1"> <div class="${e.href===window.location.pathname?"bg-white opacity-[.16] inset-0 rounded-md absolute":""}"></div> <a href="${e.href}" class="${e.href===window.location.pathname?"flex px-6 py-4 gap-4 rounded-md font-bold":"flex px-6 py-4 gap-4 rounded-md font-bold opacity-60"}"> <div class="w-6 shrink-0">${e.icon}</div> <div class="grow text-left"> <div class="${this.compact?"w-0":"w-full"} animate-width overflow-hidden"> ${e.title} </div> </div> </a> </li> `)}`:y}render(){return c` <ix-icon-button @click="${this.toggleCompact}" icon="chevron_right" class="drop-shadow-lg items-center expand-cta bg-white rounded-full text-slate-600 h-8 w-8 absolute z-20 lg:right-0 lg:top-[34px] hidden top-[27px] right-[-8px] sm:flex ${this.compact?"animate-spin-180-backwards":"animate-spin-180-forwards"}"> </ix-icon-button> <nav class="flex flex-col overflow-hidden min-h-full rounded-xl drop-shadow text-center nav-bar long text-white ${this.compact?"closed":""} whitespace-nowrap animate-width"> <div class="m-1 px-6 py-4 hidden sm:block"> <svg @click="${this.toggleCompact}" focusable="false" viewBox="0 0 178 27" fill="white" class="w-[200px]"> ${Ke.digitalRealtyLogoWithText} </svg> </div> <hr class="divider hidden sm:block"> <ul class="grow"> ${this.renderNavigation()} </ul> <dev-clear-storage-button class="white-icon self-start p-5"></dev-clear-storage-button> </nav> `}};r([d({type:Boolean})],wt.prototype,"compact",void 0),wt=r([A("navigation-bar")],wt);const us=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.header-container{display:flex;align-items:center;margin-bottom:16px}.header-container-back-btn{display:flex;flex-direction:row;justify-content:space-between;align-items:center}.back{padding-left:12px}.arrow-back-icon{font-size:22px;align-items:center;padding-right:1px}.header-rhs-actions{display:flex;flex-direction:row;justify-content:space-between;align-items:center}.profile{background-color:#092241;height:35px;margin-right:30px;margin-left:30px;border-radius:10px;color:#fff;padding-left:20px;padding-right:20px;display:flex;align-items:center}.logout{height:35px;border-radius:10px;border:none;background-color:#1456e0;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding-left:15px;padding-right:15px}.logout svg{width:1em;height:1em;font-size:20px;margin-right:5px}.add-icon{font-size:20px;align-items:center}`;let Ce=class extends Ue{constructor(){super(...arguments),this.updateLayoutBinding=this.updateLayout.bind(this),this.pageTitle="",this.showCreateUserButton=!1,this.showHeader=!0}connectedCallback(){super.connectedCallback(),window.addEventListener(S.RouteChanged,this.updateLayoutBinding)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(S.RouteChanged,this.updateLayoutBinding)}updateLayout(e){switch(this.pageTitle=e.detail.location.route.name||"",this.pageTitle){case"User Management":this.showCreateUserButton=B.hasExternalUserCreate(),this.showHeader=!0;break;case"Role Management":this.showCreateUserButton=!1,this.showHeader=!0;break;case"User Management Details":this.showCreateUserButton=!1,this.showHeader=!1;break}}getRoute(){return this.pageTitle==="User Management Details"?G.UserManagement:G.Home}dispatchCreateUserEvent(){Pe(this,S.CreateUser)}renderAppHeader(){return c` <div class="flex gap-2 items-center mt-4 mb-8 justify-between"> <div> ${this.showHeader?c`<h1 class="dlr-text-page-title">${this.pageTitle}</h1>`:c` <um-back-button .routeName="${this.getRoute()}"></um-back-button> `} </div> <div class="items-center flex gap-2 flex-wrap justify-end"> ${this.showCreateUserButton?c` <ix-button @click="${this.dispatchCreateUserEvent}" has-icon data-testid="create-user-button"> Create User <md-icon slot="icon">add</md-icon> </ix-button> `:y} </div> </div> `}render(){return c`${this.renderAppHeader()}`}};Ce.styles=[_,us],r([d({type:String})],Ce.prototype,"pageTitle",void 0),r([m()],Ce.prototype,"showCreateUserButton",void 0),r([m()],Ce.prototype,"showHeader",void 0),Ce=r([A("app-header")],Ce);const Po=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}:host{--md-outlined-text-field-label-text-color:black}.input-group{display:flex;flex-direction:row;gap:20px;margin-bottom:20px}.input-group ix-phone-input,.input-group ix-textbox{flex:1}.textfield{width:100%}ix-button{font-family:var(--root-secondary-font)}@media screen and (max-width:600px){.input-group{flex-direction:column}}`,J=e=>e?e.component.value:null,Ye=(e,t)=>{if(!e)return;const o=e.component;o.value=t},_e=e=>{if(!e)return null;const{input:t}=e;return t.value},At=(e,t)=>{if(!e)return;const{input:o}=e;o.value=t},hs=e=>e?e.component.checked:null,ps=(e,t)=>{if(!e)return;const o=e.component;o.checked=t};function Mo(e){const t=JSON.stringify(e);return JSON.parse(t)}const ms=(e,t,o)=>e.sort((i,n)=>(i[t]<n[t]?-1:1)*(o?1:-1));function gs(e){const t={};for(const[o,i]of Object.entries(e))for(const n of o.split(" "))t[n]=i;return Qi(t)}const fs=e=>{try{const t=e.startsWith("+")?eo(e):eo(`+${e}`),o=`+${t.countryCallingCode} ${new Zi(t.country||"US").input(t.nationalNumber)}`;return o.endsWith(")")||o.endsWith("(")?e:o}catch(t){return e}},vs=()=>window.matchMedia("(min-width: 1024px)").matches,Me={phone:"^[+]?[(]?[0-9]{3}[)]?[-s.]?[0-9]{3}[-s.]?[0-9]{4,6}$",name:N().UserManagement.UI.ValidationRegexPatterns.name,alphabetOnly:"^[A-Za-z]+$"},Oe=(e,t)=>{const o=e;return"component"in o&&o.component.reportValidity(),t?(o.error=!1,o.errorText="",!0):(o.error=!0,o.errorText="This field is mandatory",!1)},Oo=(e,t,o)=>{const i=e;return t!=null&&t.match(i.pattern)?(i.error=!1,i.errorText="",!0):(i.error=!0,i.errorText=o,!1)},Bo=(e,t,o)=>{if(!t)return!1;const i=e;return Yi.isEmail(t)?(i.error=!1,i.errorText="",!0):(i.error=!0,i.errorText=o,!1)},ys=e=>e.error,bs=(e,t)=>{const o=t;return J(e)===o},Ct=(e,t,o)=>{const i=J(e);return e.required&&!Oe(e,i)||e.pattern&&!Oo(e,i,o)||e.type==="email"&&!Bo(e,i,o)?!1:!(ys(e)||bs(e,t))},_t=(e,t)=>{const o=_e(e),i=e;return Wi(o)?(i.error=!1,!0):(i.error=!0,i.errorText=t,!1)},xs=(e,t)=>{t.length>0&&t.forEach(o=>{const i=e.find(n=>n.id===o.field);i&&(i.error=!0,i.errorText=o.error,i.focus())})},w={CancelCreateUser:"cancel-create-user",CloseDrawer:"close-drawer",CreateContact:"create-contact",CreateNewContact:"create-new-contact",EvacAssistanceRequired:"evac-assistance-required",NextButtonToggle:"next-button-toggle",NextStep:"next-step",ResetSuccess:"reset-success",SetStep:"set-step",ToggleDialog:"toggle-dialog",ToggleDraft:"toggle-draft",ToggleDrawer:"toggle-drawer",UpdateAccounts:"update-accounts",UpdateAttachments:"update-attachments",UpdateContact:"update-contact",UpdateDFA:"update-dfa",UpdateFlags:"update-flags",UpdateObofSelections:"update-obof-selections",ValidateStep:"validate-step"};let fe=class extends I{constructor(){super(...arguments),this.validatingForm=!1,this._newContact={firstName:"",lastName:"",email:"",phone:"",accounts:[],evacAssistance:!1},this._nextButtonEnabled=!1}firstUpdated(){this._newContact=this.newContact,this.validateStep(),this.dispatchValidateStepEvent()}get firstName(){return this.renderRoot.querySelector("#first-name")}get lastName(){return this.renderRoot.querySelector("#last-name")}get email(){return this.renderRoot.querySelector("#email")}get phone(){return this.renderRoot.querySelector("#phone-number")}validateStep(){this._nextButtonEnabled=!(this.isInvalid()||this.isEmpty())}validateInput(e,t){const o=J(e);if(this.updateContactDetails(),e.required&&!Oe(e,o)){this._nextButtonEnabled=!1;return}e.pattern&&!Oo(e,o,t)&&(this._nextButtonEnabled=!1),this.validateStep(),this.dispatchNextButtonToggleEvent()}async validateEmailInput(e,t){this._nextButtonEnabled=!1;const o=J(e);if(this.updateContactDetails(),e.required&&!Oe(e,o)){this._nextButtonEnabled=!1;return}if(!Bo(e,o,t)){this._nextButtonEnabled=!1;return}clearTimeout(this.debounceTimeout),this.debounceTimeout=window.setTimeout(async()=>{const i={emailVerificationInput:{email_address:o!=null?o:""}};try{(await v.VerificationApi.verifyEmail(i)).is_verified?(e.error=!1,e.errorText="",this._nextButtonEnabled=!(this.isInvalid()||this.isEmpty())):(e.error=!0,e.errorText=`${t}`,this._nextButtonEnabled=!1)}catch(n){e.error=!0,e.errorText="An error occurred during email verification. Please try again later.",this._nextButtonEnabled=!1}},500),this.validateStep(),this.dispatchNextButtonToggleEvent()}validatePhoneInput(e,t){const o=_e(e);if(At(e,o),this.updateContactDetails(),e.required&&!Oe(e,o)){this._nextButtonEnabled=!1;return}if(!_t(e,t)){this._nextButtonEnabled=!1;return}this.validateStep(),this.dispatchNextButtonToggleEvent()}updateContactDetails(){var e,t,o,i;this._newContact={firstName:(e=J(this.firstName))!==null&&e!==void 0?e:"",lastName:(t=J(this.lastName))!==null&&t!==void 0?t:"",email:(o=J(this.email))!==null&&o!==void 0?o:"",phone:(i=_e(this.phone))!==null&&i!==void 0?i:"",accounts:this._newContact.accounts,evacAssistance:this._newContact.evacAssistance},this.dispatchUpdateContactEvent()}clearTextFields(){this._newContact={firstName:"",lastName:"",email:"",phone:"",accounts:[],evacAssistance:!1},Ye(this.firstName,""),Ye(this.lastName,""),Ye(this.email,""),this.phone.reset(),At(this.phone,"")}resetErrorStates(){this.firstName.error=!1,this.lastName.error=!1,this.email.error=!1,this.phone.error=!1}isInvalid(){return this.firstName.error||this.lastName.error||this.email.error||this.phone.error}isEmpty(){return!this._newContact.firstName||!this._newContact.lastName||!this._newContact.email||!this._newContact.phone}dispatchNextStepEvent(){this.dispatchEvent(new CustomEvent(w.NextStep,{bubbles:!0,composed:!0}))}dispatchUpdateContactEvent(){const e=new CustomEvent(w.UpdateContact,{detail:{newContact:this._newContact},bubbles:!0,composed:!0});this.dispatchEvent(e)}dispatchNextButtonToggleEvent(){this.dispatchEvent(new CustomEvent(w.NextButtonToggle,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}dispatchValidateStepEvent(){this.dispatchEvent(new CustomEvent(w.ValidateStep,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}render(){return c` <div class="input-group"> <ix-textbox required id="first-name" label="First name" name="first-name" type="text" value="${this._newContact.firstName}" @input="${()=>this.validateInput(this.firstName,"Invalid first name")}" pattern="${Me.name}" maxLength="50" data-testid="step-one-first-name"></ix-textbox> <ix-textbox required id="last-name" label="Last name" name="last-name" type="text" value="${this._newContact.lastName}" @input="${()=>this.validateInput(this.lastName,"Invalid last name")}" pattern="${Me.name}" maxLength="50" data-testid="step-one-last-name"></ix-textbox> </div> <div class="input-group"> <ix-textbox required id="email" label="Email Address" name="email" type="email" value="${this._newContact.email}" @input="${()=>this.validateEmailInput(this.email,"Invalid email address")}" data-testid="step-one-email"></ix-textbox> <ix-phone-input required id="phone-number" label="Phone Number" name="phone" value="${this._newContact.phone}" @input="${()=>this.validatePhoneInput(this.phone,"Invalid phone number")}" @country-change="${()=>this.phone.value?this.validatePhoneInput(this.phone,"Invalid phone number"):null}" data-testid="step-one-phone-number"></ix-phone-input> </div> <div style="display:flex;justify-content:flex-end;padding-top:8px"> <ix-button type="submit" ?disabled="${!this._nextButtonEnabled||this.validatingForm}" has-icon trailing-icon @click="${this.dispatchNextStepEvent}" data-testid="step-one-next-button"> Next <md-icon slot="icon">east</md-icon> </ix-button> </div> `}};fe.styles=[Po,_],r([d({type:Object})],fe.prototype,"newContact",void 0),r([d({type:Boolean})],fe.prototype,"validatingForm",void 0),r([m()],fe.prototype,"_newContact",void 0),r([m()],fe.prototype,"_nextButtonEnabled",void 0),fe=r([A("create-user-step-one")],fe);function Tt(e){var t;for(const o of e)if(o.checked||!((t=o.children)===null||t===void 0)&&t.length&&Tt(o.children))return!0;return!1}function It(e){return e.some(t=>t.subaccounts.length)?"nested":"flat"}function Et(e,t){var o,i;if(t==="flat")return e.filter(a=>a.checked);const n=[];for(const a of e){a.checked&&n.push(a);const s=(o=a.children)===null||o===void 0?void 0:o.every(l=>l.checked);if(!((i=a.children)===null||i===void 0)&&i.length&&(a.indeterminate||!s)){const l=Et(a.children,t);n.push(...l)}}return n}function Rt(e){var t;const o=[];for(const i of e)i.checked?o.push(i):!((t=i.children)===null||t===void 0)&&t.length&&o.push(...Rt(i.children));return o}function Lo(e){const t=[];function o(i){i.checked&&t.push(i.id),i.children&&i.children.forEach(n=>{o(n)})}return e.forEach(i=>{o(i)}),t}function St(e){var t;return[e.id||e.label,...Lo((t=e.children)!==null&&t!==void 0?t:[])]}const qo=e=>{var t;return{authorityDocumentId:e.authority_document_id,changeHistoryId:e.change_history_id,fileName:e.file_name,createdAt:(t=e.created_at)===null||t===void 0?void 0:t.toString(),createdBy:e.created_by}},ws=e=>({file:e.file,fileName:e.fileName}),As=e=>({id:e.id});class Cs{async create(t){try{const o=ws(t),i=await v.AuthorityDocumentsApi.postAuthorityDocuments(o);return qo(i)}catch(o){return g.handleError(o,"Failed to upload authority document."),{}}}async getById(t){try{const o=As(t),i=await v.AuthorityDocumentsApi.getAuthorityDocument(o);return qo(i)}catch(o){return g.handleError(o,"Failed to get authority document."),{}}}async download(t){try{return await v.AuthorityDocumentsApi.downloadAuthorityDocuments({id:t})}catch(o){g.handleError(o,"Failed to download authority document.");return}}}const Ho=new Cs,zo=()=>N().UserManagement.UI.AuthorityDocuments.MaxFileSizeMB,Vo=()=>N().UserManagement.UI.AuthorityDocuments.AcceptedExtensions,_s=e=>{const t={file:e,fileName:e.name};return Ho.create(t)},jo=128;function Go(){const e=N().UserManagement.UI.AuthorityDocuments;return{minAttachments:1,maxFileSizeMB:e.MaxFileSizeMB,acceptedExtensions:e.AcceptedExtensions,fileNamePattern:new RegExp(e.FileNamePattern)}}function Jo(e,t){var o;const i=[],n=t.maxFileSizeMB*1024*1024;e.size>n&&i.push({code:"SIZE_EXCEEDED",message:`File exceeds the maximum size of ${t.maxFileSizeMB}MB.`,fileName:e.name});const a=((o=e.name.split(".").pop())===null||o===void 0?void 0:o.toLowerCase())||"";a&&!t.acceptedExtensions.includes(a)&&i.push({code:"INVALID_EXTENSION",message:`File extension for '${e.name}' is not allowed.`,fileName:e.name});const s=/^[A-Za-z0-9._() -]+$/;return t.fileNamePattern.test(e.name)||s.test(e.name)||i.push({code:"INVALID_FILENAME",message:"Filename must not contain special characters. Allowed: A-Z a-z 0-9 _ - .",fileName:e.name}),e.name.length>jo&&i.push({code:"FILENAME_TOO_LONG",message:`Filename must not exceed ${jo} characters.`,fileName:e.name}),i}function Ko(e,t){return Jo(e,t)}function Zo(e,t){const o={isValid:!0,errors:[],fileErrors:new Map};if(!e||e.length===0)return o.isValid=!1,o.errors.push({code:"MIN_ATTACHMENTS_REQUIRED",message:"At least one document is required."}),o;for(const i of e){const n=Jo(i,t);n.length>0&&(o.isValid=!1,o.fileErrors.set(i.name,n))}return o}class Ts{constructor(t){this._attachments=[],this._validationResult=null,this._documentsRequired=!1,this._onStateChanged=null,this._config=t||Go()}get attachments(){return this._attachments}get validationResult(){return this._validationResult}get isValid(){return this._validationResult?this._validationResult.isValid:!0}get documentsRequired(){return this._documentsRequired}get canProceed(){return this._documentsRequired?this.isValid&&this._attachments.length>0:this.isValid}addFiles(t){const o=new Map;for(const i of t){const n=Ko(i,this._config);if(n.length>0)o.set(i.name,n);else{const a=Object.assign(i,{id:this.generateFileId(i)});this._attachments.some(s=>s.name===a.name&&s.size===a.size)||this._attachments.push(a)}}this.validateCurrent();for(const[i,n]of o)this._validationResult.fileErrors.set(i,n);this.notifyStateChanged()}removeFile(t){const o=this._attachments.length;this._attachments=this._attachments.filter(i=>!(i.name===t||i.id===t||this.getFileKey(i)===t)),this._attachments.length!==o&&(this.validateCurrent(),this.notifyStateChanged())}clearAll(){this._attachments=[],this.validateCurrent(),this.notifyStateChanged()}validateCurrent(){if(this._attachments.length===0){this._validationResult={isValid:!0,errors:[],fileErrors:new Map};return}const t=this._attachments.map(o=>new File([o],o.name,{type:o.type}));this._validationResult=Zo(t,this._config)}getFileErrors(t){return this._validationResult?this._validationResult.fileErrors.get(t)||[]:[]}setDocumentsRequired(t){this._documentsRequired!==t&&(this._documentsRequired=t,this.notifyStateChanged())}onStateChanged(t){this._onStateChanged=t}generateFileId(t){return`${Date.now()}-${t.name}-${t.size}`}getFileKey(t){return t.id||t.name}notifyStateChanged(){this._onStateChanged&&this._onStateChanged()}}function Wo(e){return new Ts(e)}const Is=e=>({id:e.id,firstName:e.first_name,lastName:e.last_name,email:e.email,accountPermissionGroup:e.account_permission_group,accountAssociations:e.account_associations}),Es=e=>{var t;return{items:((t=e.items)!==null&&t!==void 0?t:[]).map(Is)}};class Rs{async get(t={}){try{const o=await v.UsersApi.getMyAccountsAdminsAndApprovers({isMyAccountRequest:t.isMyAccountRequest});return Es(o).items}catch(o){return g.handleError(o,"Failed to get account admins and approvers."),[]}}}const Ss=new Rs,ks=()=>Ss.get({isMyAccountRequest:!1}),Qo=async e=>(await ks()).filter(t=>{var o;return(o=t.accountAssociations)===null||o===void 0?void 0:o.includes(e)}),z={RequestedByCustomer:"REQUESTED_BY_CUSTOMER",NoUserAvailable:"NO_USER_AVAILABLE",NewCustomer:"NEW_CUSTOMER"};class Xe{constructor(t="",o="",i=o,n=""){this.value=t,this.displayText=o,this.name=i,this.email=n}isValid(){return this.value!==""}}const Us=e=>({id:e.id,name:e.account_name,status:e.status,accountNumber:e.account_number,displayName:e.account_friendly_name,statusUpdateAt:e.updated_at,statusUpdateBy:e.updated_by}),kt=e=>{var t;const o=[];return(t=e.account_associations)===null||t===void 0||t.forEach(i=>{o.push(Us(i))}),{id:e.id,firstName:e.first_name,lastName:e.last_name,email:e.email,phone:e.phone,evacAssistance:e.evacuation_assistance_required,accounts:o,status:"Active"}},$s=e=>{var t;const o=[];return(t=e.accounts)===null||t===void 0||t.forEach(i=>{o.includes(i.accountNumber)||o.push(i.accountNumber)}),{first_name:e.firstName,last_name:e.lastName,email:e.email,phone:e.phone,account_numbers:o,evacuation_assistance_required:e.evacAssistance}},Ns=e=>({id:e.id,first_name:e.firstName,last_name:e.lastName,email:e.email,phone:e.phone,evacuation_assistance_required:e.evacAssistance}),Fs=e=>({accountNumber:e.accountNumber,includeChildAccounts:!0,page:e.page,size:e.size,firstName:e.firstName,lastName:e.lastName,email:e.email,sort:e.sort,order:e.order}),Ds=e=>{var t,o;const i=[];return(t=e.content)===null||t===void 0||t.forEach(n=>{i.push(kt(n))}),{contacts:i,recordCount:(o=e.pageable)===null||o===void 0?void 0:o.total_elements}},Ps=e=>({id:e.id}),Ms=e=>({id:e.id,userProfile:Ns(e.contactInput)}),Os=e=>({userInput:{...$s(e.contactInput),change_history_id:e.changeHistoryId}});class Bs{async update(t){try{const o=Ms(t);return v.UsersApi.updateUser(o)}catch(o){return g.handleError("Failed to update user.")}}async create(t){try{const o=Os(t),i=await v.UsersApi.createUser(o);return kt(i)}catch(o){return g.handleError(o,`Failed to create user for ${t.contactInput.email}`),{}}}async search(t){try{const o=Fs(t),i=await v.UsersApi.getUsers(o);return Ds(i)}catch(o){return g.handleError(o,"Failed to get users."),{}}}async get(t){try{const o=Ps(t),i=await v.UsersApi.getUser(o);return kt(i)}catch(o){return g.handleError(o,"Failed to get user."),{}}}async getUsersReport(t){try{const o={accountNumber:t.accountNumber,includeChildAccounts:t.includeChildAccounts,firstName:t.firstName,lastName:t.lastName,email:t.email};return await v.UsersApi.getUserReport(o)}catch(o){throw g.handleError(o,"Failed to download users report."),o}}}const et=new Bs,Yo=e=>{const t=[...e.entries()].map(([o,i])=>({accountNumber:o,value:i.value})).filter(o=>!!o.value);if(t.length)return t.map(o=>o.value===z.NoUserAvailable?{reason:z.NoUserAvailable,authoriserUserId:"",accountNumber:o.accountNumber}:o.value===z.NewCustomer?{reason:z.NewCustomer,authoriserUserId:"",accountNumber:o.accountNumber}:{reason:z.RequestedByCustomer,authoriserUserId:o.value,accountNumber:o.accountNumber})},Xo=async e=>{const t=(await Promise.all(e.map(o=>_s(o)))).map(o=>o.authorityDocumentId).filter(Boolean);if(t.length!==e.length)throw new Error("Failed to upload all authority documents.");return t},Ut={noUserAvailable:"No User with Proper Permissions Available",newCustomer:"New Customer"},ei=(e,t,o)=>e?"loading":t>0?"selectable":o?"no-user":"new-customer",ti=(e,t)=>{const o=new Map(e!=null?e:new Map);t.forEach(n=>{o.has(n)||o.set(n,new Xe)});const i=new Set(t);return[...o.keys()].forEach(n=>{i.has(n)||o.delete(n)}),o},oi=(e,t)=>e.every(o=>{var i,n;return(n=(i=t==null?void 0:t.get(o))===null||i===void 0?void 0:i.isValid())!==null&&n!==void 0?n:!1}),$t=(e,t,o,i=[])=>{if(!e||!t||!o||o.size===0)return!1;const n=new Set(i),a=[...o.entries()].filter(([s])=>!n.size||n.has(s)).map(([,s])=>s).filter(s=>!!(s!=null&&s.value));return a.length?a.some(s=>s.value!==z.NewCustomer):!1},ii="data-wrap-patch";function ni(e,t){if(e.querySelector(`style[${ii}]`))return;const o=document.createElement("style");o.setAttribute(ii,""),o.textContent=t,e.appendChild(o)}function Ls(e){const t=()=>{const i=e.shadowRoot;i&&ni(i,`
|
|
2033
2033
|
.file-chip { height: auto; min-height: 40px; flex-wrap: wrap; }
|
|
2034
2034
|
.file-chip__name {
|
|
2035
2035
|
white-space: normal;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent ui-user-management following open-wc recommendations",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "ui-user-management",
|
|
6
|
-
"version": "16.0.
|
|
6
|
+
"version": "16.0.3-fix-1.558007",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
9
|
"./ui-user-management.js": "./dist/ui-user-management.js",
|