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 PisellAdjustPrice from "./index.js";
import React, { useMemo, useState } from "react";
import { InputNumber, Popover } from "antd";
//#region src/components/pisellAdjustPrice/PisellAdjustPriceInputNumber.tsx
const _excluded = [
	"value",
	"onChange",
	"originValue",
	"size",
	"prefix",
	"disabled"
];
const PisellAdjustPriceInputNumber = (props) => {
	const { value, onChange, originValue, size, prefix, disabled } = props, others = _objectWithoutProperties(props, _excluded);
	const [open, setOpen] = useState(false);
	const handleChange = (val) => {
		setOpen(false);
		onChange === null || onChange === void 0 || onChange(Number(val.toFixed(2)));
	};
	const content = useMemo(() => {
		return /* @__PURE__ */ React.createElement(PisellAdjustPrice, {
			key: `${open}`,
			originValue,
			defaultValue: value,
			value,
			onChange: handleChange
		});
	}, [
		originValue,
		value,
		open
	]);
	return /* @__PURE__ */ React.createElement(Popover, {
		open,
		content,
		trigger: ["click"],
		overlayInnerStyle: { padding: 0 },
		onOpenChange: (val) => setOpen(val),
		destroyTooltipOnHide: true,
		arrow: false,
		align: { offset: [0, 20] }
	}, /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(InputNumber, _objectSpread2(_objectSpread2({}, others), {}, {
		disabled,
		prefix,
		size: size || "large",
		value,
		readOnly: true
	}))));
};
//#endregion
export { PisellAdjustPriceInputNumber as default };
