import { jsxs as u, Fragment as f, jsx as l } from "react/jsx-runtime";
import { aa as d, y as L, ab as i, N as P, k as w, V as T, X as O, S as y, ac as E, ad as x, Z as B, ae as F, af as K } from "./index-ykl8OQ78.js";
import { useState as z, useEffect as G } from "react";
const s = [
  { label: "United States dollar (USD)", value: "usd" },
  { label: "United Arab Emirates dirham (AED)", value: "aed" },
  { label: "Afghan afghani (AFN)", value: "afn" },
  { label: "Albanian lek (ALL)", value: "all" },
  { label: "Armenian dram (AMD)", value: "amd" },
  { label: "Netherlands Antillean guilder (ANG)", value: "ang" },
  { label: "Angolan kwanza (AOA)", value: "aoa" },
  { label: "Argentine peso (ARS)", value: "ars" },
  { label: "Australian dollar (AUD)", value: "aud" },
  { label: "Aruban florin (AWG)", value: "awg" },
  { label: "Azerbaijani manat (AZN)", value: "azn" },
  { label: "Bosnia and Herzegovina convertible mark (BAM)", value: "bam" },
  { label: "Barbadian dollar (BBD)", value: "bbd" },
  { label: "Bangladeshi taka (BDT)", value: "bdt" },
  { label: "Bulgarian lev (BGN)", value: "bgn" },
  { label: "Burundian franc (BIF)", value: "bif" },
  { label: "Bermudian dollar (BMD)", value: "bmd" },
  { label: "Brunei dollar (BND)", value: "bnd" },
  { label: "Bolivian boliviano (BOB)", value: "bob" },
  { label: "Brazilian real (BRL)", value: "brl" },
  { label: "Bahamian dollar (BSD)", value: "bsd" },
  { label: "Botswana pula (BWP)", value: "bwp" },
  { label: "Belarusian ruble (BYN)", value: "byn" },
  { label: "Belize dollar (BZD)", value: "bzd" },
  { label: "Canadian dollar (CAD)", value: "cad" },
  { label: "Congolese franc (CDF)", value: "cdf" },
  { label: "Swiss franc (CHF)", value: "chf" },
  { label: "Chilean peso (CLP)", value: "clp" },
  { label: "Chinese yuan (CNY)", value: "cny" },
  { label: "Colombian peso (COP)", value: "cop" },
  { label: "Costa Rican colón (CRC)", value: "crc" },
  { label: "Cape Verdean escudo (CVE)", value: "cve" },
  { label: "Czech koruna (CZK)", value: "czk" },
  { label: "Djiboutian franc (DJF)", value: "djf" },
  { label: "Danish krone (DKK)", value: "dkk" },
  { label: "Dominican peso (DOP)", value: "dop" },
  { label: "Algerian dinar (DZD)", value: "dzd" },
  { label: "Egyptian pound (EGP)", value: "egp" },
  { label: "Ethiopian birr (ETB)", value: "etb" },
  { label: "Euro (EUR)", value: "eur" },
  { label: "Fijian dollar (FJD)", value: "fjd" },
  { label: "Falkland Islands pound (FKP)", value: "fkp" },
  { label: "British pound sterling (GBP)", value: "gbp" },
  { label: "Georgian lari (GEL)", value: "gel" },
  { label: "Gibraltar pound (GIP)", value: "gip" },
  { label: "Gambian dalasi (GMD)", value: "gmd" },
  { label: "Guinean franc (GNF)", value: "gnf" },
  { label: "Guatemalan quetzal (GTQ)", value: "gtq" },
  { label: "Guyanese dollar (GYD)", value: "gyd" },
  { label: "Hong Kong dollar (HKD)", value: "hkd" },
  { label: "Honduran lempira (HNL)", value: "hnl" },
  { label: "Haitian gourde (HTG)", value: "htg" },
  { label: "Hungarian forint (HUF)", value: "huf" },
  { label: "Indonesian rupiah (IDR)", value: "idr" },
  { label: "Israeli new shekel (ILS)", value: "ils" },
  { label: "Indian rupee (INR)", value: "inr" },
  { label: "Icelandic króna (ISK)", value: "isk" },
  { label: "Jamaican dollar (JMD)", value: "jmd" },
  { label: "Japanese yen (JPY)", value: "jpy" },
  { label: "Kenyan shilling (KES)", value: "kes" },
  { label: "Kyrgyzstani som (KGS)", value: "kgs" },
  { label: "Cambodian riel (KHR)", value: "khr" },
  { label: "Comorian franc (KMF)", value: "kmf" },
  { label: "South Korean won (KRW)", value: "krw" },
  { label: "Cayman Islands dollar (KYD)", value: "kyd" },
  { label: "Kazakhstani tenge (KZT)", value: "kzt" },
  { label: "Laotian kip (LAK)", value: "lak" },
  { label: "Lebanese pound (LBP)", value: "lbp" },
  { label: "Sri Lankan rupee (LKR)", value: "lkr" },
  { label: "Liberian dollar (LRD)", value: "lrd" },
  { label: "Lesotho loti (LSL)", value: "lsl" },
  { label: "Moroccan dirham (MAD)", value: "mad" },
  { label: "Moldovan leu (MDL)", value: "mdl" },
  { label: "Malagasy ariary (MGA)", value: "mga" },
  { label: "Macedonian denar (MKD)", value: "mkd" },
  { label: "Myanmar kyat (MMK)", value: "mmk" },
  { label: "Mongolian tögrög (MNT)", value: "mnt" },
  { label: "Macanese pataca (MOP)", value: "mop" },
  { label: "Mauritian rupee (MUR)", value: "mur" },
  { label: "Maldivian rufiyaa (MVR)", value: "mvr" },
  { label: "Malawian kwacha (MWK)", value: "mwk" },
  { label: "Mexican peso (MXN)", value: "mxn" },
  { label: "Malaysian ringgit (MYR)", value: "myr" },
  { label: "Mozambican metical (MZN)", value: "mzn" },
  { label: "Namibian dollar (NAD)", value: "nad" },
  { label: "Nigerian naira (NGN)", value: "ngn" },
  { label: "Nicaraguan córdoba (NIO)", value: "nio" },
  { label: "Norwegian krone (NOK)", value: "nok" },
  { label: "Nepalese rupee (NPR)", value: "npr" },
  { label: "New Zealand dollar (NZD)", value: "nzd" },
  { label: "Panamanian balboa (PAB)", value: "pab" },
  { label: "Peruvian sol (PEN)", value: "pen" },
  { label: "Papua New Guinean kina (PGK)", value: "pgk" },
  { label: "Philippine peso (PHP)", value: "php" },
  { label: "Pakistani rupee (PKR)", value: "pkr" },
  { label: "Polish złoty (PLN)", value: "pln" },
  { label: "Paraguayan guaraní (PYG)", value: "pyg" },
  { label: "Qatari riyal (QAR)", value: "qar" },
  { label: "Romanian leu (RON)", value: "ron" },
  { label: "Serbian dinar (RSD)", value: "rsd" },
  { label: "Russian ruble (RUB)", value: "rub" },
  { label: "Rwandan franc (RWF)", value: "rwf" },
  { label: "Saudi riyal (SAR)", value: "sar" },
  { label: "Solomon Islands dollar (SBD)", value: "sbd" },
  { label: "Seychellois rupee (SCR)", value: "scr" },
  { label: "Swedish krona (SEK)", value: "sek" },
  { label: "Singapore dollar (SGD)", value: "sgd" },
  { label: "Saint Helena pound (SHP)", value: "shp" },
  { label: "Sierra Leonean leone (SLE)", value: "sle" },
  { label: "Somali shilling (SOS)", value: "sos" },
  { label: "Surinamese dollar (SRD)", value: "srd" },
  { label: "São Tomé and Príncipe dobra (STD)", value: "std" },
  { label: "Swazi lilangeni (SZL)", value: "szl" },
  { label: "Thai baht (THB)", value: "thb" },
  { label: "Tajikistani somoni (TJS)", value: "tjs" },
  { label: "Tongan paʻanga (TOP)", value: "top" },
  { label: "Turkish lira (TRY)", value: "try" },
  { label: "Trinidad and Tobago dollar (TTD)", value: "ttd" },
  { label: "New Taiwan dollar (TWD)", value: "twd" },
  { label: "Tanzanian shilling (TZS)", value: "tzs" },
  { label: "Ukrainian hryvnia (UAH)", value: "uah" },
  { label: "Ugandan shilling (UGX)", value: "ugx" },
  { label: "Uruguayan peso (UYU)", value: "uyu" },
  { label: "Uzbekistan som (UZS)", value: "uzs" },
  { label: "Vietnamese đồng (VND)", value: "vnd" },
  { label: "Vanuatu vatu (VUV)", value: "vuv" },
  { label: "Samoan tala (WST)", value: "wst" },
  { label: "Central African CFA franc (XAF)", value: "xaf" },
  { label: "East Caribbean dollar (XCD)", value: "xcd" },
  { label: "West African CFA franc (XOF)", value: "xof" },
  { label: "CFP franc (XPF)", value: "xpf" },
  { label: "Yemeni rial (YER)", value: "yer" },
  { label: "South African rand (ZAR)", value: "zar" },
  { label: "Zambian kwacha (ZMW)", value: "zmw" }
], V = ({
  getAppData: r,
  setAppData: e,
  disabled: b,
  eventType: h
}) => {
  var k;
  const g = r("price"), o = r("currency") || s[0].value, [t, D] = z(
    s.find((a) => a.value === o) || {
      label: s[0].label,
      value: s[0].value
    }
  ), v = r("paymentOption"), c = d.find((a) => v === a.value), m = r("enabled"), p = () => C.find((a) => a.value === (r("refundCountCalendarDays") === !0 ? 1 : 0)), { t: n } = L(), N = ((k = h.recurringEvent) == null ? void 0 : k.count) !== void 0, S = !!h.seatsPerTimeSlot, R = (a, M) => 0 .toLocaleString(a, {
    style: "currency",
    currency: M,
    minimumFractionDigits: 0,
    maximumFractionDigits: 0
  }).replace(/\d/g, "").trim();
  G(() => {
    m && (r("currency") || e("currency", s[0].value), r("paymentOption") || e("paymentOption", d[0].value)), r("refundPolicy") || e("refundPolicy", i.NEVER);
  }, [m, r, e]);
  const C = [
    { value: 0, label: n("business_days") },
    { value: 1, label: n("calendar_days") }
  ];
  return /* @__PURE__ */ u(f, { children: [
    N && /* @__PURE__ */ l(P, { className: "mt-2", severity: "warning", title: n("warning_recurring_event_payment") }),
    !N && m && /* @__PURE__ */ u(f, { children: [
      /* @__PURE__ */ l("div", { className: "mt-4 block items-center justify-start sm:flex sm:space-x-2", children: /* @__PURE__ */ l(
        w,
        {
          "data-testid": "stripe-price-input",
          label: n("price"),
          className: "h-[38px]",
          addOnLeading: /* @__PURE__ */ l(f, { children: t.value ? R("en", t.value) : "" }),
          addOnSuffix: o.toUpperCase(),
          addOnClassname: "h-[38px]",
          step: "0.01",
          min: "0.5",
          type: "number",
          required: !0,
          placeholder: "Price",
          disabled: b,
          onChange: (a) => {
            e("price", T(Number(a.target.value), o));
          },
          value: g > 0 ? O(g, o) : void 0
        }
      ) }),
      /* @__PURE__ */ u("div", { className: "mt-5 w-60", children: [
        /* @__PURE__ */ l("label", { className: "text-default mb-1 block text-sm font-medium", htmlFor: "currency", children: n("currency") }),
        /* @__PURE__ */ l(
          y,
          {
            "data-testid": "stripe-currency-select",
            variant: "default",
            options: s,
            innerClassNames: {
              input: "stripe-currency-input"
            },
            value: t,
            className: "text-black",
            defaultValue: t,
            onChange: (a) => {
              a && (D(a), e("currency", a.value));
            }
          }
        )
      ] }),
      /* @__PURE__ */ u("div", { className: "mt-4 w-60", children: [
        /* @__PURE__ */ l("label", { className: "text-default mb-1 block text-sm font-medium", htmlFor: "currency", children: n("payment_option") }),
        /* @__PURE__ */ l(
          y,
          {
            "data-testid": "stripe-payment-option-select",
            defaultValue: c ? { ...c, label: n(c.label) } : { ...d[0], label: n(d[0].label) },
            options: d.map((a) => ({ ...a, label: n(a.label) || a.label })),
            onChange: (a) => {
              a && (e("paymentOption", a.value), a.value === "HOLD" && (e("refundPolicy", i.NEVER), e("refundDaysCount", void 0), e("refundCountCalendarDays", void 0)));
            },
            className: "mb-1 h-[38px] w-full",
            isDisabled: S || b
          }
        )
      ] }),
      S && v === "HOLD" && /* @__PURE__ */ l(P, { className: "mt-2", severity: "warning", title: n("seats_and_no_show_fee_error") }),
      v !== "HOLD" && /* @__PURE__ */ u("div", { className: "mt-4 w-full", children: [
        /* @__PURE__ */ l("label", { className: "text-default mb-1 block text-sm font-medium", children: n("refund_policy") }),
        /* @__PURE__ */ u(
          E,
          {
            disabled: b || v === "HOLD",
            defaultValue: "never",
            className: "flex flex-col space-y-2",
            value: r("refundPolicy"),
            onValueChange: (a) => {
              e("refundPolicy", a), a !== i.DAYS && (e("refundDaysCount", void 0), e("refundCountCalendarDays", void 0));
            },
            children: [
              /* @__PURE__ */ l(x, { className: "w-fit", value: i.ALWAYS, label: n("always"), id: "always" }),
              /* @__PURE__ */ l(x, { className: "w-fit", value: i.NEVER, label: n("never"), id: "never" }),
              /* @__PURE__ */ u("div", { className: B("text-default mb-2 flex flex-wrap items-center text-sm"), children: [
                /* @__PURE__ */ l(
                  F,
                  {
                    className: "min-w-4 bg-default border-default flex h-4 w-4 cursor-pointer items-center rounded-full border focus:border-2 focus:outline-none ltr:mr-2 rtl:ml-2",
                    value: "days",
                    id: "days",
                    children: /* @__PURE__ */ l(K, { className: "after:bg-inverted relative flex h-4 w-4 items-center justify-center after:block after:h-2 after:w-2 after:rounded-full" })
                  }
                ),
                /* @__PURE__ */ u("div", { className: "flex items-center", children: [
                  /* @__PURE__ */ u("span", { className: "me-2 ms-2", children: [
                    " ",
                    n("if_cancelled")
                  ] }),
                  /* @__PURE__ */ l(
                    w,
                    {
                      labelSrOnly: !0,
                      type: "number",
                      className: B(
                        "border-default my-0 block w-16 text-sm [appearance:textfield] ltr:mr-2 rtl:ml-2"
                      ),
                      placeholder: "2",
                      disabled: b,
                      min: 0,
                      defaultValue: r("refundDaysCount"),
                      required: r("refundPolicy") === i.DAYS,
                      value: r("refundDaysCount") ?? "",
                      onChange: (a) => e("refundDaysCount", parseInt(a.currentTarget.value))
                    }
                  ),
                  /* @__PURE__ */ l(
                    y,
                    {
                      options: C,
                      isSearchable: !1,
                      isDisabled: b,
                      onChange: (a) => e("refundCountCalendarDays", (a == null ? void 0 : a.value) === 1),
                      value: p(),
                      defaultValue: p()
                    }
                  ),
                  /* @__PURE__ */ u("span", { className: "me-2 ms-2", children: [
                    " ",
                    n("before")
                  ] })
                ] })
              ] })
            ]
          }
        )
      ] })
    ] })
  ] });
};
export {
  V as default
};
