import{h}from"@stencil/core";import{AuthenticationService,navigateTo,service}from"../../../../../api/dist/ontotext-workbench-api";export class OntoUserMenu{constructor(){this.authenticationService=service(AuthenticationService),this.logout=()=>{this.authenticationService.logout()},this.toggleDropdown=()=>{this.isOpen=!this.isOpen},this.handleOutsideClick=e=>{this.isOpen&&!this.hostElement.contains(e.target)&&(this.isOpen=!1)}}connectedCallback(){document.addEventListener("click",this.handleOutsideClick)}disconnectedCallback(){document.removeEventListener("click",this.handleOutsideClick)}render(){return h("section",{key:"1dab3b6df2cdbc139eb9c449a8a91bf016b45831",class:"onto-user-menu"},h("div",{key:"1050af1eb93e599a16fda17448abb77ebeacade4",class:"dropdown-toggle-wrapper",onClick:this.toggleDropdown},h("button",{key:"b98b83e32ed1d861f76d0e51a0040ccea992da73",class:this.isOpen?"open":""},h("i",{key:"47f321878b2c806a9aa0c65db7c2a2da900233af",class:"ri-user-line ri-lg"}),h("span",{key:"a2017e3a4b837206ff8860404b8766054d288a50",class:"username"},this.user.username),h("i",{key:"5bac7282c450c74d205dca06697b79aaa888a6e3",class:"ri-arrow-down-s-line "+(this.isOpen?"rotate-180":"")})),this.isOpen?h("section",{class:"onto-user-menu-dropdown"},h("translate-label",{onClick:navigateTo("settings"),labelKey:"user_menu.my_settings"}),this.authenticationService.isExternalUser()?"":h("translate-label",{onClick:this.logout,labelKey:"user_menu.logout"})):""))}static get is(){return"onto-user-menu"}static get originalStyleUrls(){return{$:["onto-user-menu.scss"]}}static get styleUrls(){return{$:["onto-user-menu.css"]}}static get properties(){return{user:{type:"unknown",attribute:"user",mutable:!1,complexType:{original:"AuthenticatedUser",resolved:"AuthenticatedUser",references:{AuthenticatedUser:{location:"import",path:"@ontotext/workbench-api",id:"../api/dist/ontotext-workbench-api.d.ts::AuthenticatedUser"}}},required:!1,optional:!1,docs:{tags:[],text:"Currently authenticated user"},getter:!1,setter:!1},securityConfig:{type:"unknown",attribute:"security-config",mutable:!1,complexType:{original:"SecurityConfig",resolved:"SecurityConfig",references:{SecurityConfig:{location:"import",path:"@ontotext/workbench-api",id:"../api/dist/ontotext-workbench-api.d.ts::SecurityConfig"}}},required:!1,optional:!1,docs:{tags:[],text:"Current security config"},getter:!1,setter:!1}}}static get states(){return{isOpen:{}}}static get elementRef(){return"hostElement"}}