/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */
import{LitElement as d,html as m}from"lit";import{property as u,customElement as b}from"lit/decorators.js";import{lll as n}from"@typo3/core/lit-helper.js";import h from"@typo3/core/event/debounce-event.js";import"@typo3/backend/element/icon-element.js";import{Tree as f}from"@typo3/backend/tree/tree.js";var p=function(l,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(l,e,t,r);else for(var c=l.length-1;c>=0;c--)(i=l[c])&&(o=(s<3?i(o):s>3?i(e,t,o):i(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o};let a=class extends d{constructor(){super(...arguments),this.tree=null,this.settings={searchInput:".search-input",filterTimeout:450}}createRenderRoot(){return this}firstUpdated(){const e=this.querySelector(this.settings.searchInput);e&&new h("input",t=>{const r=t.target;this.tree.filter(r.value.trim())},this.settings.filterTimeout).bindTo(e)}render(){return m`<div class=tree-toolbar><div class=tree-toolbar__menu><div class=tree-toolbar__search><label for=toolbarSearch class=visually-hidden>${n("labels.label.searchString")}</label> <input type=search id=toolbarSearch class="form-control form-control-sm search-input" placeholder=${n("tree.searchTermInfo")}></div></div><div class=tree-toolbar__submenu><button type=button class="tree-toolbar__menuitem dropdown-toggle dropdown-toggle-no-chevron float-end" data-bs-toggle=dropdown aria-expanded=false aria-label=${n("labels.openTreeOptionsMenu")}><typo3-backend-icon identifier=actions-menu-alternative size=small></typo3-backend-icon></button><ul class="dropdown-menu dropdown-menu-end"><li><button class=dropdown-item @click=${()=>this.refreshTree()}><span class=dropdown-item-columns> <span class="dropdown-item-column dropdown-item-column-icon" aria-hidden=true><typo3-backend-icon identifier=actions-refresh size=small></typo3-backend-icon> </span> <span class="dropdown-item-column dropdown-item-column-title">${n("labels.refresh")} </span> </span></button></li><li><button class=dropdown-item @click=${e=>this.collapseAll(e)}><span class=dropdown-item-columns> <span class="dropdown-item-column dropdown-item-column-icon" aria-hidden=true><typo3-backend-icon identifier=apps-pagetree-category-collapse-all size=small></typo3-backend-icon> </span> <span class="dropdown-item-column dropdown-item-column-title">${n("labels.collapse")} </span> </span></button></li></ul></div></div>`}refreshTree(){this.tree.refreshOrFilterTree()}collapseAll(e){e.preventDefault(),this.tree.nodes.forEach(t=>{t.__parents.length&&this.tree.hideChildren(t)})}};p([u({type:f})],a.prototype,"tree",void 0),a=p([b("typo3-backend-tree-toolbar")],a);export{a as TreeToolbar};
