import { aX as C, aW as a, V as b, s as F, S as O } from "./index-6jcTChn4.js";
import { useState as P, useEffect as j } from "react";
const y = [
  "BIF",
  "CLP",
  "DJF",
  "GNF",
  "JPY",
  "KMF",
  "KRW",
  "MGA",
  "PYG",
  "RWF",
  "UGX",
  "VND",
  "VUV",
  "XAF",
  "XOF",
  "XPF"
], k = (e, n) => y.includes(n.toUpperCase()) ? e : Math.round(e * 100), w = (e, n) => y.includes(n.toUpperCase()) ? e : e / 100, K = [
  {
    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" }
], E = ({
  getAppData: e,
  setAppData: n,
  disabled: p,
  eventType: u
}) => {
  var m;
  const o = e("price"), t = e("currency") || r[0].value, [s, h] = P(
    r.find((l) => l.value === t) || {
      label: r[0].label,
      value: r[0].value
    }
  ), f = e("paymentOption"), c = e("enabled"), { t: i } = C(), d = ((m = u.recurringEvent) == null ? void 0 : m.count) !== void 0, g = !!u.seatsPerTimeSlot, x = (l, v) => 0 .toLocaleString(l, {
    style: "currency",
    currency: v,
    minimumFractionDigits: 0,
    maximumFractionDigits: 0
  }).replace(/\d/g, "").trim();
  j(() => {
    c && (e("currency") || n("currency", r[0].value), e("paymentOption") || n("paymentOption", K[0].value));
  }, [c, e, n]);
  const S = (l) => {
    const N = Math.floor(l).toString();
    return parseInt(N);
  };
  return /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
    d && /* @__PURE__ */ a.jsx(b, { className: "mt-2", severity: "warning", title: i("warning_recurring_event_payment") }),
    !d && c && /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
      /* @__PURE__ */ a.jsx("div", { className: "mt-4 block items-center justify-start sm:flex sm:space-x-2", children: /* @__PURE__ */ a.jsx(
        F,
        {
          "data-testid": "stripe-price-input",
          label: i("price"),
          className: "h-[38px]",
          addOnLeading: /* @__PURE__ */ a.jsx(a.Fragment, { children: s.value ? x("en", s.value) : "" }),
          addOnSuffix: t.toUpperCase(),
          addOnClassname: "h-[38px]",
          step: "1",
          min: "1",
          type: "number",
          required: !0,
          placeholder: "Price",
          disabled: p,
          onChange: (l) => {
            n("price", k(Number(l.target.value), t));
          },
          value: o > 0 ? S(w(o, t)) : void 0
        }
      ) }),
      /* @__PURE__ */ a.jsxs("div", { className: "mt-5 w-60", children: [
        /* @__PURE__ */ a.jsx("label", { className: "text-default mb-1 block text-sm font-medium", htmlFor: "currency", children: i("currency") }),
        /* @__PURE__ */ a.jsx(
          O,
          {
            "data-testid": "stripe-currency-select",
            variant: "default",
            options: r,
            value: s,
            className: "text-black",
            defaultValue: s,
            onChange: (l) => {
              l && (h(l), n("currency", l.value));
            }
          }
        )
      ] }),
      g && f === "HOLD" && /* @__PURE__ */ a.jsx(b, { className: "mt-2", severity: "warning", title: i("seats_and_no_show_fee_error") })
    ] })
  ] });
};
export {
  E as default
};
