/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { Component, EventEmitter, forwardRef, Input, Output } 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';
var CheckboxComponent = /** @class */ (function (_super) {
    tslib_1.__extends(CheckboxComponent, _super);
    function CheckboxComponent() {
        var _this = _super.call(this) || this;
        _this.onChangeEmitter = new EventEmitter();
        return _this;
    }
    /**
     * @return {?}
     */
    CheckboxComponent.prototype.ngOnInit = /**
     * @return {?}
     */
    function () {
        this.initValues();
    };
    /**
     * @param {?} changes
     * @return {?}
     */
    CheckboxComponent.prototype.ngOnChanges = /**
     * @param {?} changes
     * @return {?}
     */
    function (changes) {
        var disabledInput = changes.disabledInput, indeterminateInput = changes.indeterminateInput, valueInput = changes.valueInput;
        if (valueInput && valueInput.currentValue !== valueInput.previousValue) {
            this.value = valueInput.currentValue;
        }
        if (disabledInput && disabledInput.currentValue !== disabledInput.previousValue) {
            this.disabled = disabledInput.currentValue;
        }
        if (indeterminateInput && indeterminateInput.currentValue !== indeterminateInput.previousValue) {
            this.indeterminate = indeterminateInput.currentValue;
        }
    };
    /**
     * @return {?}
     */
    CheckboxComponent.prototype.initValues = /**
     * @return {?}
     */
    function () {
        var defaultProps = CheckboxComponent.defaultProps;
        this.className = this.classNameInput || defaultProps.className;
        this.disabled = getBooleanValue(this.disabledInput, defaultProps.disabled);
        this.id = this.idInput || defaultProps.id;
        this.indeterminate = getBooleanValue(this.indeterminateInput, defaultProps.indeterminate);
        this.name = this.nameInput || defaultProps.name;
        this.required = getBooleanValue(this.requiredInput, defaultProps.required);
        this.value = getBooleanValue(this.valueInput, defaultProps.value);
        this.isFocused = false;
        this.isTouched = false;
    };
    /**
     * @return {?}
     */
    CheckboxComponent.prototype.toggleValue = /**
     * @return {?}
     */
    function () {
        if (!this.disabled) {
            this.value = !this.value;
            this.isFocused = false;
            this.onChange(this.value);
            this.onChangeEmitter.emit(this.value);
        }
    };
    /**
     * @param {?} event
     * @return {?}
     */
    CheckboxComponent.prototype.onFocus = /**
     * @param {?} event
     * @return {?}
     */
    function (event) {
        if (!this.disabled) {
            this.isFocused = true;
            this.onTouched();
        }
    };
    /**
     * @param {?} event
     * @return {?}
     */
    CheckboxComponent.prototype.onBlur = /**
     * @param {?} event
     * @return {?}
     */
    function (event) {
        this.isFocused = false;
        this.isTouched = true;
    };
    /**
     * @param {?} isDisabled
     * @return {?}
     */
    CheckboxComponent.prototype.setDisabledState = /**
     * @param {?} isDisabled
     * @return {?}
     */
    function (isDisabled) {
        this.disabled = isDisabled;
    };
    /**
     * @param {?} value
     * @return {?}
     */
    CheckboxComponent.prototype.writeValue = /**
     * @param {?} value
     * @return {?}
     */
    function (value) {
        this.value = value;
    };
    /**
     * @param {?} fn
     * @return {?}
     */
    CheckboxComponent.prototype.registerOnChange = /**
     * @param {?} fn
     * @return {?}
     */
    function (fn) {
        this.onChange = fn;
    };
    /**
     * @param {?} fn
     * @return {?}
     */
    CheckboxComponent.prototype.registerOnTouched = /**
     * @param {?} fn
     * @return {?}
     */
    function (fn) {
        this.onTouched = fn;
    };
    /**
     * @param {?} value
     * @return {?}
     */
    CheckboxComponent.prototype.onChange = /**
     * @param {?} value
     * @return {?}
     */
    function (value) { };
    /**
     * @return {?}
     */
    CheckboxComponent.prototype.onTouched = /**
     * @return {?}
     */
    function () { };
    CheckboxComponent.defaultProps = {
        className: '',
        disabled: false,
        id: '',
        indeterminate: false,
        name: '',
        required: false,
        value: false
    };
    CheckboxComponent.decorators = [
        { type: Component, args: [{
                    providers: [{
                            provide: FormFieldAbstract,
                            useExisting: forwardRef((/**
                             * @return {?}
                             */
                            function () { return CheckboxComponent; }))
                        }, {
                            multi: true,
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: forwardRef((/**
                             * @return {?}
                             */
                            function () { return CheckboxComponent; }))
                        }],
                    selector: 'materialize-checkbox',
                    template: "<div class=\"form-checkbox-container\" [ngClass]=\"className\">\n  <div class=\"form-checkbox-control\"\n    (click)=\"toggleValue()\"\n    (blur)=\"onBlur($event)\"\n    (focus)=\"onFocus($event)\"  \n\n    [class.active]=\"value\"\n    [class.focused]=\"isFocused\"\n    [class.indeterminate]=\"indeterminate && !value\"\n    [class.disabled]=\"disabled\"\n\n    [tabindex]=\"disabled ? '-1': '0'\">\n    <div class=\"form-checkbox-control-ripple\" materializeRipple [isRippleActive]=\"!disabled\" [rippleDuration]=\"200\"></div>\n    <input\n      type=\"checkbox\"\n      [disabled]=\"disabled\"\n      [id]=\"id\"\n      [name]=\"name\"\n      [required]=\"required\"\n      [checked]=\"value\"\n      [indeterminate]=\"indeterminate\"\n      [value]=\"value\"\n    />\n  </div>\n  <div class=\"form-checkbox-label-container\">\n    <ng-content></ng-content>\n  </div>\n</div>\n  ",
                    styles: [".form-checkbox-container{align-items:center;display:flex;flex-direction:row;padding:12px 0;position:relative}.form-checkbox-container input[type=checkbox]{display:none}.form-checkbox-label-container{color:#000;font-family:Roboto;font-size:16px;font-weight:300}.form-checkbox-control-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-checkbox-control{background:#fff;border:2px solid #6a6a6a;border-radius:2px;cursor:pointer;height:18px;margin:0 12px;outline:0;position:relative;width:18px}.form-checkbox-control::before{content:'';left:0;position:absolute;width:13px}.form-checkbox-control.active{background:#5707eb;border-color:#5707eb}.form-checkbox-control.active::before{border-bottom:2px solid #fff;border-left:2px solid #fff;height:7px;margin-top:-2px;top:50%;-webkit-transform:translateY(-50%) rotate(-45deg);transform:translateY(-50%) rotate(-45deg)}.form-checkbox-control.active .form-checkbox-control-ripple ::ng-deep .ripple{background-color:rgba(87,7,235,.3)}.form-checkbox-control.indeterminate{background:#5707eb;border-color:#5707eb}.form-checkbox-control.indeterminate::before{border-bottom:2px solid #fff;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%)}.form-checkbox-control:hover:not(.disabled).active .form-checkbox-control-ripple{background-color:rgba(87,7,235,.1)}.form-checkbox-control:hover:not(.disabled) .form-checkbox-control-ripple{background-color:rgba(106,106,106,.1)}.form-checkbox-control.focused:not(.disabled).active .form-checkbox-control-ripple{background-color:rgba(87,7,235,.3)}.form-checkbox-control.focused:not(.disabled) .form-checkbox-control-ripple{background-color:rgba(106,106,106,.3)}.form-checkbox-control.disabled{border-color:#b7b7b7;cursor:not-allowed}.form-checkbox-control.disabled.active,.form-checkbox-control.disabled.indeterminate{background-color:#b7b7b7}.form-checkbox-control.disabled .ripple-element{cursor:not-allowed}:host.ng-touched.ng-dirty.ng-invalid .form-checkbox-control{border-color:#a22027}:host.ng-touched.ng-dirty.ng-invalid .form-checkbox-control:hover .form-checkbox-control-ripple{background-color:rgba(162,32,39,.1)}:host.ng-touched.ng-dirty.ng-invalid .form-checkbox-control .form-checkbox-control-ripple ::ng-deep .ripple{background-color:rgba(162,32,39,.3)}"]
                }] }
    ];
    /** @nocollapse */
    CheckboxComponent.ctorParameters = function () { return []; };
    CheckboxComponent.propDecorators = {
        classNameInput: [{ type: Input, args: ['className',] }],
        disabledInput: [{ type: Input, args: ['disabled',] }],
        idInput: [{ type: Input, args: ['id',] }],
        indeterminateInput: [{ type: Input, args: ['indeterminate',] }],
        nameInput: [{ type: Input, args: ['name',] }],
        requiredInput: [{ type: Input, args: ['required',] }],
        valueInput: [{ type: Input, args: ['value',] }],
        onChangeEmitter: [{ type: Output, args: ['onChange',] }]
    };
    return CheckboxComponent;
}(FormFieldAbstract));
export { CheckboxComponent };
if (false) {
    /** @type {?} */
    CheckboxComponent.defaultProps;
    /** @type {?} */
    CheckboxComponent.prototype.classNameInput;
    /** @type {?} */
    CheckboxComponent.prototype.disabledInput;
    /** @type {?} */
    CheckboxComponent.prototype.idInput;
    /** @type {?} */
    CheckboxComponent.prototype.indeterminateInput;
    /** @type {?} */
    CheckboxComponent.prototype.nameInput;
    /** @type {?} */
    CheckboxComponent.prototype.requiredInput;
    /** @type {?} */
    CheckboxComponent.prototype.valueInput;
    /** @type {?} */
    CheckboxComponent.prototype.onChangeEmitter;
    /** @type {?} */
    CheckboxComponent.prototype.className;
    /** @type {?} */
    CheckboxComponent.prototype.disabled;
    /** @type {?} */
    CheckboxComponent.prototype.id;
    /** @type {?} */
    CheckboxComponent.prototype.indeterminate;
    /** @type {?} */
    CheckboxComponent.prototype.isFocused;
    /** @type {?} */
    CheckboxComponent.prototype.isTouched;
    /** @type {?} */
    CheckboxComponent.prototype.name;
    /** @type {?} */
    CheckboxComponent.prototype.required;
    /** @type {?} */
    CheckboxComponent.prototype.value;
}
//# sourceMappingURL=data:application/json;base64, 