import { useAppointmentBookingContext } from "../../context.js";
import Deposit$1 from "../../deposit/index.js";
import React from "react";
import { locales } from "@pisell/utils";
import { PisellText } from "@pisell/materials";
import "./index.less";
//#region src/components/appointmentBooking/components/Deposit/index.tsx
const DepositContent = (props) => {
	const { isAgreeDepositPolicy, setIsAgreeDepositPolicy, deposit, depositProtocolRequest, showTitle = true } = props;
	return /* @__PURE__ */ React.createElement("div", { className: "appointment-deposit-wrap" }, showTitle ? /* @__PURE__ */ React.createElement("div", { className: "appointment-deposit-top" }, /* @__PURE__ */ React.createElement("span", null, locales.getText("pisell2.appointment.deposit")), /* @__PURE__ */ React.createElement(PisellText.Amount, {
		value: deposit === null || deposit === void 0 ? void 0 : deposit.total,
		showCurrencySymbol: true,
		className: "amount"
	})) : null, /* @__PURE__ */ React.createElement(Deposit$1, {
		total: deposit === null || deposit === void 0 ? void 0 : deposit.total,
		protocols: deposit === null || deposit === void 0 ? void 0 : deposit.protocols,
		isAgreePolicy: isAgreeDepositPolicy,
		onChange: (value) => setIsAgreeDepositPolicy(value),
		depositProtocolRequest
	}));
};
const Deposit = (props) => {
	const { showTitle = true } = props;
	const { setIsAgreeDepositPolicy, isAgreeDepositPolicy, summary, appointmentBooking } = useAppointmentBookingContext();
	const { deposit } = summary;
	const depositProtocolRequest = (id) => {
		var _appointmentBooking$g;
		return appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$g = appointmentBooking.getProtocol) === null || _appointmentBooking$g === void 0 ? void 0 : _appointmentBooking$g.call(appointmentBooking, id);
	};
	return /* @__PURE__ */ React.createElement(DepositContent, {
		showTitle,
		isAgreeDepositPolicy: !!isAgreeDepositPolicy,
		setIsAgreeDepositPolicy,
		deposit,
		depositProtocolRequest
	});
};
//#endregion
export { DepositContent, Deposit as default };
