import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as s,transformTag as r}from"@stencil/core/internal/client";import{b as o}from"./index.esm.js";import{a as n}from"./keycodes.js";import{n as a}from"./negate.js";const l=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.change=i(this,"change",7),this.layout="grid",this.handleChangeFilter=t=>{t.stopPropagation(),this.filter=t.detail},this.isIncluded=(t,e)=>this.isSeparator(t)?!(0===e&&!t.text):!this.filter||t.text.toLocaleLowerCase().includes(this.filter.toLocaleLowerCase()),this.isEmptyGroup=(t,e,i)=>{if(!this.isSeparator(t))return!1;const s=i[e+1];return!s||this.isSeparator(s)},this.handleChange=t=>{t.preventDefault(),this.handleItemChange(t.detail)},this.handleKeyDown=t=>{var e;if(t.key!==n)return;const i=null===(e=this.host.shadowRoot)||void 0===e?void 0:e.querySelector("limel-list"),s=this.getItems().filter(a(this.isSeparator));i&&s.length>0&&(i.focus(),this.handleItemChange(s[0]))}}render(){return[s("limel-input-field",{key:"314fbd746ab8a22f16ac001e02056e1e5325cdb6",tabIndex:0,value:this.filter,type:"search","leading-icon":"search",placeholder:this.translator.get("webclient.global-search-route"),onChange:this.handleChangeFilter,onKeyDown:this.handleKeyDown}),s("limel-list",{key:"8be5b8bb377375d362ff441349d9131d0eec24f9",items:this.getItems(),type:"selectable",class:{"has-interactive-items":!0,"has-grid-layout":"grid"===this.layout},onChange:this.handleChange})]}isSeparator(t){return!!t&&"object"==typeof t&&"separator"in t}get navigator(){return this.platform.get(o.Navigator)}get translator(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(o.Translate)}handleItemChange(t){this.change.emit(t),this.filter=void 0,this.navigator.navigate(t.path)}getItems(){return this.items.filter(this.isIncluded).filter(a(this.isEmptyGroup))}static get delegatesFocus(){return!0}get host(){return this}static get style(){return":host(limebb-browser){isolation:isolate;display:flex;flex-direction:column;background-color:rgba(var(--contrast-100))}limel-input-field{position:sticky;top:0;z-index:1;padding:0.5rem 0.75rem;background-color:rgba(var(--contrast-100), 0.75);backdrop-filter:blur(0.25rem);-webkit-backdrop-filter:blur(0.25rem)}"}},[17,"limebb-browser",{platform:[16],context:[16],items:[16],layout:[1],filter:[32]}]),h=l,c=function(){"undefined"!=typeof customElements&&["limebb-browser"].forEach((t=>{"limebb-browser"===t&&(customElements.get(r(t))||customElements.define(r(t),l))}))};export{h as LimebbBrowser,c as defineCustomElement}