import { jsxs as u, Fragment as g, jsx as a } from "react/jsx-runtime";
import { a9 as b, q as z, aa as s, ab as N, w as M, f as C, y as K, z as G, S as m, ac as U, ad as D, J as S, ae as V, af as H, b as _ } from "./index-T-3isYi5.js";
import { useState as I, useEffect as Y } from "react";
const o = [
  { 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" }
], W = ({
  getAppData: r,
  setAppData: n,
  disabled: i,
  eventType: k
}) => {
  var R;
  const p = r("price"), c = r("currency") || o[0].value, [v, L] = I(
    o.find((e) => e.value === c) || {
      label: o[0].label,
      value: o[0].value
    }
  ), t = r("paymentOption"), f = b.find((e) => t === e.value), h = r("enabled"), w = () => B.find((e) => e.value === (r("refundCountCalendarDays") === !0 ? 1 : 0)), y = r("autoChargeNoShowFeeIfCancelled"), x = r("autoChargeNoShowFeeTimeUnit"), P = r("autoChargeNoShowFeeTimeValue"), { t: l } = z(), T = ((R = k.recurringEvent) == null ? void 0 : R.count) !== void 0, F = !!k.seatsPerTimeSlot, O = (e, E) => 0 .toLocaleString(e, {
    style: "currency",
    currency: E,
    minimumFractionDigits: 0,
    maximumFractionDigits: 0
  }).replace(/\d/g, "").trim();
  Y(() => {
    h && (r("currency") || n("currency", o[0].value), r("paymentOption") || n("paymentOption", b[0].value)), r("refundPolicy") || n("refundPolicy", s.NEVER);
  }, [h, r, n]);
  const B = [
    { value: 0, label: l("business_days") },
    { value: 1, label: l("calendar_days") }
  ], d = [
    { value: N.enum.minutes, label: l("minutes") },
    { value: N.enum.hours, label: l("hours") },
    { value: N.enum.days, label: l("days") }
  ];
  return /* @__PURE__ */ u(g, { children: [
    T && /* @__PURE__ */ a(M, { className: "mt-2", severity: "warning", title: l("warning_recurring_event_payment") }),
    !T && h && /* @__PURE__ */ u(g, { children: [
      /* @__PURE__ */ a("div", { className: "mt-4 block items-center justify-start sm:flex sm:space-x-2", children: /* @__PURE__ */ a(
        C,
        {
          "data-testid": "stripe-price-input",
          label: l("price"),
          className: "h-[38px]",
          addOnLeading: /* @__PURE__ */ a(g, { children: v.value ? O("en", v.value) : "" }),
          addOnSuffix: c.toUpperCase(),
          addOnClassname: "h-[38px]",
          step: "0.01",
          min: "0.5",
          type: "number",
          required: !0,
          placeholder: "Price",
          disabled: i,
          onChange: (e) => {
            n("price", K(Number(e.target.value), c));
          },
          value: p > 0 ? G(p, c) : 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: l("currency") }),
        /* @__PURE__ */ a(
          m,
          {
            "data-testid": "stripe-currency-select",
            variant: "default",
            options: o,
            innerClassNames: {
              input: "stripe-currency-input"
            },
            value: v,
            className: "text-black",
            defaultValue: v,
            onChange: (e) => {
              e && (L(e), n("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: l("payment_option") }),
        /* @__PURE__ */ a(
          m,
          {
            "data-testid": "stripe-payment-option-select",
            defaultValue: f ? { ...f, label: l(f.label) } : { ...b[0], label: l(b[0].label) },
            options: b.map((e) => ({ ...e, label: l(e.label) || e.label })),
            onChange: (e) => {
              e && (n("paymentOption", e.value), e.value === "HOLD" && (n("refundPolicy", s.NEVER), n("refundDaysCount", void 0), n("refundCountCalendarDays", void 0)));
            },
            className: "mb-1 h-[38px] w-full",
            isDisabled: F || i
          }
        )
      ] }),
      F && t === "HOLD" && /* @__PURE__ */ a(M, { className: "mt-2", severity: "warning", title: l("seats_and_no_show_fee_error") }),
      t !== "HOLD" && /* @__PURE__ */ u("div", { className: "mt-4 w-full", children: [
        /* @__PURE__ */ a("label", { className: "text-default mb-1 block text-sm font-medium", children: l("refund_policy") }),
        /* @__PURE__ */ u(
          U,
          {
            disabled: i || t === "HOLD",
            defaultValue: "never",
            className: "flex flex-col stack-y-2",
            value: r("refundPolicy"),
            onValueChange: (e) => {
              n("refundPolicy", e), e !== s.DAYS && (n("refundDaysCount", void 0), n("refundCountCalendarDays", void 0));
            },
            children: [
              /* @__PURE__ */ a(D, { className: "w-fit", value: s.ALWAYS, label: l("always"), id: "always" }),
              /* @__PURE__ */ a(D, { className: "w-fit", value: s.NEVER, label: l("never"), id: "never" }),
              /* @__PURE__ */ u("div", { className: S("text-default mb-2 flex flex-wrap items-center text-sm"), children: [
                /* @__PURE__ */ a(
                  V,
                  {
                    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__ */ a(H, { 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: [
                    " ",
                    l("if_cancelled")
                  ] }),
                  /* @__PURE__ */ a(
                    C,
                    {
                      labelSrOnly: !0,
                      type: "number",
                      className: S(
                        "border-default my-0 block w-16 text-sm [appearance:textfield] ltr:mr-2 rtl:ml-2"
                      ),
                      placeholder: "2",
                      disabled: i,
                      min: 0,
                      defaultValue: r("refundDaysCount"),
                      required: r("refundPolicy") === s.DAYS,
                      value: r("refundDaysCount") ?? "",
                      onChange: (e) => n("refundDaysCount", parseInt(e.currentTarget.value))
                    }
                  ),
                  /* @__PURE__ */ a(
                    m,
                    {
                      options: B,
                      isSearchable: !1,
                      isDisabled: i,
                      onChange: (e) => n("refundCountCalendarDays", (e == null ? void 0 : e.value) === 1),
                      value: w(),
                      defaultValue: w()
                    }
                  ),
                  /* @__PURE__ */ u("span", { className: "me-2 ms-2", children: [
                    " ",
                    l("before")
                  ] })
                ] })
              ] })
            ]
          }
        )
      ] }),
      t === "HOLD" && /* @__PURE__ */ u("div", { className: "mt-4", children: [
        /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(
          _,
          {
            checked: y,
            onChange: (e) => n("autoChargeNoShowFeeIfCancelled", e.target.checked),
            description: l("auto_charge_for_last_minute_cancellation")
          }
        ) }),
        y && /* @__PURE__ */ a("div", { children: /* @__PURE__ */ u("div", { className: "mt-2 flex items-center", children: [
          /* @__PURE__ */ a(
            C,
            {
              labelSrOnly: !0,
              type: "number",
              className: S(
                "border-default my-0 block w-16 text-sm [appearance:textfield] ltr:mr-2 rtl:ml-2"
              ),
              placeholder: "2",
              disabled: i,
              min: 0,
              defaultValue: P,
              required: y,
              value: P ?? "",
              onChange: (e) => n("autoChargeNoShowFeeTimeValue", parseInt(e.currentTarget.value))
            }
          ),
          /* @__PURE__ */ a(
            m,
            {
              options: d,
              isSearchable: !1,
              isDisabled: i,
              onChange: (e) => n("autoChargeNoShowFeeTimeUnit", e == null ? void 0 : e.value),
              value: d.find((e) => e.value === x) || d[0],
              defaultValue: d.find((e) => e.value === x) || d[0]
            }
          ),
          /* @__PURE__ */ a("span", { className: "me-2 ms-2", children: l("before_scheduled_start_time") })
        ] }) })
      ] })
    ] })
  ] });
};
export {
  W as default
};
