/**
 * @fileoverview added by tsickle
 * Generated from: components/checkbox/checkbox.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/*
 MIT License

 Copyright (c) 2019 Temainfo Software

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
 The above copyright notice and this permission notice shall be included in all
 copies or substantial portions of the Software.
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 */
import { Component, Input, ViewChild, Output, EventEmitter, Optional, Self } from '@angular/core';
import { NgControl } from '@angular/forms';
import { ValueAccessorBase } from '../input/core/value-accessor';
export class TlCheckBox extends ValueAccessorBase {
    /**
     * @param {?} ngControl
     */
    constructor(ngControl) {
        super();
        this.ngControl = ngControl;
        this.label = '';
        this.tabindex = '0';
        this.disabled = null;
        this.color = 'basic';
        this.indeterminate = false;
        this.labelWidth = 'auto';
        this.checkBox = new EventEmitter();
        this.focusBox = new EventEmitter();
        this._checked = false;
        this.setControl();
    }
    /**
     * @param {?} value
     * @return {?}
     */
    set checked(value) {
        this._checked = value;
        this.value = value;
    }
    /**
     * @return {?}
     */
    get checked() {
        return this._checked;
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        if (!this.label) {
            throw new EvalError('The [label] property is required!');
        }
    }
    /**
     * @return {?}
     */
    get control() {
        var _a;
        return (_a = this.ngControl) === null || _a === void 0 ? void 0 : _a.control;
    }
    /**
     * @return {?}
     */
    setControl() {
        if (this.ngControl) {
            this.ngControl.valueAccessor = this;
        }
    }
    /**
     * @param {?} boolean
     * @return {?}
     */
    check(boolean) {
        if (this.checkbox.nativeElement.indeterminate) {
            this.checkbox.nativeElement.indeterminate = false;
            this.value = true;
            this.emitEvent();
            return;
        }
        if (!this.disabled) {
            this.value = !boolean;
            this.emitEvent();
        }
    }
    /**
     * @return {?}
     */
    emitEvent() {
        this.checkBox.emit(this.value);
    }
    /**
     * @return {?}
     */
    focusCheckBox() {
        this.focusBox.emit(this.value);
    }
    /**
     * @param {?} changes
     * @return {?}
     */
    ngOnChanges(changes) {
        if (changes['indeterminate']) {
            this.checkbox.nativeElement.indeterminate = changes['indeterminate'].currentValue;
        }
    }
}
TlCheckBox.decorators = [
    { type: Component, args: [{
                selector: 'tl-checkbox',
                template: "<div [class]=\"'check-container '+ color\">\n  <input #checkbox\n         class=\"ui-check-input\"\n         type=\"checkbox\"\n         #model=\"ngModel\"\n         (change)=\"emitEvent()\"\n         [checked]=\"value\"\n         [attr.disabled]=\"disabled\"\n         [tabindex]=\"tabindex\"\n         [(ngModel)]=\"value\">\n  <label class=\"cbx\" (click)=\"check(value)\">\n    <span tabindex=\"-1\" (focus)=\"focusCheckBox()\" (keydown.space)=\"$event.preventDefault(); check(value)\">\n      <svg width=\"12px\" height=\"10px\" viewBox=\"0 0 12 10\" *ngIf=\"!checkbox.indeterminate\">\n        <polyline points=\"1.5 6 4.5 9 10.5 1\"></polyline>\n      </svg>\n      <svg width=\"12px\" height=\"10px\" *ngIf=\"checkbox.indeterminate\" style=\"stroke: none\">\n        <rect width=\"16\" height=\"2\" y=\"4\" style=\"fill:white;\"></rect>\n      </svg>\n    </span>\n    <span class=\"checkbox-label\" [style.width]=\"labelWidth\">{{label}}</span>\n  </label>\n</div>\n",
                styles: [".cbx{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;cursor:pointer;margin:auto;user-select:none}.cbx span{display:inline-block;transform:translateZ(0);vertical-align:middle}.cbx span:first-child{border:1px solid #9098a9;border-radius:3px;height:18px;position:relative;transform:scale(1);transition:all .2s ease;vertical-align:middle;width:18px}.cbx span:first-child svg{fill:none;left:2px;position:absolute;stroke-dasharray:16px;stroke-dashoffset:16px;stroke-linecap:round;stroke-linejoin:round;stroke-width:2;top:3px;transform:translateZ(0);transition:all .3s ease;transition-delay:.1s}.cbx span:first-child svg:before{border-radius:50%;content:\"\";display:block;height:100%;opacity:1;transform:scale(0);width:100%}.ui-check-input{display:none}.ui-check-input:indeterminate+.cbx span:first-child{-webkit-animation:wave .4s ease;animation:wave .4s ease}.ui-check-input:indeterminate+.cbx span:first-child svg{stroke-dashoffset:0}.ui-check-input:indeterminate+.cbx span:first-child:before{opacity:0;transform:scale(3.5);transition:all .6s ease}.ui-check-input:checked+.cbx span:first-child{-webkit-animation:wave .4s ease;animation:wave .4s ease}.ui-check-input:checked+.cbx span:first-child svg{stroke-dashoffset:0}.ui-check-input:checked+.cbx span:first-child:before{opacity:0;transform:scale(3.5);transition:all .6s ease}@-webkit-keyframes wave{50%{transform:scale(.9)}}@keyframes wave{50%{transform:scale(.9)}}.checkbox-label{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;font-family:Segoe UI,Lato,\"sans-serif\",Arial;font-size:12px;font-weight:400!important;left:5px;margin:0!important;position:relative;user-select:none}.checkbox-label:hover{cursor:pointer}"]
            }] }
];
/** @nocollapse */
TlCheckBox.ctorParameters = () => [
    { type: NgControl, decorators: [{ type: Optional }, { type: Self }] }
];
TlCheckBox.propDecorators = {
    checked: [{ type: Input, args: ['checked',] }],
    label: [{ type: Input }],
    tabindex: [{ type: Input }],
    disabled: [{ type: Input }],
    color: [{ type: Input }],
    indeterminate: [{ type: Input }],
    labelWidth: [{ type: Input }],
    checkbox: [{ type: ViewChild, args: ['checkbox', { static: true },] }],
    checkBox: [{ type: Output }],
    focusBox: [{ type: Output }]
};
if (false) {
    /** @type {?} */
    TlCheckBox.prototype.label;
    /** @type {?} */
    TlCheckBox.prototype.tabindex;
    /** @type {?} */
    TlCheckBox.prototype.disabled;
    /** @type {?} */
    TlCheckBox.prototype.color;
    /** @type {?} */
    TlCheckBox.prototype.indeterminate;
    /** @type {?} */
    TlCheckBox.prototype.labelWidth;
    /** @type {?} */
    TlCheckBox.prototype.checkbox;
    /** @type {?} */
    TlCheckBox.prototype.checkBox;
    /** @type {?} */
    TlCheckBox.prototype.focusBox;
    /**
     * @type {?}
     * @private
     */
    TlCheckBox.prototype._checked;
    /** @type {?} */
    TlCheckBox.prototype.ngControl;
}
//# sourceMappingURL=data:application/json;base64, 