const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../pisellModal/index.js");
const require_index$1 = require("../../input/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
//#region src/components/productCard/hooks/useOpenNote.tsx
const useOpenNote = ({ onNoteChange }, ref) => {
	const [open, setOpen] = (0, react.useState)(false);
	const [item, setItem] = (0, react.useState)({});
	const [value, setValue] = (0, react.useState)();
	(0, react.useImperativeHandle)(ref, () => {
		return { open: ({ item }) => {
			setItem(item);
			setValue(item === null || item === void 0 ? void 0 : item.note);
			setOpen(true);
		} };
	});
	const handleOk = () => {
		onNoteChange(value);
		setOpen(false);
	};
	return /* @__PURE__ */ react.default.createElement(require_index.default, {
		platform: (0, _pisell_utils.isMobile)() ? "h5" : "pc",
		open,
		bodyStyle: { padding: 0 },
		title: (item === null || item === void 0 ? void 0 : item.note) ? _pisell_utils.locales.getText("pisell2.product.card.discount.edit.note") : _pisell_utils.locales.getText("pisell2.product.card.discount.add.note"),
		onCancel: () => setOpen(false),
		onOk: handleOk,
		destroyOnClose: true,
		mobileModalHeight: "80vh",
		className: "pisell-lowcode__booking-select-pet-modal-wrap",
		okText: _pisell_utils.locales.getText("pisell2.product.card.confirm"),
		cancelText: _pisell_utils.locales.getText("pisell2.product.card.cancel")
	}, /* @__PURE__ */ react.default.createElement(require_index$1.default.TextArea, {
		size: "large",
		placeholder: _pisell_utils.locales.getText("pisell2.product.card.note.pla"),
		autoSize: { minRows: 4 },
		allowClear: true,
		value,
		onChange: (e) => {
			setValue(e.target.value);
		}
	}));
};
var useOpenNote_default = (0, react.forwardRef)(useOpenNote);
//#endregion
exports.default = useOpenNote_default;
