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