/*
 * Copyright (C) 2016-2020 Kano Computing Ltd.
 * License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 */
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import '@kano/styles/color.js';
import { LitElement, css, svg, customElement, html, property } from 'lit-element/lit-element.js';
let KcCircleProgress = class KcCircleProgress extends LitElement {
    constructor() {
        super(...arguments);
        this.radius = 56;
        this.strokeWidth = 8;
        this.value = 0.5;
    }
    static get styles() {
        return [css `
            :host {
                display: block;
            }
            #circle-full {
                fill: transparent;
                stroke:var(--color-stone);
                stroke-linecap: round;
            }
            #circle {
                fill: transparent;
                stroke:var(--color-amber);
                transition: stroke-dashoffset linear 200ms;
                stroke-linecap: round;
                display: block;
            }
        `];
    }
    render() {
        return html `
            <svg xmlns="http://www.w3.org/2000/svg" id="svg" width=${this.radius} height=${this.radius} viewBox="0 0 ${this.radius} ${this.radius}">${this.renderCircles()}</svg>
        `;
    }
    renderCircles() {
        const r = this.radius / 2 - this.strokeWidth / 2;
        const c = Math.PI * (r * 2);
        const val = Math.max(0, Math.min(1, this.value));
        return svg `
            <circle id="circle-full"
                    cx=${this.radius / 2}
                    cy=${this.radius / 2}
                    r=${r}
                    stroke-width="${this.strokeWidth}px"></circle>
            <circle id="circle"
                    cx=${this.radius / 2}
                    cy=${this.radius / 2}
                    r=${r}
                    stroke-width="${this.strokeWidth}px"
                    stroke-dasharray=${c}
                    stroke-dashoffset=${(1 - val) * c}
                    transform="rotate(270, ${this.radius / 2}, ${this.radius / 2})"></circle>
        `;
    }
};
__decorate([
    property({ type: Number })
], KcCircleProgress.prototype, "radius", void 0);
__decorate([
    property({ type: Number })
], KcCircleProgress.prototype, "strokeWidth", void 0);
__decorate([
    property({ type: Number })
], KcCircleProgress.prototype, "value", void 0);
KcCircleProgress = __decorate([
    customElement('kc-circle-progress')
], KcCircleProgress);
export { KcCircleProgress };
//# sourceMappingURL=kc-circle-progress.js.map