import { aX as a, aL as P, aK as l, V as p, s as g, aY as w, aZ as _, S as h } from "./index-GTnBs7av.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 q = ({
  getAppData: n,
  setAppData: t,
  eventType: o
}) => {
  var v, x;
  const d = n("price"), r = n("currency") || i[0].value, [c, j] = m(i.find((e) => e.value === r)), [O, N] = m(
    k(r) ? S[r] : ""
  ), y = n("paymentOption"), u = ((v = a) == null ? void 0 : v.find((e) => y === e.value)) || {
    label: a[0].label,
    value: a[0].value
  }, f = !!o.seatsPerTimeSlot, [b, F] = m(n("enabled")), { t: s } = P(), C = ((x = o.recurringEvent) == null ? void 0 : x.count) !== void 0;
  return E(() => {
    b && (n("currency") || t("currency", i[0].value), n("paymentOption") || t("paymentOption", a[0].value));
  }, []), C ? /* @__PURE__ */ l.jsx(p, { className: "mt-2", severity: "warning", title: s("warning_recurring_event_payment") }) : b ? /* @__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: r,
        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) => {
          t("price", w(Number(e.target.value), r)), c && t("currency", c.value);
        },
        value: d > 0 ? _(d, r) : 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]), t("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) } : { ...a[0], label: s(a[0].label) },
          options: a.map((e) => ({ ...e, label: s(e.label) || e.label })),
          onChange: (e) => {
            e && t("paymentOption", e.value);
          },
          className: "mb-1 h-[38px] w-full",
          isDisabled: f
        }
      )
    ] }),
    f && y === "HOLD" && /* @__PURE__ */ l.jsx(p, { className: "mt-2", severity: "warning", title: s("seats_and_no_show_fee_error") })
  ] }) : null;
};
export {
  q as default
};
