import { jsx as l, jsxs as m, Fragment as w } from "react/jsx-runtime";
import { useState as o, useEffect as _ } from "react";
import { c as i, i as k, a as x } from "./currencyOptions-kannG2hu.js";
import { z as r, q as E, x as S, f as F, G as q, J as T, S as O } from "./index-ZQlxzdt5.js";
const G = ({
  getAppData: n,
  setAppData: t,
  eventType: d
}) => {
  var p, h;
  const y = n("price"), a = n("currency") || i[0].value, [s, N] = o(i.find((e) => e.value === a)), [C, P] = o(
    k(a) ? x[a] : ""
  ), f = n("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] = o(n("enabled")), { t: c } = E(), g = ((h = d.recurringEvent) == null ? void 0 : h.count) !== void 0;
  return _(() => {
    v && (n("currency") || t("currency", i[0].value), n("paymentOption") || t("paymentOption", r[0].value));
  }, []), g ? /* @__PURE__ */ l(S, { className: "mt-2", severity: "warning", title: c("warning_recurring_event_payment") }) : v ? /* @__PURE__ */ m(w, { 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) => {
          t("price", q(Number(e.target.value), a)), s && t("currency", s.value);
        },
        value: y > 0 ? T(y, a) : void 0
      }
    ) }),
    /* @__PURE__ */ m("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), P(x[e.value]), t("currency", e.value));
          }
        }
      )
    ] }),
    /* @__PURE__ */ m("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 && t("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 {
  G as default
};
