import { h, Fragment } from "@stencil/core";
export class BpSdkLabel {
    constructor() {
        this.label = undefined;
        this.helpText = undefined;
        this.value = undefined;
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-label');
        customElements.whenDefined('bp-sdk-external-label').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return h("bp-sdk-external-label", { label: this.label, helpText: this.helpText, value: this.value });
    }
    renderInternal() {
        return (h(Fragment, null, h("bp-sdk-label-before", { label: this.label, helpText: this.helpText }), h("div", { class: "bp-sdk-label__container" }, this.renderLabel()), h("bp-sdk-label-after", { label: this.label, helpText: this.helpText })));
    }
    renderLabel() {
        if (!!this.value) {
            return (h("div", { class: "bp-sdk-label__content_and_value" }, this.label, " : ", this.value));
        }
        return h("div", { class: "bp-sdk-label__content", innerHTML: this.label });
    }
    static get is() { return "bp-sdk-label"; }
    static get originalStyleUrls() {
        return {
            "$": ["bp-sdk-label.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-label.css"]
        };
    }
    static get properties() {
        return {
            "label": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "html to render"
                },
                "attribute": "label",
                "reflect": false
            },
            "helpText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Help text"
                },
                "attribute": "help-text",
                "reflect": false
            },
            "value": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The label's associated value"
                },
                "attribute": "value",
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "useExternal": {}
        };
    }
}
