var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/appointmentBooking/deposit/index.tsx
var deposit_exports = {};
__export(deposit_exports, {
  default: () => deposit_default
});
module.exports = __toCommonJS(deposit_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_utils2 = require("../utils");
var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
var import_PolicyModal = __toESM(require("./components/PolicyModal"));
var import_index = require("./index.less");
var Deposit = (props) => {
  var _a, _b;
  const {
    protocols,
    total,
    title,
    isAgreePolicy = true,
    isShowTitle = true,
    onChange,
    depositProtocolRequest
  } = props;
  const context = (0, import_useEngineContext.default)();
  const [visible, setVisible] = (0, import_react.useState)(false);
  const [policyItem, setPolicyItem] = (0, import_react.useState)();
  const isEn = (0, import_react.useMemo)(() => {
    var _a2, _b2;
    const _locale = ((_b2 = (_a2 = context == null ? void 0 : context.engine) == null ? void 0 : _a2.props) == null ? void 0 : _b2.locale) || "en";
    return _locale === "en";
  }, [(_b = (_a = context == null ? void 0 : context.engine) == null ? void 0 : _a.props) == null ? void 0 : _b.locale]);
  const _policyText = (0, import_react.useCallback)(
    (item, index) => {
      if (!item || !(protocols == null ? void 0 : protocols.length)) return "";
      return (0, import_utils2.getPunctuationMark)(index, protocols.length, isEn);
    },
    [protocols]
  );
  const handleAgreed = () => {
    onChange && onChange(!isAgreePolicy);
  };
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "appointment-deposit-bottom" }, isShowTitle ? /* @__PURE__ */ import_react.default.createElement("span", { className: "title" }, title) : null, /* @__PURE__ */ import_react.default.createElement("div", { className: "tip" }, isEn ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellText.Amount,
    {
      value: total,
      showCurrencySymbol: true,
      className: "amount"
    }
  ), /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("pisell2.appointment.deposit.amount.tip1"))) : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("pisell2.appointment.deposit.amount.tip1")), /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellText.Amount,
    {
      value: total,
      showCurrencySymbol: true,
      className: "amount"
    }
  ), /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("pisell2.appointment.deposit.amount.tip2")))), (protocols == null ? void 0 : protocols.length) > 0 ? /* @__PURE__ */ import_react.default.createElement("div", { className: "checkbox-wrap", onClick: () => handleAgreed() }, /* @__PURE__ */ import_react.default.createElement(import_antd.Checkbox, { checked: isAgreePolicy }), /* @__PURE__ */ import_react.default.createElement("div", { className: "policy-box" }, /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("pisell2.appointment.deposit.agreed")), /* @__PURE__ */ import_react.default.createElement("div", { className: "policy-wrap" }, protocols == null ? void 0 : protocols.map((item, index) => {
    return /* @__PURE__ */ import_react.default.createElement(
      "span",
      {
        key: item == null ? void 0 : item.id,
        onClick: (e) => {
          e.stopPropagation();
          e.preventDefault();
          setPolicyItem(item);
          setVisible(true);
        }
      },
      item == null ? void 0 : item.title,
      /* @__PURE__ */ import_react.default.createElement("span", { className: "symbol" }, _policyText(item, index))
    );
  })))) : null), /* @__PURE__ */ import_react.default.createElement(
    import_PolicyModal.default,
    {
      open: visible,
      onCancel: () => setVisible(false),
      item: policyItem,
      depositProtocolRequest
    }
  ));
};
var deposit_default = Deposit;
