import { Component, HostBinding, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, EventEmitter, forwardRef, ChangeDetectorRef } from '@angular/core';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { NG_VALUE_ACCESSOR, FormControl } from '@angular/forms';
import { uniqueId } from '@eui/core';
import { BaseDirective } from '../../base.directive';
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/slide-toggle";
export class EuiSlideToggleComponent extends BaseDirective {
    constructor(cd) {
        super();
        this.cd = cd;
        this.id = `eui-slide-toggle-${uniqueId()}`;
        this._isChecked = false;
        this._disabled = false;
        this.changed = new EventEmitter();
        this.slideToggleControl = new FormControl();
        this.onChange = () => { };
        this.onTouch = () => { };
    }
    get isChecked() { return this._isChecked; }
    set isChecked(value) { this._isChecked = coerceBooleanProperty(value); }
    get disabled() { return this._disabled; }
    set disabled(value) { this._disabled = coerceBooleanProperty(value); }
    get cssClasses() {
        return [
            super.getCssClasses('eui-slide-toggle'),
        ].join(' ').trim();
    }
    onSlideChange(e) {
        this.isChecked = e.checked;
        this.changed.emit(e.checked);
        this.onChange(e.checked);
    }
    writeValue(value) {
        this.isChecked = value;
        this.cd.detectChanges();
    }
    setDisabledState(isDisabled) {
        this.disabled = isDisabled;
        this.cd.detectChanges();
    }
    registerOnChange(fn) {
        this.onChange = fn;
    }
    registerOnTouched(fn) {
        this.onTouch = fn;
    }
}
/** @nocollapse */ EuiSlideToggleComponent.ɵfac = function EuiSlideToggleComponent_Factory(t) { return new (t || EuiSlideToggleComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
/** @nocollapse */ EuiSlideToggleComponent.ɵcmp = i0.ɵɵdefineComponent({ type: EuiSlideToggleComponent, selectors: [["eui-slide-toggle"]], hostVars: 2, hostBindings: function EuiSlideToggleComponent_HostBindings(rf, ctx) { if (rf & 2) {
        i0.ɵɵclassMap(ctx.cssClasses);
    } }, inputs: { id: "id", isChecked: "isChecked", disabled: "disabled" }, outputs: { changed: "changed" }, features: [i0.ɵɵProvidersFeature([{
                provide: NG_VALUE_ACCESSOR,
                useExisting: forwardRef((() => EuiSlideToggleComponent)),
                multi: true,
            }]), i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 3, consts: [["aria-label", "Toggle", 3, "id", "checked", "disabled", "change"]], template: function EuiSlideToggleComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵelementStart(0, "mat-slide-toggle", 0);
        i0.ɵɵlistener("change", function EuiSlideToggleComponent_Template_mat_slide_toggle_change_0_listener($event) { return ctx.onSlideChange($event); });
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        i0.ɵɵproperty("id", ctx.id)("checked", ctx.isChecked)("disabled", ctx.disabled);
    } }, directives: [i1.MatSlideToggle], styles: [".mat-slide-toggle.mat-checked .mat-slide-toggle-thumb{background-color:#fffcf4}.mat-slide-toggle.mat-checked .mat-slide-toggle-bar{background-color:rgba(255,252,244,.54)}.mat-slide-toggle.mat-checked .mat-ripple-element{background-color:#fffcf4}.mat-slide-toggle.mat-primary.mat-checked .mat-slide-toggle-thumb{background-color:#004494}.mat-slide-toggle.mat-primary.mat-checked .mat-slide-toggle-bar{background-color:rgba(0,68,148,.54)}.mat-slide-toggle.mat-primary.mat-checked .mat-ripple-element{background-color:#004494}.mat-slide-toggle.mat-warn.mat-checked .mat-slide-toggle-thumb{background-color:#da2131}.mat-slide-toggle.mat-warn.mat-checked .mat-slide-toggle-bar{background-color:rgba(218,33,49,.54)}.mat-slide-toggle.mat-warn.mat-checked .mat-ripple-element{background-color:#da2131}.mat-slide-toggle:not(.mat-checked) .mat-ripple-element{background-color:#000}.mat-slide-toggle-thumb{background-color:#fafafa;box-shadow:0 2px 1px -1px rgba(0,0,0,.2),0 1px 1px 0 rgba(0,0,0,.14),0 1px 3px 0 rgba(0,0,0,.12)}.mat-slide-toggle-bar{background-color:rgba(0,0,0,.38)}.eui-slide-toggle .mat-slide-toggle{transform:scale(1)}.eui-slide-toggle .mat-slide-toggle .mat-slide-toggle-label{padding:0}.eui-slide-toggle .mat-slide-toggle .mat-slide-toggle-thumb{background-color:var(--eui-color-grey-lightester-2)}.eui-slide-toggle .mat-slide-toggle .mat-slide-toggle-bar{background-color:rgba(0,0,0,.25)}.eui-slide-toggle .mat-slide-toggle.mat-checked .mat-slide-toggle-bar{background-color:var(--eui-color-success-light)}.eui-slide-toggle--size-s .mat-slide-toggle-bar{transform:scale(.75)}.eui-slide-toggle--size-m .mat-slide-toggle-bar{transform:scale(1)}.eui-slide-toggle--size-l .mat-slide-toggle-bar{transform:scale(1.25)}.eui-slide-toggle--size-xl .mat-slide-toggle-bar{transform:scale(1.5)}.eui-slide-toggle--size-2xl .mat-slide-toggle-bar{transform:scale(2)}.eui-slide-toggle--size-2xl .mat-slide-toggle-ripple{transform:scale(1.35)}.eui-t-compact .eui-slide-toggle--size-m .mat-slide-toggle-bar,.eui-t-compact .eui-slide-toggle--size-s .mat-slide-toggle-bar{transform:scale(.75)}.eui-t-compact .eui-slide-toggle--size-l .mat-slide-toggle-bar{transform:scale(1)}.eui-t-compact .eui-slide-toggle--size-xl .mat-slide-toggle-bar{transform:scale(1.25)}.eui-t-compact .eui-slide-toggle--size-2xl .mat-slide-toggle-bar{transform:scale(1.5)}.eui-slide-toggle--primary .mat-slide-toggle .mat-slide-toggle-thumb{background-color:var(--eui-color-primary)}.eui-slide-toggle--primary .mat-slide-toggle .mat-slide-toggle-bar{background-color:rgba(0,0,0,.25)}.eui-slide-toggle--primary .mat-slide-toggle.mat-checked .mat-ripple-element,.eui-slide-toggle--primary .mat-slide-toggle.mat-checked .mat-slide-toggle-thumb{background-color:#004494;color:#fff}.eui-slide-toggle--primary .mat-slide-toggle.mat-checked .mat-slide-toggle-bar{background-color:var(--eui-color-primary-lighter)}.eui-slide-toggle--secondary .mat-slide-toggle .mat-slide-toggle-thumb{background-color:var(--eui-color-grey-lightester)}.eui-slide-toggle--secondary .mat-slide-toggle.mat-checked .mat-ripple-element,.eui-slide-toggle--secondary .mat-slide-toggle.mat-checked .mat-slide-toggle-thumb{background-color:#d2d2d2;color:#333}.eui-slide-toggle--secondary .mat-slide-toggle.mat-checked .mat-slide-toggle-bar{background-color:var(--eui-color-grey-lighter)}.eui-slide-toggle--info .mat-slide-toggle .mat-slide-toggle-thumb{background-color:var(--eui-color-info)}.eui-slide-toggle--info .mat-slide-toggle.mat-checked .mat-ripple-element,.eui-slide-toggle--info .mat-slide-toggle.mat-checked .mat-slide-toggle-thumb{background-color:#006fb4;color:#fff}.eui-slide-toggle--info .mat-slide-toggle.mat-checked .mat-slide-toggle-bar{background-color:var(--eui-color-info-lighter)}.eui-slide-toggle--success .mat-slide-toggle .mat-slide-toggle-thumb{background-color:var(--eui-color-success)}.eui-slide-toggle--success .mat-slide-toggle.mat-checked .mat-ripple-element,.eui-slide-toggle--success .mat-slide-toggle.mat-checked .mat-slide-toggle-thumb{background-color:#467a39;color:#fff}.eui-slide-toggle--success .mat-slide-toggle.mat-checked .mat-slide-toggle-bar{background-color:var(--eui-color-success-lighter)}.eui-slide-toggle--warning .mat-slide-toggle .mat-slide-toggle-thumb{background-color:var(--eui-color-warning)}.eui-slide-toggle--warning .mat-slide-toggle.mat-checked .mat-ripple-element,.eui-slide-toggle--warning .mat-slide-toggle.mat-checked .mat-slide-toggle-thumb{background-color:#f29527;color:#333}.eui-slide-toggle--warning .mat-slide-toggle.mat-checked .mat-slide-toggle-bar{background-color:var(--eui-color-warning-lighter)}.eui-slide-toggle--danger .mat-slide-toggle .mat-slide-toggle-thumb{background-color:var(--eui-color-danger)}.eui-slide-toggle--danger .mat-slide-toggle.mat-checked .mat-ripple-element,.eui-slide-toggle--danger .mat-slide-toggle.mat-checked .mat-slide-toggle-thumb{background-color:var(--eui-color-danger);color:#fff}.eui-slide-toggle--danger .mat-slide-toggle.mat-checked .mat-slide-toggle-bar{background-color:var(--eui-color-danger-lighter)}.eui-slide-toggle--accent .mat-slide-toggle .mat-slide-toggle-thumb{background-color:var(--eui-color-accent)}.eui-slide-toggle--accent .mat-slide-toggle.mat-checked .mat-ripple-element,.eui-slide-toggle--accent .mat-slide-toggle.mat-checked .mat-slide-toggle-thumb{background-color:var(--eui-color-accent);color:#333}.eui-slide-toggle--accent .mat-slide-toggle.mat-checked .mat-slide-toggle-bar{background-color:var(--eui-color-accent-lighter)}"], encapsulation: 2, changeDetection: 0 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiSlideToggleComponent, [{
        type: Component,
        args: [{
                templateUrl: './eui-slide-toggle.component.html',
                selector: 'eui-slide-toggle',
                styleUrls: ['./styles/index.scss'],
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                providers: [{
                        provide: NG_VALUE_ACCESSOR,
                        useExisting: forwardRef((() => EuiSlideToggleComponent)),
                        multi: true,
                    }],
            }]
    }], function () { return [{ type: i0.ChangeDetectorRef }]; }, { id: [{
            type: Input
        }], isChecked: [{
            type: Input
        }], disabled: [{
            type: Input
        }], changed: [{
            type: Output
        }], cssClasses: [{
            type: HostBinding,
            args: ['class']
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 