import { jsxs as u, Fragment as o, jsx as n } from "react/jsx-runtime";
import { useState as k, useEffect as P } from "react";
import { y as x, N as p, k as w, S as K } from "./index-_1f6rhg6.js";
const h = [
  "BIF",
  "CLP",
  "DJF",
  "GNF",
  "JPY",
  "KMF",
  "KRW",
  "MGA",
  "PYG",
  "RWF",
  "UGX",
  "VND",
  "VUV",
  "XAF",
  "XOF",
  "XPF"
], U = (e, a) => h.includes(a.toUpperCase()) ? e : Math.round(e * 100), _ = (e, a) => h.includes(a.toUpperCase()) ? e : e / 100, V = [
  {
    label: "on_booking_option",
    value: "ON_BOOKING"
  }
], r = [
  { label: "United States dollar (USD)", value: "usd" },
  { label: "Singapore dollar (SGD)", value: "sgd" },
  { label: "Malaysian ringgit (MYR)", value: "myr" },
  { label: "Indonesian rupiah (IDR)", value: "idr" },
  { label: "Japanese yen (JPY)", value: "jpy" },
  { label: "Hong Kong dollar (HKD)", value: "hkd" },
  { label: "Thai baht (THB)", value: "thb" },
  { label: "Australian dollar (AUD)", value: "aud" },
  { label: "New Zealand dollar (NZD)", value: "nzd" },
  { label: "British pound sterling (GBP)", value: "gbp" },
  { label: "Philippine peso (PHP)", value: "php" },
  { label: "Indian rupee (INR)", value: "inr" },
  { label: "Chinese yuan (CNY)", value: "cny" },
  { label: "Euro (EUR)", value: "eur" },
  { label: "Swiss franc (CHF)", value: "chf" },
  { label: "Danish krone (DKK)", value: "dkk" },
  { label: "Swedish krona (SEK)", value: "sek" },
  { label: "Norwegian krone (NOK)", value: "nok" },
  { label: "Vietnamese đồng (VND)", value: "vnd" },
  { label: "Canadian dollar (CAD)", value: "cad" },
  { label: "South Korean won (KRW)", value: "krw" }
], R = ({
  getAppData: e,
  setAppData: a,
  disabled: f,
  eventType: d
}) => {
  var b;
  const m = e("price"), t = e("currency") || r[0].value, [i, g] = k(
    r.find((l) => l.value === t) || {
      label: r[0].label,
      value: r[0].value
    }
  ), N = e("paymentOption"), c = e("enabled"), { t: s } = x(), v = ((b = d.recurringEvent) == null ? void 0 : b.count) !== void 0, S = !!d.seatsPerTimeSlot, C = (l, y) => 0 .toLocaleString(l, {
    style: "currency",
    currency: y,
    minimumFractionDigits: 0,
    maximumFractionDigits: 0
  }).replace(/\d/g, "").trim();
  P(() => {
    c && (e("currency") || a("currency", r[0].value), e("paymentOption") || a("paymentOption", V[0].value));
  }, [c, e, a]);
  const F = (l) => {
    const O = Math.floor(l).toString();
    return parseInt(O);
  };
  return /* @__PURE__ */ u(o, { children: [
    v && /* @__PURE__ */ n(p, { className: "mt-2", severity: "warning", title: s("warning_recurring_event_payment") }),
    !v && c && /* @__PURE__ */ u(o, { children: [
      /* @__PURE__ */ n("div", { className: "mt-4 block items-center justify-start sm:flex sm:space-x-2", children: /* @__PURE__ */ n(
        w,
        {
          "data-testid": "stripe-price-input",
          label: s("price"),
          className: "h-[38px]",
          addOnLeading: /* @__PURE__ */ n(o, { children: i.value ? C("en", i.value) : "" }),
          addOnSuffix: t.toUpperCase(),
          addOnClassname: "h-[38px]",
          step: "1",
          min: "1",
          type: "number",
          required: !0,
          placeholder: "Price",
          disabled: f,
          onChange: (l) => {
            a("price", U(Number(l.target.value), t));
          },
          value: m > 0 ? F(_(m, t)) : void 0
        }
      ) }),
      /* @__PURE__ */ u("div", { className: "mt-5 w-60", children: [
        /* @__PURE__ */ n("label", { className: "text-default mb-1 block text-sm font-medium", htmlFor: "currency", children: s("currency") }),
        /* @__PURE__ */ n(
          K,
          {
            "data-testid": "stripe-currency-select",
            variant: "default",
            options: r,
            value: i,
            className: "text-black",
            defaultValue: i,
            onChange: (l) => {
              l && (g(l), a("currency", l.value));
            }
          }
        )
      ] }),
      S && N === "HOLD" && /* @__PURE__ */ n(p, { className: "mt-2", severity: "warning", title: s("seats_and_no_show_fee_error") })
    ] })
  ] });
};
export {
  R as default
};
