import{a as P}from"./chunk-ML5MTN55.js";import{b as n,c as I,d as S}from"./chunk-N2JMDMYD.js";import{ea as T}from"./chunk-62DTW4JT.js";import{C as E,I as c,L as x,O as u,P as l,T as v,g as b,s as g}from"./chunk-GHYBLXL4.js";import{F as d,Na as L,fa as M,ja as p,pa as o,s as h}from"./chunk-ZSMGRWAG.js";import{a as s,b as a}from"./chunk-GAL4ENT6.js";var k={WhistleblowerEForm:"e-form",Headline:"headline",Label:"label",GoToSecurePostBox:"to-pb",ExternalLink:"external-link",Dashboard:"dashboard",AppPageLink:"app-link",PrintButton:"print"};var O=(t,i)=>{let e=t?.[i]?.Text||"";return i===n.WHISTLEBLOWER_E_FORM&&(!e||e==="WB FORM")?"Go to reporting|t:179":e},A=(t,i)=>{switch(i){case n.WHISTLEBLOWER_E_FORM:return["wb",t.WhistleblowerEForm?.FormBundleId?.toString()??""];case n.APP_PAGE_LINK:return["app-page",{appPageName:t.AppPageLink.AppPageLinkName}];case n.DASHBOARD:return"";default:return null}},D=t=>{if(!t)return;let i=t.match(/fa-[\w-]+/)[0],e=t.replace(i,"")?.trim()??"";return{name:i,set:e}},R=t=>Object.values(t).some(i=>i?.Text);var B=(()=>{class t{#r=o(l);#t=o(T);#o=o(g);#e=o(L);#n=o(c);#i=o(v);menuAction(e){switch(e){case n.GO_TO_SECURE_POST_BOX:return()=>this.goToSecurePostBox();case n.PRINT_BUTTON:return()=>this.printPage();default:return null}}processMenuItems(e,r=!1){return e.filter(m=>S(m,this.#n.appConfig()?.AppPages)&&(!r||R(m))).map(m=>this.processMenuItem(m))}processMenuItem(e){let r=I(e);return a(s({},e),{type:r,e2eId:k?.[r]||"",text:O(e,r),action:this.menuAction(r),routerLink:A(e,r),link:this.getLink(e),icon:D(e[r]?.Icon)||{}})}printPage(){window.print()}goToSecurePostBox(){this.#t.open(P,{autoFocus:"first-tabbable",direction:this.#i.direction()}).afterClosed().pipe(E(this.#e),d(r=>!!r)).subscribe(()=>void this.#o.navigate(["wb-secure-postbox"]))}getLink(e){let r=I(e);return r===n.DOCUMENT_LINK?u([this.#r.assetsUrl(),e.DocumentLink.Link]):r===n.EXTERNAL_LINK?e.ExternalLink.Link:null}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=p({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var pe=(()=>{class t{#r=o(b);#t=o(c);#o=o(l);#e=o(B);loadAppConfig(e){let r=u([this.#o.commonUrl(),x.GET_APP_CONFIG]),m={AppGuid:this.#t.appGuid(),LanguageISO6391Code:e||""};return this.#r.post(r,m).pipe(h(f=>this.processMenuItems(f)),M(f=>this.#t.appConfig.set(f)))}processMenuItems(e){return a(s({},e),{Dashboard:{MenuItems:this.#e.processMenuItems(e.Dashboard.MenuItems)},MenuLeft:a(s({},e.MenuLeft),{MenuItems:this.#e.processMenuItems(e.MenuLeft.MenuItems,!0)}),BottomMenu:a(s({},e.BottomMenu),{MenuItems:this.#e.processMenuItems(e.BottomMenu.MenuItems)}),AppPages:e.AppPages.map(r=>a(s({},r),{MenuItems:this.#e.processMenuItems(r.MenuItems)}))})}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=p({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();export{pe as a};
