import { S as Se, b as Ce, s as Ee, f as v, c as Te, n as ne, e as z, l as H, p as S, w as Ae, v as Ne, Q as xe, H as Pe, E as f, o as p, K as ie, L as De, m as c, q as w, x, y as P, z as Fe, r as Oe, B as le, J as oe, A as ee, D as Ue } from "./CashierConfirmModal-Bop0eOiK.js";
import { a as ze, i as He, $ as je, b as Re } from "./CashierError-D3O2fglb.js";
import { d as re, u as We } from "./CashierMethodDetails-WRu0moNB.js";
function ae(t, e) {
  ze(t, e);
}
function Be(t) {
  He({
    fallbackLocale: "en"
  }), je.set(t);
}
const ce = {
  en: {
    generalMin: "Min",
    generalMax: "Max",
    showAll: "SHOW ALL",
    showLess: "SHOW LESS"
  },
  uk: {
    generalMin: "Мін",
    generalMax: "Макс"
  },
  hr: {
    generalMin: "Minimalno",
    generalMax: "Maksimalno",
    showAll: "Prikaži sve",
    showLess: "Prikaži manje"
  },
  tr: {
    generalMin: "Min",
    generalMax: "Maks",
    showAll: "HEPSİNİ GÖSTER",
    showLess: "DAHA AZ GÖSTER"
  },
  "en-us": {
    generalMin: "Min",
    generalMax: "Max",
    showAll: "SHOW ALL",
    showLess: "SHOW LESS"
  }
};
function qe(t) {
  Te(t, "svelte-yskyrk", "*,*::before,*::after{margin:0;padding:0;list-style:none;text-decoration:none;outline:none;box-sizing:border-box}.CashierMethodList{display:flex;flex-direction:column;background:var(--emw--color-background, #fff);box-shadow:0 0 4px var(--mmw--color-black-transparency-10, rgba(0, 0, 0, 0.1));width:100%;border-radius:var(--mmw--border-radius-medium-plus, 6px);container-name:method-list;container-type:inline-size}.SelectorWrapper{display:flex;flex-direction:row;align-items:center;justify-content:left;cursor:pointer;position:relative;height:var(--mmw-method-height, 80px);box-sizing:border-box;border-bottom:1px solid var(--mmw--color-grey-105, #E8E9EB);padding:0 var(--emw--spacing-small, 12px)}.SelectorWrapper:first-child{border-radius:var(--mmw--border-radius-medium-plus, 6px) var(--mmw--border-radius-medium-plus, 6px) 0 0}.SelectorWrapper:last-child{border-radius:0 0 var(--mmw--border-radius-medium-plus, 6px) var(--mmw--border-radius-medium-plus, 6px)}.SelectorWrapper.checked{background:var(--emw--color-background-secondary, #F9F8F8)}.SelectorWrapper:not(.checked):hover{background:linear-gradient(0, var(--emw--color-background-secondary, #F9F8F8) 0%, var(--emw--color-background, #fff) 100%)}.MethodLogo{display:flex;justify-content:center;align-items:center;margin-right:var(--mmw--spacing-small, 14px);width:var(--mmw-logo-width, 110px);min-height:var(--mmw-logo-height, 64px);background:var(--emw--color-background, #FFF);border:1px solid var(--mmw--color-grey-105, #E8E9EB);border-radius:var(--mmw--border-radius-medium-plus, 6px);overflow:hidden;max-height:calc(100% - var(--emw--spacing-small, 12px) - var(--emw--spacing-small, 12px))}.MethodLogo img{width:100%;height:100%}.MethodTitle{color:var(--mmw--color-grey-10, #111);font-size:var(--emw--font-size-medium, 16px);word-break:break-all}.MethodLimits{display:flex;flex-direction:column;align-items:flex-end;margin-left:auto}.Limits{max-width:100%;white-space:nowrap;font-size:var(--emw--font-size-small, 14px);line-height:var(--emw--line-height-xl, 24px);color:var(--mmw--color-grey-290, #666);font-weight:var(--emw--font-weight-normal, 400);font-style:normal}.ShowAllButton{cursor:pointer;color:var(--mmw--color-grey-290, #666);text-align:center;font-size:var(--emw--font-size-x-small, 12px);font-style:normal;font-weight:var(--emw--font-weight-semibold, 500);font-family:inherit;background:var(--emw--color-gray-50, #F7F8FA);line-height:normal;border:1px solid var(--mmw--color-grey-105, #E8E9EB);border-radius:var(--emw--border-radius-medium, 4px);margin:var(--emw--spacing-small, 12px) auto;height:36px;display:flex;align-items:center;justify-content:center;width:80%}.ShowAllButton:hover{background:var(--emw--color-background, #fff)}@container method-list (width < 450px){.MethodLogo{min-width:var(--mmw-logo-small-width, 90px);min-height:var(--mmw-logo--small-height, 50px);overflow:hidden}.CashierMethodList .MethodTitle{display:inline-block;flex-grow:1;font-size:var(--emw--font-size-medium, 16px);line-height:120%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.CashierMethodList .MethodLimits .Limits{flex-shrink:0;font-size:var(--emw--font-size-x-small, 12px)}}@container method-list (max-width: 300px){.Limits{display:none}}");
}
function me(t, e, n) {
  const a = t.slice();
  return a[47] = e[n], a[49] = n, a;
}
function ue(t) {
  let e;
  return {
    c() {
      e = p("cashier-spinner"), f(
        e,
        "clientstylingurl",
        /*clientstylingurl*/
        t[4]
      ), f(
        e,
        "clientstyling",
        /*clientstyling*/
        t[3]
      );
    },
    m(n, a) {
      H(n, e, a);
    },
    p(n, a) {
      a[0] & /*clientstylingurl*/
      16 && f(
        e,
        "clientstylingurl",
        /*clientstylingurl*/
        n[4]
      ), a[0] & /*clientstyling*/
      8 && f(
        e,
        "clientstyling",
        /*clientstyling*/
        n[3]
      );
    },
    d(n) {
      n && z(e);
    }
  };
}
function de(t) {
  let e, n, a, o = ie(
    /*paymentMethodsToShow*/
    t[8]
  ), i = [];
  for (let l = 0; l < o.length; l += 1)
    i[l] = he(me(t, o, l));
  let r = (
    /*methodsButtonToggleText*/
    t[7] && fe(t)
  );
  return {
    c() {
      e = p("div"), n = p("div");
      for (let l = 0; l < i.length; l += 1)
        i[l].c();
      a = S(), r && r.c(), w(n, "class", "CashierMethodList"), w(e, "class", "CashierMethodListWidget");
    },
    m(l, m) {
      H(l, e, m), c(e, n);
      for (let u = 0; u < i.length; u += 1)
        i[u] && i[u].m(n, null);
      c(e, a), r && r.m(e, null), t[26](e);
    },
    p(l, m) {
      if (m[0] & /*selectedPaymentMethod, paymentMethodsToShow, selectPayMeth, formatter, $_*/
      57664) {
        o = ie(
          /*paymentMethodsToShow*/
          l[8]
        );
        let u;
        for (u = 0; u < o.length; u += 1) {
          const C = me(l, o, u);
          i[u] ? i[u].p(C, m) : (i[u] = he(C), i[u].c(), i[u].m(n, null));
        }
        for (; u < i.length; u += 1)
          i[u].d(1);
        i.length = o.length;
      }
      /*methodsButtonToggleText*/
      l[7] ? r ? r.p(l, m) : (r = fe(l), r.c(), r.m(e, null)) : r && (r.d(1), r = null);
    },
    d(l) {
      l && z(e), De(i, l), r && r.d(), t[26](null);
    }
  };
}
function he(t) {
  let e, n, a, o, i, r, l, m, u = (
    /*payMeth*/
    (t[47].Label || /*payMeth*/
    t[47].Name) + ""
  ), C, E, _, y, A = (
    /*$_*/
    t[13]("generalMin") + ""
  ), D, b, L = (
    /*formatter*/
    t[14].format(
      /*payMeth*/
      t[47].DisplayCurrency.MinAmountLimit
    ) + ""
  ), N, F, M = (
    /*payMeth*/
    t[47].DisplayCurrency.Name + ""
  ), j, G, k, R = (
    /*$_*/
    t[13]("generalMax") + ""
  ), W, B, O = (
    /*formatter*/
    t[14].format(
      /*payMeth*/
      t[47].DisplayCurrency.MaxAmountLimit
    ) + ""
  ), J, V, q = (
    /*payMeth*/
    t[47].DisplayCurrency.Name + ""
  ), Y, X, I, K;
  function Q() {
    return (
      /*click_handler*/
      t[24](
        /*payMeth*/
        t[47]
      )
    );
  }
  return {
    c() {
      e = p("div"), n = p("div"), a = p("img"), r = S(), l = p("div"), m = p("span"), C = P(u), E = S(), _ = p("div"), y = p("span"), D = P(A), b = S(), N = P(L), F = S(), j = P(M), G = S(), k = p("span"), W = P(R), B = S(), J = P(O), V = S(), Y = P(q), X = S(), le(a.src, o = /*payMeth*/
      t[47].LogoUrl) || w(a, "src", o), w(a, "alt", i = /*payMeth*/
      t[47].Label), w(n, "class", "MethodLogo"), w(l, "class", "MethodTitle"), w(y, "class", "Limits"), w(k, "class", "Limits"), w(_, "class", "MethodLimits"), w(e, "class", "SelectorWrapper"), oe(
        e,
        "checked",
        /*selectedPaymentMethod*/
        t[6] === /*payMeth*/
        t[47].Name
      );
    },
    m(U, g) {
      H(U, e, g), c(e, n), c(n, a), c(e, r), c(e, l), c(l, m), c(m, C), c(e, E), c(e, _), c(_, y), c(y, D), c(y, b), c(y, N), c(y, F), c(y, j), c(_, G), c(_, k), c(k, W), c(k, B), c(k, J), c(k, V), c(k, Y), c(e, X), I || (K = [
        ee(e, "click", Q),
        ee(e, "keyup", Je)
      ], I = !0);
    },
    p(U, g) {
      t = U, g[0] & /*paymentMethodsToShow*/
      256 && !le(a.src, o = /*payMeth*/
      t[47].LogoUrl) && w(a, "src", o), g[0] & /*paymentMethodsToShow*/
      256 && i !== (i = /*payMeth*/
      t[47].Label) && w(a, "alt", i), g[0] & /*paymentMethodsToShow*/
      256 && u !== (u = /*payMeth*/
      (t[47].Label || /*payMeth*/
      t[47].Name) + "") && x(C, u), g[0] & /*$_*/
      8192 && A !== (A = /*$_*/
      t[13]("generalMin") + "") && x(D, A), g[0] & /*paymentMethodsToShow*/
      256 && L !== (L = /*formatter*/
      t[14].format(
        /*payMeth*/
        t[47].DisplayCurrency.MinAmountLimit
      ) + "") && x(N, L), g[0] & /*paymentMethodsToShow*/
      256 && M !== (M = /*payMeth*/
      t[47].DisplayCurrency.Name + "") && x(j, M), g[0] & /*$_*/
      8192 && R !== (R = /*$_*/
      t[13]("generalMax") + "") && x(W, R), g[0] & /*paymentMethodsToShow*/
      256 && O !== (O = /*formatter*/
      t[14].format(
        /*payMeth*/
        t[47].DisplayCurrency.MaxAmountLimit
      ) + "") && x(J, O), g[0] & /*paymentMethodsToShow*/
      256 && q !== (q = /*payMeth*/
      t[47].DisplayCurrency.Name + "") && x(Y, q), g[0] & /*selectedPaymentMethod, paymentMethodsToShow*/
      320 && oe(
        e,
        "checked",
        /*selectedPaymentMethod*/
        t[6] === /*payMeth*/
        t[47].Name
      );
    },
    d(U) {
      U && z(e), I = !1, Oe(K);
    }
  };
}
function fe(t) {
  let e, n, a, o;
  return {
    c() {
      e = p("div"), n = P(
        /*methodsButtonToggleText*/
        t[7]
      ), w(e, "class", "ShowAllButton");
    },
    m(i, r) {
      H(i, e, r), c(e, n), a || (o = ee(
        e,
        "click",
        /*click_handler_1*/
        t[25]
      ), a = !0);
    },
    p(i, r) {
      r[0] & /*methodsButtonToggleText*/
      128 && x(
        n,
        /*methodsButtonToggleText*/
        i[7]
      );
    },
    d(i) {
      i && z(e), a = !1, o();
    }
  };
}
function ge(t) {
  let e, n, a;
  return {
    c() {
      e = p("cashier-error"), n = p("span"), a = P(
        /*errorMessage*/
        t[10]
      ), w(n, "slot", "text"), f(
        e,
        "lang",
        /*lang*/
        t[0]
      ), f(
        e,
        "assetsurl",
        /*assetsurl*/
        t[1]
      ), f(
        e,
        "translationurl",
        /*translationurl*/
        t[2]
      ), f(
        e,
        "clientstylingurl",
        /*clientstylingurl*/
        t[4]
      ), f(
        e,
        "clientstyling",
        /*clientstyling*/
        t[3]
      ), f(e, "hidebuttons", "true");
    },
    m(o, i) {
      H(o, e, i), c(e, n), c(n, a);
    },
    p(o, i) {
      i[0] & /*errorMessage*/
      1024 && x(
        a,
        /*errorMessage*/
        o[10]
      ), i[0] & /*lang*/
      1 && f(
        e,
        "lang",
        /*lang*/
        o[0]
      ), i[0] & /*assetsurl*/
      2 && f(
        e,
        "assetsurl",
        /*assetsurl*/
        o[1]
      ), i[0] & /*translationurl*/
      4 && f(
        e,
        "translationurl",
        /*translationurl*/
        o[2]
      ), i[0] & /*clientstylingurl*/
      16 && f(
        e,
        "clientstylingurl",
        /*clientstylingurl*/
        o[4]
      ), i[0] & /*clientstyling*/
      8 && f(
        e,
        "clientstyling",
        /*clientstyling*/
        o[3]
      );
    },
    d(o) {
      o && z(e);
    }
  };
}
function Ie(t) {
  let e, n, a, o = (
    /*showSpinner*/
    t[12] && ue(t)
  ), i = (
    /*showMethodsList*/
    (t[9] || /*desktopView*/
    t[11]) && de(t)
  ), r = (
    /*errorMessage*/
    t[10] && ge(t)
  );
  return {
    c() {
      o && o.c(), e = S(), i && i.c(), n = S(), r && r.c(), a = Ae();
    },
    m(l, m) {
      o && o.m(l, m), H(l, e, m), i && i.m(l, m), H(l, n, m), r && r.m(l, m), H(l, a, m);
    },
    p(l, m) {
      /*showSpinner*/
      l[12] ? o ? o.p(l, m) : (o = ue(l), o.c(), o.m(e.parentNode, e)) : o && (o.d(1), o = null), /*showMethodsList*/
      l[9] || /*desktopView*/
      l[11] ? i ? i.p(l, m) : (i = de(l), i.c(), i.m(n.parentNode, n)) : i && (i.d(1), i = null), /*errorMessage*/
      l[10] ? r ? r.p(l, m) : (r = ge(l), r.c(), r.m(a.parentNode, a)) : r && (r.d(1), r = null);
    },
    i: ne,
    o: ne,
    d(l) {
      l && (z(e), z(n), z(a)), o && o.d(l), i && i.d(l), r && r.d(l);
    }
  };
}
const Je = () => {
};
function Ye(t, e, n) {
  let a;
  Ne(t, Re, (s) => n(13, a = s)), re.extend(We);
  let { lang: o = "en" } = e, { local: i = "en-US" } = e, { endpoint: r } = e, { session: l } = e, { customerid: m } = e, { assetsurl: u } = e, { currency: C } = e, { numberofmethodsshown: E } = e, { translationurl: _ = "" } = e, { clientstyling: y = "" } = e, { clientstylingurl: A = "" } = e, { ismobileview: D } = e, b = [], L, N, F = "", M = [], j = !0, G = new Intl.NumberFormat(i, { minimumFractionDigits: 2 }), k = "", R, W = !0, B = !1;
  var O;
  (function(s) {
    s.PlayerSessionIsNotValid = "PlayerSessionIsNotValid", s.Success = "Success", s.JwtTokenError = "JwtTokenError";
  })(O || (O = {})), xe();
  const J = () => {
    let s = _;
    if (s)
      return fetch(s).then((d) => d.json()).then((d) => {
        Object.keys(d).forEach((T) => {
          ae(T, d[T]);
        });
      }).catch((d) => {
        console.log(d);
      });
  };
  Object.keys(ce).forEach((s) => {
    ae(s, ce[s]);
  });
  const V = () => {
    Be(o);
  }, q = () => {
    n(12, B = !0);
    const s = new URL(`${r}/v1/player/${m}/payment/GetPaymentMetadata`), d = new Headers();
    d.append("accept", "application/json"), d.append("Content-Type", "application/json"), d.append("X-Client-Request-Timestamp", re.utc().format("YYYY-MM-DD HH:mm:ss.SSS"));
    const T = {
      method: "POST",
      headers: d,
      body: JSON.stringify({
        XPaymentSessionToken: l,
        Currency: C,
        Tags: { UserAgent: window.navigator.userAgent }
      })
    };
    fetch(s, T).then((h) => h.json()).then((h) => {
      if (h.error) {
        n(10, k = h.error);
        return;
      }
      if (h.ResponseCode !== O.Success) {
        R = h.ResponseCode, K();
        return;
      }
      b = h.PaymentMethods?.Ordering ? Y(h) : X(h), n(7, F = E && +E > 0 && b.length > +E ? a("showAll") : ""), n(8, M = F ? b.slice(0, +E) : b), window.postMessage(
        {
          type: "StartSessionCountdown",
          paymentMethodName: b[0].Name,
          xPaymentSessionToken: h.XPaymentSessionToken
        },
        window.location.href
      );
    }).finally(() => n(12, B = !1));
  }, Y = (s) => {
    const d = [];
    return s.PaymentMethods.Ordering.DefaultPaymentMethodsOrder.forEach((T) => {
      const h = s.PaymentMethods.PaymentMethods.find((Z) => Z.Name === T);
      if (h) {
        const Z = h?.Logos.find(($) => $.LogoType === "Desktop") || {}, ke = h?.Logos.find(($) => $.LogoType === "Mobile") || {}, se = W ? Z : ke;
        d.push({
          ...h,
          LogoUrl: se.LogoUrl ? `https:${se.LogoUrl}` : ""
        });
      }
    }), d;
  }, X = (s) => s.PaymentMethods.PaymentMethods.map((d) => ({
    ...d,
    LogoUrl: d.Logos && d.Logos.length && d.Logos[0].LogoUrl ? `https:${d.Logos[0].LogoUrl}` : ""
  })), I = (s) => {
    n(6, N = s.Name), window.postMessage({ type: "SelectPayMeth", details: s }, window.location.href), dispatchEvent(new CustomEvent(
      "selectPayMeth",
      {
        detail: s,
        bubbles: !0,
        cancelable: !0,
        composed: !0
      }
    ));
  }, K = () => {
    window.postMessage(
      {
        type: "ErrorResponseCode",
        errorResponseCode: R
      },
      window.location.href
    );
  }, Q = () => {
    n(11, W = D === "false");
  }, U = () => {
    M == b ? we() : g();
  }, g = () => {
    n(8, M = b), n(7, F = a("showLess"));
  }, we = () => {
    n(8, M = b.slice(0, +E)), N && !M.find((s) => s.Name === N) && M.splice(0, 0, b.find((s) => s.Name === N)), n(7, F = a("showAll"));
  }, pe = () => {
    n(9, j = !0);
  }, ye = (s) => {
    n(9, j = !s.hideMethodsList);
  }, be = () => {
    let s = document.createElement("style");
    s.innerHTML = y, L.appendChild(s);
  }, Le = () => {
    let s = new URL(A), d = document.createElement("style");
    fetch(s.href).then((T) => T.text()).then((T) => {
      d.innerHTML = T, setTimeout(
        () => {
          L.appendChild(d);
        },
        1
      ), setTimeout(
        () => {
        },
        500
      );
    });
  };
  Pe(() => (window.addEventListener("message", te, !1), () => {
    window.removeEventListener("message", te, !1);
  }));
  const te = (s) => {
    switch (s.data.type) {
      case "BackToMethodList":
        pe();
        break;
      case "HideMethodsList":
        ye(s.data.details);
        break;
    }
  }, Me = (s) => I(s), ve = () => U();
  function _e(s) {
    Fe[s ? "unshift" : "push"](() => {
      L = s, n(5, L);
    });
  }
  return t.$$set = (s) => {
    "lang" in s && n(0, o = s.lang), "local" in s && n(17, i = s.local), "endpoint" in s && n(18, r = s.endpoint), "session" in s && n(19, l = s.session), "customerid" in s && n(20, m = s.customerid), "assetsurl" in s && n(1, u = s.assetsurl), "currency" in s && n(21, C = s.currency), "numberofmethodsshown" in s && n(22, E = s.numberofmethodsshown), "translationurl" in s && n(2, _ = s.translationurl), "clientstyling" in s && n(3, y = s.clientstyling), "clientstylingurl" in s && n(4, A = s.clientstylingurl), "ismobileview" in s && n(23, D = s.ismobileview);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*endpoint, session, customerid*/
    1835008 && r && l && m && q(), t.$$.dirty[0] & /*lang*/
    1 && o && V(), t.$$.dirty[0] & /*clientstyling, customStylingContainer*/
    40 && y && L && be(), t.$$.dirty[0] & /*clientstylingurl, customStylingContainer*/
    48 && A && L && Le(), t.$$.dirty[0] & /*ismobileview*/
    8388608 && D && Q(), t.$$.dirty[0] & /*lang, translationurl*/
    5 && o && _ && J();
  }, [
    o,
    u,
    _,
    y,
    A,
    L,
    N,
    F,
    M,
    j,
    k,
    W,
    B,
    a,
    G,
    I,
    U,
    i,
    r,
    l,
    m,
    C,
    E,
    D,
    Me,
    ve,
    _e
  ];
}
class Ge extends Se {
  constructor(e) {
    super(), Ce(
      this,
      e,
      Ye,
      Ie,
      Ee,
      {
        lang: 0,
        local: 17,
        endpoint: 18,
        session: 19,
        customerid: 20,
        assetsurl: 1,
        currency: 21,
        numberofmethodsshown: 22,
        translationurl: 2,
        clientstyling: 3,
        clientstylingurl: 4,
        ismobileview: 23
      },
      qe,
      [-1, -1]
    );
  }
  get lang() {
    return this.$$.ctx[0];
  }
  set lang(e) {
    this.$$set({ lang: e }), v();
  }
  get local() {
    return this.$$.ctx[17];
  }
  set local(e) {
    this.$$set({ local: e }), v();
  }
  get endpoint() {
    return this.$$.ctx[18];
  }
  set endpoint(e) {
    this.$$set({ endpoint: e }), v();
  }
  get session() {
    return this.$$.ctx[19];
  }
  set session(e) {
    this.$$set({ session: e }), v();
  }
  get customerid() {
    return this.$$.ctx[20];
  }
  set customerid(e) {
    this.$$set({ customerid: e }), v();
  }
  get assetsurl() {
    return this.$$.ctx[1];
  }
  set assetsurl(e) {
    this.$$set({ assetsurl: e }), v();
  }
  get currency() {
    return this.$$.ctx[21];
  }
  set currency(e) {
    this.$$set({ currency: e }), v();
  }
  get numberofmethodsshown() {
    return this.$$.ctx[22];
  }
  set numberofmethodsshown(e) {
    this.$$set({ numberofmethodsshown: e }), v();
  }
  get translationurl() {
    return this.$$.ctx[2];
  }
  set translationurl(e) {
    this.$$set({ translationurl: e }), v();
  }
  get clientstyling() {
    return this.$$.ctx[3];
  }
  set clientstyling(e) {
    this.$$set({ clientstyling: e }), v();
  }
  get clientstylingurl() {
    return this.$$.ctx[4];
  }
  set clientstylingurl(e) {
    this.$$set({ clientstylingurl: e }), v();
  }
  get ismobileview() {
    return this.$$.ctx[23];
  }
  set ismobileview(e) {
    this.$$set({ ismobileview: e }), v();
  }
}
Ue(Ge, { lang: {}, local: {}, endpoint: {}, session: {}, customerid: {}, assetsurl: {}, currency: {}, numberofmethodsshown: {}, translationurl: {}, clientstyling: {}, clientstylingurl: {}, ismobileview: {} }, [], [], !0);
export {
  Ge as default
};
