import { Component, HostBinding, ChangeDetectionStrategy, ViewEncapsulation, ContentChildren, forwardRef, QueryList, Input } from '@angular/core';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { BaseDirective } from '../../../base.directive';
import { EuiListComponent } from '../eui-list.component';
import { EuiListService } from '../services/eui-list.service';
import { EuiIconComponent, EuiLabelComponent } from '../../atoms';
import * as i0 from "@angular/core";
import * as i1 from "../services/eui-list.service";
import * as i2 from "@angular/common";
import * as i3 from "../../atoms/eui-icon/eui-icon.component";
const _c0 = ["euiListItem", ""];
function EuiListItemComponent_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 6);
    i0.ɵɵprojection(1, 1);
    i0.ɵɵelementEnd();
} }
function EuiListItemComponent_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 7);
    i0.ɵɵprojection(1, 2);
    i0.ɵɵelementEnd();
} }
function EuiListItemComponent_div_4_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 8);
    i0.ɵɵlistener("click", function EuiListItemComponent_div_4_Template_div_click_0_listener($event) { i0.ɵɵrestoreView(_r5); const ctx_r4 = i0.ɵɵnextContext(); return ctx_r4.toggleCollapse($event); });
    i0.ɵɵelement(1, "span", 9);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵclassProp("eui-list-item__content-toggle--expanded", !ctx_r2.isCollapsed);
    i0.ɵɵadvance(1);
    i0.ɵɵpropertyInterpolate("aria-label", ctx_r2.isCollapsed ? "Expand" : "Collapse");
} }
function EuiListItemComponent_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10);
    i0.ɵɵprojection(1, 3);
    i0.ɵɵelementEnd();
} }
const _c1 = ["*", [["", "eui-icon", ""], ["", "euiIcon", ""]], [["", "eui-label", ""], ["", "euiLabel", ""]], [["", "eui-list", ""], ["", "euiList", ""]]];
const _c2 = ["*", "[eui-icon], [euiIcon]", "[eui-label], [euiLabel]", "[eui-list], [euiList]"];
export class EuiListItemComponent extends BaseDirective {
    constructor(euiListService) {
        super();
        this.euiListService = euiListService;
        this._isCollapsible = false;
        this._isCollapsed = true;
    }
    get isCollapsible() { return this._isCollapsible; }
    set isCollapsible(value) { this._isCollapsible = coerceBooleanProperty(value); }
    get isCollapsed() { return this._isCollapsed; }
    set isCollapsed(value) { this._isCollapsed = coerceBooleanProperty(value); }
    get cssClasses() {
        return [
            super.getCssClasses('eui-list-item'),
        ].join(' ').trim();
    }
    ngOnInit() {
        this.isCollapsible = this.euiListService.isCollapsible;
    }
    toggleCollapse(event) {
        if (this.isCollapsible) {
            this.isCollapsed = !this.isCollapsed;
        }
        if (event) {
            event.preventDefault();
            event.stopPropagation();
            event.cancelBubble = true;
        }
    }
}
/** @nocollapse */ EuiListItemComponent.ɵfac = function EuiListItemComponent_Factory(t) { return new (t || EuiListItemComponent)(i0.ɵɵdirectiveInject(i1.EuiListService)); };
/** @nocollapse */ EuiListItemComponent.ɵcmp = i0.ɵɵdefineComponent({ type: EuiListItemComponent, selectors: [["", "euiListItem", ""], ["eui-list-item"]], contentQueries: function EuiListItemComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
        i0.ɵɵcontentQuery(dirIndex, EuiListComponent, false);
        i0.ɵɵcontentQuery(dirIndex, EuiIconComponent, false);
        i0.ɵɵcontentQuery(dirIndex, EuiLabelComponent, false);
    } if (rf & 2) {
        var _t;
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.euiListComponent = _t);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.euiIconComponent = _t);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.euiLabelComponent = _t);
    } }, hostVars: 2, hostBindings: function EuiListItemComponent_HostBindings(rf, ctx) { if (rf & 2) {
        i0.ɵɵclassMap(ctx.cssClasses);
    } }, inputs: { isCollapsible: "isCollapsible", isCollapsed: "isCollapsed" }, features: [i0.ɵɵInheritDefinitionFeature], attrs: _c0, ngContentSelectors: _c2, decls: 7, vars: 6, consts: [["role", "list-item", 1, "eui-list-item__container"], [1, "eui-list-item__content"], ["class", "eui-list-item__content-icon", 4, "ngIf"], ["class", "eui-list-item__content-text", 4, "ngIf"], ["class", "eui-list-item__content-toggle", 3, "eui-list-item__content-toggle--expanded", "click", 4, "ngIf"], ["class", "eui-list-item__sub-list", 4, "ngIf"], [1, "eui-list-item__content-icon"], [1, "eui-list-item__content-text"], [1, "eui-list-item__content-toggle", 3, "click"], ["euiIcon", "", "euiSecondary", "", "euiSizeXL", "", "iconClass", "eui-icon-angle-down", 3, "aria-label"], [1, "eui-list-item__sub-list"]], template: function EuiListItemComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵprojectionDef(_c1);
        i0.ɵɵelementStart(0, "div", 0);
        i0.ɵɵelementStart(1, "div", 1);
        i0.ɵɵtemplate(2, EuiListItemComponent_div_2_Template, 2, 0, "div", 2);
        i0.ɵɵtemplate(3, EuiListItemComponent_div_3_Template, 2, 0, "div", 3);
        i0.ɵɵtemplate(4, EuiListItemComponent_div_4_Template, 2, 3, "div", 4);
        i0.ɵɵelementEnd();
        i0.ɵɵtemplate(5, EuiListItemComponent_div_5_Template, 2, 0, "div", 5);
        i0.ɵɵprojection(6);
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        i0.ɵɵclassProp("eui-list-item--has-submenu", ctx.euiListComponent.length > 0);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.euiIconComponent.length > 0);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.euiLabelComponent.length > 0);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.euiListComponent.length > 0 && ctx.isCollapsible);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.euiListComponent.length > 0 && !ctx.isCollapsed || ctx.euiListComponent.length > 0 && !ctx.isCollapsible);
    } }, directives: [i2.NgIf, i3.EuiIconComponent], styles: [".eui-list{display:block;height:auto;position:relative}.eui-list .eui-list-item{-webkit-tap-highlight-color:transparent;-webkit-user-select:none;background:none;border:none;box-shadow:none;cursor:pointer;display:block;max-width:100%;outline:none;overflow:hidden;padding:var(--eui-spacing-2xs) var(--eui-spacing-xs);position:relative;text-align:left;text-decoration:none;text-overflow:ellipsis;user-select:none;white-space:nowrap;width:100%}.eui-list .eui-list-item:hover{background-color:var(--eui-color-grey-lightest)}.eui-list .eui-list-item .eui-list-item__container{align-items:center;display:flex}.eui-list .eui-list-item .eui-list-item__container .eui-list-item__content{align-items:center;display:flex;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.eui-list .eui-list-item .eui-list-item__container .eui-list-item__content .eui-list-item__content-icon{align-items:center;display:flex}.eui-list .eui-list-item .eui-list-item__container .eui-list-item__content .eui-list-item__content-icon .eui-icon{margin-right:var(--eui-spacing-xs)}.eui-list .eui-list-item .eui-list-item__container .eui-list-item__content .eui-list-item__content-text{display:block;margin-right:var(--eui-spacing-s);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.eui-list .eui-list-item .eui-list-item__container .eui-list-item__content .eui-list-item__content-text .eui-label{line-height:var(--eui-spacing-s)}.eui-list .eui-list-item .eui-list-item__container .eui-list-item__content .eui-list-item__content-text .eui-label+.eui-label{display:block}.eui-list .eui-list-item .eui-list-item__container .eui-list-item__content .eui-list-item__content-toggle{align-items:center;display:inline-flex;font-size:var(--eui-font-size-m);margin-left:auto;transition:all .3s linear}.eui-list .eui-list-item .eui-list-item__container.eui-list-item--has-submenu{display:block;width:100%}.eui-list .eui-list-item .eui-list-item__container.eui-list-item--has-submenu .eui-list-item__content{align-items:center;display:flex;width:100%}.eui-list .eui-list-item .eui-list-item__container.eui-list-item--has-submenu .eui-list-item__sub-list{margin-left:var(--eui-spacing)}.eui-list .eui-list-item .eui-list-item__container.eui-list-item--has-submenu .eui-list-item__sub-list .eui-list-item{padding-right:0}navigation-list nav{height:auto}.eui-list-item--primary{color:var(--eui-color-primary)}.eui-list-item--secondary{color:var(--eui-color-grey-darker)}.eui-list-item--info{color:var(--eui-color-info)}.eui-list-item--success{color:var(--eui-color-success)}.eui-list-item--warning{color:var(--eui-color-warning-darkester-2)}.eui-list-item--danger{color:var(--eui-color-danger)}.eui-list-item__content-toggle--expanded{transform:rotate(-180deg)}.eui-list-item--disabled{background-image:none;box-shadow:none;cursor:not-allowed;opacity:var(--eui-disabled-opacity-base);pointer-events:none}"], encapsulation: 2, changeDetection: 0 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiListItemComponent, [{
        type: Component,
        args: [{
                templateUrl: './eui-list-item.component.html',
                selector: '[euiListItem], eui-list-item',
                styleUrls: ['../styles/_index.scss'],
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
            }]
    }], function () { return [{ type: i1.EuiListService }]; }, { isCollapsible: [{
            type: Input
        }], isCollapsed: [{
            type: Input
        }], cssClasses: [{
            type: HostBinding,
            args: ['class']
        }], euiListComponent: [{
            type: ContentChildren,
            args: [forwardRef(() => EuiListComponent)]
        }], euiIconComponent: [{
            type: ContentChildren,
            args: [forwardRef(() => EuiIconComponent)]
        }], euiLabelComponent: [{
            type: ContentChildren,
            args: [forwardRef(() => EuiLabelComponent)]
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 