import { ChangeDetectionStrategy, Component, forwardRef } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import * as i0 from "@angular/core";
import * as i1 from "../../directives/evo-ui-class.directive";
import * as i2 from "@angular/forms";
export class EvoToggleComponent {
    constructor(changeDetector) {
        this.changeDetector = changeDetector;
        this.isDisabled = false;
        this.onChange = (_value) => { };
        this.onTouched = () => { };
    }
    get value() {
        return this._value;
    }
    set value(value) {
        if (value !== this._value) {
            this._value = value;
            this.onChange(value);
        }
    }
    get totalClasses() {
        const classes = [];
        if (this.isDisabled) {
            classes.push('disabled');
        }
        return classes;
    }
    writeValue(value) {
        if (value !== this._value) {
            this._value = value;
            this.changeDetector.detectChanges();
        }
    }
    registerOnChange(fn) {
        this.onChange = fn;
    }
    registerOnTouched(fn) {
        this.onTouched = fn;
    }
    setDisabledState(state) {
        this.isDisabled = state;
        this.changeDetector.detectChanges();
    }
}
EvoToggleComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: EvoToggleComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
EvoToggleComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: EvoToggleComponent, selector: "evo-toggle", providers: [
        {
            provide: NG_VALUE_ACCESSOR,
            useExisting: forwardRef(() => EvoToggleComponent),
            multi: true,
        },
    ], ngImport: i0, template: "<label class=\"evo-toggle\" [evoUiClass]=\"totalClasses\">\n    <input type=\"checkbox\" [(ngModel)]=\"value\" [disabled]=\"isDisabled\">\n    <span class=\"slider\"></span>\n</label>\n", styles: [":host{position:relative;display:inline-block}.evo-toggle{display:flex;justify-content:center;align-items:center;width:40px;height:24px;cursor:pointer}.evo-toggle_disabled{cursor:default;opacity:.5}.evo-toggle input{display:none}.slider{position:absolute;display:inline-block;width:34px;height:14px;background-color:#c6c6c6;border-radius:16px;transition:background-color .3s;mix-blend-mode:normal}.slider:before{position:absolute;top:-3px;left:-3px;width:20px;height:20px;background-color:#f4f6f8;border-radius:50%;box-shadow:0 1px 3px #0003,0 2px 2px #0000001f,0 0 2px #00000024;transition:color .3s,background-color .3s,transform .3s;content:\"\"}input[type=checkbox]:checked+.slider{background:rgba(9,134,226,.5)}input[type=checkbox]:checked+.slider:before{right:0;left:0;background-color:#0986e2;transform:translate(18px);pointer-events:none}\n"], directives: [{ type: i1.EvoUiClassDirective, selector: "[evoUiClass]", inputs: ["class", "evoUiClass"] }, { type: i2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { 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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: EvoToggleComponent, decorators: [{
            type: Component,
            args: [{ selector: 'evo-toggle', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
                        {
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: forwardRef(() => EvoToggleComponent),
                            multi: true,
                        },
                    ], template: "<label class=\"evo-toggle\" [evoUiClass]=\"totalClasses\">\n    <input type=\"checkbox\" [(ngModel)]=\"value\" [disabled]=\"isDisabled\">\n    <span class=\"slider\"></span>\n</label>\n", styles: [":host{position:relative;display:inline-block}.evo-toggle{display:flex;justify-content:center;align-items:center;width:40px;height:24px;cursor:pointer}.evo-toggle_disabled{cursor:default;opacity:.5}.evo-toggle input{display:none}.slider{position:absolute;display:inline-block;width:34px;height:14px;background-color:#c6c6c6;border-radius:16px;transition:background-color .3s;mix-blend-mode:normal}.slider:before{position:absolute;top:-3px;left:-3px;width:20px;height:20px;background-color:#f4f6f8;border-radius:50%;box-shadow:0 1px 3px #0003,0 2px 2px #0000001f,0 0 2px #00000024;transition:color .3s,background-color .3s,transform .3s;content:\"\"}input[type=checkbox]:checked+.slider{background:rgba(9,134,226,.5)}input[type=checkbox]:checked+.slider:before{right:0;left:0;background-color:#0986e2;transform:translate(18px);pointer-events:none}\n"] }]
        }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
//# sourceMappingURL=data:application/json;base64, 