import { Component, EventEmitter, forwardRef, Input, Output, ViewChild, } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { EvoControlStates } from '../../common/evo-control-state-manager/evo-control-states.enum';
import { EvoBaseControl } from '../../common/evo-base-control';
import * as i0 from "@angular/core";
import * as i1 from "../evo-control-error/evo-control-error.component";
import * as i2 from "@angular/forms";
import * as i3 from "../../directives/evo-ui-class.directive";
import * as i4 from "@angular/common";
export class EvoCheckboxComponent extends EvoBaseControl {
    constructor(injector, cdr) {
        super(injector);
        this.injector = injector;
        this.cdr = cdr;
        this.indeterminateChange = new EventEmitter();
        this.indeterminate = undefined;
        this.disabled = false;
        this.value = false;
    }
    set setIndeterminate(value) {
        this.indeterminate = value;
    }
    onChange(_value) { }
    onTouched() { }
    get checkboxClass() {
        return {
            invalid: this.currentState[EvoControlStates.invalid],
        };
    }
    onInputChange(value) {
        this.value = value;
        this.onChange(value);
        if (this.indeterminate === true) {
            this.indeterminate = false;
            this.indeterminateChange.emit(false);
        }
        this.cdr.markForCheck();
    }
    writeValue(value) {
        this.value = value;
        this.cdr.markForCheck();
    }
    registerOnChange(fn) {
        this.onChange = fn;
    }
    registerOnTouched(fn) {
        this.onTouched = fn;
    }
    setDisabledState(state) {
        this.disabled = state;
        this.cdr.markForCheck();
    }
}
EvoCheckboxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: EvoCheckboxComponent, deps: [{ token: i0.Injector }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
EvoCheckboxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: EvoCheckboxComponent, selector: "evo-checkbox", inputs: { setIndeterminate: ["indeterminate", "setIndeterminate"] }, outputs: { indeterminateChange: "indeterminateChange" }, providers: [
        {
            provide: NG_VALUE_ACCESSOR,
            useExisting: forwardRef(() => EvoCheckboxComponent),
            multi: true,
        },
    ], viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["inputElement"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<label class=\"evo-checkbox\">\n    <input\n        #inputElement\n        class=\"evo-checkbox__input\"\n        type=\"checkbox\"\n        [indeterminate]=\"indeterminate\"\n        [evoUiClass]=\"checkboxClass\"\n        [disabled]=\"disabled\"\n        [ngModel]=\"value\"\n        (ngModelChange)=\"onInputChange($event)\"\n    >\n    <span class=\"evo-checkbox__text\">\n        <ng-content></ng-content>\n    </span>\n</label>\n<evo-control-error\n    *ngIf=\"showErrors\"\n    [errors]=\"control.errors\"\n    [errorsMessages]=\"errorsMessages\"\n></evo-control-error>\n", styles: [":host{display:inline-block;color:#212121}.evo-checkbox{position:relative;display:inline-block;min-height:24px;margin:0;color:inherit}.evo-checkbox__input{position:absolute;top:1px;left:0;z-index:-1;width:16px;height:16px;opacity:0;appearance:none}.evo-checkbox__text{position:relative;display:inline-block;padding-top:1px;padding-left:32px;color:inherit;font-size:14px;line-height:22px;cursor:pointer;-webkit-user-select:none;user-select:none}.evo-checkbox__text:empty{padding-left:20px}.evo-checkbox__text:empty:after{content:\"1\";display:inline-block;width:0;visibility:hidden;opacity:0}.evo-checkbox__text:before{content:\"\";position:absolute;top:0;left:0;box-sizing:border-box;width:16px;height:16px;margin:4px;background:#FFFFFF none center;border:2px solid #C6C6C6;border-radius:2px;transition:background .3s,border-color .3s}input:checked+.evo-checkbox__text:before{background:#0986E2 url(\"data:image/svg+xml,%3Csvg width%3D%2216px%22 height%3D%2216px%22 viewBox%3D%220 0 16 16%22 version%3D%221.1%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22 xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22 fill%3D%22%23ffffff%22%3E    %3Cpath d%3D%22M6.85333%2C11.8133 C6.50667%2C12.16 5.94667%2C12.16 5.6%2C11.8133 L2.40889%2C8.62222 C2.06222%2C8.27556 2.06222%2C7.71556 2.40889%2C7.36889 C2.75556%2C7.02222 3.31556%2C7.02222 3.66222%2C7.36889 L6.22222%2C9.92889 L12.3378%2C3.81333 C12.6844%2C3.46667 13.2444%2C3.46667 13.5911%2C3.81333 C13.9378%2C4.16 13.9378%2C4.72 13.5911%2C5.06667 L6.85333%2C11.8133 Z%22 id%3D%22Shape%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E\") no-repeat center;border-color:#0986e2}input:indeterminate+.evo-checkbox__text:before{background:#0986E2 url(\"data:image/svg+xml,%3Csvg width%3D%2216px%22 height%3D%2216px%22 viewBox%3D%220 0 16 16%22 version%3D%221.1%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22 xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22 fill%3D%22%23ffffff%22%3E    %3Cpath d%3D%22M4%2C7 C3.44772%2C7 3%2C7.44772 3%2C8 C3%2C8.55229 3.44772%2C9 4%2C9 L12%2C9 C12.5523%2C9 13%2C8.55229 13%2C8 C13%2C7.44772 12.5523%2C7 12%2C7 L4%2C7 Z%22 id%3D%22Shape%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E\") no-repeat center;border-color:#0986e2}input:disabled:not(:checked)+.evo-checkbox__text{cursor:default}input:disabled:not(:checked)+.evo-checkbox__text:before{background-color:#f4f6f8;border-color:#c6c6c6}input.evo-checkbox_invalid+.evo-checkbox__text:before{border-color:#ff1817}input:disabled:checked+.evo-checkbox__text,input:disabled:indeterminate+.evo-checkbox__text{cursor:default}input:disabled:checked+.evo-checkbox__text:before,input:disabled:indeterminate+.evo-checkbox__text:before{background-color:#c6c6c6;border-color:#c6c6c6}\n"], components: [{ type: i1.EvoControlErrorComponent, selector: "evo-control-error", inputs: ["errors", "errorsMessages", "showCount"] }], directives: [{ type: i2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { type: i3.EvoUiClassDirective, selector: "[evoUiClass]", inputs: ["class", "evoUiClass"] }, { type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: EvoCheckboxComponent, decorators: [{
            type: Component,
            args: [{ selector: 'evo-checkbox', providers: [
                        {
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: forwardRef(() => EvoCheckboxComponent),
                            multi: true,
                        },
                    ], template: "<label class=\"evo-checkbox\">\n    <input\n        #inputElement\n        class=\"evo-checkbox__input\"\n        type=\"checkbox\"\n        [indeterminate]=\"indeterminate\"\n        [evoUiClass]=\"checkboxClass\"\n        [disabled]=\"disabled\"\n        [ngModel]=\"value\"\n        (ngModelChange)=\"onInputChange($event)\"\n    >\n    <span class=\"evo-checkbox__text\">\n        <ng-content></ng-content>\n    </span>\n</label>\n<evo-control-error\n    *ngIf=\"showErrors\"\n    [errors]=\"control.errors\"\n    [errorsMessages]=\"errorsMessages\"\n></evo-control-error>\n", styles: [":host{display:inline-block;color:#212121}.evo-checkbox{position:relative;display:inline-block;min-height:24px;margin:0;color:inherit}.evo-checkbox__input{position:absolute;top:1px;left:0;z-index:-1;width:16px;height:16px;opacity:0;appearance:none}.evo-checkbox__text{position:relative;display:inline-block;padding-top:1px;padding-left:32px;color:inherit;font-size:14px;line-height:22px;cursor:pointer;-webkit-user-select:none;user-select:none}.evo-checkbox__text:empty{padding-left:20px}.evo-checkbox__text:empty:after{content:\"1\";display:inline-block;width:0;visibility:hidden;opacity:0}.evo-checkbox__text:before{content:\"\";position:absolute;top:0;left:0;box-sizing:border-box;width:16px;height:16px;margin:4px;background:#FFFFFF none center;border:2px solid #C6C6C6;border-radius:2px;transition:background .3s,border-color .3s}input:checked+.evo-checkbox__text:before{background:#0986E2 url(\"data:image/svg+xml,%3Csvg width%3D%2216px%22 height%3D%2216px%22 viewBox%3D%220 0 16 16%22 version%3D%221.1%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22 xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22 fill%3D%22%23ffffff%22%3E    %3Cpath d%3D%22M6.85333%2C11.8133 C6.50667%2C12.16 5.94667%2C12.16 5.6%2C11.8133 L2.40889%2C8.62222 C2.06222%2C8.27556 2.06222%2C7.71556 2.40889%2C7.36889 C2.75556%2C7.02222 3.31556%2C7.02222 3.66222%2C7.36889 L6.22222%2C9.92889 L12.3378%2C3.81333 C12.6844%2C3.46667 13.2444%2C3.46667 13.5911%2C3.81333 C13.9378%2C4.16 13.9378%2C4.72 13.5911%2C5.06667 L6.85333%2C11.8133 Z%22 id%3D%22Shape%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E\") no-repeat center;border-color:#0986e2}input:indeterminate+.evo-checkbox__text:before{background:#0986E2 url(\"data:image/svg+xml,%3Csvg width%3D%2216px%22 height%3D%2216px%22 viewBox%3D%220 0 16 16%22 version%3D%221.1%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22 xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22 fill%3D%22%23ffffff%22%3E    %3Cpath d%3D%22M4%2C7 C3.44772%2C7 3%2C7.44772 3%2C8 C3%2C8.55229 3.44772%2C9 4%2C9 L12%2C9 C12.5523%2C9 13%2C8.55229 13%2C8 C13%2C7.44772 12.5523%2C7 12%2C7 L4%2C7 Z%22 id%3D%22Shape%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E\") no-repeat center;border-color:#0986e2}input:disabled:not(:checked)+.evo-checkbox__text{cursor:default}input:disabled:not(:checked)+.evo-checkbox__text:before{background-color:#f4f6f8;border-color:#c6c6c6}input.evo-checkbox_invalid+.evo-checkbox__text:before{border-color:#ff1817}input:disabled:checked+.evo-checkbox__text,input:disabled:indeterminate+.evo-checkbox__text{cursor:default}input:disabled:checked+.evo-checkbox__text:before,input:disabled:indeterminate+.evo-checkbox__text:before{background-color:#c6c6c6;border-color:#c6c6c6}\n"] }]
        }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { setIndeterminate: [{
                type: Input,
                args: ['indeterminate']
            }], indeterminateChange: [{
                type: Output
            }], inputElement: [{
                type: ViewChild,
                args: ['inputElement']
            }] } });
//# sourceMappingURL=data:application/json;base64, 