import { Component, Input, TemplateRef, ViewChild } from '@angular/core';
import { Color } from '@mintplayer/ng-bootstrap';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/forms";
import * as i3 from "@mintplayer/ng-bootstrap/dropdown";
import * as i4 from "@mintplayer/ng-bootstrap/has-overlay";
import * as i5 from "@mintplayer/ng-bootstrap/toggle-button";
import * as i6 from "@mintplayer/ng-bootstrap/button-type";
export class BsMultiselectComponent {
    constructor() {
        this.colors = Color;
        this.items = [];
        this.selectedItems = [];
    }
    // itemChange(item: any, ev: Event) {
    itemChange(item, value) {
        // const value = (<any>ev.target).checked;
        if (value) {
            this.selectedItems.push(item);
        }
        else {
            this.selectedItems.splice(this.selectedItems.findIndex((i) => i === item), 1);
        }
    }
    defaultTrackBy(index, item) {
        return item;
    }
}
BsMultiselectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsMultiselectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
BsMultiselectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: BsMultiselectComponent, selector: "bs-multiselect", inputs: { items: "items", selectedItems: "selectedItems", itemsTrackBy: "itemsTrackBy" }, viewQueries: [{ propertyName: "defaultButtonTemplate", first: true, predicate: ["defaultButtonTemplate"], descendants: true }], ngImport: i0, template: "<bs-has-overlay></bs-has-overlay>\n<div bsDropdown [hasBackdrop]=\"true\" [closeOnClickOutside]=\"true\">\n    <button bsDropdownToggle [color]=\"colors.primary\">\n        <ng-container *ngTemplateOutlet=\"buttonTemplate ?? defaultButtonTemplate; context: { $implicit: selectedItems.length }\"></ng-container>\n    </button>\n    <div *bsDropdownMenu class=\"bg-white mw-250px p-3 border rounded shadow\">\n        <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n        <hr class=\"my-2\" *ngIf=\"headerTemplate\">\n        <bs-toggle-button *ngFor=\"let item of items; trackBy: itemsTrackBy ?? defaultTrackBy\" [ngModel]=\"selectedItems.indexOf(item) > -1\" (ngModelChange)=\"itemChange(item, $event)\" class=\"d-block\">{{ item }}</bs-toggle-button>\n        <hr class=\"my-2\" *ngIf=\"footerTemplate\">\n        <ng-container *ngTemplateOutlet=\"footerTemplate\"></ng-container>\n    </div>\n</div>\n<ng-template #defaultButtonTemplate let-count>\n    {{ count }} selected\n</ng-template>", styles: [".mw-250px{min-width:250px}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i3.BsDropdownDirective, selector: "[bsDropdown]", inputs: ["hasBackdrop", "sameWidth", "closeOnClickOutside", "sameDropdownWidth", "isOpen"], outputs: ["isOpenChange"] }, { kind: "directive", type: i3.BsDropdownToggleDirective, selector: "[bsDropdownToggle]" }, { kind: "directive", type: i3.BsDropdownMenuDirective, selector: "[bsDropdownMenu]" }, { kind: "component", type: i4.BsHasOverlayComponent, selector: "bs-has-overlay" }, { kind: "component", type: i5.BsToggleButtonComponent, selector: "bs-toggle-button", inputs: ["type", "isToggled", "disabled", "name", "value", "group"], outputs: ["isToggledChange"] }, { kind: "directive", type: i5.BsToggleButtonValueAccessor, selector: "bs-toggle-button" }, { kind: "directive", type: i6.BsButtonTypeDirective, selector: "button[color],input[type=\"button\"][color],input[type=\"submit\"][color]", inputs: ["color"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsMultiselectComponent, decorators: [{
            type: Component,
            args: [{ selector: 'bs-multiselect', template: "<bs-has-overlay></bs-has-overlay>\n<div bsDropdown [hasBackdrop]=\"true\" [closeOnClickOutside]=\"true\">\n    <button bsDropdownToggle [color]=\"colors.primary\">\n        <ng-container *ngTemplateOutlet=\"buttonTemplate ?? defaultButtonTemplate; context: { $implicit: selectedItems.length }\"></ng-container>\n    </button>\n    <div *bsDropdownMenu class=\"bg-white mw-250px p-3 border rounded shadow\">\n        <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n        <hr class=\"my-2\" *ngIf=\"headerTemplate\">\n        <bs-toggle-button *ngFor=\"let item of items; trackBy: itemsTrackBy ?? defaultTrackBy\" [ngModel]=\"selectedItems.indexOf(item) > -1\" (ngModelChange)=\"itemChange(item, $event)\" class=\"d-block\">{{ item }}</bs-toggle-button>\n        <hr class=\"my-2\" *ngIf=\"footerTemplate\">\n        <ng-container *ngTemplateOutlet=\"footerTemplate\"></ng-container>\n    </div>\n</div>\n<ng-template #defaultButtonTemplate let-count>\n    {{ count }} selected\n</ng-template>", styles: [".mw-250px{min-width:250px}\n"] }]
        }], propDecorators: { items: [{
                type: Input
            }], selectedItems: [{
                type: Input
            }], defaultButtonTemplate: [{
                type: ViewChild,
                args: ['defaultButtonTemplate']
            }], itemsTrackBy: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 