const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
//#region src/components/booking/hooks/useClearCart.tsx
const useClearCart = (state, dispatch) => {
	var _state$service3;
	const [open, setOpen] = (0, react.useState)(false);
	const handleOpenModal = (0, react.useCallback)(() => {
		setOpen(true);
	}, []);
	const handleConfirm = (0, react.useCallback)(() => {
		dispatch({
			type: "setService",
			payload: { value: [] }
		});
		setOpen(false);
	}, []);
	const handleCancel = (0, react.useCallback)(() => {
		setOpen(false);
	}, []);
	return (0, react.useMemo)(() => {
		var _state$service, _state$service2;
		const showClearBtn = !!((_state$service = state.service) === null || _state$service === void 0 || (_state$service = _state$service.value) === null || _state$service === void 0 ? void 0 : _state$service.length) && !state.channelDisabledEdit;
		return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, showClearBtn && /* @__PURE__ */ react.default.createElement("span", {
			className: (0, classnames.default)("pisell-lowcode__booking-service-clear-btn", { ["pisell-lowcode__booking-service-clear-btn-disabled"]: !((_state$service2 = state.service) === null || _state$service2 === void 0 || (_state$service2 = _state$service2.value) === null || _state$service2 === void 0 ? void 0 : _state$service2.length) }),
			onClick: handleOpenModal
		}, /* @__PURE__ */ react.default.createElement(_pisell_materials.Iconfont, { type: "pisell2-trash-01" }), " ", /* @__PURE__ */ react.default.createElement("span", null, _pisell_utils.locales.getText("pisell2.booking.info.text.clear-cart"))), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal, {
			open,
			platform: "pc",
			title: _pisell_utils.locales.getText("pisell2.booking.info.text.clear-cart-modal.title"),
			onOk: handleConfirm,
			onCancel: handleCancel,
			okText: _pisell_utils.locales.getText("pisell2.booking.info.text.clear-cart-modal.confirm"),
			cancelText: _pisell_utils.locales.getText("pisell2.booking.info.text.clear-cart-modal.cancel"),
			destroyOnClose: true
		}, /* @__PURE__ */ react.default.createElement("div", { style: { margin: "24px 0" } }, /* @__PURE__ */ react.default.createElement("span", null, _pisell_utils.locales.getText("pisell2.booking.info.text.clear-cart-modal.content")))));
	}, [
		(_state$service3 = state.service) === null || _state$service3 === void 0 || (_state$service3 = _state$service3.value) === null || _state$service3 === void 0 ? void 0 : _state$service3.length,
		state.channelDisabledEdit,
		open
	]);
};
//#endregion
exports.default = useClearCart;
