import { h } from "@stencil/core";
import { generateId } from "@boldpenguin/sdk-utility";
export class BpSdkButton {
    constructor() {
        this.text = undefined;
        this.buttonId = generateId(8);
        this.buttonDisabled = false;
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-button');
        customElements.whenDefined('bp-sdk-external-button').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-button", { buttonId: this.buttonId, text: this.text, buttonDisabled: this.buttonDisabled }, h("slot", null)));
    }
    renderInternal() {
        return (h("button", { type: "button", class: "bp-sdk-button", id: this.buttonId, disabled: this.buttonDisabled }, h("slot", null), h("span", { class: "bp-sdk-button__text" }, this.text)));
    }
    static get is() { return "bp-sdk-button"; }
    static get originalStyleUrls() {
        return {
            "$": ["bp-sdk-button.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-button.css"]
        };
    }
    static get properties() {
        return {
            "text": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Text to be displayed"
                },
                "attribute": "text",
                "reflect": false
            },
            "buttonId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Id for button"
                },
                "attribute": "button-id",
                "reflect": false,
                "defaultValue": "generateId(8)"
            },
            "buttonDisabled": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Controls disabled state of button"
                },
                "attribute": "button-disabled",
                "reflect": false,
                "defaultValue": "false"
            }
        };
    }
    static get states() {
        return {
            "useExternal": {}
        };
    }
}
