"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PropertyEditorInteger = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const core_1 = require("@material-ui/core");
const PropertyEditorInteger = (props) => {
    const onChange = (event) => {
        try {
            let val = undefined;
            if (props.decimal) {
                val = parseFloat(event.target.value);
            }
            else {
                val = parseInt(event.target.value, 10);
            }
            if (props.max !== undefined && val > props.max) {
                val = props.max;
            }
            if (props.min !== undefined && val < props.min) {
                val = props.min;
            }
            if (props.parentDefaultValue && props.parentDefaultValue === val) {
                Reflect.set(props.editObject, props.propertyName, null);
            }
            else {
                Reflect.set(props.editObject, props.propertyName, val);
            }
            props.updateCallback();
        }
        catch { }
    };
    let value = Reflect.get(props.editObject, props.propertyName) ?? props.parentDefaultValue;
    if (!value && value !== 0) {
        value = "";
    }
    let variant = props.variant || "outlined";
    return ((0, jsx_runtime_1.jsx)(core_1.TextField, { "data-testid": "property-editor-integer", value: value, type: "number", label: props.label, onChange: onChange, helperText: props.hint, autoFocus: props.autoFocus, variant: variant }));
};
exports.PropertyEditorInteger = PropertyEditorInteger;
//# sourceMappingURL=PropertyEditorInteger.js.map