import { jsx as _jsx } from "react/jsx-runtime";
import { TextField } from "@material-ui/core";
export const PropertyEditorInteger = (props) => {
    var _a;
    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 (_a) { }
    };
    let value = (_a = Reflect.get(props.editObject, props.propertyName)) !== null && _a !== void 0 ? _a : props.parentDefaultValue;
    if (!value && value !== 0) {
        value = "";
    }
    let variant = props.variant || "outlined";
    return (_jsx(TextField, { "data-testid": "property-editor-integer", value: value, type: "number", label: props.label, onChange: onChange, helperText: props.hint, autoFocus: props.autoFocus, variant: variant }, void 0));
};
//# sourceMappingURL=PropertyEditorInteger.js.map