const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_types = require("../../types.js");
const require_index = require("../CupInfoCard/index.js");
const require_index$1 = require("../CustomerCard/index.js");
const require_hooks = require("./hooks.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/components/ecocup/components/CupActionModal/index.tsx
const CupActionModal = (props) => {
	var _cupData$rent_shop;
	const { visible, onCancel, onOk, data } = props;
	const { type, cupData } = data || {};
	const cupAction = require_hooks.useCupAction();
	const style = (0, react.useMemo)(() => {
		if ((data === null || data === void 0 ? void 0 : data.type) === require_types.ECupActionType.MISSING || (data === null || data === void 0 ? void 0 : data.type) === require_types.ECupActionType.BROKEN) return {
			backgroundColor: "#FEE4E2",
			color: "#F04438"
		};
		return {
			backgroundColor: "#F6F2FF",
			color: "#7F56DA"
		};
	}, [data === null || data === void 0 ? void 0 : data.type]);
	const _onCancel = () => {
		if (cupAction === null || cupAction === void 0 ? void 0 : cupAction.loading) return;
		onCancel === null || onCancel === void 0 || onCancel();
	};
	const _onOk = () => {
		if (cupAction === null || cupAction === void 0 ? void 0 : cupAction.loading) return;
		cupAction.run((cupData === null || cupData === void 0 ? void 0 : cupData.eco_cup_id) || (cupData === null || cupData === void 0 ? void 0 : cupData.id), type).then((res) => {
			if (res) {
				(0, _pisell_materials.PisellToast)({ content: _pisell_utils.locales.getText(`pisell2.text.ecocup.toast.success-${type}`) });
				onOk === null || onOk === void 0 || onOk(cupData);
			}
		});
	};
	return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal, {
		open: visible,
		headerDivider: false,
		title: _pisell_utils.locales.getText(`pisell2.text.ecocup.cup-action-modal.title-${data === null || data === void 0 ? void 0 : data.type}`),
		onCancel: _onCancel,
		onOk: _onOk,
		okText: _pisell_utils.locales.getText(`pisell2.text.ecocup.button.mark-as-${data === null || data === void 0 ? void 0 : data.type}`),
		cancelText: _pisell_utils.locales.getText("pisell2.text.ecocup.button.cancel"),
		okButtonProps: { loading: cupAction === null || cupAction === void 0 ? void 0 : cupAction.loading },
		width: 580,
		destroyOnClose: true,
		wrapClassName: "pisell2-ecocup-cup-action-modal"
	}, /* @__PURE__ */ react.default.createElement("div", { className: "pisell2-ecocup-cup-action-modal-content" }, /* @__PURE__ */ react.default.createElement("div", {
		className: "pisell2-ecocup-cup-action-modal-content-cup",
		style: require_objectSpread2._objectSpread2({}, style)
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, {
		type: "RestOutlined",
		size: 24
	}), /* @__PURE__ */ react.default.createElement("span", { style: { color: (data === null || data === void 0 ? void 0 : data.type) === require_types.ECupActionType.RETURN ? "#667085" : "#F04438" } }, _pisell_utils.locales.getText("pisell2.text.ecocup.cup-action-modal.cup-id")), /* @__PURE__ */ react.default.createElement("span", null, (cupData === null || cupData === void 0 ? void 0 : cupData.eco_cup_code) || (cupData === null || cupData === void 0 ? void 0 : cupData.code) || "")), /* @__PURE__ */ react.default.createElement("div", { className: "pisell2-ecocup-cup-action-modal-info" }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell2-ecocup-cup-action-modal-info-left" }, /* @__PURE__ */ react.default.createElement(require_index.default, {
		type: "rentInfo",
		data: {
			shop: cupData === null || cupData === void 0 || (_cupData$rent_shop = cupData.rent_shop) === null || _cupData$rent_shop === void 0 ? void 0 : _cupData$rent_shop.name,
			time: cupData === null || cupData === void 0 ? void 0 : cupData.rent_time
		}
	})), /* @__PURE__ */ react.default.createElement("div", { className: "pisell2-ecocup-cup-action-modal-info-right" }, /* @__PURE__ */ react.default.createElement(require_index$1.default, data === null || data === void 0 ? void 0 : data.customerData)))));
};
//#endregion
exports.default = CupActionModal;
