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 "@mintplayer/ng-bootstrap/dropdown";
import * as i3 from "@mintplayer/ng-bootstrap/has-overlay";
import * as i4 from "@mintplayer/ng-bootstrap/toggle-button";
import * as i5 from "@mintplayer/ng-bootstrap/button-type";
export class BsMultiselectComponent {
    constructor() {
        this.colors = Color;
        this.items = [];
        this.selectedItems = [];
    }
    itemChange(item, ev) {
        const value = ev.target.checked;
        if (value) {
            this.selectedItems.push(item);
        }
        else {
            this.selectedItems.splice(this.selectedItems.findIndex((i) => i === item), 1);
        }
    }
}
BsMultiselectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsMultiselectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
BsMultiselectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: BsMultiselectComponent, selector: "bs-multiselect", inputs: { items: "items", selectedItems: "selectedItems" }, 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\" [isToggled]=\"selectedItems.indexOf(item) > -1\" (change)=\"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.BsDropdownDirective, selector: "[bsDropdown]", inputs: ["hasBackdrop", "sameWidth", "closeOnClickOutside", "sameDropdownWidth", "isOpen"], outputs: ["isOpenChange"] }, { kind: "directive", type: i2.BsDropdownToggleDirective, selector: "[bsDropdownToggle]" }, { kind: "directive", type: i2.BsDropdownMenuDirective, selector: "[bsDropdownMenu]" }, { kind: "component", type: i3.BsHasOverlayComponent, selector: "bs-has-overlay" }, { kind: "component", type: i4.BsToggleButtonComponent, selector: "bs-toggle-button", inputs: ["type", "isToggled", "disabled", "name", "value", "group"], outputs: ["isToggledChange"] }, { kind: "directive", type: i4.BsToggleButtonValueAccessor, selector: "bs-toggle-button" }, { kind: "directive", type: i5.BsButtonTypeDirective, selector: "button[color],input[type=\"button\"][color],input[type=\"submit\"][color]", inputs: ["color"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", 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\" [isToggled]=\"selectedItems.indexOf(item) > -1\" (change)=\"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']
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibXVsdGlzZWxlY3QuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9taW50cGxheWVyLW5nLWJvb3RzdHJhcC9tdWx0aXNlbGVjdC9zcmMvY29tcG9uZW50L211bHRpc2VsZWN0LmNvbXBvbmVudC50cyIsIi4uLy4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvbWludHBsYXllci1uZy1ib290c3RyYXAvbXVsdGlzZWxlY3Qvc3JjL2NvbXBvbmVudC9tdWx0aXNlbGVjdC5jb21wb25lbnQuaHRtbCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLEtBQUssRUFBRSxXQUFXLEVBQUUsU0FBUyxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ3pFLE9BQU8sRUFBRSxLQUFLLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQzs7Ozs7OztBQU9qRCxNQUFNLE9BQU8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