import { aL as p, b1 as t, aK as l, V as v, s as S, b2 as O, S as h } from "./index-GTnBs7av.js";
import { useState as j, useEffect as w } from "react";
const o = [{ label: "BTC", value: "BTC", unit: "sats" }], P = ({
  eventType: d,
  getAppData: c,
  setAppData: a
}) => {
  var x, y;
  const { t: n } = p(), i = c("price"), s = c("currency"), [r, g] = j(
    o.find((e) => e.value === s) || o[0]
  ), b = c("paymentOption"), u = ((x = t) == null ? void 0 : x.find((e) => b === e.value)) || {
    label: t[0].label,
    value: t[0].value
  }, f = !!d.seatsPerTimeSlot, [m] = j(c("enabled")), N = ((y = d.recurringEvent) == null ? void 0 : y.count) !== void 0;
  return w(() => {
    !s && m && a("currency", r.value);
  }, [s, r, a, m]), /* @__PURE__ */ l.jsx(l.Fragment, { children: N ? /* @__PURE__ */ l.jsx(v, { className: "mt-2", severity: "warning", title: n("warning_recurring_event_payment") }) : m && /* @__PURE__ */ l.jsxs(l.Fragment, { children: [
    /* @__PURE__ */ l.jsx("div", { className: "mt-2 block items-center sm:flex", children: /* @__PURE__ */ l.jsx(
      S,
      {
        label: "Price",
        labelSrOnly: !0,
        addOnLeading: /* @__PURE__ */ l.jsx(O, { className: "h-4 w-4" }),
        addOnSuffix: r.unit || r.value,
        type: "number",
        required: !0,
        className: "block w-full rounded-sm border-gray-300 pl-2 pr-12 text-sm",
        placeholder: "Price",
        onChange: (e) => {
          a("price", Number(e.target.value)), s && a("currency", s);
        },
        value: i && i > 0 ? i : void 0
      }
    ) }),
    /* @__PURE__ */ l.jsxs("div", { className: "mt-5 w-60", children: [
      /* @__PURE__ */ l.jsx("label", { className: "text-default block text-sm font-medium", htmlFor: "currency", children: n("currency") }),
      /* @__PURE__ */ l.jsx(
        h,
        {
          variant: "default",
          options: o,
          value: r,
          className: "text-black",
          defaultValue: r,
          onChange: (e) => {
            e && (g(e), a("currency", e.value));
          }
        }
      )
    ] }),
    /* @__PURE__ */ l.jsxs("div", { className: "mt-2 w-60", children: [
      /* @__PURE__ */ l.jsx("label", { className: "text-default block text-sm font-medium", htmlFor: "currency", children: "Payment option" }),
      /* @__PURE__ */ l.jsx(
        h,
        {
          defaultValue: u ? { ...u, label: n(u.label) } : { ...t[0], label: n(t[0].label) },
          options: t.map((e) => ({ ...e, label: n(e.label) || e.label })),
          onChange: (e) => {
            e && a("paymentOption", e.value);
          },
          className: "mb-1 h-[38px] w-full",
          isDisabled: f
        }
      )
    ] }),
    f && b === "HOLD" && /* @__PURE__ */ l.jsx(v, { className: "mt-2", severity: "warning", title: n("seats_and_no_show_fee_error") })
  ] }) });
};
export {
  P as default
};
