import { t as x, r as E, v as F, x as a, q as t, W as q, y as D, f as T, S as f } from "./index-jYYVpIDL.js";
import { useMemo as _, useState as o } from "react";
import { A as L } from "./AppCard-pSUVQRE0.js";
import { c as h, i as R, a as v } from "./currencyOptions-kannG2hu.js";
const U = function({ app: g, eventType: j }) {
  var y, b;
  const i = x.useSearchParams(), u = x.usePathname(), C = _(
    () => `${u}${i ? `?${i.toString()}` : ""}`,
    [u, i]
  ), { t: n } = E(), { getAppData: r, setAppData: s } = F(), p = r("price"), c = r("currency"), S = r("paymentOption"), A = r("enabled"), [l, P] = o(h.find((e) => e.value === c)), [k, N] = o(
    R(c) ? v[c] : ""
  ), [d, O] = o(A), m = ((y = a) == null ? void 0 : y.find((e) => S === e.value)) || {
    label: a[0].label,
    value: a[0].value
  }, w = ((b = j.recurringEvent) == null ? void 0 : b.count) !== void 0;
  return /* @__PURE__ */ t.jsx(
    L,
    {
      returnTo: q + C,
      app: g,
      switchChecked: d,
      switchOnClick: (e) => {
        O(e);
      },
      description: /* @__PURE__ */ t.jsx(t.Fragment, { children: "Add a mock payment to your events" }),
      children: /* @__PURE__ */ t.jsx(t.Fragment, { children: w ? /* @__PURE__ */ t.jsx(D, { className: "mt-2", severity: "warning", title: n("warning_recurring_event_payment") }) : d && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
        /* @__PURE__ */ t.jsx("div", { className: "mt-2 block items-center sm:flex", children: /* @__PURE__ */ t.jsx(
          T,
          {
            id: "test-mock-payment-app-price",
            label: "Price",
            labelSrOnly: !0,
            addOnLeading: k,
            addOnSuffix: c,
            step: "0.01",
            min: "0.5",
            type: "number",
            required: !0,
            className: "block w-full rounded-sm pl-2 text-sm",
            placeholder: "Price",
            onChange: (e) => {
              s("price", Number(e.target.value) * 100), l && s("currency", l.value);
            },
            value: p > 0 ? p / 100 : void 0
          }
        ) }),
        /* @__PURE__ */ t.jsxs("div", { className: "mt-5 w-60", children: [
          /* @__PURE__ */ t.jsx("label", { className: "text-default mb-1 block text-sm font-medium", htmlFor: "currency", children: n("currency") }),
          /* @__PURE__ */ t.jsx(
            f,
            {
              id: "test-mock-payment-app-currency-id",
              variant: "default",
              options: h,
              value: l,
              className: "text-black",
              defaultValue: l,
              onChange: (e) => {
                e && (P(e), N(v[e.value]), s("currency", e.value));
              }
            }
          )
        ] }),
        /* @__PURE__ */ t.jsxs("div", { className: "mt-4 w-60", children: [
          /* @__PURE__ */ t.jsx("label", { className: "text-default mb-1 block text-sm font-medium", htmlFor: "currency", children: "Payment option" }),
          /* @__PURE__ */ t.jsx(
            f,
            {
              defaultValue: m ? { ...m, label: n(m.label) } : { ...a[0], label: n(a[0].label) },
              options: a.map((e) => ({ ...e, label: n(e.label) || e.label })),
              onChange: (e) => {
                e && s("paymentOption", e.value);
              },
              className: "mb-1 h-[38px] w-full",
              isDisabled: !1
            }
          )
        ] })
      ] }) })
    }
  );
};
export {
  U as default
};
