@digital-realty/app-shell 14.0.0 → 14.0.1-IXUAT-11078.548846
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/bootstrap.js +1 -1
- package/package.json +1 -1
package/dist/bootstrap.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate as w}from"tslib";import{LitElement as A,html as c}from"lit";import{property as I}from"lit/decorators.js";import{ApplicationInsights as Z,DistributedTracingModes as ee}from"@microsoft/applicationinsights-web";import{authedUser as P}from"@digital-realty/ix-account-switcher";import{UserManager as te}from"oidc-client-ts";import"@digital-realty/ix-app-logic/views/splash-screen.js";import{makeObservable as se,action as ne,observable as oe,toJS as ae}from"mobx";function i(){var e;const t=(e=window.gpConfig)==null?void 0:e["app-shell"];if(!t)throw new Error("App-shell config not loaded. Ensure config.json is fetched before app bootstrap.");return t}const{PortalInterxion:re,PortalGlobalPortal:ie,PortalServiceFabric:le,PortalMarketplacePortal:ce}=i(),pe={strict:"strictly_necessary",performance:"performance",targeting:"targeting"},ue={accept:"accept_all",reject:"reject_all",custom:"customize",no:"no_sell",bypass:"gpc_bypass"},b="globalportalappshell",u="user-authentication",g="redirect-url",de="ui-cookie-policy",me="date-format",R="Global Portal",T="Service Fabric",y="Marketplace Portal",v="EMEA Customer Portal",N="x-auth",[d,he,ge,_e]=["CREATE","UPDATE","READ","APPROVE"],[O,_,Ee,fe,k,Ce,_t,Se,L,Et,we,Ae,x,U,M,ft,Ie,Ct,Pe,D,V,G,be,j,Re,Te,$,ye]=["Cloud Connect","Cross Connect","Custom Roles","Customer Care","Customer Equipment Connection (CEC)","Customer Support","DCIM-enabled location data","Default System Roles","External User","Facility Access","Internal Roles","Internal User","Internet Exchange","Intra-Customer Connectivity (ICC)","IP Bandwidth","OSP Access","Permanent Badge","PoP/POE Room Access","Remote Hands","Remote Hands Package","Service Exchange Cloud Router","Service Exchange Port","Shipping & Receiving","Space & Power","Trouble Ticket","Visitor Access","User","ESG Reporting"],ve=[Pe,Ce,Re,be,Te,Ie,fe],Ne=[_,O,k,x,U,M,D,V,G,j],H=[_,O,k,x,U,M,D,V,G,j],Oe={LocationChanged:"location-changed",VaadinRouterLocationChanged:"vaadin-router-location-changed",CreateUserClicked:"create-user-clicked"},B={SessionStorage:{HasOutstandingChanges:"hasOutstandingChanges",ShowLastLoginPopup:"showLastLoginPopup"}},[ke,Le,xe]=["Security","DCIM","Planned Site Maintenance"],Ue=[ke,Le,xe],Me=[{label:R,href:ie,selected:!0},{label:y,href:ce},{label:v,href:re},{label:T,href:le,target:"_blank"}],F={appInsights:"_appInsights"},De=()=>{const{ApplicationInsightsInstrumentationKey:e,ApplicationInsightsCorrelationHeaderExcludedDomains:t}=i(),s=new Z({config:{instrumentationKey:e,enableCorsCorrelation:!0,enableRequestHeaderTracking:!0,enableResponseHeaderTracking:!0,enableAutoRouteTracking:!0,autoTrackPageVisitTime:!0,enableAjaxErrorStatusText:!0,enableAjaxPerfTracking:!0,enableUnhandledPromiseRejectionTracking:!0,isCookieUseDisabled:!0,distributedTracingMode:ee.AI_AND_W3C,correlationHeaderExcludedDomains:t.split(",").map(n=>n.trim())}});return s.loadAppInsights(),s.trackPageView(),s.addTelemetryInitializer(n=>{n.tags["ai.cloud.role"]=b}),s},m=(e,t,s)=>(...n)=>{const[o,...a]=n;typeof o=="string"&&o.startsWith("[mobx]")&&t===4?s.trackException({exception:{message:a[0].message,stack:a[0].stack,name:o},severityLevel:4}):s.trackTrace({severityLevel:t,message:o},a),e.apply(console,[o,...a])},Ve=e=>{console.log=m(console.log,2,e),console.info=m(console.info,2,e),console.warn=m(console.warn,3,e),console.error=m(console.error,4,e),window.console=console},Ge=()=>{const{ApplicationInsightsInstrumentationKey:e}=i();if(!e)return;const t=De();window[F.appInsights]=t,window.dispatchEvent(new Event("appInsightsInitialized")),Ve(t)},z=async e=>{const t=new TextEncoder().encode(e),s=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(s)).map(n=>n.toString(16).padStart(2,"0")).join("")};function je(){const{location:e}=window,t=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`,{LoginAuthority:s,GlobalPortalClientId:n,GlobalPortalUIScopes:o,GlobalPlanBShellPostLogoutRedirectUrl:a}=i();return{authority:s,client_id:n,redirect_uri:`${t}/auth-callback`,response_type:"code",scope:o,post_logout_redirect_uri:a,monitorSession:!1}}const E=new te(je()),$e=e=>{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(window.atob(t).split("").map(n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(s)},He=()=>{localStorage.removeItem(u)},l=()=>{const e=localStorage.getItem(u);return e?JSON.parse(e):null},K=()=>{var e;const t=localStorage.getItem(N);return t?(e=JSON.parse(t))==null?void 0:e.email:null},Be=async()=>{const e=l();if(!e)return null;const t=(e.profile.given_name||"")+(e.profile.family_name||"")+e.profile.sub;return await z(t)},J=()=>{const e=l();return e?e.id_token:null},W=(e,t)=>{const s={...t,...e},n=$e(e.access_token);return s.profile.sub=n.sub,s.profile.account_number=n.account_number,s.expires_at=n.exp,s.is_federated=n.is_federated,n.previous_login_date&&(s.profile.previous_login_date=n.previous_login_date),P.setAccount({accountNumber:n.account_number,email:n.email,name:n.name,givenName:n.given_name,familyName:n.family_name,authTime:n.exp,accessToken:e.access_token,idToken:e.id_token}),localStorage.setItem(u,JSON.stringify(s)),s},Fe=e=>{W(e,null)},Y=()=>{const e=l();return e?e.access_token:null},ze=()=>{const e=l();return e&&e.is_federated!==null&&e.is_federated!==void 0?String(e.is_federated).toLowerCase()==="true":!1},Ke=()=>{const e=l();return e!=null&&e.expires_at?e.expires_at>Date.now()/1e3:!1},Je=()=>{var e;const t=l();return((e=t==null?void 0:t.profile)==null?void 0:e.previous_login_date)||null},We=["authenticate","auth-callback","logout"],Ye=e=>e.expires_at&&new Date(e.expires_at*1e3),qe=e=>e.expires_at&&new Date(e.expires_at*1e3+i().TokenValidForOfflineUsePostExpiryInHours*60*60*1e3),q=()=>{if(!i().IsLoginEnabled)return!1;const e=l();if(!J())return!0;if(!e.expires_at)return!1;const t=new Date;return navigator.onLine?t>Ye(e):t>qe(e)},Xe=()=>{const e=window.location.pathname.split("/");return We.includes(e[e.length-1])},Qe=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="authenticate"?(i().IsLoginEnabled?E.signinRedirect():window.location.href="/",!0):!1},Ze=()=>{let e="/";const t=localStorage.getItem(g);t&&(localStorage.removeItem(g),e=t),sessionStorage.setItem(B.SessionStorage.ShowLastLoginPopup,"true"),window.location.href=e},et=e=>{if(!e.id_token)throw new Error("Missing property:id_token");return e},f=e=>{const t=Xe();(!t||e)&&(t||localStorage.setItem(g,window.location.href),window.location.href="/authenticate")},tt=async e=>{const t=`${e.profile.sub}-${e.profile.customer_id}`,s=await z(t);return{...e,profile:{...e.profile,hashed_identifier:s}}},st=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="auth-callback"?(E.signinRedirectCallback().then(et).then(tt).then(Fe).then(Ze).catch(f),!0):!1};class nt extends A{render(){return c` <ix-splash-screen></ix-splash-screen> `}}window.customElements.define("splash-screen",nt);class ot{constructor(){this.permissions=[],this.loading=!1,this.getPermissions=async()=>{var t;const s=(t=P)==null?void 0:t.access_token;if(!s)return[];const{ApiBaseUrl:n}=i(),o=await fetch(`${n}/usermanagement/my-permissions?exclude_parents=false&exclude_siblings=true`,{headers:{Authorization:`Bearer ${s}`}});return o.ok?o.json():[]},se(this,{permissions:oe,setPermissions:ne})}setPermissions(t){this.permissions=t}tryLoadPermissions(){try{this.loading||(this.loading=!0,this.getPermissions().then(t=>{this.setPermissions(t),this.loading=!1}).catch(()=>{this.loading=!1}))}catch(t){this.loading=!1}}clearPermissions(){this.setPermissions([])}hasExternalUserCreate(){return this.hasPermission(L,d)||this.hasPermission($,d)}hasConnectivityCreate(){return this.hasPermission(_,d)}hasPrivilegeLevel(t,s){const n=[_e,d,he,ge],o=n.findIndex(r=>r===t),a=n.findIndex(r=>r===s);return o>=a}hasPermission(t,s){return ae(this.permissions).some(n=>n.permission_name===t&&this.hasPrivilegeLevel(s,n.privilege))}}const C=new ot,X=()=>{const e=new Headers;return e.append("Authorization",`Bearer ${Y()}`),e},at=async()=>{const{ApiBaseUrl:e}=i(),t=`${e}/inventory/locations?embed=permissions&page_size=1000`;let s=[],n=1;for(;;){const a=await fetch(`${t}&cursor=${n}`,{headers:X()});if(!a.ok)return Promise.reject();const r=await a.json();if(s.push(...r.items),r.self===r.last)break;n++}s=s.filter(a=>a.permissions.some(r=>H.includes(r.name)));const o=new Map;for(const a of s)o.has(a.account_number)?o.get(a.account_number).push(a.site_id):o.set(a.account_number,[a.site_id]);return o},rt=async e=>{const{ApiBaseUrl:t}=i(),s=new URLSearchParams;s.append("process","Cross_connect");const n=[...e.keys()],o=[...new Set([...e.values()].flat())];s.append("account_number",n.join(",")),s.append("site",o.join(","));const a=await fetch(`${t}/site-navigations/site-configurations?${s}`,{headers:X()});return a.ok?await a.json():Promise.reject()},it=async()=>{try{const e=await at();return e.size===0?!1:(await rt(e)).some(t=>{var s;return t.portal==="GlobalPortal"&&!!((s=e.get(t.account_number))!=null&&s.includes(t.site))})}catch(e){return console.error("Failed to determine portal-managed inventory:",e),!1}};class S extends A{constructor(){super(),this._currentView="splash",this.appLoaded=!1,this._onPopState=()=>{i().IsLoginEnabled&&q()&&f()};try{Ge()}catch(s){console.error("Telemetry initialization failed:",s)}const t=window.location.pathname;if(t==="/session-expired"){this._currentView="session-expired",this._loadView("session-expired");return}if(t==="/logout"){this._currentView="logout",this._loadView("logout");return}if(Qe()||st()){this._currentView="splash";return}if(q()){this._currentView="splash",f();return}this._currentView="app",this._loadApp()}async _loadView(t){t==="session-expired"?await import("@digital-realty/ix-app-logic/views/session-expiry.js"):t==="logout"&&await import("./logout-DHu3NPe-.js")}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this._onPopState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this._onPopState)}_getAccountNumber(){var t,s,n;return(n=new URLSearchParams(window.location.search).get("selected_account_number"))!=null?n:(s=(t=l())==null?void 0:t.profile)==null?void 0:s.account_number}_isESGAccessOnly(t,s){const n=t.filter(o=>o.account_number===s);return n.length===1&&n[0].permission_name==="ESG Reporting"}async _applyGomFF(){var t,s;const n=K(),o=structuredClone(window.gpConfig);if(!n||!o)return;const a=((t=i().SuperusersWhitelist)!=null?t:"").split(",").map(h=>h.trim().toLowerCase()).includes(n.toLowerCase()),r=!!((s=o["app-shell"])!=null&&s.IsInventoryManagementEnabled),p=await it()&&(a||r);o["app-shell"].IsInventoryManagementEnabled=p,o["ui-launchpad"].IsInventoryManagementEnabled=p,window.gpConfig=Object.freeze(o)}_applyMfeOverrides(t,s){const n={};for(const o of Object.keys(t))n[o]={...t[o],enabled:s.includes(o)};return n}async _loadApp(){var t;const{authedUser:s}=await import("@digital-realty/ix-account-switcher");await s.hydrateStore();const[n,o]=await Promise.allSettled([fetch("./registered-apps.json").then(Q=>Q.json()),C.getPermissions()]);if(n.status==="rejected"){console.error("Failed to load registered apps:",n.reason);return}if(o.status==="rejected"){console.error("Failed to load permissions:",o.reason);return}const{registeredApps:a}=n.value,r=o.value,p=(t=this._getAccountNumber())!=null?t:"",h=this._isESGAccessOnly(r,p)?this._applyMfeOverrides(a,["ui-esg"]):a;await this._applyGomFF(),window.registeredApps=Object.freeze(h),C.setPermissions(r),await import("./app-CQYtI6QN.js"),this.appLoaded=!0}render(){switch(this._currentView){case"session-expired":return c`<ix-session-expiry></ix-session-expiry>`;case"logout":return c`<ixp-logout></ixp-logout>`;case"app":return this.appLoaded?c`<global-portal-app appTitle="DLR" showDrawer></global-portal-app>`:c`<splash-screen></splash-screen>`;default:return c`<splash-screen></splash-screen>`}}}w([I({type:String})],S.prototype,"_currentView",void 0),w([I({type:Boolean})],S.prototype,"appLoaded",void 0),window.customElements.define("gp-bootstrap",S);export{Oe as A,N as B,Ee as C,me as D,ye as E,de as F,R as G,Ne as I,y as M,H as O,Ue as R,ve as S,$ as U,J as a,Be as b,He as c,K as d,Y as e,l as f,i as g,W as h,Je as i,ze as j,B as k,Ae as l,L as m,Se as n,we as o,C as p,v as q,Me as r,T as s,F as t,E as u,b as v,pe as w,Ke as x,ue as y,u as z};
|
|
1
|
+
import{__decorate as C}from"tslib";import{LitElement as w,html as c}from"lit";import{property as A}from"lit/decorators.js";import{ApplicationInsights as Z,DistributedTracingModes as ee}from"@microsoft/applicationinsights-web";import{authedUser as I}from"@digital-realty/ix-account-switcher";import{UserManager as te}from"oidc-client-ts";import"@digital-realty/ix-app-logic/views/splash-screen.js";import{makeObservable as se,action as ne,observable as oe,toJS as re}from"mobx";function i(){var e;const t=(e=window.gpConfig)==null?void 0:e["app-shell"];if(!t)throw new Error("App-shell config not loaded. Ensure config.json is fetched before app bootstrap.");return t}const{PortalInterxion:ae,PortalGlobalPortal:ie,PortalServiceFabric:le,PortalMarketplacePortal:ce}=i(),pe={strict:"strictly_necessary",performance:"performance",targeting:"targeting"},ue={accept:"accept_all",reject:"reject_all",custom:"customize",no:"no_sell",bypass:"gpc_bypass"},P="globalportalappshell",u="user-authentication",h="redirect-url",de="ui-cookie-policy",me="date-format",R="Global Portal",b="Service Fabric",T="Marketplace Portal",v="EMEA Customer Portal",y="x-auth",[d,he,ge,_e]=["CREATE","UPDATE","READ","APPROVE"],[N,g,Ee,fe,O,Se,Et,Ce,k,ft,we,Ae,U,L,x,St,Ie,Ct,Pe,M,D,V,Re,G,be,Te,j,ve]=["Cloud Connect","Cross Connect","Custom Roles","Customer Care","Customer Equipment Connection (CEC)","Customer Support","DCIM-enabled location data","Default System Roles","External User","Facility Access","Internal Roles","Internal User","Internet Exchange","Intra-Customer Connectivity (ICC)","IP Bandwidth","OSP Access","Permanent Badge","PoP/POE Room Access","Remote Hands","Remote Hands Package","Service Exchange Cloud Router","Service Exchange Port","Shipping & Receiving","Space & Power","Trouble Ticket","Visitor Access","User","ESG Reporting"],ye=[Pe,Se,be,Re,Te,Ie,fe],Ne=[g,N,O,U,L,x,M,D,V,G],$=[g,N,O,U,L,x,M,D,V,G],Oe={LocationChanged:"location-changed",VaadinRouterLocationChanged:"vaadin-router-location-changed",CreateUserClicked:"create-user-clicked"},H={SessionStorage:{HasOutstandingChanges:"hasOutstandingChanges",ShowLastLoginPopup:"showLastLoginPopup"}},[ke,Ue,Le]=["Security","DCIM","Planned Site Maintenance"],xe=[ke,Ue,Le],Me=[{label:R,href:ie,selected:!0},{label:T,href:ce},{label:v,href:ae},{label:b,href:le,target:"_blank"}],B={appInsights:"_appInsights"},De=()=>{const{ApplicationInsightsInstrumentationKey:e,ApplicationInsightsCorrelationHeaderExcludedDomains:t}=i(),s=new Z({config:{instrumentationKey:e,enableCorsCorrelation:!0,enableRequestHeaderTracking:!0,enableResponseHeaderTracking:!0,enableAutoRouteTracking:!0,autoTrackPageVisitTime:!0,enableAjaxErrorStatusText:!0,enableAjaxPerfTracking:!0,enableUnhandledPromiseRejectionTracking:!0,isCookieUseDisabled:!0,distributedTracingMode:ee.AI_AND_W3C,correlationHeaderExcludedDomains:t.split(",").map(n=>n.trim())}});return s.loadAppInsights(),s.trackPageView(),s.addTelemetryInitializer(n=>{n.tags["ai.cloud.role"]=P}),s},m=(e,t,s)=>(...n)=>{const[o,...r]=n;typeof o=="string"&&o.startsWith("[mobx]")&&t===4?s.trackException({exception:{message:r[0].message,stack:r[0].stack,name:o},severityLevel:4}):s.trackTrace({severityLevel:t,message:o},r),e.apply(console,[o,...r])},Ve=e=>{console.log=m(console.log,2,e),console.info=m(console.info,2,e),console.warn=m(console.warn,3,e),console.error=m(console.error,4,e),window.console=console},Ge=()=>{const{ApplicationInsightsInstrumentationKey:e}=i();if(!e)return;const t=De();window[B.appInsights]=t,window.dispatchEvent(new Event("appInsightsInitialized")),Ve(t)},F=async e=>{const t=new TextEncoder().encode(e),s=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(s)).map(n=>n.toString(16).padStart(2,"0")).join("")};function je(){const{location:e}=window,t=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`,{LoginAuthority:s,GlobalPortalClientId:n,GlobalPortalUIScopes:o,GlobalPlanBShellPostLogoutRedirectUrl:r}=i();return{authority:s,client_id:n,redirect_uri:`${t}/auth-callback`,response_type:"code",scope:o,post_logout_redirect_uri:r,monitorSession:!1}}const _=new te(je()),$e=e=>{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(window.atob(t).split("").map(n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(s)},He=()=>{localStorage.removeItem(u)},l=()=>{const e=localStorage.getItem(u);return e?JSON.parse(e):null},z=()=>{var e;const t=localStorage.getItem(y);return t?(e=JSON.parse(t))==null?void 0:e.email:null},Be=async()=>{const e=l();if(!e)return null;const t=(e.profile.given_name||"")+(e.profile.family_name||"")+e.profile.sub;return await F(t)},K=()=>{const e=l();return e?e.id_token:null},J=(e,t)=>{const s={...t,...e},n=$e(e.access_token);return s.profile.sub=n.sub,s.profile.account_number=n.account_number,s.expires_at=n.exp,s.is_federated=n.is_federated,n.previous_login_date&&(s.profile.previous_login_date=n.previous_login_date),I.setAccount({accountNumber:n.account_number,email:n.email,name:n.name,givenName:n.given_name,familyName:n.family_name,authTime:n.exp,accessToken:e.access_token,idToken:e.id_token}),localStorage.setItem(u,JSON.stringify(s)),s},Fe=e=>{J(e,null)},Y=()=>{const e=l();return e?e.access_token:null},ze=()=>{const e=l();return e&&e.is_federated!==null&&e.is_federated!==void 0?String(e.is_federated).toLowerCase()==="true":!1},Ke=()=>{const e=l();return e!=null&&e.expires_at?e.expires_at>Date.now()/1e3:!1},Je=()=>{var e;const t=l();return((e=t==null?void 0:t.profile)==null?void 0:e.previous_login_date)||null},Ye=["authenticate","auth-callback","logout"],qe=e=>e.expires_at&&new Date(e.expires_at*1e3),We=e=>e.expires_at&&new Date(e.expires_at*1e3+i().TokenValidForOfflineUsePostExpiryInHours*60*60*1e3),q=()=>{if(!i().IsLoginEnabled)return!1;const e=l();if(!K())return!0;if(!e.expires_at)return!1;const t=new Date;return navigator.onLine?t>qe(e):t>We(e)},Xe=()=>{const e=window.location.pathname.split("/");return Ye.includes(e[e.length-1])},Qe=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="authenticate"?(i().IsLoginEnabled?_.signinRedirect():window.location.href="/",!0):!1},Ze=()=>{let e="/";const t=localStorage.getItem(h);t&&(localStorage.removeItem(h),e=t),sessionStorage.setItem(H.SessionStorage.ShowLastLoginPopup,"true"),window.location.href=e},et=e=>{if(!e.id_token)throw new Error("Missing property:id_token");return e},E=e=>{const t=Xe();(!t||e)&&(t||localStorage.setItem(h,window.location.href),window.location.href="/authenticate")},tt=async e=>{const t=`${e.profile.sub}-${e.profile.customer_id}`,s=await F(t);return{...e,profile:{...e.profile,hashed_identifier:s}}},st=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="auth-callback"?(_.signinRedirectCallback().then(et).then(tt).then(Fe).then(Ze).catch(E),!0):!1};class nt extends w{render(){return c` <ix-splash-screen></ix-splash-screen> `}}window.customElements.define("splash-screen",nt);class ot{constructor(){this.permissions=[],this.loading=!1,this.getPermissions=async()=>{var t;const s=(t=I)==null?void 0:t.access_token;if(!s)return[];const{ApiBaseUrl:n}=i(),o=await fetch(`${n}/usermanagement/my-permissions?exclude_parents=false&exclude_siblings=true`,{headers:{Authorization:`Bearer ${s}`}});return o.ok?o.json():[]},se(this,{permissions:oe,setPermissions:ne})}setPermissions(t){this.permissions=t}tryLoadPermissions(){try{this.loading||(this.loading=!0,this.getPermissions().then(t=>{this.setPermissions(t),this.loading=!1}).catch(()=>{this.loading=!1}))}catch(t){this.loading=!1}}clearPermissions(){this.setPermissions([])}hasExternalUserCreate(){return this.hasPermission(k,d)||this.hasPermission(j,d)}hasConnectivityCreate(){return this.hasPermission(g,d)}hasPrivilegeLevel(t,s){const n=[_e,d,he,ge],o=n.findIndex(a=>a===t),r=n.findIndex(a=>a===s);return o>=r}hasPermission(t,s){return re(this.permissions).some(n=>n.permission_name===t&&this.hasPrivilegeLevel(s,n.privilege))}}const f=new ot,W=()=>{const e=new Headers;return e.append("Authorization",`Bearer ${Y()}`),e},rt=async()=>{const{ApiBaseUrl:e}=i(),t=`${e}/inventory/locations?embed=permissions&page_size=1000`;let s=[],n=1;for(;;){const r=await fetch(`${t}&cursor=${n}`,{headers:W()});if(!r.ok)return Promise.reject();const a=await r.json();if(s.push(...a.items),a.self===a.last)break;n++}s=s.filter(r=>r.permissions.some(a=>$.includes(a.name)));const o=new Map;for(const r of s)o.has(r.account_number)?o.get(r.account_number).push(r.site_id):o.set(r.account_number,[r.site_id]);return o},at=async e=>{const{ApiBaseUrl:t}=i(),s=new URLSearchParams;s.append("process","Cross_connect");const n=[...e.keys()],o=[...new Set([...e.values()].flat())];s.append("account_number",n.join(",")),s.append("site",o.join(","));const r=await fetch(`${t}/site-navigations/site-configurations?${s}`,{headers:W()});return r.ok?await r.json():Promise.reject()},it=async()=>{try{const e=await rt();return e.size===0?!1:(await at(e)).some(t=>{var s;return t.portal==="GlobalPortal"&&!!((s=e.get(t.account_number))!=null&&s.includes(t.site))})}catch(e){return console.error("Failed to determine portal-managed inventory:",e),!1}},lt="SUPERUSER";class S extends w{_isSuperUser(t){return t.some(s=>{var n;return(n=s.provenance)==null?void 0:n.includes(lt)})}constructor(){super(),this._currentView="splash",this.appLoaded=!1,this._onPopState=()=>{i().IsLoginEnabled&&q()&&E()};try{Ge()}catch(s){console.error("Telemetry initialization failed:",s)}const t=window.location.pathname;if(t==="/session-expired"){this._currentView="session-expired",this._loadView("session-expired");return}if(t==="/logout"){this._currentView="logout",this._loadView("logout");return}if(Qe()||st()){this._currentView="splash";return}if(q()){this._currentView="splash",E();return}this._currentView="app",this._loadApp()}async _loadView(t){t==="session-expired"?await import("@digital-realty/ix-app-logic/views/session-expiry.js"):t==="logout"&&await import("./logout-DHu3NPe-.js")}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this._onPopState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this._onPopState)}_getAccountNumber(){var t,s,n;return(n=new URLSearchParams(window.location.search).get("selected_account_number"))!=null?n:(s=(t=l())==null?void 0:t.profile)==null?void 0:s.account_number}_isESGAccessOnly(t,s){const n=t.filter(o=>o.account_number===s);return n.length===1&&n[0].permission_name==="ESG Reporting"}async _applyGomFF(t){var s;const n=z(),o=structuredClone(window.gpConfig);if(!n||!o)return;const r=this._isSuperUser(t),a=!!((s=o["app-shell"])!=null&&s.IsInventoryManagementEnabled),p=await it()&&(r||a);o["app-shell"].IsInventoryManagementEnabled=p,o["ui-launchpad"].IsInventoryManagementEnabled=p,window.gpConfig=Object.freeze(o)}_applyMfeOverrides(t,s){const n={};for(const o of Object.keys(t))n[o]={...t[o],enabled:s.includes(o)};return n}async _loadApp(){var t;const{authedUser:s}=await import("@digital-realty/ix-account-switcher");await s.hydrateStore();const[n,o]=await Promise.allSettled([fetch("./registered-apps.json").then(Q=>Q.json()),f.getPermissions()]);if(n.status==="rejected"){console.error("Failed to load registered apps:",n.reason);return}if(o.status==="rejected"){console.error("Failed to load permissions:",o.reason);return}const{registeredApps:r}=n.value,a=o.value,p=(t=this._getAccountNumber())!=null?t:"",X=this._isESGAccessOnly(a,p)?this._applyMfeOverrides(r,["ui-esg"]):r;await this._applyGomFF(a),window.registeredApps=Object.freeze(X),f.setPermissions(a),await import("./app-CQYtI6QN.js"),this.appLoaded=!0}render(){switch(this._currentView){case"session-expired":return c`<ix-session-expiry></ix-session-expiry>`;case"logout":return c`<ixp-logout></ixp-logout>`;case"app":return this.appLoaded?c`<global-portal-app appTitle="DLR" showDrawer></global-portal-app>`:c`<splash-screen></splash-screen>`;default:return c`<splash-screen></splash-screen>`}}}C([A({type:String})],S.prototype,"_currentView",void 0),C([A({type:Boolean})],S.prototype,"appLoaded",void 0),window.customElements.define("gp-bootstrap",S);export{Oe as A,y as B,Ee as C,me as D,ve as E,de as F,R as G,Ne as I,T as M,$ as O,xe as R,ye as S,j as U,K as a,Be as b,He as c,z as d,Y as e,l as f,i as g,J as h,Je as i,ze as j,H as k,Ae as l,k as m,Ce as n,we as o,f as p,v as q,Me as r,b as s,B as t,_ as u,P as v,pe as w,Ke as x,ue as y,u as z};
|