// © 2022 SolarWinds Worldwide, LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to
//  deal in the Software without restriction, including without limitation the
//  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
//  sell copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
import { ChangeDetectorRef, Component, ElementRef, forwardRef, HostBinding, HostListener, Input, Optional, ViewChild, ViewEncapsulation, } from "@angular/core";
import { MenuGroupComponent } from "../menu-group/menu-group.component";
import { MenuItemBaseComponent } from "../menu-item/menu-item-base";
import * as i0 from "@angular/core";
import * as i1 from "../menu-group/menu-group.component";
import * as i2 from "../../../checkbox/checkbox.component";
/**
 * @ignore
 */
/**
 * Menu item component with check/uncheck option,
 * use (change) event to get state of this item
 */
export class MenuOptionComponent extends MenuItemBaseComponent {
    constructor(group, cd) {
        super(group, cd);
        this.group = group;
        this.name = "";
        this.value = "";
        this.checked = false;
        // Is needed to predefine item state, sets nui-checkbox [disabled] property
        this.disabled = false;
    }
    stopPropagationOfClick(event) {
        event.stopPropagation();
        if (!this.disabled) {
            event.preventDefault();
            this.checked = !this.checked;
            this.actionDone.emit(this.checked);
        }
    }
    get checkedClass() {
        return this.checked;
    }
    doAction() {
        this.checked = !this.checked;
        this.actionDone.emit(this.checked);
    }
}
MenuOptionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: MenuOptionComponent, deps: [{ token: i1.MenuGroupComponent, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
MenuOptionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: MenuOptionComponent, selector: "nui-menu-option", inputs: { name: "name", value: "value", checked: "checked" }, host: { attributes: { "role": "menuitemcheckbox" }, listeners: { "click": "stopPropagationOfClick($event)" }, properties: { "class.checked": "this.checkedClass" } }, providers: [
        {
            provide: MenuItemBaseComponent,
            useExisting: forwardRef(() => MenuOptionComponent),
        },
    ], viewQueries: [{ propertyName: "menuItem", first: true, predicate: ["menuOption"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
        <div class="nui-menu-item__option" #menuOption tabindex="-1">
            <nui-checkbox
                class="nui-menu-item__checkbox"
                [name]="name"
                [value]="value"
                [checked]="checked"
                [disabled]="disabled"
            >
                <ng-content></ng-content>
            </nui-checkbox>
        </div>
    `, isInline: true, styles: [".nui-menu .nui-menu-item .nui-menu-item__option,.nui-menu-popup-host .nui-menu-item .nui-menu-item__option,.nui-menu-popup .nui-menu-item .nui-menu-item__option{padding:0}.nui-menu .nui-menu-item .nui-menu-item__option .nui-checkbox__label,.nui-menu-popup-host .nui-menu-item .nui-menu-item__option .nui-checkbox__label,.nui-menu-popup .nui-menu-item .nui-menu-item__option .nui-checkbox__label{font-weight:400;font-size:13px;width:100%;padding:7px 12px}.nui-menu .nui-menu-item .nui-menu-item__option .nui-checkbox__label:focus,.nui-menu-popup-host .nui-menu-item .nui-menu-item__option .nui-checkbox__label:focus,.nui-menu-popup .nui-menu-item .nui-menu-item__option .nui-checkbox__label:focus{border-radius:0;background-color:var(--transparent,transparent)}.nui-menu .nui-menu-item .nui-menu-item__option .nui-menu-item__checkbox,.nui-menu-popup-host .nui-menu-item .nui-menu-item__option .nui-menu-item__checkbox,.nui-menu-popup .nui-menu-item .nui-menu-item__option .nui-menu-item__checkbox{width:100%}.nui-menu .nui-menu-item .nui-menu-item__option .nui-menu-item__checkbox>.nui-checkbox,.nui-menu-popup-host .nui-menu-item .nui-menu-item__option .nui-menu-item__checkbox>.nui-checkbox,.nui-menu-popup .nui-menu-item .nui-menu-item__option .nui-menu-item__checkbox>.nui-checkbox{padding:0}.nui-menu .nui-menu-item .nui-menu-item__option .nui-checkbox__translucent,.nui-menu-popup-host .nui-menu-item .nui-menu-item__option .nui-checkbox__translucent,.nui-menu-popup .nui-menu-item .nui-menu-item__option .nui-checkbox__translucent{cursor:not-allowed}.nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option{padding:5px;color:var(--nui-color-off,#4d4d4d)}.nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option:active,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option:active,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option:active,.nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option:focus,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option:focus,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option:focus{outline:0;box-shadow:none}.nui-menu .nui-menu-item.checked>.nui-menu-item__option,.nui-menu-popup-host .nui-menu-item.checked>.nui-menu-item__option,.nui-menu-popup .nui-menu-item.checked>.nui-menu-item__option{color:red}.nui-menu .nui-menu-item.checked>.nui-menu-item__option .nui-checkbox__label:hover,.nui-menu-popup-host .nui-menu-item.checked>.nui-menu-item__option .nui-checkbox__label:hover,.nui-menu-popup .nui-menu-item.checked>.nui-menu-item__option .nui-checkbox__label:hover{background-color:transparent}\n"], components: [{ type: i2.CheckboxComponent, selector: "nui-checkbox", inputs: ["ariaLabel", "ariaLabelledby", "ariaDescribedby", "name", "title", "value", "hovered", "checked", "required", "hint", "disabled", "indeterminate"], outputs: ["valueChange"] }], encapsulation: i0.ViewEncapsulation.None });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: MenuOptionComponent, decorators: [{
            type: Component,
            args: [{ selector: "nui-menu-option", template: `
        <div class="nui-menu-item__option" #menuOption tabindex="-1">
            <nui-checkbox
                class="nui-menu-item__checkbox"
                [name]="name"
                [value]="value"
                [checked]="checked"
                [disabled]="disabled"
            >
                <ng-content></ng-content>
            </nui-checkbox>
        </div>
    `, providers: [
                        {
                            provide: MenuItemBaseComponent,
                            useExisting: forwardRef(() => MenuOptionComponent),
                        },
                    ], encapsulation: ViewEncapsulation.None, host: { role: "menuitemcheckbox" }, styles: [".nui-menu .nui-menu-item .nui-menu-item__option,.nui-menu-popup-host .nui-menu-item .nui-menu-item__option,.nui-menu-popup .nui-menu-item .nui-menu-item__option{padding:0}.nui-menu .nui-menu-item .nui-menu-item__option .nui-checkbox__label,.nui-menu-popup-host .nui-menu-item .nui-menu-item__option .nui-checkbox__label,.nui-menu-popup .nui-menu-item .nui-menu-item__option .nui-checkbox__label{font-weight:400;font-size:13px;width:100%;padding:7px 12px}.nui-menu .nui-menu-item .nui-menu-item__option .nui-checkbox__label:focus,.nui-menu-popup-host .nui-menu-item .nui-menu-item__option .nui-checkbox__label:focus,.nui-menu-popup .nui-menu-item .nui-menu-item__option .nui-checkbox__label:focus{border-radius:0;background-color:var(--transparent,transparent)}.nui-menu .nui-menu-item .nui-menu-item__option .nui-menu-item__checkbox,.nui-menu-popup-host .nui-menu-item .nui-menu-item__option .nui-menu-item__checkbox,.nui-menu-popup .nui-menu-item .nui-menu-item__option .nui-menu-item__checkbox{width:100%}.nui-menu .nui-menu-item .nui-menu-item__option .nui-menu-item__checkbox>.nui-checkbox,.nui-menu-popup-host .nui-menu-item .nui-menu-item__option .nui-menu-item__checkbox>.nui-checkbox,.nui-menu-popup .nui-menu-item .nui-menu-item__option .nui-menu-item__checkbox>.nui-checkbox{padding:0}.nui-menu .nui-menu-item .nui-menu-item__option .nui-checkbox__translucent,.nui-menu-popup-host .nui-menu-item .nui-menu-item__option .nui-checkbox__translucent,.nui-menu-popup .nui-menu-item .nui-menu-item__option .nui-checkbox__translucent{cursor:not-allowed}.nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option{padding:5px;color:var(--nui-color-off,#4d4d4d)}.nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option:active,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option:active,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option:active,.nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option:focus,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option:focus,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__option:focus{outline:0;box-shadow:none}.nui-menu .nui-menu-item.checked>.nui-menu-item__option,.nui-menu-popup-host .nui-menu-item.checked>.nui-menu-item__option,.nui-menu-popup .nui-menu-item.checked>.nui-menu-item__option{color:red}.nui-menu .nui-menu-item.checked>.nui-menu-item__option .nui-checkbox__label:hover,.nui-menu-popup-host .nui-menu-item.checked>.nui-menu-item__option .nui-checkbox__label:hover,.nui-menu-popup .nui-menu-item.checked>.nui-menu-item__option .nui-checkbox__label:hover{background-color:transparent}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.MenuGroupComponent, decorators: [{
                    type: Optional
                }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { name: [{
                type: Input
            }], value: [{
                type: Input
            }], checked: [{
                type: Input
            }], menuItem: [{
                type: ViewChild,
                args: ["menuOption"]
            }], stopPropagationOfClick: [{
                type: HostListener,
                args: ["click", ["$event"]]
            }], checkedClass: [{
                type: HostBinding,
                args: ["class.checked"]
            }] } });
//# sourceMappingURL=data:application/json;base64, 