import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _objectWithoutProperties } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import { withMode } from "../../dataSourceForm/utils.js";
import ReadPretty from "./ReadPretty.js";
import React, { useCallback } from "react";
import { InputNumber } from "antd";
//#region src/components/dataSourceComponents/fields/InputNumber/WithMode.tsx
const _excluded = [
	"useThousandsSeparator",
	"formatter",
	"parser"
];
const InputNumber$1 = (props) => {
	const { useThousandsSeparator, formatter: propsFormatter, parser: propsParser } = props, rest = _objectWithoutProperties(props, _excluded);
	const formatter = useCallback((value, info) => {
		if (!value) return "";
		if (useThousandsSeparator) {
			const parts = value.toString().split(".");
			parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
			return parts.join(".");
		}
		return propsFormatter ? propsFormatter(value, info) : value.toString();
	}, [useThousandsSeparator, propsFormatter]);
	const parser = useCallback((value) => {
		if (!value) return null;
		if (useThousandsSeparator) return value.replace(/,/g, "");
		return propsParser ? propsParser(value) : value;
	}, [useThousandsSeparator, propsParser]);
	return /* @__PURE__ */ React.createElement(InputNumber, _objectSpread2(_objectSpread2({}, rest), {}, {
		formatter,
		parser
	}));
};
const InputNumberWithMode = withMode(InputNumber$1, ReadPretty);
//#endregion
export { InputNumberWithMode as default };
