import * as tslib_1 from "tslib";
import { Component, Input, EventEmitter, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
import { describeArc } from '../util/svg';
import { OnChange } from '../core/decorators';
/**
 * Circular Progress Bar Component
 */
var ProgressBarCircleComponent = /** @class */ (function () {
    function ProgressBarCircleComponent() {
        var _this = this;
        /**
         * circle radius(in pixels)
         * @default 124
         */
        this.radius = 124;
        /**
         * progress bar percentage, 0~100
         * @default 0
         */
        this.percent = 0;
        /**
         * @docs-private
         */
        this.percentChange = new EventEmitter();
        /**
         * Whether the progress is in success
         * @default false
         */
        this.isSuccess = false;
        /**
         * success text when done
         * @default 完成
         */
        this.successText = '完成';
        /**
         * Whether the progress is in error
         * @default false
         */
        this.isError = false;
        /**
         * error text when in error
         * @default 错误
         */
        this.errorText = '错误';
        /**
         * Whether show progress text
         * @default false
         */
        this.showProgressText = false;
        /**
         * current percentage path's d string
         * @docs-private
         */
        this.circlePath = 'M 0 0';
        this.percentChange.subscribe(function (percent) {
            var r = _this.radius;
            var deg = Math.floor(percent / 100 * 360);
            if (deg > 359.9999) {
                deg = 359.9999;
            }
            _this.circlePath = describeArc(r, r, r, 0, deg);
        });
    }
    Object.defineProperty(ProgressBarCircleComponent.prototype, "progressText", {
        /**
         * get progress text
         * @docs-private
         */
        get: function () {
            if (this.isError) {
                return this.errorText;
            }
            if (this.isSuccess) {
                return this.successText;
            }
            return this.percent + '%';
        },
        enumerable: true,
        configurable: true
    });
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Number)
    ], ProgressBarCircleComponent.prototype, "radius", void 0);
    tslib_1.__decorate([
        OnChange(),
        Input(),
        tslib_1.__metadata("design:type", Number)
    ], ProgressBarCircleComponent.prototype, "percent", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Boolean)
    ], ProgressBarCircleComponent.prototype, "isSuccess", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", String)
    ], ProgressBarCircleComponent.prototype, "successText", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Boolean)
    ], ProgressBarCircleComponent.prototype, "isError", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", String)
    ], ProgressBarCircleComponent.prototype, "errorText", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Boolean)
    ], ProgressBarCircleComponent.prototype, "showProgressText", void 0);
    ProgressBarCircleComponent = tslib_1.__decorate([
        Component({
            selector: 'nb-progress-bar-circle',
            template: "<svg class=\"svg\" [attr.width]=\"radius * 2\" [attr.height]=\"radius * 2\"><circle [attr.cx]=\"radius\" [attr.cy]=\"radius\" [attr.r]=\"radius\" class=\"svg-back-circle\"></circle><path [attr.d]=\"circlePath\" class=\"svg-front-circle\"></path></svg><div *ngIf=\"showProgressText\" class=\"progress-text\">{{ progressText }}</div>",
            encapsulation: ViewEncapsulation.None,
            changeDetection: ChangeDetectionStrategy.OnPush,
            preserveWhitespaces: false,
            host: {
                'class': 'nb-widget nb-progress-bar-circle',
                '[class.success]': 'isSuccess',
                '[class.error]': 'isError'
            },
            exportAs: 'nbProgressBarCircle'
        }),
        tslib_1.__metadata("design:paramtypes", [])
    ], ProgressBarCircleComponent);
    return ProgressBarCircleComponent;
}());
export { ProgressBarCircleComponent };
//# sourceMappingURL=progress-bar-circle.js.map