import { jsx as l, jsxs as o, Fragment as g } from "react/jsx-runtime";
import { useState as m, useEffect as _ } from "react";
import { c as i, i as k, a as x } from "./currencyOptions-r01lKGBF.js";
import { v as r, o as E, t as S, d as F, w as T, x as q, S as O } from "./index-C62tPk5p.js";
const I = ({
  getAppData: t,
  setAppData: n,
  eventType: d
}) => {
  var p, h;
  const y = t("price"), a = t("currency") || i[0].value, [s, N] = m(i.find((e) => e.value === a)), [C, w] = m(
    k(a) ? x[a] : ""
  ), f = t("paymentOption"), u = ((p = r) == null ? void 0 : p.find((e) => f === e.value)) || {
    label: r[0].label,
    value: r[0].value
  }, b = !!d.seatsPerTimeSlot, [v, L] = m(t("enabled")), { t: c } = E(), P = ((h = d.recurringEvent) == null ? void 0 : h.count) !== void 0;
  return _(() => {
    v && (t("currency") || n("currency", i[0].value), t("paymentOption") || n("paymentOption", r[0].value));
  }, []), P ? /* @__PURE__ */ l(S, { className: "mt-2", severity: "warning", title: c("warning_recurring_event_payment") }) : v ? /* @__PURE__ */ o(g, { children: [
    /* @__PURE__ */ l("div", { className: "mt-2 block items-center sm:flex", children: /* @__PURE__ */ l(
      F,
      {
        label: "Price",
        labelSrOnly: !0,
        addOnLeading: C,
        addOnSuffix: a,
        step: "0.01",
        min: "0.5",
        type: "number",
        required: !0,
        className: "block w-full rounded-sm pl-2 text-sm",
        placeholder: "Price",
        "data-testid": "paypal-price-input",
        onChange: (e) => {
          n("price", T(Number(e.target.value), a)), s && n("currency", s.value);
        },
        value: y > 0 ? q(y, a) : void 0
      }
    ) }),
    /* @__PURE__ */ o("div", { className: "mt-5 w-60", children: [
      /* @__PURE__ */ l("label", { className: "text-default mb-1 block text-sm font-medium", htmlFor: "currency", children: c("currency") }),
      /* @__PURE__ */ l(
        O,
        {
          variant: "default",
          "data-testid": "paypal-currency-select",
          options: i,
          value: s,
          className: "text-black",
          defaultValue: s,
          onChange: (e) => {
            e && (N(e), w(x[e.value]), n("currency", e.value));
          }
        }
      )
    ] }),
    /* @__PURE__ */ o("div", { className: "mt-4 w-60", children: [
      /* @__PURE__ */ l("label", { className: "text-default mb-1 block text-sm font-medium", htmlFor: "currency", children: "Payment option" }),
      /* @__PURE__ */ l(
        O,
        {
          "data-testid": "paypal-payment-option-select",
          defaultValue: u ? { ...u, label: c(u.label) } : { ...r[0], label: c(r[0].label) },
          options: r.map((e) => ({ ...e, label: c(e.label) || e.label })),
          onChange: (e) => {
            e && n("paymentOption", e.value);
          },
          className: "mb-1 h-[38px] w-full",
          isDisabled: b
        }
      )
    ] }),
    b && f === "HOLD" && /* @__PURE__ */ l(S, { className: "mt-2", severity: "warning", title: c("seats_and_no_show_fee_error") })
  ] }) : null;
};
export {
  I as default
};
