import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { PropertyEditorText } from "../../CommonUI/PropertyEditing/PropertyEditorText";
import { PropertyEditorBoolean } from "../../CommonUI/PropertyEditing/PropertyEditorBoolean";
import { Collapse, Tooltip } from "@material-ui/core";
import { BaseTextEntryControl } from "./BaseTextEntryControl";
import { PropertyEditorInteger } from "../../CommonUI/PropertyEditing/PropertyEditorInteger";
export class XImageControl extends BaseTextEntryControl {
    constructor() {
        super(...arguments);
        this.staticImageLink = true;
        this.tooltip = "";
    }
    getAddedData() {
        return;
    }
    render() {
        const customWidth = this.fullWidth
            ? "100%"
            : this.width
                ? `${this.width}px`
                : "200px";
        let imageSource = this.staticImageLink ? this.link ? this.link : "" : this.valueName ? this.getFormDataValue(this.valueName) : "";
        return (_jsx("div", { children: _jsx(Tooltip, Object.assign({ title: this.tooltip }, { children: _jsx("input", { type: "image", src: imageSource, width: customWidth, "data-testid": "image", value: (this.valueName) ? this.getFormDataValue(this.valueName) : "", alt: "" }, void 0) }), void 0) }, void 0));
    }
    renderEditUI() {
        return _jsx(XImageFieldEditUi, { editMe: this }, void 0);
    }
}
function XImageFieldEditUi(props) {
    return (_jsxs(_Fragment, { children: [_jsx(PropertyEditorText, { label: "Tooltip", updateCallback: props.editMe.controlUpdate, propertyName: "tooltip", editObject: props.editMe }, void 0),
            _jsx(PropertyEditorBoolean, { label: "Static Image Link", updateCallback: props.editMe.controlUpdate, propertyName: "staticImageLink", editObject: props.editMe }, void 0),
            _jsx(Collapse, Object.assign({ in: props.editMe.staticImageLink }, { children: _jsx(PropertyEditorText, { label: "Static Image Link", updateCallback: props.editMe.controlUpdate, propertyName: "link", editObject: props.editMe }, void 0) }), void 0),
            _jsx(Collapse, Object.assign({ in: !props.editMe.staticImageLink }, { children: _jsx(PropertyEditorText, { editObject: props.editMe, label: "Value Name", propertyName: "valueName", updateCallback: props.editMe.controlUpdate }, void 0) }), void 0),
            _jsx(PropertyEditorBoolean, { label: "Full Width", updateCallback: props.editMe.controlUpdate, propertyName: "fullWidth", editObject: props.editMe }, void 0),
            _jsx(Collapse, Object.assign({ in: !props.editMe.fullWidth }, { children: _jsx(PropertyEditorInteger, { label: "Width", updateCallback: props.editMe.controlUpdate, propertyName: "width", editObject: props.editMe }, void 0) }), void 0)] }, void 0));
}
//# sourceMappingURL=XImageControl.js.map