import { NgClass, NgIf } from '@angular/common';
import { ChangeDetectionStrategy, Component, ViewChild, ViewEncapsulation } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormsModule, ReactiveFormsModule, UntypedFormControl } from '@angular/forms';
import { KbqBadgeModule } from '@koobiq/components/badge';
import { KbqButtonModule } from '@koobiq/components/button';
import { KbqHighlightModule, KbqPseudoCheckboxModule } from '@koobiq/components/core';
import { KbqDividerModule } from '@koobiq/components/divider';
import { KbqFormFieldModule } from '@koobiq/components/form-field';
import { KbqIcon } from '@koobiq/components/icon';
import { KbqInputModule } from '@koobiq/components/input';
import { KbqTitleModule } from '@koobiq/components/title';
import { FlatTreeControl, KbqTreeFlatDataSource, KbqTreeFlattener, KbqTreeModule, kbqTreeSelectAllValue, KbqTreeSelection } from '@koobiq/components/tree';
import { KbqTreeSelect, KbqTreeSelectModule } from '@koobiq/components/tree-select';
import { KbqTreeSelectFlatNode } from '../filter-bar.types';
import { getId, KbqBasePipe, KbqPipeMinWidth } from './base-pipe';
import { KbqPipeButton } from './pipe-button';
import { KbqPipeState } from './pipe-state';
import { KbqPipeTitleDirective } from './pipe-title';
import * as i0 from "@angular/core";
import * as i1 from "@koobiq/components/button";
import * as i2 from "@koobiq/components/form-field";
import * as i3 from "@koobiq/components/input";
import * as i4 from "@angular/forms";
import * as i5 from "@koobiq/components/core";
import * as i6 from "@koobiq/components/tree";
import * as i7 from "@koobiq/components/tree-select";
import * as i8 from "@koobiq/components/badge";
export class KbqPipeMultiTreeSelectComponent extends KbqBasePipe {
    /** selected value */
    get selected() {
        return this.data.value;
    }
    /** Whether the current pipe is empty. */
    get isEmpty() {
        return (super.isEmpty ||
            (Array.isArray(this.data.value) && !this.data.value.length) ||
            (this.selectedAllEqualsSelectedNothing && this.allOptionsSelected));
    }
    get selectAllCheckboxState() {
        if (!this.select)
            return 'unchecked';
        const arrayOfOptions = this.select.options.toArray().filter((option) => option.value !== kbqTreeSelectAllValue);
        if (arrayOfOptions.every((option) => option.selected)) {
            return 'checked';
        }
        else if (arrayOfOptions.every((option) => !option.selected)) {
            return 'unchecked';
        }
        return 'indeterminate';
    }
    get numberOfSelectedLeaves() {
        return this.select.selected.filter(({ value }) => value !== kbqTreeSelectAllValue).length;
    }
    /** true if all options selected */
    get allOptionsSelected() {
        const dataNodesLength = this.treeControl?.dataNodes?.length;
        const dataNodesForSelect = this.data.selectAll ? dataNodesLength - 1 : dataNodesLength;
        return this.select?.triggerValues?.length === dataNodesForSelect;
    }
    get selectedAllEqualsSelectedNothing() {
        return this.data.selectedAllEqualsSelectedNothing ?? this.filterBar.selectedAllEqualsSelectedNothing;
    }
    /** true if all visible options selected */
    get allVisibleOptionsSelected() {
        return this.tree.renderedOptions
            .filter((option) => option.value !== kbqTreeSelectAllValue)
            .every((option) => option.selected);
    }
    constructor() {
        super();
        /** control for search options */
        this.searchControl = new UntypedFormControl();
        /** updates values for selection and value template */
        this.updateTemplates = (templates) => {
            const template = templates?.find((template) => getId(template) === getId(this.data));
            if (template?.values) {
                this.values = template.values;
                this.valueTemplate = template.valueTemplate;
                const values = [...template.values];
                if (this.data.selectAll) {
                    values.unshift({
                        name: this.localeData.pipe.selectAll,
                        value: kbqTreeSelectAllValue,
                        children: null
                    });
                }
                this.dataSource.data = values;
            }
        };
        /** handler for select all options in select */
        this.selectAllHandler = (event) => {
            event.preventDefault();
            this.toggleSelectAllNode();
        };
        this.transformer = (node, level, parent) => {
            const flatNode = new KbqTreeSelectFlatNode();
            flatNode.name = node.name;
            flatNode.value = node.value;
            flatNode.parent = parent;
            flatNode.level = level;
            flatNode.expandable = !!node.children;
            return flatNode;
        };
        this.getLevel = (node) => {
            return node.level;
        };
        this.isExpandable = (node) => {
            return node.expandable;
        };
        this.getChildren = (node) => {
            return node.children;
        };
        this.getValue = (node) => {
            return node.value;
        };
        this.getViewValue = (node) => {
            return `${node.name}`;
        };
        this.treeFlattener = new KbqTreeFlattener(this.transformer, this.getLevel, this.isExpandable, this.getChildren);
        this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable, this.getValue, this.getViewValue);
        this.dataSource = new KbqTreeFlatDataSource(this.treeControl, this.treeFlattener);
        this.filterBar?.internalTemplatesChanges.pipe(takeUntilDestroyed()).subscribe(this.updateTemplates);
    }
    ngOnInit() {
        this.searchControl.valueChanges.subscribe((value) => this.treeControl.filterNodes(value));
    }
    ngAfterViewInit() {
        super.ngAfterViewInit();
        this.select.closedStream
            .pipe(takeUntilDestroyed(this.destroyRef))
            .subscribe(() => this.filterBar?.onClosePipe.next(this.data));
    }
    isNodeHasChild(_, nodeData) {
        return nodeData.expandable;
    }
    isNodeSelectAll(_, nodeData) {
        return nodeData.value === kbqTreeSelectAllValue;
    }
    onSelect({ value: option }) {
        if (!option)
            return;
        if (option.isExpandable) {
            this.tree.setStateChildren(option, !option.selected);
        }
        this.toggleParents(option.data.parent);
        this.data.value = this.select.selectedValues;
        this.emitChangePipeEvent();
        this.stateChanges.next();
    }
    searchKeydownHandler() {
        if (this.data.selectAll && this.tree.keyManager.activeItemIndex === 0) {
            this.toggleSelectAllNode();
        }
    }
    toggleSelectAllNode(emitEvent = true) {
        if (this.select.search?.ngControl.value) {
            const renderedOptions = this.tree.renderedOptions.filter(({ value }) => value !== kbqTreeSelectAllValue);
            if (this.allVisibleOptionsSelected) {
                renderedOptions.forEach((option) => option.setSelected(false));
            }
            else {
                renderedOptions.forEach((option) => option.setSelected(true));
            }
        }
        else {
            if (this.allOptionsSelected) {
                this.tree.selectionModel.clear();
            }
            else {
                const [, ...dataNodesForSelect] = this.treeControl.dataNodes;
                // @todo DS-3827
                this.tree.selectionModel.select(...dataNodesForSelect);
            }
        }
        this.data.value = [...this.select.selectedValues];
        if (emitEvent) {
            this.emitChangePipeEvent();
        }
        this.stateChanges.next();
    }
    /** opens select */
    open() {
        setTimeout(() => this.select.open());
    }
    onOpen() {
        this.treeControl.expandAll();
    }
    onClose() {
        if (this.selectedAllEqualsSelectedNothing && this.allOptionsSelected) {
            this.toggleSelectAllNode(false);
        }
    }
    emitChangePipeEvent() {
        if (this.selectedAllEqualsSelectedNothing && this.allOptionsSelected) {
            this.filterBar?.onChangePipe.emit({ ...this.data, value: [] });
        }
        else {
            this.filterBar?.onChangePipe.emit(this.data);
        }
    }
    toggleParents(parent) {
        if (!parent) {
            return;
        }
        const descendants = this.treeControl.getDescendants(parent);
        const isParentSelected = this.select.selectionModel.selected.includes(parent);
        if (!isParentSelected && descendants.every((d) => this.select.selectionModel.selected.includes(d))) {
            this.select.selectionModel.select(parent);
            this.toggleParents(parent.parent);
        }
        else if (isParentSelected) {
            this.select.selectionModel.deselect(parent);
            this.toggleParents(parent.parent);
        }
    }
    /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqPipeMultiTreeSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: KbqPipeMultiTreeSelectComponent, isStandalone: true, selector: "kbq-pipe-multi-tree-select", providers: [
            {
                provide: KbqBasePipe,
                useExisting: this
            }
        ], viewQueries: [{ propertyName: "select", first: true, predicate: KbqTreeSelect, descendants: true }, { propertyName: "tree", first: true, predicate: KbqTreeSelection, descendants: true }], usesInheritance: true, ngImport: i0, template: "<kbq-tree-select\n    #select\n    [autoSelect]=\"false\"\n    [disabled]=\"data.disabled\"\n    [kbqPipeTitle]=\"pipeTooltip\"\n    [multiple]=\"true\"\n    [ngClass]=\"{ 'kbq-active': select.panelOpen }\"\n    [ngModel]=\"selected\"\n    [panelClass]=\"'kbq-pipe-multi-tree-select__panel'\"\n    [selectAllHandler]=\"selectAllHandler\"\n    [tabIndex]=\"-1\"\n    (closed)=\"onClose()\"\n    (opened)=\"onOpen()\"\n    (selectionChange)=\"onSelect($event)\"\n>\n    <!-- eslint-disable-next-line @angular-eslint/template/prefer-control-flow -->\n    <kbq-form-field *ngIf=\"data.search\" kbqFormFieldWithoutBorders kbqSelectSearch>\n        <i kbq-icon=\"kbq-magnifying-glass_16\" kbqPrefix></i>\n        <input\n            autocomplete=\"off\"\n            kbqInput\n            type=\"text\"\n            placeholder=\"{{ localeData.search.placeholder }}\"\n            [formControl]=\"searchControl\"\n            (keydown.enter)=\"searchKeydownHandler()\"\n        />\n        <kbq-cleaner />\n    </kbq-form-field>\n\n    <div kbq-select-search-empty-result>{{ localeData.pipe.emptySearchResult }}</div>\n\n    <kbq-cleaner #kbqSelectCleaner />\n\n    <button\n        kbq-button\n        kbq-select-matcher\n        [disabled]=\"data.disabled\"\n        [kbqPipeState]=\"data\"\n        [ngClass]=\"{ 'kbq-active': select.panelOpen }\"\n    >\n        <span #kbqTitleText kbqPipeMinWidth class=\"kbq-pipe__name\">{{ data.name }}</span>\n\n        @if (select.selected?.length === 1) {\n            <span #kbqTitleText class=\"kbq-pipe__value\" [class.kbq-pipe__value_empty]=\"!select.triggerValue\">\n                {{ select.selected[0].name }}\n            </span>\n        } @else if (\n            select.selected?.length > 1 &&\n            (!selectedAllEqualsSelectedNothing || (selectedAllEqualsSelectedNothing && !allOptionsSelected))\n        ) {\n            <kbq-badge [badgeColor]=\"'contrast'\" [compact]=\"true\">\n                {{ numberOfSelectedLeaves }}\n            </kbq-badge>\n        }\n    </button>\n\n    <kbq-tree-selection [dataSource]=\"dataSource\" [treeControl]=\"treeControl\">\n        <kbq-tree-option\n            *kbqTreeNodeDef=\"let node; when: isNodeSelectAll\"\n            kbqTreeNodePadding\n            [class.kbq-selected]=\"allOptionsSelected\"\n            [selectable]=\"false\"\n            (click)=\"toggleSelectAllNode()\"\n        >\n            <kbq-pseudo-checkbox [state]=\"selectAllCheckboxState\" />\n            <span [innerHTML]=\"treeControl.getViewValue(node) | mcHighlight: treeControl.filterValue.value\"></span>\n        </kbq-tree-option>\n\n        <kbq-tree-option *kbqTreeNodeDef=\"let node\" kbqTreeNodePadding [checkboxThirdState]=\"true\">\n            <span [innerHTML]=\"treeControl.getViewValue(node) | mcHighlight: treeControl.filterValue.value\"></span>\n        </kbq-tree-option>\n\n        <kbq-tree-option\n            *kbqTreeNodeDef=\"let node; when: isNodeHasChild\"\n            kbqTreeNodePadding\n            [checkboxThirdState]=\"true\"\n        >\n            <kbq-tree-node-toggle [node]=\"node\" />\n            <span [innerHTML]=\"treeControl.getViewValue(node) | mcHighlight: treeControl.filterValue.value\"></span>\n        </kbq-tree-option>\n    </kbq-tree-selection>\n</kbq-tree-select>\n\n@if (showRemoveButton) {\n    <kbq-pipe-button />\n}\n\n<ng-template #pipeTooltip>\n    <div class=\"kbq-pipe-tooltip__name kbq-text-compact\">{{ data.name }}</div>\n    <div class=\"kbq-pipe-tooltip__value kbq-text-compact\">{{ select.triggerValue }}</div>\n</ng-template>\n", styles: ["@keyframes kbq-progress{0%{background-position:0 0}to{background-position:64px 0}}.kbq-progress{position:relative}.kbq-progress:after{content:\"\";position:absolute;border-radius:inherit;inset:0;background:linear-gradient(135deg,#0000000a 12px,#ffffff1a 12px 22px,#0000000a 22px 34px,#ffffff1a 34px) repeat;background-size:32px 32px;animation:kbq-progress 1s linear infinite}.kbq-group{display:flex;flex-direction:row}.kbq-group .kbq-group_justified>.kbq-group-item{width:100%}.kbq-group .kbq-group-item+.kbq-group-item{margin-left:calc(-1 * var(--kbq-size-border-width))}.kbq-group>.kbq-group-item:first-child:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.kbq-group>.kbq-group-item:first-child:not(:last-child)>.kbq-form-field__container{border-bottom-right-radius:0;border-top-right-radius:0}.kbq-group>.kbq-group-item:last-child:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.kbq-group>.kbq-group-item:last-child:not(:first-child)>.kbq-form-field__container{border-bottom-left-radius:0;border-top-left-radius:0}.kbq-group>.kbq-group-item:not(:first-child):not(:last-child){border-radius:0}.kbq-group>.kbq-group-item:not(:first-child):not(:last-child)>.kbq-form-field__container{border-radius:0}.kbq-vertical-group{display:flex;flex-direction:column}.kbq-vertical-group>.kbq-group-item:first-child:not(:last-child){border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-right-radius:var(--kbq-size-border-radius)}.kbq-vertical-group>.kbq-group-item:first-child:not(:last-child)>.kbq-form-field__container{border-bottom-right-radius:0;border-bottom-left-radius:0}.kbq-vertical-group>.kbq-group-item:last-child:not(:first-child){border-top-right-radius:0;border-top-left-radius:0;border-bottom-left-radius:var(--kbq-size-border-radius)}.kbq-vertical-group>.kbq-group-item:last-child:not(:first-child)>.kbq-form-field__container{border-top-right-radius:0;border-top-left-radius:0}.kbq-vertical-group>.kbq-group-item:not(:first-child):not(:last-child){border-radius:0}.kbq-vertical-group>.kbq-group-item:not(:first-child):not(:last-child)>.kbq-form-field__container{border-radius:0}.kbq-vertical-group .kbq-group-item+.kbq-group-item{margin-top:calc(-1 * var(--kbq-size-border-width))}.kbq-truncate-line{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.kbq-no-select{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.kbq-pipe{display:flex;flex-direction:row;max-height:32px}.kbq-pipe .kbq-select .kbq-select__trigger{height:unset}.kbq-pipe .kbq-button-wrapper{max-width:320px}.kbq-pipe .kbq-pipe__name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1 1 auto;color:var(--kbq-foreground-contrast-secondary)}.kbq-pipe .kbq-pipe__value{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1 1 auto}.kbq-pipe .kbq-pipe__value:not(.kbq-pipe__value_empty){margin-left:4px}.kbq-pipe .kbq-pipe__separator{z-index:1;margin-left:-1px;margin-right:0;height:var(--kbq-size-l);align-self:center;color:var(--kbq-line-contrast-less)}.kbq-pipe .kbq-select:not(:hover,.kbq-active)+.kbq-pipe-button:not(:hover,.kbq-active):after,.kbq-pipe .kbq-tree-select:not(:hover,.kbq-active)+.kbq-pipe-button:not(:hover,.kbq-active):after,.kbq-pipe .kbq-button:not(:hover,.kbq-active,[disabled])+.kbq-pipe-button:not(:hover,.kbq-active):after{content:\"\";position:absolute;left:0;top:var(--kbq-size-s);width:1px;height:var(--kbq-size-l);background:var(--kbq-line-contrast-less)}.kbq-pipe .kbq-button.cdk-keyboard-focused{z-index:1}.kbq-pipe.kbq-pipe_disabled .kbq-pipe__name,.kbq-pipe.kbq-pipe_disabled .kbq-pipe__value{color:var(--kbq-states-foreground-disabled)}.kbq-pipe.kbq-pipe_removable .kbq-button,.kbq-pipe.kbq-pipe_cleanable:not(.kbq-pipe_empty) .kbq-button{border-bottom-right-radius:unset;border-top-right-radius:unset;border-right:none}.kbq-pipe.kbq-pipe_removable .kbq-button.cdk-keyboard-focused:after,.kbq-pipe.kbq-pipe_cleanable:not(.kbq-pipe_empty) .kbq-button.cdk-keyboard-focused:after{content:\"\";position:absolute;right:0;top:0;bottom:0;width:1px;background:var(--kbq-states-line-focus-theme)}.kbq-pipe.kbq-pipe_removable .kbq-button-icon,.kbq-pipe.kbq-pipe_cleanable:not(.kbq-pipe_empty) .kbq-button-icon{border-bottom-left-radius:unset;border-top-left-radius:unset;border-left:none}.kbq-pipe.kbq-pipe_removable .kbq-button-icon.cdk-keyboard-focused:after,.kbq-pipe.kbq-pipe_cleanable:not(.kbq-pipe_empty) .kbq-button-icon.cdk-keyboard-focused:after{content:\"\";position:absolute;left:0;top:0;bottom:0;width:1px;background:var(--kbq-states-line-focus-theme)}.kbq-pipe-tooltip__name{color:var(--kbq-foreground-white-secondary)}.kbq-pipe-tooltip__value{color:var(--kbq-foreground-white)}\n", ".kbq-pipe__multi-tree-select .kbq-pipe__value{margin-left:var(--kbq-size-xxs)}.kbq-pipe__multi-tree-select .kbq-badge{align-self:center;margin-left:var(--kbq-size-xs)}.kbq-pipe__multi-tree-select .kbq-tree-select .kbq-select__trigger{height:unset}.kbq-pipe-multi-tree-select__panel .kbq-select__content{max-height:404px}\n"], dependencies: [{ kind: "ngmodule", type: KbqButtonModule }, { kind: "component", type: i1.KbqButton, selector: "[kbq-button]", inputs: ["kbqStyle", "disabled", "tabIndex"] }, { kind: "directive", type: i1.KbqButtonCssStyler, selector: "[kbq-button]" }, { kind: "ngmodule", type: KbqDividerModule }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: KbqPipeState, selector: "[kbqPipeState]", inputs: ["kbqPipeState"] }, { kind: "component", type: KbqPipeButton, selector: "kbq-pipe-button", inputs: ["readonly"] }, { kind: "ngmodule", type: KbqTitleModule }, { kind: "directive", type: KbqPipeTitleDirective, selector: "[kbqPipeTitle]", inputs: ["kbqPipeTitle"], exportAs: ["kbqPipeTitle"] }, { kind: "directive", type: KbqPipeMinWidth, selector: "[kbqPipeMinWidth]" }, { kind: "ngmodule", type: KbqFormFieldModule }, { kind: "component", type: i2.KbqCleaner, selector: "kbq-cleaner", exportAs: ["kbqCleaner"] }, { kind: "component", type: i2.KbqFormField, selector: "kbq-form-field", inputs: ["noBorders"], exportAs: ["kbqFormField"] }, { kind: "directive", type: i2.KbqPrefix, selector: "[kbqPrefix]", exportAs: ["kbqPrefix"] }, { kind: "directive", type: i2.KbqFormFieldWithoutBorders, selector: "kbq-form-field[kbqFormFieldWithoutBorders]", exportAs: ["kbqFormFieldWithoutBorders"] }, { kind: "directive", type: i2.KbqValidateDirective, selector: "        input[kbqInput],        input[kbqNumberInput],        input[kbqInputPassword],        input[kbqTimepicker],        input[kbqDatepicker],        textarea[kbqTextarea],        kbq-select,        kbq-tree-select,        kbq-tag-list    ", exportAs: ["KbqValidate"] }, { kind: "directive", type: i2.KbqTrim, selector: "[kbqInput], [kbqTextarea]", exportAs: ["KbqTrim"] }, { kind: "component", type: KbqIcon, selector: "[kbq-icon]", inputs: ["small", "autoColor", "kbq-icon"] }, { kind: "ngmodule", type: KbqInputModule }, { kind: "directive", type: i3.KbqInput, selector: "input[kbqInput],input[kbqNumberInput]", inputs: ["errorStateMatcher", "placeholder", "disabled", "id", "required", "type", "value"], exportAs: ["kbqInput"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: KbqHighlightModule }, { kind: "pipe", type: i5.KbqHighlightPipe, name: "mcHighlight" }, { kind: "ngmodule", type: KbqTreeModule }, { kind: "directive", type: i6.KbqTreeNodeDef, selector: "[kbqTreeNodeDef]", inputs: ["kbqTreeNodeDefWhen", "kbqTreeNode"] }, { kind: "directive", type: i6.KbqTreeNodePadding, selector: "[kbqTreeNodePadding]", inputs: ["kbqTreeNodePaddingIndent"], exportAs: ["kbqTreeNodePadding"] }, { kind: "component", type: i6.KbqTreeSelection, selector: "kbq-tree-selection", inputs: ["treeControl", "autoSelect", "noUnselectLast", "disabled", "tabIndex"], outputs: ["navigationChange", "selectionChange", "onSelectAll", "onCopy"], exportAs: ["kbqTreeSelection"] }, { kind: "component", type: i6.KbqTreeOption, selector: "kbq-tree-option", inputs: ["checkboxThirdState", "disabled", "selectable", "showCheckbox"], outputs: ["onSelectionChange"], exportAs: ["kbqTreeOption"] }, { kind: "component", type: i6.KbqTreeNodeToggleComponent, selector: "kbq-tree-node-toggle", exportAs: ["kbqTreeNodeToggle"] }, { kind: "ngmodule", type: KbqTreeSelectModule }, { kind: "component", type: i7.KbqTreeSelect, selector: "kbq-tree-select", inputs: ["hiddenItemsText", "panelClass", "backdropClass", "errorStateMatcher", "sortComparator", "multiline", "placeholder", "required", "multiple", "autoSelect", "id", "hasBackdrop", "tabIndex", "disabled", "selectAllHandler", "panelMinWidth", "panelWidth", "searchMinOptionsThreshold", "hiddenItemsTextFormatter"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["kbqTreeSelect"] }, { kind: "directive", type: i5.KbqSelectSearch, selector: "[kbqSelectSearch]", exportAs: ["kbqSelectSearch"] }, { kind: "directive", type: i5.KbqSelectMatcher, selector: "kbq-select-matcher, [kbq-select-matcher]", inputs: ["useDefaultHandlers"] }, { kind: "directive", type: i5.KbqSelectSearchEmptyResult, selector: "[kbq-select-search-empty-result]", exportAs: ["kbqSelectSearchEmptyResult"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: KbqBadgeModule }, { kind: "component", type: i8.KbqBadge, selector: "kbq-badge", inputs: ["compact", "outline", "badgeColor"] }, { kind: "directive", type: i8.KbqBadgeCssStyler, selector: "kbq-badge" }, { kind: "ngmodule", type: KbqPseudoCheckboxModule }, { kind: "component", type: i5.KbqPseudoCheckbox, selector: "kbq-pseudo-checkbox", inputs: ["big", "state", "disabled"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqPipeMultiTreeSelectComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, selector: 'kbq-pipe-multi-tree-select', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [
                        {
                            provide: KbqBasePipe,
                            useExisting: this
                        }
                    ], imports: [
                        KbqButtonModule,
                        KbqDividerModule,
                        NgClass,
                        KbqPipeState,
                        KbqPipeButton,
                        KbqTitleModule,
                        KbqPipeTitleDirective,
                        KbqPipeMinWidth,
                        KbqFormFieldModule,
                        KbqIcon,
                        KbqInputModule,
                        ReactiveFormsModule,
                        KbqHighlightModule,
                        KbqTreeModule,
                        KbqTreeSelectModule,
                        NgIf,
                        FormsModule,
                        KbqBadgeModule,
                        KbqPseudoCheckboxModule
                    ], template: "<kbq-tree-select\n    #select\n    [autoSelect]=\"false\"\n    [disabled]=\"data.disabled\"\n    [kbqPipeTitle]=\"pipeTooltip\"\n    [multiple]=\"true\"\n    [ngClass]=\"{ 'kbq-active': select.panelOpen }\"\n    [ngModel]=\"selected\"\n    [panelClass]=\"'kbq-pipe-multi-tree-select__panel'\"\n    [selectAllHandler]=\"selectAllHandler\"\n    [tabIndex]=\"-1\"\n    (closed)=\"onClose()\"\n    (opened)=\"onOpen()\"\n    (selectionChange)=\"onSelect($event)\"\n>\n    <!-- eslint-disable-next-line @angular-eslint/template/prefer-control-flow -->\n    <kbq-form-field *ngIf=\"data.search\" kbqFormFieldWithoutBorders kbqSelectSearch>\n        <i kbq-icon=\"kbq-magnifying-glass_16\" kbqPrefix></i>\n        <input\n            autocomplete=\"off\"\n            kbqInput\n            type=\"text\"\n            placeholder=\"{{ localeData.search.placeholder }}\"\n            [formControl]=\"searchControl\"\n            (keydown.enter)=\"searchKeydownHandler()\"\n        />\n        <kbq-cleaner />\n    </kbq-form-field>\n\n    <div kbq-select-search-empty-result>{{ localeData.pipe.emptySearchResult }}</div>\n\n    <kbq-cleaner #kbqSelectCleaner />\n\n    <button\n        kbq-button\n        kbq-select-matcher\n        [disabled]=\"data.disabled\"\n        [kbqPipeState]=\"data\"\n        [ngClass]=\"{ 'kbq-active': select.panelOpen }\"\n    >\n        <span #kbqTitleText kbqPipeMinWidth class=\"kbq-pipe__name\">{{ data.name }}</span>\n\n        @if (select.selected?.length === 1) {\n            <span #kbqTitleText class=\"kbq-pipe__value\" [class.kbq-pipe__value_empty]=\"!select.triggerValue\">\n                {{ select.selected[0].name }}\n            </span>\n        } @else if (\n            select.selected?.length > 1 &&\n            (!selectedAllEqualsSelectedNothing || (selectedAllEqualsSelectedNothing && !allOptionsSelected))\n        ) {\n            <kbq-badge [badgeColor]=\"'contrast'\" [compact]=\"true\">\n                {{ numberOfSelectedLeaves }}\n            </kbq-badge>\n        }\n    </button>\n\n    <kbq-tree-selection [dataSource]=\"dataSource\" [treeControl]=\"treeControl\">\n        <kbq-tree-option\n            *kbqTreeNodeDef=\"let node; when: isNodeSelectAll\"\n            kbqTreeNodePadding\n            [class.kbq-selected]=\"allOptionsSelected\"\n            [selectable]=\"false\"\n            (click)=\"toggleSelectAllNode()\"\n        >\n            <kbq-pseudo-checkbox [state]=\"selectAllCheckboxState\" />\n            <span [innerHTML]=\"treeControl.getViewValue(node) | mcHighlight: treeControl.filterValue.value\"></span>\n        </kbq-tree-option>\n\n        <kbq-tree-option *kbqTreeNodeDef=\"let node\" kbqTreeNodePadding [checkboxThirdState]=\"true\">\n            <span [innerHTML]=\"treeControl.getViewValue(node) | mcHighlight: treeControl.filterValue.value\"></span>\n        </kbq-tree-option>\n\n        <kbq-tree-option\n            *kbqTreeNodeDef=\"let node; when: isNodeHasChild\"\n            kbqTreeNodePadding\n            [checkboxThirdState]=\"true\"\n        >\n            <kbq-tree-node-toggle [node]=\"node\" />\n            <span [innerHTML]=\"treeControl.getViewValue(node) | mcHighlight: treeControl.filterValue.value\"></span>\n        </kbq-tree-option>\n    </kbq-tree-selection>\n</kbq-tree-select>\n\n@if (showRemoveButton) {\n    <kbq-pipe-button />\n}\n\n<ng-template #pipeTooltip>\n    <div class=\"kbq-pipe-tooltip__name kbq-text-compact\">{{ data.name }}</div>\n    <div class=\"kbq-pipe-tooltip__value kbq-text-compact\">{{ select.triggerValue }}</div>\n</ng-template>\n", styles: ["@keyframes kbq-progress{0%{background-position:0 0}to{background-position:64px 0}}.kbq-progress{position:relative}.kbq-progress:after{content:\"\";position:absolute;border-radius:inherit;inset:0;background:linear-gradient(135deg,#0000000a 12px,#ffffff1a 12px 22px,#0000000a 22px 34px,#ffffff1a 34px) repeat;background-size:32px 32px;animation:kbq-progress 1s linear infinite}.kbq-group{display:flex;flex-direction:row}.kbq-group .kbq-group_justified>.kbq-group-item{width:100%}.kbq-group .kbq-group-item+.kbq-group-item{margin-left:calc(-1 * var(--kbq-size-border-width))}.kbq-group>.kbq-group-item:first-child:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.kbq-group>.kbq-group-item:first-child:not(:last-child)>.kbq-form-field__container{border-bottom-right-radius:0;border-top-right-radius:0}.kbq-group>.kbq-group-item:last-child:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.kbq-group>.kbq-group-item:last-child:not(:first-child)>.kbq-form-field__container{border-bottom-left-radius:0;border-top-left-radius:0}.kbq-group>.kbq-group-item:not(:first-child):not(:last-child){border-radius:0}.kbq-group>.kbq-group-item:not(:first-child):not(:last-child)>.kbq-form-field__container{border-radius:0}.kbq-vertical-group{display:flex;flex-direction:column}.kbq-vertical-group>.kbq-group-item:first-child:not(:last-child){border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-right-radius:var(--kbq-size-border-radius)}.kbq-vertical-group>.kbq-group-item:first-child:not(:last-child)>.kbq-form-field__container{border-bottom-right-radius:0;border-bottom-left-radius:0}.kbq-vertical-group>.kbq-group-item:last-child:not(:first-child){border-top-right-radius:0;border-top-left-radius:0;border-bottom-left-radius:var(--kbq-size-border-radius)}.kbq-vertical-group>.kbq-group-item:last-child:not(:first-child)>.kbq-form-field__container{border-top-right-radius:0;border-top-left-radius:0}.kbq-vertical-group>.kbq-group-item:not(:first-child):not(:last-child){border-radius:0}.kbq-vertical-group>.kbq-group-item:not(:first-child):not(:last-child)>.kbq-form-field__container{border-radius:0}.kbq-vertical-group .kbq-group-item+.kbq-group-item{margin-top:calc(-1 * var(--kbq-size-border-width))}.kbq-truncate-line{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.kbq-no-select{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.kbq-pipe{display:flex;flex-direction:row;max-height:32px}.kbq-pipe .kbq-select .kbq-select__trigger{height:unset}.kbq-pipe .kbq-button-wrapper{max-width:320px}.kbq-pipe .kbq-pipe__name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1 1 auto;color:var(--kbq-foreground-contrast-secondary)}.kbq-pipe .kbq-pipe__value{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1 1 auto}.kbq-pipe .kbq-pipe__value:not(.kbq-pipe__value_empty){margin-left:4px}.kbq-pipe .kbq-pipe__separator{z-index:1;margin-left:-1px;margin-right:0;height:var(--kbq-size-l);align-self:center;color:var(--kbq-line-contrast-less)}.kbq-pipe .kbq-select:not(:hover,.kbq-active)+.kbq-pipe-button:not(:hover,.kbq-active):after,.kbq-pipe .kbq-tree-select:not(:hover,.kbq-active)+.kbq-pipe-button:not(:hover,.kbq-active):after,.kbq-pipe .kbq-button:not(:hover,.kbq-active,[disabled])+.kbq-pipe-button:not(:hover,.kbq-active):after{content:\"\";position:absolute;left:0;top:var(--kbq-size-s);width:1px;height:var(--kbq-size-l);background:var(--kbq-line-contrast-less)}.kbq-pipe .kbq-button.cdk-keyboard-focused{z-index:1}.kbq-pipe.kbq-pipe_disabled .kbq-pipe__name,.kbq-pipe.kbq-pipe_disabled .kbq-pipe__value{color:var(--kbq-states-foreground-disabled)}.kbq-pipe.kbq-pipe_removable .kbq-button,.kbq-pipe.kbq-pipe_cleanable:not(.kbq-pipe_empty) .kbq-button{border-bottom-right-radius:unset;border-top-right-radius:unset;border-right:none}.kbq-pipe.kbq-pipe_removable .kbq-button.cdk-keyboard-focused:after,.kbq-pipe.kbq-pipe_cleanable:not(.kbq-pipe_empty) .kbq-button.cdk-keyboard-focused:after{content:\"\";position:absolute;right:0;top:0;bottom:0;width:1px;background:var(--kbq-states-line-focus-theme)}.kbq-pipe.kbq-pipe_removable .kbq-button-icon,.kbq-pipe.kbq-pipe_cleanable:not(.kbq-pipe_empty) .kbq-button-icon{border-bottom-left-radius:unset;border-top-left-radius:unset;border-left:none}.kbq-pipe.kbq-pipe_removable .kbq-button-icon.cdk-keyboard-focused:after,.kbq-pipe.kbq-pipe_cleanable:not(.kbq-pipe_empty) .kbq-button-icon.cdk-keyboard-focused:after{content:\"\";position:absolute;left:0;top:0;bottom:0;width:1px;background:var(--kbq-states-line-focus-theme)}.kbq-pipe-tooltip__name{color:var(--kbq-foreground-white-secondary)}.kbq-pipe-tooltip__value{color:var(--kbq-foreground-white)}\n", ".kbq-pipe__multi-tree-select .kbq-pipe__value{margin-left:var(--kbq-size-xxs)}.kbq-pipe__multi-tree-select .kbq-badge{align-self:center;margin-left:var(--kbq-size-xs)}.kbq-pipe__multi-tree-select .kbq-tree-select .kbq-select__trigger{height:unset}.kbq-pipe-multi-tree-select__panel .kbq-select__content{max-height:404px}\n"] }]
        }], ctorParameters: () => [], propDecorators: { select: [{
                type: ViewChild,
                args: [KbqTreeSelect]
            }], tree: [{
                type: ViewChild,
                args: [KbqTreeSelection]
            }] } });
//# sourceMappingURL=data:application/json;base64, 