/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Component, forwardRef, Input } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { FormFieldAbstract } from '../form/form-field.abstract';
import { getBooleanValue } from '../../utils/get-boolean-value.util';
export class SwitchComponent extends FormFieldAbstract {
    constructor() {
        super();
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        this.initValues();
    }
    /**
     * @return {?}
     */
    initValues() {
        const { defaultProps } = SwitchComponent;
        this.className = this.classNameInput || defaultProps.className;
        this.disabled = getBooleanValue(this.disabledInput, defaultProps.disabled);
        this.id = this.idInput || defaultProps.id;
        this.name = this.nameInput || defaultProps.name;
        this.required = getBooleanValue(this.requiredInput, defaultProps.required);
        this.value = getBooleanValue(this.valueInput, defaultProps.value);
        this.isFocused = false;
    }
    /**
     * @return {?}
     */
    toggleValue() {
        if (!this.disabled) {
            this.isFocused = false;
            this.value = !this.value;
            this.onChange(this.value);
        }
    }
    /**
     * @param {?} event
     * @return {?}
     */
    onBlur(event) {
        this.isFocused = false;
    }
    /**
     * @param {?} event
     * @return {?}
     */
    onFocus(event) {
        if (!this.disabled) {
            this.isFocused = true;
            this.onTouched();
        }
    }
    /**
     * @param {?} isDisabled
     * @return {?}
     */
    setDisabledState(isDisabled) {
        this.disabled = isDisabled;
    }
    /**
     * @param {?} value
     * @return {?}
     */
    writeValue(value) {
        this.value = value;
    }
    /**
     * @param {?} fn
     * @return {?}
     */
    registerOnChange(fn) {
        this.onChange = fn;
    }
    /**
     * @param {?} fn
     * @return {?}
     */
    registerOnTouched(fn) {
        this.onTouched = fn;
    }
    /**
     * @param {?} value
     * @return {?}
     */
    onChange(value) { }
    /**
     * @return {?}
     */
    onTouched() { }
}
SwitchComponent.defaultProps = {
    className: '',
    disabled: false,
    id: '',
    name: '',
    required: false,
    value: false
};
SwitchComponent.decorators = [
    { type: Component, args: [{
                providers: [{
                        provide: FormFieldAbstract,
                        useExisting: forwardRef((/**
                         * @return {?}
                         */
                        () => SwitchComponent))
                    }, {
                        multi: true,
                        provide: NG_VALUE_ACCESSOR,
                        useExisting: forwardRef((/**
                         * @return {?}
                         */
                        () => SwitchComponent))
                    }],
                selector: 'materialize-switch',
                template: "\n<div class=\"form-switch-container\" [ngClass]=\"className\">\n  <div class=\"form-switch-label-container\">\n    <ng-content></ng-content>\n  </div>\n  <div class=\"form-switch-control-container\">\n    <div class=\"form-switch-control\"\n      (click)=\"toggleValue()\"\n      (focus)=\"onFocus($event)\"\n      (blur)=\"onBlur($event)\"\n\n      [class.active]=\"value\"\n      [class.disabled]=\"disabled\"\n      [class.focused]=\"isFocused\"\n\n      [tabindex]=\"disabled ? '-1': '0'\">\n      <div class=\"form-switch-indicator\">\n        <div class=\"form-switch-indicator-ripple\" materializeRipple [isRippleActive]=\"!disabled\" [rippleDuration]=\"200\"></div>\n      </div>\n    </div>\n    <input\n      type=\"checkbox\"\n      [disabled]=\"disabled\"\n      [id]=\"id\"\n      [name]=\"name\"\n      [required]=\"required\"\n      [value]=\"value\"\n    />\n  </div>\n</div>\n",
                styles: [".form-switch-container{display:flex;flex-direction:row;padding:16px 0;position:relative}.form-switch-container input[type=checkbox]{display:none}.form-switch-label-container{align-items:center;color:#000;display:flex;flex:1;font-family:Roboto;font-size:16px;font-weight:300}.form-switch-control-container{padding:0 12px}.form-switch-indicator{background:#fff;border-radius:50%;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);height:20px;left:0;margin-top:-3px;outline:0;position:absolute;top:0;transition:left 150ms ease-in;width:20px}.form-switch-indicator-ripple{border-radius:50%;height:40px;left:50%;position:absolute;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);transition:background-color .3s;width:40px;z-index:10}.form-switch-control{background-color:#b7b7b7;border-radius:100px;cursor:pointer;height:14px;outline:0;position:relative;-webkit-tap-highlight-color:transparent;width:34px}.form-switch-control:hover:not(.disabled).active .form-switch-indicator-ripple{background-color:rgba(87,7,235,.1)}.form-switch-control:hover:not(.disabled) .form-switch-indicator-ripple{background-color:rgba(106,106,106,.1)}.form-switch-control.active{background-color:#b58ffc}.form-switch-control.active .form-switch-indicator{background-color:#5707eb;left:14px}.form-switch-control.active .form-switch-indicator-ripple ::ng-deep .ripple{background-color:rgba(87,7,235,.3)}.form-switch-control.focused:not(.disabled).active .form-switch-indicator-ripple{background-color:rgba(87,7,235,.3)}.form-switch-control.focused:not(.disabled) .form-switch-indicator-ripple{background-color:rgba(106,106,106,.3)}.form-switch-control.disabled{background-color:#f4f3f4;cursor:not-allowed}.form-switch-control.disabled.active,.form-switch-control.disabled.active .form-switch-indicator{background-color:#d6c1fd}.form-switch-control.disabled .form-switch-indicator{background-color:#f4f3f4}.form-switch-control.disabled .ripple-element{cursor:not-allowed}:host.ng-touched.ng-dirty.ng-invalid .form-switch-control{background-color:#eda1a6}:host.ng-touched.ng-dirty.ng-invalid .form-switch-control:hover .form-switch-indicator-ripple{background-color:rgba(162,32,39,.1)}:host.ng-touched.ng-dirty.ng-invalid .form-switch-control .form-switch-indicator{background-color:#a22027}:host.ng-touched.ng-dirty.ng-invalid .form-switch-control .form-switch-indicator-ripple ::ng-deep .ripple{background-color:rgba(162,32,39,.3)}"]
            }] }
];
/** @nocollapse */
SwitchComponent.ctorParameters = () => [];
SwitchComponent.propDecorators = {
    classNameInput: [{ type: Input, args: ['className',] }],
    disabledInput: [{ type: Input, args: ['disabled',] }],
    idInput: [{ type: Input, args: ['id',] }],
    nameInput: [{ type: Input, args: ['name',] }],
    requiredInput: [{ type: Input, args: ['required',] }],
    valueInput: [{ type: Input, args: ['value',] }]
};
if (false) {
    /** @type {?} */
    SwitchComponent.defaultProps;
    /** @type {?} */
    SwitchComponent.prototype.classNameInput;
    /** @type {?} */
    SwitchComponent.prototype.disabledInput;
    /** @type {?} */
    SwitchComponent.prototype.idInput;
    /** @type {?} */
    SwitchComponent.prototype.nameInput;
    /** @type {?} */
    SwitchComponent.prototype.requiredInput;
    /** @type {?} */
    SwitchComponent.prototype.valueInput;
    /** @type {?} */
    SwitchComponent.prototype.className;
    /** @type {?} */
    SwitchComponent.prototype.disabled;
    /** @type {?} */
    SwitchComponent.prototype.id;
    /** @type {?} */
    SwitchComponent.prototype.isFocused;
    /** @type {?} */
    SwitchComponent.prototype.name;
    /** @type {?} */
    SwitchComponent.prototype.required;
    /** @type {?} */
    SwitchComponent.prototype.value;
}
//# sourceMappingURL=data:application/json;base64, 