const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_utils = require("../../../utils.js");
const require_model = require("../../model.js");
const require_utils$1 = require("../addTimeModal/utils.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
require("./index.less");
//#region src/components/booking/info/service/actions/index.tsx
const Actions = ({ currentService }) => {
	var _state$bookingConfig2;
	const { state, dispatch } = (0, react.useContext)(require_model.Context);
	const appointment_card = (0, react.useMemo)(() => {
		var _state$bookingConfig;
		return (state === null || state === void 0 || (_state$bookingConfig = state.bookingConfig) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.config) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.information_tab) === null || _state$bookingConfig === void 0 ? void 0 : _state$bookingConfig.appointment_card) || { quick_time: 1 };
	}, [state === null || state === void 0 || (_state$bookingConfig2 = state.bookingConfig) === null || _state$bookingConfig2 === void 0 || (_state$bookingConfig2 = _state$bookingConfig2.config) === null || _state$bookingConfig2 === void 0 ? void 0 : _state$bookingConfig2.information_tab]);
	const onAddTime = () => {
		dispatch({
			type: "setService",
			payload: {
				addTimeModal: true,
				cacheItem: currentService
			}
		});
	};
	const addTimeProducts = (0, react.useMemo)(() => {
		return (state.addTimeProducts || []).some((item) => require_utils$1.isUsableProduct(item.add_time, currentService));
	}, [state.addTimeProducts, currentService]);
	const showAddTimeButton = (0, react.useMemo)(() => {
		if (state.renderType === "eventBooking") return false;
		if (state.disabledEdit) return false;
		if (appointment_card.quick_time !== 1) return false;
		if (require_utils.getIsEdit(state)) return false;
		if (!addTimeProducts) return false;
		return true;
	}, [
		state,
		appointment_card.quick_time,
		addTimeProducts
	]);
	return /* @__PURE__ */ react.default.createElement("div", { className: "actions-wrap" }, showAddTimeButton && /* @__PURE__ */ react.default.createElement(antd.Button, {
		className: "action-item",
		size: "large",
		onClick: (e) => {
			e.preventDefault();
			e.stopPropagation();
			onAddTime();
		}
	}, _pisell_utils.locales.getText("page.booking.text.add-time")));
};
//#endregion
exports.default = Actions;
