import { __decorate, __extends, __metadata, __read, __spread } from "tslib";
/**
 * @license
 * Copyright Alibaba.com All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
 */
import { BACKSPACE } from '@angular/cdk/keycodes';
import { CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
import { ChangeDetectorRef, Component, ContentChild, ElementRef, EventEmitter, forwardRef, Host, Injector, Input, Optional, Output, Renderer2, Self, TemplateRef, ViewChild } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { merge, of as observableOf } from 'rxjs';
import { filter, tap } from 'rxjs/operators';
import { InputBoolean, isNotNil, NzConfigService, NzNoAnimationDirective, NzTreeBase, NzTreeHigherOrderServiceToken, slideMotion, WithConfig, zoomMotion } from 'ng-zorro-antd/core';
import { NzSelectSearchComponent } from 'ng-zorro-antd/select';
import { NzTreeComponent } from 'ng-zorro-antd/tree';
import { NzTreeSelectService } from './tree-select.service';
import * as i0 from "@angular/core";
import * as i1 from "./tree-select.service";
import * as i2 from "ng-zorro-antd/core";
import * as i3 from "@angular/cdk/overlay";
import * as i4 from "@angular/common";
import * as i5 from "ng-zorro-antd/tree";
import * as i6 from "ng-zorro-antd/empty";
import * as i7 from "ng-zorro-antd/select";
var _c0 = ["nzTreeTemplate"];
var _c1 = ["treeRef"];
function NzTreeSelectComponent_ng_template_0_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 11);
    i0.ɵɵelement(1, "nz-embed-empty", 12);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2784 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzComponentName", "tree-select")("specificContent", ctx_r2784.nzNotFoundContent);
} }
var _c2 = function () { return []; };
function NzTreeSelectComponent_ng_template_0_Template(rf, ctx) { if (rf & 1) {
    var _r2786 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 7);
    i0.ɵɵelementStart(1, "nz-tree", 8, 9);
    i0.ɵɵlistener("nzExpandChange", function NzTreeSelectComponent_ng_template_0_Template_nz_tree_nzExpandChange_1_listener($event) { i0.ɵɵrestoreView(_r2786); var ctx_r2785 = i0.ɵɵnextContext(); return ctx_r2785.onExpandedKeysChange($event); })("nzClick", function NzTreeSelectComponent_ng_template_0_Template_nz_tree_nzClick_1_listener($event) { i0.ɵɵrestoreView(_r2786); var ctx_r2787 = i0.ɵɵnextContext(); return ctx_r2787.nzTreeClick.emit($event); })("nzCheckedKeysChange", function NzTreeSelectComponent_ng_template_0_Template_nz_tree_nzCheckedKeysChange_1_listener() { i0.ɵɵrestoreView(_r2786); var ctx_r2788 = i0.ɵɵnextContext(); return ctx_r2788.updateSelectedNodes(); })("nzSelectedKeysChange", function NzTreeSelectComponent_ng_template_0_Template_nz_tree_nzSelectedKeysChange_1_listener() { i0.ɵɵrestoreView(_r2786); var ctx_r2789 = i0.ɵɵnextContext(); return ctx_r2789.updateSelectedNodes(); })("nzCheckBoxChange", function NzTreeSelectComponent_ng_template_0_Template_nz_tree_nzCheckBoxChange_1_listener($event) { i0.ɵɵrestoreView(_r2786); var ctx_r2790 = i0.ɵɵnextContext(); return ctx_r2790.nzTreeCheckBoxChange.emit($event); })("nzSearchValueChange", function NzTreeSelectComponent_ng_template_0_Template_nz_tree_nzSearchValueChange_1_listener($event) { i0.ɵɵrestoreView(_r2786); var ctx_r2791 = i0.ɵɵnextContext(); return ctx_r2791.setSearchValues($event); });
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, NzTreeSelectComponent_ng_template_0_span_3_Template, 2, 2, "span", 10);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2776 = i0.ɵɵnextContext();
    i0.ɵɵclassMap(ctx_r2776.dropdownClassName);
    i0.ɵɵclassProp("ant-select-dropdown-placement-bottomLeft", ctx_r2776.dropDownPosition === "bottom")("ant-select-dropdown-placement-topLeft", ctx_r2776.dropDownPosition === "top");
    i0.ɵɵproperty("@slideMotion", ctx_r2776.nzOpen ? ctx_r2776.dropDownPosition : "void")("@.disabled", ctx_r2776.noAnimation == null ? null : ctx_r2776.noAnimation.nzNoAnimation)("nzNoAnimation", ctx_r2776.noAnimation == null ? null : ctx_r2776.noAnimation.nzNoAnimation)("ngStyle", ctx_r2776.nzDropdownStyle);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("hidden", ctx_r2776.isNotFound)("nzData", ctx_r2776.nzNodes)("nzMultiple", ctx_r2776.nzMultiple)("nzSearchValue", ctx_r2776.inputValue)("nzHideUnMatched", ctx_r2776.nzHideUnMatched)("nzShowIcon", ctx_r2776.nzShowIcon)("nzCheckable", ctx_r2776.nzCheckable)("nzAsyncData", ctx_r2776.nzAsyncData)("nzShowExpand", ctx_r2776.nzShowExpand)("nzShowLine", ctx_r2776.nzShowLine)("nzExpandedIcon", ctx_r2776.nzExpandedIcon)("nzExpandAll", ctx_r2776.nzDefaultExpandAll)("nzExpandedKeys", ctx_r2776.expandedKeys)("nzCheckedKeys", ctx_r2776.nzCheckable ? ctx_r2776.value : i0.ɵɵpureFunction0(28, _c2))("nzSelectedKeys", !ctx_r2776.nzCheckable ? ctx_r2776.value : i0.ɵɵpureFunction0(29, _c2))("nzTreeTemplate", ctx_r2776.treeTemplate)("nzCheckStrictly", ctx_r2776.nzCheckStrictly);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r2776.nzNodes.length === 0 || ctx_r2776.isNotFound);
} }
function NzTreeSelectComponent_ng_container_2_nz_select_item_1_Template(rf, ctx) { if (rf & 1) {
    var _r2796 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "nz-select-item", 15);
    i0.ɵɵlistener("@zoomMotion.done", function NzTreeSelectComponent_ng_container_2_nz_select_item_1_Template_nz_select_item_animation_zoomMotion_done_0_listener() { i0.ɵɵrestoreView(_r2796); var ctx_r2795 = i0.ɵɵnextContext(2); return ctx_r2795.updatePosition(); })("delete", function NzTreeSelectComponent_ng_container_2_nz_select_item_1_Template_nz_select_item_delete_0_listener() { i0.ɵɵrestoreView(_r2796); var node_r2794 = ctx.$implicit; var ctx_r2797 = i0.ɵɵnextContext(2); return ctx_r2797.removeSelected(node_r2794, true); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var node_r2794 = ctx.$implicit;
    var ctx_r2792 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("@zoomMotion", undefined)("@.disabled", ctx_r2792.noAnimation == null ? null : ctx_r2792.noAnimation.nzNoAnimation)("nzNoAnimation", ctx_r2792.noAnimation == null ? null : ctx_r2792.noAnimation.nzNoAnimation)("deletable", true)("disabled", node_r2794.isDisabled || ctx_r2792.nzDisabled)("label", ctx_r2792.nzDisplayWith(node_r2794));
} }
function NzTreeSelectComponent_ng_container_2_nz_select_item_3_Template(rf, ctx) { if (rf & 1) {
    var _r2799 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "nz-select-item", 16);
    i0.ɵɵlistener("@zoomMotion.done", function NzTreeSelectComponent_ng_container_2_nz_select_item_3_Template_nz_select_item_animation_zoomMotion_done_0_listener() { i0.ɵɵrestoreView(_r2799); var ctx_r2798 = i0.ɵɵnextContext(2); return ctx_r2798.updatePosition(); });
    i0.ɵɵpipe(1, "slice");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2793 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("@zoomMotion", undefined)("@.disabled", ctx_r2793.noAnimation == null ? null : ctx_r2793.noAnimation.nzNoAnimation)("nzNoAnimation", ctx_r2793.noAnimation == null ? null : ctx_r2793.noAnimation.nzNoAnimation)("contentTemplateOutlet", ctx_r2793.nzMaxTagPlaceholder)("contentTemplateOutletContext", i0.ɵɵpipeBind2(1, 8, ctx_r2793.selectedNodes, ctx_r2793.nzMaxTagCount))("deletable", false)("disabled", false)("label", "+ " + (ctx_r2793.selectedNodes.length - ctx_r2793.nzMaxTagCount) + " ...");
} }
function NzTreeSelectComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, NzTreeSelectComponent_ng_container_2_nz_select_item_1_Template, 1, 6, "nz-select-item", 13);
    i0.ɵɵpipe(2, "slice");
    i0.ɵɵtemplate(3, NzTreeSelectComponent_ng_container_2_nz_select_item_3_Template, 2, 11, "nz-select-item", 14);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r2777 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind3(2, 3, ctx_r2777.selectedNodes, 0, ctx_r2777.nzMaxTagCount))("ngForTrackBy", ctx_r2777.trackValue);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r2777.selectedNodes.length > ctx_r2777.nzMaxTagCount);
} }
function NzTreeSelectComponent_nz_select_search_3_Template(rf, ctx) { if (rf & 1) {
    var _r2801 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "nz-select-search", 17);
    i0.ɵɵlistener("keydown", function NzTreeSelectComponent_nz_select_search_3_Template_nz_select_search_keydown_0_listener($event) { i0.ɵɵrestoreView(_r2801); var ctx_r2800 = i0.ɵɵnextContext(); return ctx_r2800.onKeyDownInput($event); })("isComposingChange", function NzTreeSelectComponent_nz_select_search_3_Template_nz_select_search_isComposingChange_0_listener($event) { i0.ɵɵrestoreView(_r2801); var ctx_r2802 = i0.ɵɵnextContext(); return ctx_r2802.isComposing = $event; })("valueChange", function NzTreeSelectComponent_nz_select_search_3_Template_nz_select_search_valueChange_0_listener($event) { i0.ɵɵrestoreView(_r2801); var ctx_r2803 = i0.ɵɵnextContext(); return ctx_r2803.setInputValue($event); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2778 = i0.ɵɵnextContext();
    i0.ɵɵproperty("value", ctx_r2778.inputValue)("mirrorSync", ctx_r2778.isMultiple)("disabled", ctx_r2778.nzDisabled)("showInput", ctx_r2778.nzOpen);
} }
function NzTreeSelectComponent_nz_select_placeholder_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "nz-select-placeholder", 18);
} if (rf & 2) {
    var ctx_r2779 = i0.ɵɵnextContext();
    i0.ɵɵstyleProp("display", ctx_r2779.placeHolderDisplay);
    i0.ɵɵproperty("placeholder", ctx_r2779.nzPlaceHolder);
} }
function NzTreeSelectComponent_nz_select_item_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "nz-select-item", 19);
} if (rf & 2) {
    var ctx_r2780 = i0.ɵɵnextContext();
    i0.ɵɵproperty("deletable", false)("disabled", false)("label", ctx_r2780.nzDisplayWith(ctx_r2780.selectedNodes[0]));
} }
function NzTreeSelectComponent_nz_select_arrow_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "nz-select-arrow");
} }
function NzTreeSelectComponent_nz_select_clear_7_Template(rf, ctx) { if (rf & 1) {
    var _r2805 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "nz-select-clear", 20);
    i0.ɵɵlistener("clear", function NzTreeSelectComponent_nz_select_clear_7_Template_nz_select_clear_clear_0_listener() { i0.ɵɵrestoreView(_r2805); var ctx_r2804 = i0.ɵɵnextContext(); return ctx_r2804.onClearSelection(); });
    i0.ɵɵelementEnd();
} }
export function higherOrderServiceFactory(injector) {
    return injector.get(NzTreeSelectService);
}
var NZ_CONFIG_COMPONENT_NAME = 'treeSelect';
var TREE_SELECT_DEFAULT_CLASS = 'ant-select-dropdown ant-select-tree-dropdown';
var NzTreeSelectComponent = /** @class */ (function (_super) {
    __extends(NzTreeSelectComponent, _super);
    function NzTreeSelectComponent(nzTreeService, nzConfigService, renderer, cdr, elementRef, noAnimation) {
        var _this = _super.call(this, nzTreeService) || this;
        _this.nzConfigService = nzConfigService;
        _this.renderer = renderer;
        _this.cdr = cdr;
        _this.elementRef = elementRef;
        _this.noAnimation = noAnimation;
        _this.nzAllowClear = true;
        _this.nzShowExpand = true;
        _this.nzShowLine = false;
        _this.nzCheckable = false;
        _this.nzShowSearch = false;
        _this.nzDisabled = false;
        _this.nzAsyncData = false;
        _this.nzMultiple = false;
        _this.nzDefaultExpandAll = false;
        _this.nzCheckStrictly = false;
        _this.nzNodes = [];
        _this.nzOpen = false;
        _this.nzPlaceHolder = '';
        _this.nzDisplayWith = function (node) { return node.title; };
        _this.nzOpenChange = new EventEmitter();
        _this.nzCleared = new EventEmitter();
        _this.nzRemoved = new EventEmitter();
        _this.nzExpandChange = new EventEmitter();
        _this.nzTreeClick = new EventEmitter();
        _this.nzTreeCheckBoxChange = new EventEmitter();
        _this.dropdownClassName = TREE_SELECT_DEFAULT_CLASS;
        _this.isComposing = false;
        _this.isDestroy = true;
        _this.isNotFound = false;
        _this.inputValue = '';
        _this.dropDownPosition = 'bottom';
        _this.selectedNodes = [];
        _this.expandedKeys = [];
        _this.value = [];
        _this.onTouched = function () { return null; };
        _this.renderer.addClass(_this.elementRef.nativeElement, 'ant-select');
        _this.renderer.addClass(_this.elementRef.nativeElement, 'ant-tree-select');
        return _this;
    }
    Object.defineProperty(NzTreeSelectComponent.prototype, "nzExpandedKeys", {
        get: function () {
            return this.expandedKeys;
        },
        set: function (value) {
            this.expandedKeys = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NzTreeSelectComponent.prototype, "treeTemplate", {
        get: function () {
            return this.nzTreeTemplate || this.nzTreeTemplateChild;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NzTreeSelectComponent.prototype, "placeHolderDisplay", {
        get: function () {
            return this.inputValue || this.isComposing || this.selectedNodes.length ? 'none' : 'block';
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NzTreeSelectComponent.prototype, "isMultiple", {
        get: function () {
            return this.nzMultiple || this.nzCheckable;
        },
        enumerable: true,
        configurable: true
    });
    NzTreeSelectComponent.prototype.ngOnInit = function () {
        this.isDestroy = false;
        this.selectionChangeSubscription = this.subscribeSelectionChange();
    };
    NzTreeSelectComponent.prototype.ngOnDestroy = function () {
        this.isDestroy = true;
        this.closeDropDown();
        this.selectionChangeSubscription.unsubscribe();
    };
    NzTreeSelectComponent.prototype.setDisabledState = function (isDisabled) {
        this.nzDisabled = isDisabled;
        this.closeDropDown();
    };
    NzTreeSelectComponent.prototype.ngOnChanges = function (changes) {
        var nzNodes = changes.nzNodes, nzDropdownClassName = changes.nzDropdownClassName;
        if (nzNodes) {
            this.updateSelectedNodes(true);
        }
        if (nzDropdownClassName) {
            var className = this.nzDropdownClassName && this.nzDropdownClassName.trim();
            this.dropdownClassName = className ? TREE_SELECT_DEFAULT_CLASS + " " + className : TREE_SELECT_DEFAULT_CLASS;
        }
    };
    NzTreeSelectComponent.prototype.writeValue = function (value) {
        var _this = this;
        if (isNotNil(value)) {
            if (this.isMultiple && Array.isArray(value)) {
                this.value = value;
            }
            else {
                this.value = [value];
            }
            this.updateSelectedNodes(true);
        }
        else {
            this.value = [];
            this.selectedNodes.forEach(function (node) {
                _this.removeSelected(node, false);
            });
            this.selectedNodes = [];
        }
        this.cdr.markForCheck();
    };
    NzTreeSelectComponent.prototype.registerOnChange = function (fn) {
        this.onChange = fn;
    };
    NzTreeSelectComponent.prototype.registerOnTouched = function (fn) {
        this.onTouched = fn;
    };
    NzTreeSelectComponent.prototype.trigger = function () {
        if (this.nzDisabled || (!this.nzDisabled && this.nzOpen)) {
            this.closeDropDown();
        }
        else {
            this.openDropdown();
            if (this.nzShowSearch || this.isMultiple) {
                this.focusOnInput();
            }
        }
    };
    NzTreeSelectComponent.prototype.openDropdown = function () {
        if (!this.nzDisabled) {
            this.nzOpen = true;
            this.nzOpenChange.emit(this.nzOpen);
            this.updateCdkConnectedOverlayStatus();
            this.updatePosition();
        }
    };
    NzTreeSelectComponent.prototype.closeDropDown = function () {
        this.onTouched();
        this.nzOpen = false;
        this.inputValue = '';
        this.nzOpenChange.emit(this.nzOpen);
        this.cdr.markForCheck();
    };
    NzTreeSelectComponent.prototype.onKeyDownInput = function (e) {
        var keyCode = e.keyCode;
        var eventTarget = e.target;
        if (this.isMultiple && !eventTarget.value && keyCode === BACKSPACE) {
            e.preventDefault();
            if (this.selectedNodes.length) {
                var removeNode = this.selectedNodes[this.selectedNodes.length - 1];
                this.removeSelected(removeNode);
            }
        }
    };
    NzTreeSelectComponent.prototype.onExpandedKeysChange = function (value) {
        this.nzExpandChange.emit(value);
        this.expandedKeys = __spread(value.keys);
    };
    NzTreeSelectComponent.prototype.setInputValue = function (value) {
        this.inputValue = value;
        this.updatePosition();
    };
    NzTreeSelectComponent.prototype.removeSelected = function (node, emit) {
        if (emit === void 0) { emit = true; }
        node.isSelected = false;
        node.isChecked = false;
        if (this.nzCheckable) {
            this.nzTreeService.conduct(node);
        }
        else {
            this.nzTreeService.setSelectedNodeList(node, this.nzMultiple);
        }
        if (emit) {
            this.nzRemoved.emit(node);
        }
    };
    NzTreeSelectComponent.prototype.focusOnInput = function () {
        if (this.nzSelectSearchComponent) {
            this.nzSelectSearchComponent.focus();
        }
    };
    NzTreeSelectComponent.prototype.subscribeSelectionChange = function () {
        var _this = this;
        return merge(this.nzTreeClick.pipe(tap(function (event) {
            var node = event.node;
            if (_this.nzCheckable && !node.isDisabled && !node.isDisableCheckbox) {
                node.isChecked = !node.isChecked;
                node.isHalfChecked = false;
                if (!_this.nzCheckStrictly) {
                    _this.nzTreeService.conduct(node);
                }
            }
            if (_this.nzCheckable) {
                node.isSelected = false;
            }
        }), filter(function (event) {
            var node = event.node;
            return _this.nzCheckable ? !node.isDisabled && !node.isDisableCheckbox : !node.isDisabled && node.isSelectable;
        })), this.nzCheckable ? this.nzTreeCheckBoxChange : observableOf(), this.nzCleared, this.nzRemoved).subscribe(function () {
            _this.updateSelectedNodes();
            var value = _this.selectedNodes.map(function (node) { return node.key; });
            _this.value = __spread(value);
            if (_this.nzShowSearch || _this.isMultiple) {
                _this.inputValue = '';
                _this.isNotFound = false;
            }
            if (_this.isMultiple) {
                _this.onChange(value);
                _this.focusOnInput();
                _this.updatePosition();
            }
            else {
                _this.closeDropDown();
                _this.onChange(value.length ? value[0] : null);
            }
        });
    };
    NzTreeSelectComponent.prototype.updateSelectedNodes = function (init) {
        if (init === void 0) { init = false; }
        if (init) {
            var nodes = this.coerceTreeNodes(this.nzNodes);
            this.nzTreeService.isMultiple = this.isMultiple;
            this.nzTreeService.isCheckStrictly = this.nzCheckStrictly;
            this.nzTreeService.initTree(nodes);
            if (this.nzCheckable) {
                this.nzTreeService.conductCheck(this.value, this.nzCheckStrictly);
            }
            else {
                this.nzTreeService.conductSelectedKeys(this.value, this.isMultiple);
            }
        }
        this.selectedNodes = __spread((this.nzCheckable ? this.getCheckedNodeList() : this.getSelectedNodeList()));
    };
    NzTreeSelectComponent.prototype.updatePosition = function () {
        var _this = this;
        setTimeout(function () {
            if (_this.cdkConnectedOverlay && _this.cdkConnectedOverlay.overlayRef) {
                _this.cdkConnectedOverlay.overlayRef.updatePosition();
            }
        });
    };
    NzTreeSelectComponent.prototype.onPositionChange = function (position) {
        this.dropDownPosition = position.connectionPair.originY;
    };
    NzTreeSelectComponent.prototype.onClearSelection = function () {
        var _this = this;
        this.selectedNodes.forEach(function (node) {
            _this.removeSelected(node, false);
        });
        this.nzCleared.emit();
    };
    NzTreeSelectComponent.prototype.setSearchValues = function ($event) {
        var _this = this;
        Promise.resolve().then(function () {
            _this.isNotFound = (_this.nzShowSearch || _this.isMultiple) && !!_this.inputValue && $event.matchedKeys.length === 0;
        });
    };
    NzTreeSelectComponent.prototype.updateCdkConnectedOverlayStatus = function () {
        this.triggerWidth = this.cdkOverlayOrigin.elementRef.nativeElement.getBoundingClientRect().width;
    };
    NzTreeSelectComponent.prototype.trackValue = function (_index, option) {
        return option.key;
    };
    /** @nocollapse */ NzTreeSelectComponent.ɵfac = function NzTreeSelectComponent_Factory(t) { return new (t || NzTreeSelectComponent)(i0.ɵɵdirectiveInject(i1.NzTreeSelectService), i0.ɵɵdirectiveInject(i2.NzConfigService), i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i2.NzNoAnimationDirective, 9)); };
    /** @nocollapse */ NzTreeSelectComponent.ɵcmp = i0.ɵɵdefineComponent({ type: NzTreeSelectComponent, selectors: [["nz-tree-select"]], contentQueries: function NzTreeSelectComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
            i0.ɵɵstaticContentQuery(dirIndex, _c0, true);
        } if (rf & 2) {
            var _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.nzTreeTemplateChild = _t.first);
        } }, viewQuery: function NzTreeSelectComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(NzSelectSearchComponent, true);
            i0.ɵɵviewQuery(_c1, true);
            i0.ɵɵstaticViewQuery(CdkOverlayOrigin, true);
            i0.ɵɵviewQuery(CdkConnectedOverlay, true);
        } if (rf & 2) {
            var _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.nzSelectSearchComponent = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.treeRef = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.cdkOverlayOrigin = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.cdkConnectedOverlay = _t.first);
        } }, hostVars: 20, hostBindings: function NzTreeSelectComponent_HostBindings(rf, ctx) { if (rf & 1) {
            i0.ɵɵlistener("click", function NzTreeSelectComponent_click_HostBindingHandler() { return ctx.trigger(); });
        } if (rf & 2) {
            i0.ɵɵclassProp("ant-select-lg", ctx.nzSize === "large")("ant-select-sm", ctx.nzSize === "small")("ant-select-enabled", !ctx.nzDisabled)("ant-select-disabled", ctx.nzDisabled)("ant-select-single", !ctx.isMultiple)("ant-select-show-arrow", !ctx.isMultiple)("ant-select-show-search", !ctx.isMultiple)("ant-select-multiple", ctx.isMultiple)("ant-select-allow-clear", ctx.nzAllowClear)("ant-select-open", ctx.nzOpen);
        } }, inputs: { nzAllowClear: "nzAllowClear", nzShowExpand: "nzShowExpand", nzShowLine: "nzShowLine", nzDropdownMatchSelectWidth: "nzDropdownMatchSelectWidth", nzCheckable: "nzCheckable", nzHideUnMatched: "nzHideUnMatched", nzShowIcon: "nzShowIcon", nzShowSearch: "nzShowSearch", nzDisabled: "nzDisabled", nzAsyncData: "nzAsyncData", nzMultiple: "nzMultiple", nzDefaultExpandAll: "nzDefaultExpandAll", nzCheckStrictly: "nzCheckStrictly", nzExpandedIcon: "nzExpandedIcon", nzNotFoundContent: "nzNotFoundContent", nzNodes: "nzNodes", nzOpen: "nzOpen", nzSize: "nzSize", nzPlaceHolder: "nzPlaceHolder", nzDropdownStyle: "nzDropdownStyle", nzDropdownClassName: "nzDropdownClassName", nzExpandedKeys: "nzExpandedKeys", nzDisplayWith: "nzDisplayWith", nzMaxTagCount: "nzMaxTagCount", nzMaxTagPlaceholder: "nzMaxTagPlaceholder", nzTreeTemplate: "nzTreeTemplate" }, outputs: { nzOpenChange: "nzOpenChange", nzCleared: "nzCleared", nzRemoved: "nzRemoved", nzExpandChange: "nzExpandChange", nzTreeClick: "nzTreeClick", nzTreeCheckBoxChange: "nzTreeCheckBoxChange" }, exportAs: ["nzTreeSelect"], features: [i0.ɵɵProvidersFeature([
                NzTreeSelectService,
                {
                    provide: NzTreeHigherOrderServiceToken,
                    useFactory: higherOrderServiceFactory,
                    deps: [[new Self(), Injector]]
                },
                {
                    provide: NG_VALUE_ACCESSOR,
                    useExisting: forwardRef((function () { return NzTreeSelectComponent; })),
                    multi: true
                }
            ]), i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], decls: 8, vars: 11, consts: [["cdkConnectedOverlay", "", "nzConnectedOverlay", "", 3, "cdkConnectedOverlayOrigin", "cdkConnectedOverlayOpen", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayWidth", "backdropClick", "detach", "positionChange"], ["cdkOverlayOrigin", "", 1, "ant-select-selector"], [4, "ngIf"], [3, "value", "mirrorSync", "disabled", "showInput", "keydown", "isComposingChange", "valueChange", 4, "ngIf"], [3, "placeholder", "display", 4, "ngIf"], [3, "deletable", "disabled", "label", 4, "ngIf"], [3, "clear", 4, "ngIf"], [3, "nzNoAnimation", "ngStyle"], ["nzNoAnimation", "", "nzSelectMode", "", 3, "hidden", "nzData", "nzMultiple", "nzSearchValue", "nzHideUnMatched", "nzShowIcon", "nzCheckable", "nzAsyncData", "nzShowExpand", "nzShowLine", "nzExpandedIcon", "nzExpandAll", "nzExpandedKeys", "nzCheckedKeys", "nzSelectedKeys", "nzTreeTemplate", "nzCheckStrictly", "nzExpandChange", "nzClick", "nzCheckedKeysChange", "nzSelectedKeysChange", "nzCheckBoxChange", "nzSearchValueChange"], ["treeRef", ""], ["class", "ant-select-not-found", 4, "ngIf"], [1, "ant-select-not-found"], [3, "nzComponentName", "specificContent"], [3, "nzNoAnimation", "deletable", "disabled", "label", "delete", 4, "ngFor", "ngForOf", "ngForTrackBy"], [3, "nzNoAnimation", "contentTemplateOutlet", "contentTemplateOutletContext", "deletable", "disabled", "label", 4, "ngIf"], [3, "nzNoAnimation", "deletable", "disabled", "label", "delete"], [3, "nzNoAnimation", "contentTemplateOutlet", "contentTemplateOutletContext", "deletable", "disabled", "label"], [3, "value", "mirrorSync", "disabled", "showInput", "keydown", "isComposingChange", "valueChange"], [3, "placeholder"], [3, "deletable", "disabled", "label"], [3, "clear"]], template: function NzTreeSelectComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, NzTreeSelectComponent_ng_template_0_Template, 4, 30, "ng-template", 0);
            i0.ɵɵlistener("backdropClick", function NzTreeSelectComponent_Template_ng_template_backdropClick_0_listener() { return ctx.closeDropDown(); })("detach", function NzTreeSelectComponent_Template_ng_template_detach_0_listener() { return ctx.closeDropDown(); })("positionChange", function NzTreeSelectComponent_Template_ng_template_positionChange_0_listener($event) { return ctx.onPositionChange($event); });
            i0.ɵɵelementStart(1, "div", 1);
            i0.ɵɵtemplate(2, NzTreeSelectComponent_ng_container_2_Template, 4, 7, "ng-container", 2);
            i0.ɵɵtemplate(3, NzTreeSelectComponent_nz_select_search_3_Template, 1, 4, "nz-select-search", 3);
            i0.ɵɵtemplate(4, NzTreeSelectComponent_nz_select_placeholder_4_Template, 1, 3, "nz-select-placeholder", 4);
            i0.ɵɵtemplate(5, NzTreeSelectComponent_nz_select_item_5_Template, 1, 3, "nz-select-item", 5);
            i0.ɵɵtemplate(6, NzTreeSelectComponent_nz_select_arrow_6_Template, 1, 0, "nz-select-arrow", 2);
            i0.ɵɵtemplate(7, NzTreeSelectComponent_nz_select_clear_7_Template, 1, 0, "nz-select-clear", 6);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵproperty("cdkConnectedOverlayOrigin", ctx.cdkOverlayOrigin)("cdkConnectedOverlayOpen", ctx.nzOpen)("cdkConnectedOverlayHasBackdrop", true)("cdkConnectedOverlayMinWidth", ctx.nzDropdownMatchSelectWidth ? null : ctx.triggerWidth)("cdkConnectedOverlayWidth", ctx.nzDropdownMatchSelectWidth ? ctx.triggerWidth : null);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", ctx.isMultiple);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.nzShowSearch);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.nzPlaceHolder && ctx.selectedNodes.length === 0);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.isMultiple && ctx.selectedNodes.length === 1);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.isMultiple);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.nzAllowClear);
        } }, directives: [i3.CdkConnectedOverlay, i2.NzConnectedOverlayDirective, i3.CdkOverlayOrigin, i4.NgIf, i2.NzNoAnimationDirective, i4.NgStyle, i5.NzTreeComponent, i6.NzEmbedEmptyComponent, i4.NgForOf, i7.NzSelectItemComponent, i7.NzSelectSearchComponent, i7.NzSelectPlaceholderComponent, i7.NzSelectArrowComponent, i7.NzSelectClearComponent], pipes: [i4.SlicePipe], styles: [".ant-select-dropdown[_ngcontent-%COMP%] {\n        top: 100%;\n        left: 0;\n        position: relative;\n        width: 100%;\n        margin-top: 4px;\n        margin-bottom: 4px;\n        overflow: auto;\n      }"], data: { animation: [slideMotion, zoomMotion] } });
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzTreeSelectComponent.prototype, "nzAllowClear", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzTreeSelectComponent.prototype, "nzShowExpand", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzTreeSelectComponent.prototype, "nzShowLine", void 0);
    __decorate([
        InputBoolean(), WithConfig(NZ_CONFIG_COMPONENT_NAME, true),
        __metadata("design:type", Boolean)
    ], NzTreeSelectComponent.prototype, "nzDropdownMatchSelectWidth", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzTreeSelectComponent.prototype, "nzCheckable", void 0);
    __decorate([
        InputBoolean(), WithConfig(NZ_CONFIG_COMPONENT_NAME, false),
        __metadata("design:type", Boolean)
    ], NzTreeSelectComponent.prototype, "nzHideUnMatched", void 0);
    __decorate([
        InputBoolean(), WithConfig(NZ_CONFIG_COMPONENT_NAME, false),
        __metadata("design:type", Boolean)
    ], NzTreeSelectComponent.prototype, "nzShowIcon", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzTreeSelectComponent.prototype, "nzShowSearch", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Object)
    ], NzTreeSelectComponent.prototype, "nzDisabled", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Object)
    ], NzTreeSelectComponent.prototype, "nzAsyncData", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Object)
    ], NzTreeSelectComponent.prototype, "nzMultiple", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Object)
    ], NzTreeSelectComponent.prototype, "nzDefaultExpandAll", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Object)
    ], NzTreeSelectComponent.prototype, "nzCheckStrictly", void 0);
    __decorate([
        WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default'),
        __metadata("design:type", String)
    ], NzTreeSelectComponent.prototype, "nzSize", void 0);
    return NzTreeSelectComponent;
}(NzTreeBase));
export { NzTreeSelectComponent };
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(NzTreeSelectComponent, [{
        type: Component,
        args: [{
                selector: 'nz-tree-select',
                exportAs: 'nzTreeSelect',
                animations: [slideMotion, zoomMotion],
                template: "\n    <ng-template\n      cdkConnectedOverlay\n      nzConnectedOverlay\n      [cdkConnectedOverlayOrigin]=\"cdkOverlayOrigin\"\n      [cdkConnectedOverlayOpen]=\"nzOpen\"\n      [cdkConnectedOverlayHasBackdrop]=\"true\"\n      [cdkConnectedOverlayMinWidth]=\"nzDropdownMatchSelectWidth ? null : triggerWidth\"\n      [cdkConnectedOverlayWidth]=\"nzDropdownMatchSelectWidth ? triggerWidth : null\"\n      (backdropClick)=\"closeDropDown()\"\n      (detach)=\"closeDropDown()\"\n      (positionChange)=\"onPositionChange($event)\"\n    >\n      <div\n        [class]=\"dropdownClassName\"\n        [@slideMotion]=\"nzOpen ? dropDownPosition : 'void'\"\n        [@.disabled]=\"noAnimation?.nzNoAnimation\"\n        [nzNoAnimation]=\"noAnimation?.nzNoAnimation\"\n        [class.ant-select-dropdown-placement-bottomLeft]=\"dropDownPosition === 'bottom'\"\n        [class.ant-select-dropdown-placement-topLeft]=\"dropDownPosition === 'top'\"\n        [ngStyle]=\"nzDropdownStyle\"\n      >\n        <nz-tree\n          #treeRef\n          [hidden]=\"isNotFound\"\n          nzNoAnimation\n          nzSelectMode\n          [nzData]=\"nzNodes\"\n          [nzMultiple]=\"nzMultiple\"\n          [nzSearchValue]=\"inputValue\"\n          [nzHideUnMatched]=\"nzHideUnMatched\"\n          [nzShowIcon]=\"nzShowIcon\"\n          [nzCheckable]=\"nzCheckable\"\n          [nzAsyncData]=\"nzAsyncData\"\n          [nzShowExpand]=\"nzShowExpand\"\n          [nzShowLine]=\"nzShowLine\"\n          [nzExpandedIcon]=\"nzExpandedIcon\"\n          [nzExpandAll]=\"nzDefaultExpandAll\"\n          [nzExpandedKeys]=\"expandedKeys\"\n          [nzCheckedKeys]=\"nzCheckable ? value : []\"\n          [nzSelectedKeys]=\"!nzCheckable ? value : []\"\n          [nzTreeTemplate]=\"treeTemplate\"\n          [nzCheckStrictly]=\"nzCheckStrictly\"\n          (nzExpandChange)=\"onExpandedKeysChange($event)\"\n          (nzClick)=\"nzTreeClick.emit($event)\"\n          (nzCheckedKeysChange)=\"updateSelectedNodes()\"\n          (nzSelectedKeysChange)=\"updateSelectedNodes()\"\n          (nzCheckBoxChange)=\"nzTreeCheckBoxChange.emit($event)\"\n          (nzSearchValueChange)=\"setSearchValues($event)\"\n        >\n        </nz-tree>\n        <span *ngIf=\"nzNodes.length === 0 || isNotFound\" class=\"ant-select-not-found\">\n          <nz-embed-empty [nzComponentName]=\"'tree-select'\" [specificContent]=\"nzNotFoundContent\"></nz-embed-empty>\n        </span>\n      </div>\n    </ng-template>\n\n    <div cdkOverlayOrigin class=\"ant-select-selector\">\n      <ng-container *ngIf=\"isMultiple\">\n        <nz-select-item\n          *ngFor=\"let node of selectedNodes | slice: 0:nzMaxTagCount; trackBy: trackValue\"\n          [@zoomMotion]\n          [@.disabled]=\"noAnimation?.nzNoAnimation\"\n          [nzNoAnimation]=\"noAnimation?.nzNoAnimation\"\n          [deletable]=\"true\"\n          [disabled]=\"node.isDisabled || nzDisabled\"\n          [label]=\"nzDisplayWith(node)\"\n          (@zoomMotion.done)=\"updatePosition()\"\n          (delete)=\"removeSelected(node, true)\"\n        ></nz-select-item>\n\n        <nz-select-item\n          *ngIf=\"selectedNodes.length > nzMaxTagCount\"\n          [@zoomMotion]\n          (@zoomMotion.done)=\"updatePosition()\"\n          [@.disabled]=\"noAnimation?.nzNoAnimation\"\n          [nzNoAnimation]=\"noAnimation?.nzNoAnimation\"\n          [contentTemplateOutlet]=\"nzMaxTagPlaceholder\"\n          [contentTemplateOutletContext]=\"selectedNodes | slice: nzMaxTagCount\"\n          [deletable]=\"false\"\n          [disabled]=\"false\"\n          [label]=\"'+ ' + (selectedNodes.length - nzMaxTagCount) + ' ...'\"\n        ></nz-select-item>\n      </ng-container>\n\n      <nz-select-search\n        *ngIf=\"nzShowSearch\"\n        (keydown)=\"onKeyDownInput($event)\"\n        (isComposingChange)=\"isComposing = $event\"\n        (valueChange)=\"setInputValue($event)\"\n        [value]=\"inputValue\"\n        [mirrorSync]=\"isMultiple\"\n        [disabled]=\"nzDisabled\"\n        [showInput]=\"nzOpen\"\n      >\n      </nz-select-search>\n\n      <nz-select-placeholder\n        *ngIf=\"nzPlaceHolder && selectedNodes.length === 0\"\n        [placeholder]=\"nzPlaceHolder\"\n        [style.display]=\"placeHolderDisplay\"\n      >\n      </nz-select-placeholder>\n\n      <nz-select-item\n        *ngIf=\"!isMultiple && selectedNodes.length === 1\"\n        [deletable]=\"false\"\n        [disabled]=\"false\"\n        [label]=\"nzDisplayWith(selectedNodes[0])\"\n      ></nz-select-item>\n\n      <nz-select-arrow *ngIf=\"!isMultiple\"></nz-select-arrow>\n\n      <nz-select-clear *ngIf=\"nzAllowClear\" (clear)=\"onClearSelection()\"></nz-select-clear>\n    </div>\n  ",
                providers: [
                    NzTreeSelectService,
                    {
                        provide: NzTreeHigherOrderServiceToken,
                        useFactory: higherOrderServiceFactory,
                        deps: [[new Self(), Injector]]
                    },
                    {
                        provide: NG_VALUE_ACCESSOR,
                        useExisting: forwardRef((function () { return NzTreeSelectComponent; })),
                        multi: true
                    }
                ],
                host: {
                    '[class.ant-select-lg]': 'nzSize==="large"',
                    '[class.ant-select-sm]': 'nzSize==="small"',
                    '[class.ant-select-enabled]': '!nzDisabled',
                    '[class.ant-select-disabled]': 'nzDisabled',
                    '[class.ant-select-single]': '!isMultiple',
                    '[class.ant-select-show-arrow]': '!isMultiple',
                    '[class.ant-select-show-search]': '!isMultiple',
                    '[class.ant-select-multiple]': 'isMultiple',
                    '[class.ant-select-allow-clear]': 'nzAllowClear',
                    '[class.ant-select-open]': 'nzOpen',
                    '(click)': 'trigger()'
                },
                styles: [
                    "\n      .ant-select-dropdown {\n        top: 100%;\n        left: 0;\n        position: relative;\n        width: 100%;\n        margin-top: 4px;\n        margin-bottom: 4px;\n        overflow: auto;\n      }\n    "
                ]
            }]
    }], function () { return [{ type: i1.NzTreeSelectService }, { type: i2.NzConfigService }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i2.NzNoAnimationDirective, decorators: [{
                type: Host
            }, {
                type: Optional
            }] }]; }, { nzAllowClear: [{
            type: Input
        }], nzShowExpand: [{
            type: Input
        }], nzShowLine: [{
            type: Input
        }], nzDropdownMatchSelectWidth: [{
            type: Input
        }], nzCheckable: [{
            type: Input
        }], nzHideUnMatched: [{
            type: Input
        }], nzShowIcon: [{
            type: Input
        }], nzShowSearch: [{
            type: Input
        }], nzDisabled: [{
            type: Input
        }], nzAsyncData: [{
            type: Input
        }], nzMultiple: [{
            type: Input
        }], nzDefaultExpandAll: [{
            type: Input
        }], nzCheckStrictly: [{
            type: Input
        }], nzExpandedIcon: [{
            type: Input
        }], nzNotFoundContent: [{
            type: Input
        }], nzNodes: [{
            type: Input
        }], nzOpen: [{
            type: Input
        }], nzSize: [{
            type: Input
        }], nzPlaceHolder: [{
            type: Input
        }], nzDropdownStyle: [{
            type: Input
        }], nzDropdownClassName: [{
            type: Input
        }], nzExpandedKeys: [{
            type: Input
        }], nzDisplayWith: [{
            type: Input
        }], nzMaxTagCount: [{
            type: Input
        }], nzMaxTagPlaceholder: [{
            type: Input
        }], nzOpenChange: [{
            type: Output
        }], nzCleared: [{
            type: Output
        }], nzRemoved: [{
            type: Output
        }], nzExpandChange: [{
            type: Output
        }], nzTreeClick: [{
            type: Output
        }], nzTreeCheckBoxChange: [{
            type: Output
        }], nzSelectSearchComponent: [{
            type: ViewChild,
            args: [NzSelectSearchComponent, { static: false }]
        }], treeRef: [{
            type: ViewChild,
            args: ['treeRef', { static: false }]
        }], cdkOverlayOrigin: [{
            type: ViewChild,
            args: [CdkOverlayOrigin, { static: true }]
        }], cdkConnectedOverlay: [{
            type: ViewChild,
            args: [CdkConnectedOverlay, { static: false }]
        }], nzTreeTemplate: [{
            type: Input
        }], nzTreeTemplateChild: [{
            type: ContentChild,
            args: ['nzTreeTemplate', { static: true }]
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 