import { h } from "@stencil/core";
import { ElementQuestionBase } from '../../../utils/element-question-base';
export class ElementRadioEditor {
    constructor() {
        this.label = {
            name: 'Header',
            labelQuestion: 'Formulate your question',
            labelRequired: 'Required',
            labelOCOptionAdd: 'Add Option',
            labelOCOptionRemove: 'Delete Option',
            labelOCOther: 'Other',
            labelOCOtherAdd: 'Add "Other"',
            labelOCOtherRemove: 'Remove "Other"',
            labelOCImageUpload: 'Upload Image',
            labelOCImageDelete: 'Delete Image',
            labelOrientation: 'Oriëntation',
            labelOrientationH: 'Horizontal',
            labelOrientationV: 'Vertical',
            placeholderOptions: 'Option'
        };
        this.handleOther = (event) => {
            const target = event.target;
            this.handler.set('options', target.value, { localize: true });
            this.handler.set('other', event.detail, { emit: true, localize: true });
        };
    }
    prop(path, options = {}) {
        return this.handler.prop(path, Object.assign(Object.assign({}, options), { label: this.label }));
    }
    render() {
        const { labelOrientationH, labelOrientationV } = this.label;
        return (h(ElementQuestionBase, { question: this.prop('question', { localize: true }), required: this.prop('required') },
            h("bce-option-creator", Object.assign({}, this.prop('options', { default: () => [], localize: true }), { "allow-other": true, label: this.label, other: this.handler.tryGet('other', { localize: true }), onOther: this.handleOther })),
            h("bce-select", Object.assign({}, this.prop('orientation'), { type: "radio" }),
                h("bce-option", { value: "horizontal" }, labelOrientationH),
                h("bce-option", { value: "vertical" }, labelOrientationV)),
            h("slot", null)));
    }
    static get is() { return "bce-element-radio-editor"; }
    static get encapsulation() { return "shadow"; }
    static get properties() { return {
        "handler": {
            "type": "unknown",
            "mutable": false,
            "complexType": {
                "original": "InputHandler",
                "resolved": "InputHandler",
                "references": {
                    "InputHandler": {
                        "location": "import",
                        "path": "../../../utils/input-handler"
                    }
                }
            },
            "required": true,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            }
        },
        "language": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string | undefined",
                "references": {}
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "language",
            "reflect": false
        },
        "label": {
            "type": "unknown",
            "mutable": false,
            "complexType": {
                "original": "RadioElement.Label",
                "resolved": "Label",
                "references": {
                    "RadioElement": {
                        "location": "import",
                        "path": "./element-radio"
                    }
                }
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "defaultValue": "{\n    name: 'Header',\n    labelQuestion: 'Formulate your question',\n    labelRequired: 'Required',\n    labelOCOptionAdd: 'Add Option',\n    labelOCOptionRemove: 'Delete Option',\n    labelOCOther: 'Other',\n    labelOCOtherAdd: 'Add \"Other\"',\n    labelOCOtherRemove: 'Remove \"Other\"',\n    labelOCImageUpload: 'Upload Image',\n    labelOCImageDelete: 'Delete Image',\n    labelOrientation: 'Ori\u00EBntation',\n    labelOrientationH: 'Horizontal',\n    labelOrientationV: 'Vertical',\n    placeholderOptions: 'Option'\n  }"
        }
    }; }
}
