(()=>{function e(e,t,n,i,o,r,a,c,s,p,u,l,d,g,h){var f,y,m,v,A=this,S=i.current();function O(e){var t;A.canEdit=e.owner.tenant.id===A.user.tenant&&!!(t=e).manifest&&!t.manifest.noAppSwitcher,A.appid=e.id,A.currentApp=e}function U(e){A.user=e,A.supportActivated=e.supportUserEnabled}function b(){n.listByVisibleLinks().then(N).then(function(e){var t;A.applications=e,t=n.getCurrentContextPath(),A.applications.forEach(function(e){e.currentApp=t===e.contextPath})})}function N(e){function t(e){return!!_.get(e,"cloud")}var n=a.appOption("hideCloudApps");return n||(A.oneCloudApplications=e.filter(t)),e.filter(function(e){return!t(e)})}function $(){A.navOpen=!A.navOpen}function w(){document.documentElement.clientWidth<1200&&$()}function k(){e.$emit("userUpdated")}function D(e){p.success(e)}function E(e){_.set(A,"supportUrl",e)}function V(e){A.backendVersion=e.value}function C(e){A.uiVersion=e}_.assign(A,{$onInit:function(){f=e.$on("c8yUser:update",function(e,t){A.user.userName===t.user.userName&&_.assign(A.user,t.user)}),S.then(U),b(),y=e.$on("c8yApplication:update",b),m=e.$on("c8yApplication:create",b),v=e.$on("c8yApplication:delete",b),u.getSystemOptionValue({category:"support-user",key:"enabled"},!0).then(function(e){A.activateSupportUserAvailable=!e}),u.getSupportUrl().then(E),n.getConfig().then(O),l.getBackendVersion().then(V),l.getUIVersion().then(C),A.hideAppEdit=a.getFlag("hideAppEdit"),A.hideVersions=a.appOption("hide_powered"),A.showRightDrawer=a.appOption("rightDrawer"),A.beta=a.getFlag("beta"),A.menuStatus={},1200<document.documentElement.clientWidth&&!A.navHiddenOnStartup&&_.delay($,300);t.$on("navigateByMenu",w)},$onDestroy:function(){f(),y(),m(),v()},toggleNav:$,getUserName:function(){var e=A.user||{};return((e,t)=>{var n=(e||"").trim().split(/\s+/).shift().substr(0,1),t=(t||"").trim().split(/\s+/).pop();return(n=t?"".concat(n,". "):(e||"").split(/\s+/).shift())+t})(e.firstName,e.lastName)||e.userName},editUser:function(){c.editUserUI().then(k)},isLoading:function(){return e.loading},activateSupportAccess:function(){var e=a.appOption("company_name"),t=g("Activate support user access"),n=g("Support user access activated."),o=h.getString("When clicking OK you agree that a support user gets access to your tenant to help you in your specific problem."),e=e?h.getString("When clicking OK you agree that support personnel from {{company_name}} gets access to your user interface in order to be able to help you with your specific problem.",{company_name:e}):o,o=s({status:"danger",title:t,body:e});return o.then(i.activateSupportUser).then(function(){A.supportActivated=!0,D(n)})},deactivateSupportAccess:function(){var e=a.appOption("company_name"),t=g("Deactivate support user access"),n=g("Support user access deactivated."),o=h.getString("When clicking OK you agree that you no longer need support."),e=e?h.getString("When clicking OK you agree that you no longer need support from support personnel of {{company_name}}.",{company_name:e}):o,o=s({status:"danger",title:t,body:e});return o.then(i.deactivateSupportUser).then(function(){A.supportActivated=!1,D(n)})},logout:o.logout,getHref:n.getHref,rootNodes:r.rootNodes,showAccessDeniedRequestsList:d.showAccessDeniedRequestsList,navOpen:!1,toggle:function(){A.headerOpen=!A.headerOpen,A.onToggle({open:A.headerOpen})}})}e.$inject=["$rootScope","$scope","c8yApplication","c8yUser","c8yAuth","c8yNavigator","c8yBase","c8yUiUtil","c8yModal","c8yAlert","c8ySettings","c8ySystem","c8yAccessDenied","gettext","gettextCatalog"],angular.module("c8y.ui").component("c8yUiHeader",{templateUrl:":::PLUGIN_PATH:::/ui/containers/header.html",controllerAs:"vm",controller:e,bindings:{navOpen:"=",navHiddenOnStartup:"=",onToggle:"&"}})})();