import { MDCLinearProgress } from '@material/linear-progress';
import { h } from '@stencil/core';
export class LinearProgress {
    constructor() {
        this.backgroundColor = '#00e676'; // default color
    }
    async show() {
        return this.opened ? this.close() : this.open();
    }
    async close() {
        this.mdcLinearProgressEl.close();
        this.opened = false;
    }
    async open() {
        this.mdcLinearProgressEl.open();
        this.opened = true;
    }
    componentDidLoad() {
        this.mdcLinearProgressEl = new MDCLinearProgress(this.linearEl);
        if (this.timeout && this.timeout > 0) {
            this.open();
            setTimeout(() => this.close(), this.timeout);
        }
    }
    componentWillUpdate() {
        if (this.timeout > 0) {
            this.open();
            setTimeout(() => { this.close(); this.timeout = 0; }, this.timeout);
        }
    }
    getClasses() {
        return {
            'mdc-linear-progress': true,
            'mdc-linear-progress--closed': !this.opened,
            'mdc-linear-progress--indeterminate': this.indeterminate,
        };
    }
    render() {
        return (h("div", { role: "progressbar", class: this.getClasses(), ref: el => this.linearEl = el },
            h("div", { class: "mdc-linear-progress__buffering-dots" }),
            h("div", { class: "mdc-linear-progress__buffer" }),
            h("div", { class: "mdc-linear-progress__bar mdc-linear-progress__primary-bar" },
                h("span", { class: "mdc-linear-progress__bar-inner", style: { 'background-color': this.backgroundColor } })),
            h("div", { class: "mdc-linear-progress__bar mdc-linear-progress__secondary-bar" },
                h("span", { class: "mdc-linear-progress__bar-inner", style: { 'background-color': this.backgroundColor } }))));
    }
    static get is() { return "materials-linear-progress"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() { return {
        "$": ["linear-progress.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["linear-progress.css"]
    }; }
    static get properties() { return {
        "indeterminate": {
            "type": "boolean",
            "mutable": false,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "indeterminate",
            "reflect": false
        },
        "opened": {
            "type": "boolean",
            "mutable": true,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "opened",
            "reflect": false
        },
        "backgroundColor": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "background-color",
            "reflect": false,
            "defaultValue": "'#00e676'"
        },
        "timeout": {
            "type": "number",
            "mutable": true,
            "complexType": {
                "original": "number",
                "resolved": "number",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "timeout",
            "reflect": false
        }
    }; }
    static get methods() { return {
        "show": {
            "complexType": {
                "signature": "() => Promise<void>",
                "parameters": [],
                "references": {
                    "Promise": {
                        "location": "global"
                    }
                },
                "return": "Promise<void>"
            },
            "docs": {
                "text": "",
                "tags": []
            }
        },
        "close": {
            "complexType": {
                "signature": "() => Promise<void>",
                "parameters": [],
                "references": {
                    "Promise": {
                        "location": "global"
                    }
                },
                "return": "Promise<void>"
            },
            "docs": {
                "text": "",
                "tags": []
            }
        },
        "open": {
            "complexType": {
                "signature": "() => Promise<void>",
                "parameters": [],
                "references": {
                    "Promise": {
                        "location": "global"
                    }
                },
                "return": "Promise<void>"
            },
            "docs": {
                "text": "",
                "tags": []
            }
        }
    }; }
}
