import PisellModal from "../../pisellModal/index.js";
import Input from "../../input/index.js";
import React, { forwardRef, useImperativeHandle, useState } from "react";
import { isMobile, locales } from "@pisell/utils";
//#region src/components/productCard/hooks/useOpenNote.tsx
const useOpenNote = ({ onNoteChange }, ref) => {
	const [open, setOpen] = useState(false);
	const [item, setItem] = useState({});
	const [value, setValue] = useState();
	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.createElement(PisellModal, {
		platform: isMobile() ? "h5" : "pc",
		open,
		bodyStyle: { padding: 0 },
		title: (item === null || item === void 0 ? void 0 : item.note) ? locales.getText("pisell2.product.card.discount.edit.note") : 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: locales.getText("pisell2.product.card.confirm"),
		cancelText: locales.getText("pisell2.product.card.cancel")
	}, /* @__PURE__ */ React.createElement(Input.TextArea, {
		size: "large",
		placeholder: locales.getText("pisell2.product.card.note.pla"),
		autoSize: { minRows: 4 },
		allowClear: true,
		value,
		onChange: (e) => {
			setValue(e.target.value);
		}
	}));
};
var useOpenNote_default = forwardRef(useOpenNote);
//#endregion
export { useOpenNote_default as default };
