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