import { h } from "@stencil/core";
import { linker } from '../../utils/input-linker';
export class BceElementLinkTemplate {
    constructor() {
        this.href = '';
        this.text = '';
        this.icon = '';
        this.labelHref = 'Reference';
        this.labelText = 'Text';
        this.labelIcon = 'Icon';
        this.placeholderHref = 'https://example.com';
        this.placeholderText = 'Example';
        this.placeholderIcon = 'globe';
        this._link = linker(this, this.handleInput);
        this._href = this._link('href');
        this._text = this._link('text');
        this._icon = this._link('icon');
    }
    handleInput(name, event) {
        const input = event.target;
        if (!input)
            return;
        event.cancelBubble = true;
        this[name] = input.value;
        this.value = this.updateValue({ [name]: input.value });
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    updateValue(part = {}) {
        const current = {
            href: this.href,
            text: this.text,
            icon: this.icon
        };
        return Object.assign({}, current, part);
    }
    componentDidLoad() {
        this.value = this.updateValue();
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    render() {
        return [
            h("bce-input", Object.assign({ type: "text" }, this._href)),
            h("bce-input", Object.assign({ type: "text" }, this._text)),
            h("bce-input", Object.assign({ type: "text" }, this._icon))
        ];
    }
    static get is() { return "bce-element-link-template"; }
    static get properties() { return {
        "value": {
            "type": "unknown",
            "mutable": false,
            "complexType": {
                "original": "LinkTemplate",
                "resolved": "undefined | { readonly text: string; readonly href: string; readonly icon: string; }",
                "references": {
                    "LinkTemplate": {
                        "location": "local"
                    }
                }
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            }
        },
        "href": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "href",
            "reflect": false,
            "defaultValue": "''"
        },
        "text": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "text",
            "reflect": false,
            "defaultValue": "''"
        },
        "icon": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "icon",
            "reflect": false,
            "defaultValue": "''"
        },
        "labelHref": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-href",
            "reflect": false,
            "defaultValue": "'Reference'"
        },
        "labelText": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-text",
            "reflect": false,
            "defaultValue": "'Text'"
        },
        "labelIcon": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-icon",
            "reflect": false,
            "defaultValue": "'Icon'"
        },
        "placeholderHref": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "placeholder-href",
            "reflect": false,
            "defaultValue": "'https://example.com'"
        },
        "placeholderText": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "placeholder-text",
            "reflect": false,
            "defaultValue": "'Example'"
        },
        "placeholderIcon": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "placeholder-icon",
            "reflect": false,
            "defaultValue": "'globe'"
        }
    }; }
    static get elementRef() { return "el"; }
}
