import { Component, ViewEncapsulation, Input, ElementRef, Renderer2, HostListener, forwardRef } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
var NzCheckboxComponent = (function () {
    function NzCheckboxComponent(_elementRef, _render) {
        this._elementRef = _elementRef;
        this._render = _render;
        this._prefixCls = 'ant-checkbox';
        this._innerPrefixCls = this._prefixCls + "-inner";
        this._inputPrefixCls = this._prefixCls + "-input";
        this._checked = false;
        this._focused = false;
        // ngModel Access
        this.onChange = Function.prototype;
        this.onTouched = Function.prototype;
        this.nzDisabled = false;
        this.nzIndeterminate = false;
        this._el = this._elementRef.nativeElement;
    }
    Object.defineProperty(NzCheckboxComponent.prototype, "nzChecked", {
        get: function () {
            return this._checked;
        },
        set: function (value) {
            this.updateValue(value);
        },
        enumerable: true,
        configurable: true
    });
    ;
    NzCheckboxComponent.prototype.onClick = function (e) {
        e.preventDefault();
        if (!this.nzDisabled) {
            this.updateValue(!this._checked);
        }
    };
    NzCheckboxComponent.prototype.updateValue = function (value) {
        if (value === this._checked) {
            return;
        }
        this.onChange(value);
        this._checked = value;
    };
    NzCheckboxComponent.prototype.nzFocus = function () {
        this._focused = true;
    };
    NzCheckboxComponent.prototype.nzBlur = function () {
        this._focused = false;
    };
    Object.defineProperty(NzCheckboxComponent.prototype, "_classMap", {
        get: function () {
            return _a = {},
                _a[this._prefixCls] = true,
                _a[this._prefixCls + "-checked"] = this._checked && (!this.nzIndeterminate),
                _a[this._prefixCls + "-focused"] = this._focused,
                _a[this._prefixCls + "-disabled"] = this.nzDisabled,
                _a[this._prefixCls + "-indeterminate"] = this.nzIndeterminate,
                _a;
            var _a;
        },
        enumerable: true,
        configurable: true
    });
    NzCheckboxComponent.prototype.writeValue = function (value) {
        this._checked = value;
    };
    NzCheckboxComponent.prototype.registerOnChange = function (fn) {
        this.onChange = fn;
    };
    NzCheckboxComponent.prototype.registerOnTouched = function (fn) {
        this.onTouched = fn;
    };
    NzCheckboxComponent.prototype.ngOnInit = function () {
        this._render.addClass(this._el, this._prefixCls + "-wrapper");
    };
    return NzCheckboxComponent;
}());
export { NzCheckboxComponent };
NzCheckboxComponent.decorators = [
    { type: Component, args: [{
                selector: '[nz-checkbox]',
                encapsulation: ViewEncapsulation.None,
                template: "\n    <span [ngClass]=\"_classMap\">\n      <span [ngClass]=\"_innerPrefixCls\"></span>\n      <input type=\"checkbox\"\n        [ngClass]=\"_inputPrefixCls\"\n        [(ngModel)]=\"nzChecked\"\n        (focus)=\"nzFocus()\"\n        (blur)=\"nzBlur()\">\n    </span>\n    <ng-content></ng-content>\n  ",
                providers: [
                    {
                        provide: NG_VALUE_ACCESSOR,
                        useExisting: forwardRef(function () { return NzCheckboxComponent; }),
                        multi: true
                    }
                ],
                styles: [
                    "/* stylelint-disable at-rule-empty-line-before,at-rule-name-space-after,at-rule-no-unknown */\n/* stylelint-disable declaration-bang-space-before */\n/* stylelint-disable declaration-bang-space-before */\n@keyframes antCheckboxEffect {\n  0% {\n    transform: scale(1);\n    opacity: 0.5;\n  }\n  100% {\n    transform: scale(1.6);\n    opacity: 0;\n  }\n}\n.ant-checkbox {\n  white-space: nowrap;\n  cursor: pointer;\n  outline: none;\n  display: inline-block;\n  line-height: 1;\n  position: relative;\n  vertical-align: text-bottom;\n}\n.ant-checkbox-wrapper:hover .ant-checkbox-inner,\n.ant-checkbox:hover .ant-checkbox-inner,\n.ant-checkbox-input:focus + .ant-checkbox-inner {\n  border-color: #108ee9;\n}\n.ant-checkbox-checked:after {\n  position: absolute;\n  top: 0;\n  left: 0;\n  width: 100%;\n  height: 100%;\n  border-radius: 2px;\n  border: 1px solid #108ee9;\n  content: '';\n  animation: antCheckboxEffect 0.36s ease-in-out;\n  animation-fill-mode: both;\n  visibility: hidden;\n}\n.ant-checkbox:hover:after,\n.ant-checkbox-wrapper:hover .ant-checkbox:after {\n  visibility: visible;\n}\n.ant-checkbox-inner {\n  position: relative;\n  top: 0;\n  left: 0;\n  display: block;\n  width: 14px;\n  height: 14px;\n  border: 1px solid #d9d9d9;\n  border-radius: 2px;\n  background-color: #fff;\n  transition: all .3s;\n}\n.ant-checkbox-inner:after {\n  transform: rotate(45deg) scale(0);\n  position: absolute;\n  left: 4px;\n  top: 1px;\n  display: table;\n  width: 5px;\n  height: 8px;\n  border: 2px solid #fff;\n  border-top: 0;\n  border-left: 0;\n  content: ' ';\n  transition: all 0.1s cubic-bezier(0.71, -0.46, 0.88, 0.6);\n}\n.ant-checkbox-input {\n  position: absolute;\n  left: 0;\n  z-index: 1;\n  cursor: pointer;\n  opacity: 0;\n  filter: alpha(opacity=0);\n  top: 0;\n  bottom: 0;\n  right: 0;\n  width: 100%;\n  height: 100%;\n}\n.ant-checkbox-indeterminate .ant-checkbox-inner:after {\n  content: ' ';\n  transform: scale(1);\n  position: absolute;\n  left: 2px;\n  top: 5px;\n  width: 8px;\n  height: 1px;\n}\n.ant-checkbox-indeterminate.ant-checkbox-disabled .ant-checkbox-inner:after {\n  border-color: rgba(0, 0, 0, 0.25);\n}\n.ant-checkbox-checked .ant-checkbox-inner:after {\n  transform: rotate(45deg) scale(1);\n  position: absolute;\n  left: 4px;\n  top: 1px;\n  display: table;\n  width: 5px;\n  height: 8px;\n  border: 2px solid #fff;\n  border-top: 0;\n  border-left: 0;\n  content: ' ';\n  transition: all 0.2s cubic-bezier(0.12, 0.4, 0.29, 1.46) 0.1s;\n}\n.ant-checkbox-checked .ant-checkbox-inner,\n.ant-checkbox-indeterminate .ant-checkbox-inner {\n  background-color: #108ee9;\n  border-color: #108ee9;\n}\n.ant-checkbox-disabled {\n  cursor: not-allowed;\n}\n.ant-checkbox-disabled.ant-checkbox-checked .ant-checkbox-inner:after {\n  animation-name: none;\n  border-color: rgba(0, 0, 0, 0.25);\n}\n.ant-checkbox-disabled .ant-checkbox-input {\n  cursor: not-allowed;\n}\n.ant-checkbox-disabled .ant-checkbox-inner {\n  border-color: #d9d9d9 !important;\n  background-color: #f7f7f7;\n}\n.ant-checkbox-disabled .ant-checkbox-inner:after {\n  animation-name: none;\n  border-color: #f7f7f7;\n}\n.ant-checkbox-disabled + span {\n  color: rgba(0, 0, 0, 0.25);\n  cursor: not-allowed;\n}\n.ant-checkbox-wrapper {\n  cursor: pointer;\n  font-size: 12px;\n  display: inline-block;\n}\n.ant-checkbox-wrapper:not(:last-child) {\n  margin-right: 8px;\n}\n.ant-checkbox-wrapper + span,\n.ant-checkbox + span {\n  padding-left: 8px;\n  padding-right: 8px;\n}\n.ant-checkbox-group {\n  font-size: 12px;\n}\n.ant-checkbox-group-item {\n  display: inline-block;\n}\n@media \0screen {\n  .ant-checkbox-checked .ant-checkbox-inner:before,\n  .ant-checkbox-checked .ant-checkbox-inner:after {\n    font-family: 'anticon';\n    text-rendering: optimizeLegibility;\n    -webkit-font-smoothing: antialiased;\n    -moz-osx-font-smoothing: grayscale;\n    content: \"\\e632\";\n    font-weight: bold;\n    font-size: 8px;\n    border: 0;\n    color: #fff;\n    left: 2px;\n    top: 3px;\n    position: absolute;\n  }\n}\n"
                ]
            },] },
];
/** @nocollapse */
NzCheckboxComponent.ctorParameters = function () { return [
    { type: ElementRef, },
    { type: Renderer2, },
]; };
NzCheckboxComponent.propDecorators = {
    'nzDisabled': [{ type: Input },],
    'nzIndeterminate': [{ type: Input },],
    'nzChecked': [{ type: Input },],
    'onClick': [{ type: HostListener, args: ['click', ['$event'],] },],
};
