import { jsx as n, jsxs as p } from "react/jsx-runtime";
import { useRef as Q } from "react";
import { f, s as e, c as K, Q as V, g as $, a as H, L as J, u as X, d as Y, S as Z } from "./index2.js";
import { N as g, a as oo, b as no, C as eo, P as v, c as h, S as so } from "./useStreamLayerApp2.js";
const ao = /* @__PURE__ */ e("div")({
  name: "Container",
  class: "c5b6wdg",
  propsAsIs: !1
}), io = "a1rlj479", to = "s35f1di", ro = "sj4471g", lo = "b12050d8", co = "b1d5ybek", po = (o) => o === "left" || o === "right" ? to : lo, mo = (o) => o === "left" || o === "right" ? ro : co, uo = (o) => o === "left" ? "avdxyl3" : o === "right" ? "a1bisd08" : o === "top" ? "a1u9y2aj" : "a1qqaks", N = ({
  children: o,
  style: s,
  className: i,
  enabled: t = !0,
  hiding: a,
  direction: r = "left",
  onAnimationEnd: l
}) => /* @__PURE__ */ n(ao, {
  style: s,
  className: f(i, io, uo(r), t && !a && po(r), t && a && mo(r)),
  onAnimationEnd: l,
  children: o
}), vo = /* @__PURE__ */ e("a")({
  name: "Link",
  class: "l1sgte8c",
  propsAsIs: !1
}), Io = /* @__PURE__ */ e("div")({
  name: "BannerContainer",
  class: "b7yfc72",
  propsAsIs: !1
}), go = () => vo, ho = /* @__PURE__ */ e(go())({
  name: "BannerLink",
  class: "bejjq94",
  propsAsIs: !0
}), Ao = /* @__PURE__ */ e("img")({
  name: "BannerImg",
  class: "b1j94hdr",
  propsAsIs: !1
}), bo = ({ promotion: o, promotionId: s, hiding: i, direction: t = "bottom" }) => {
  var a;
  return (a = o.additionalBanner) != null && a.imageUrl ? /* @__PURE__ */ n(N, { direction: t, hiding: i, children: /* @__PURE__ */ n(Io, { className: "BannerContainer", children: /* @__PURE__ */ n(
    ho,
    {
      className: "BannerLink",
      href: o.additionalBanner.url,
      style: { backgroundImage: `url(${o.additionalBanner.imageUrl})` },
      "data-promo-id": s,
      "data-promo-type": o.type,
      "data-analytics": "banner",
      target: "_blank",
      children: /* @__PURE__ */ n(Ao, { src: o.additionalBanner.imageUrl, alt: "promo" })
    }
  ) }) }) : null;
}, yo = /* @__PURE__ */ e("div")({
  name: "NotificationContent",
  class: "n1ku6hz",
  propsAsIs: !1
}), fo = /* @__PURE__ */ e("div")({
  name: "NotificationContainer",
  class: "nbxqmol",
  propsAsIs: !1
}), $o = /* @__PURE__ */ e("div")({
  name: "Body",
  class: "b1gu3eml",
  propsAsIs: !1
}), No = /* @__PURE__ */ e("div")({
  name: "Title",
  class: "t1u17zva",
  propsAsIs: !1
}), Co = /* @__PURE__ */ e("div")({
  name: "Text",
  class: "t10ko1g",
  propsAsIs: !1
}), A = /* @__PURE__ */ e("div")({
  name: "Media",
  class: "mntc42e",
  propsAsIs: !1
}), So = () => A, w = /* @__PURE__ */ e(So())({
  name: "MediaImgFit",
  class: "ml060eo",
  propsAsIs: !0
}), Mo = () => A, W = /* @__PURE__ */ e(Mo())({
  name: "MediaImgCentered",
  class: "m1vqlvig",
  propsAsIs: !0
}), To = () => W, ko = /* @__PURE__ */ e(To())({
  name: "MediaImgBottom",
  class: "m1e7tvi5",
  propsAsIs: !0
}), Bo = () => A, Lo = /* @__PURE__ */ e(Bo())({
  name: "MediaImgSolid",
  class: "mqvntt2",
  propsAsIs: !0
}), Eo = () => A, Oo = /* @__PURE__ */ e(Eo())({
  name: "MediaImgMiddle",
  class: "m12jtj3u",
  propsAsIs: !0
}), xo = /* @__PURE__ */ e("img")({
  name: "CtaIcon",
  class: "ckq1frv",
  propsAsIs: !1
}), _o = /* @__PURE__ */ e("button")({
  name: "Button",
  class: "bis90pl",
  propsAsIs: !1
}), Po = () => K, jo = /* @__PURE__ */ e(Po())({
  name: "StyledChevronRight",
  class: "s9mjmz3",
  propsAsIs: !0
}), qo = /* @__PURE__ */ e("div")({
  name: "Logo",
  class: "l1cf50a7",
  propsAsIs: !1
}), Do = {
  [g.UNSET]: w,
  [g.FIT]: w,
  [g.CENTERED]: W,
  [g.BOTTOM]: ko,
  [g.SOLID]: Lo,
  [g.MIDDLE]: Oo
}, Ro = ({ src: o, imagePosition: s }) => {
  const i = Do[s];
  return /* @__PURE__ */ n(i, { children: /* @__PURE__ */ n("img", { src: o, alt: "" }) });
}, Uo = ({ notification: o, promotionId: s, hiding: i, direction: t = "left" }) => {
  if (!o || !o.promotion || o.enabled !== oo.NOTIFICATION_ENABLED)
    return null;
  const { title: a, body: r, image: l, promotion: u } = o, { sponsorLogo: m, sponsorLogoMode: c, imagePosition: I, ctaButton: d } = u;
  return /* @__PURE__ */ n(N, { direction: t, hiding: i, children: /* @__PURE__ */ p(fo, { children: [
    c !== no.NOTIFICATION_SPONSOR_LOGO_NONE && /* @__PURE__ */ n(qo, { children: /* @__PURE__ */ n("img", { src: m, alt: a }) }),
    /* @__PURE__ */ p(yo, { children: [
      /* @__PURE__ */ n(Ro, { src: l, imagePosition: I }),
      /* @__PURE__ */ p($o, { children: [
        a && /* @__PURE__ */ n(No, { children: a }),
        r && /* @__PURE__ */ n(Co, { children: r })
      ] }),
      /* @__PURE__ */ p(_o, { name: "promo-button", style: { color: d == null ? void 0 : d.textColor, backgroundColor: d == null ? void 0 : d.color }, children: [
        (d == null ? void 0 : d.ctaIcon) && (d == null ? void 0 : d.ctaIconMode) === eo.CTA_ICON_TRANSPARENT && /* @__PURE__ */ n(xo, { src: d == null ? void 0 : d.ctaIcon, alt: "cta-icon" }),
        (d == null ? void 0 : d.label) || "Open"
      ] }),
      /* @__PURE__ */ n(jo, { name: "chevronRight" })
    ] })
  ] }) });
}, wo = /* @__PURE__ */ e("div")({
  name: "OverlayContainer",
  class: "okzhq2w",
  propsAsIs: !1
}), Fo = /* @__PURE__ */ e("div")({
  name: "PromoOverlay",
  class: "pmgz5i",
  propsAsIs: !1
}), Go = /* @__PURE__ */ e("div")({
  name: "Header",
  class: "hyxi3jt",
  propsAsIs: !1
}), zo = /* @__PURE__ */ e("div")({
  name: "HeaderContent",
  class: "h149e3gp",
  propsAsIs: !1
}), Ko = "h10toh7", F = /* @__PURE__ */ e("img")({
  name: "SponsorLogo",
  class: "s1jyea6t",
  propsAsIs: !1
}), Ho = /* @__PURE__ */ e("div")({
  name: "SponsorName",
  class: "szpfa3h",
  propsAsIs: !1
}), Wo = /* @__PURE__ */ e("div")({
  name: "Media",
  class: "m1crmu01",
  propsAsIs: !1
}), Qo = /* @__PURE__ */ e("img")({
  name: "PromoImg",
  class: "p1l37r8s",
  propsAsIs: !1
}), Vo = "s1nmch9k", G = /* @__PURE__ */ e("div")({
  name: "Content",
  class: "c1er0ljd",
  propsAsIs: !1
}), Jo = /* @__PURE__ */ e("div")({
  name: "Description",
  class: "dydopmr",
  propsAsIs: !1
}), Xo = /* @__PURE__ */ e("div")({
  name: "Sponsor",
  class: "s1w6nt04",
  propsAsIs: !1
}), Yo = /* @__PURE__ */ e("div")({
  name: "SponsorText",
  class: "s1evcmtq",
  propsAsIs: !1
}), Zo = /* @__PURE__ */ e("div")({
  name: "ADLogo",
  class: "awodx0x",
  propsAsIs: !1
}), on = /* @__PURE__ */ e("span")({
  name: "SponsoredText",
  class: "s1q3n6oi",
  propsAsIs: !1
}), nn = /* @__PURE__ */ e("div")({
  name: "CloseIconWrap",
  class: "c8d4xfk",
  propsAsIs: !1
}), en = () => K, sn = /* @__PURE__ */ e(en())({
  name: "CloseIcon",
  class: "ct6oobh",
  propsAsIs: !0
}), an = /* @__PURE__ */ e("div")({
  name: "ActionBtnWrap",
  class: "a1gyg7tt",
  propsAsIs: !1
}), tn = /* @__PURE__ */ e("a")({
  name: "ActionButton",
  class: "a17rwbtk",
  propsAsIs: !1
}), rn = /* @__PURE__ */ e("div")({
  name: "Title",
  class: "t3vxzaw",
  propsAsIs: !1
}), ln = "h10f3u0j", z = ({ promotion: o, promotionId: s, onClose: i }) => {
  var t, a, r, l, u, m, c, I, d, C, S, M, T, k, B, L, E, O, x, _, P, j, q, D, R, U;
  const b = o.type === v.INGAME_IAB11_LBAR || o.type === v.INGAME_IAB11, y = ((t = o.sponsor) == null ? void 0 : t.logo) && o.logoMode === h.CENTER;
  return /* @__PURE__ */ p(Fo, { className: "PromoOverlay", children: [
    /* @__PURE__ */ p(Go, { children: [
      /* @__PURE__ */ p(zo, { className: f(!y && Ko), children: [
        ((a = o.sponsor) == null ? void 0 : a.logo) && o.logoMode === h.LEFT && /* @__PURE__ */ n(F, { src: (r = o.sponsor) == null ? void 0 : r.logo, alt: "promo" }),
        /* @__PURE__ */ p(
          Xo,
          {
            style: {
              paddingLeft: (l = o.sponsor) != null && l.logo && o.logoMode === h.LEFT ? "0px" : "8px"
            },
            children: [
              ((u = o.sponsor) == null ? void 0 : u.logo) && o.logoMode === h.LEFT && /* @__PURE__ */ n(Ho, { children: (m = o.sponsor) == null ? void 0 : m.name }),
              /* @__PURE__ */ p(Yo, { className: "SponsorText", children: [
                /* @__PURE__ */ n(Zo, { children: "AD" }),
                /* @__PURE__ */ n(on, { children: "SPONSORED" })
              ] })
            ]
          }
        )
      ] }),
      /* @__PURE__ */ n(nn, { className: "ClosePromoIcon", onClick: i, children: /* @__PURE__ */ n(sn, { name: "icon-cross" }) })
    ] }),
    /* @__PURE__ */ p(Wo, { children: [
      y && /* @__PURE__ */ n(F, { className: Vo, src: (c = o.sponsor) == null ? void 0 : c.logo, alt: "promo" }),
      /* @__PURE__ */ n(G, { children: (d = (I = o.banner) == null ? void 0 : I.video) != null && d.url ? /* @__PURE__ */ n(
        V,
        {
          source: (S = (C = o.banner) == null ? void 0 : C.video) == null ? void 0 : S.url,
          poster: (T = (M = o.banner) == null ? void 0 : M.video) == null ? void 0 : T.thumbnailUrl,
          aspectRatio: b ? "1/1" : "16/9",
          onPlay: () => {
            $.emit("advertisement", {
              action: "videoPlay",
              payload: {
                advertisementId: s,
                advertisementType: o.type
              }
            });
          }
        }
      ) : (k = o.banner) != null && k.imageUrl ? /* @__PURE__ */ n(Qo, { style: b ? { aspectRatio: "1/1" } : {}, src: (B = o.banner) == null ? void 0 : B.imageUrl, alt: "promo" }) : null }),
      !b && /* @__PURE__ */ p(G, { children: [
        ((L = o.banner) == null ? void 0 : L.title) && /* @__PURE__ */ n(rn, { className: f("AdvTitle", y && ln), children: (E = o.banner) == null ? void 0 : E.title }),
        ((O = o.banner) == null ? void 0 : O.body) && /* @__PURE__ */ n(Jo, { className: "AdvDescription", children: (x = o.banner) == null ? void 0 : x.body })
      ] })
    ] }),
    /* @__PURE__ */ n(an, { children: /* @__PURE__ */ n(
      tn,
      {
        href: (_ = o.banner) == null ? void 0 : _.url,
        style: {
          backgroundColor: ((j = (P = o.banner) == null ? void 0 : P.ctaButton) == null ? void 0 : j.color) || "#009dc4",
          color: ((D = (q = o.banner) == null ? void 0 : q.ctaButton) == null ? void 0 : D.textColor) || "#fff"
        },
        "data-analytics": "button",
        "data-promo-id": s,
        "data-promo-type": o.type,
        target: "_blank",
        children: (U = (R = o.banner) == null ? void 0 : R.ctaButton) == null ? void 0 : U.label
      }
    ) })
  ] });
}, dn = /* @__PURE__ */ e("div")({
  name: "SidebarContainer",
  class: "s1abskp8",
  propsAsIs: !1
}), cn = ({
  children: o,
  direction: s,
  style: i,
  className: t,
  hiding: a
}) => /* @__PURE__ */ n(N, {
  direction: s,
  style: i,
  hiding: a,
  className: t,
  children: /* @__PURE__ */ n(dn, {
    children: o
  })
}), pn = (o) => (o == null ? void 0 : o.type) === v.INGAME_IAB11_LBAR || (o == null ? void 0 : o.type) === v.INGAME_IAB21_LBAR, mn = (o) => (o == null ? void 0 : o.type) === v.INGAME_IAB11 || (o == null ? void 0 : o.type) === v.INGAME_IAB21, un = ({
  advertisement: o,
  close: s,
  skipTypeCheck: i,
  layoutMode: t = "side-by-side",
  sidebar: a,
  isNotification: r,
  banner: l
}) => r && o.notification ? /* @__PURE__ */ n(Uo, { notification: o.notification, promotionId: o.question.id }) : !a && !l && (i || mn(o.promotion)) ? /* @__PURE__ */ n(wo, { className: "PromoOverlayContainer", children: /* @__PURE__ */ n(z, { promotionId: o.question.id, promotion: o.promotion, onClose: s }) }) : a && (i || pn(o.promotion)) ? /* @__PURE__ */ n(cn, { className: "PromoSidebarContainer", direction: a, hiding: !1, children: /* @__PURE__ */ n(z, { promotionId: o.question.id, promotion: o.promotion, onClose: s }) }) : l ? /* @__PURE__ */ n(
  bo,
  {
    promotionId: o.question.id,
    hiding: !1,
    promotion: o.promotion,
    direction: l
  }
) : null, vn = /* @__PURE__ */ e("div")({
  name: "AdvertisementUIWrap",
  class: "aa6pjif",
  propsAsIs: !1
}), In = (o) => {
  const s = o.target;
  if (s instanceof HTMLAnchorElement && s.target === "_blank") {
    const i = s.getAttribute("data-promo-id") || "", t = s.getAttribute("data-promo-type") || v.UNSET;
    s.getAttribute("data-analytics") === "button" && $.emit("advertisement", {
      action: "buttonSelect",
      payload: {
        advertisementId: i,
        advertisementType: t
      }
    }), s.getAttribute("data-analytics") === "banner" && $.emit("advertisement", {
      action: "bannerSelect",
      payload: {
        advertisementId: i,
        advertisementType: t
      }
    });
  }
}, gn = ({
  gamification: o,
  layoutMode: s,
  skipTypeCheck: i,
  sidebar: t,
  banner: a,
  notification: r,
  isMobileScreen: l,
  persistent: u
}) => {
  const m = Q(null), c = H(o.advertisement.$store);
  J(m, {
    enabled: !!c.data,
    event: "click",
    listener: In
  });
  const I = !a && !t;
  return c.data === void 0 || !u && c.isViewed ? null : /* @__PURE__ */ n(vn, {
    ref: m,
    style: {
      height: I ? "auto" : "100%"
    },
    className: l ? "mobile-view" : "",
    children: /* @__PURE__ */ n(un, {
      skipTypeCheck: i,
      sidebar: t,
      banner: a,
      advertisement: c.data,
      close: c.close,
      layoutMode: s,
      isNotification: r
    })
  });
}, hn = ({
  sdk: o,
  sidebar: s,
  banner: i,
  skipTypeCheck: t,
  layoutMode: a,
  isMobileScreen: r,
  persistent: l,
  notification: u
}) => {
  const m = H(o.featuresList.getStore());
  if (s && i)
    return /* @__PURE__ */ n("div", {
      style: {
        color: "red"
      },
      children: "define either sidebar or banner, not both."
    });
  if (!m)
    return null;
  const c = o.getFeature(so.GAMES);
  return c ? /* @__PURE__ */ n(gn, {
    gamification: c,
    sidebar: s,
    banner: i,
    layoutMode: a,
    isMobileScreen: r,
    persistent: l,
    notification: u,
    skipTypeCheck: t
  }) : null;
}, $n = ({
  event: o,
  sidebar: s,
  banner: i,
  isMobileScreen: t,
  persistent: a,
  notification: r
}) => {
  const l = X();
  return l ? /* @__PURE__ */ p("div", { className: "StreamLayerSDK", children: [
    /* @__PURE__ */ n(Y, { children: /* @__PURE__ */ n(
      hn,
      {
        sdk: l,
        sidebar: s,
        banner: i,
        isMobileScreen: t,
        persistent: a,
        notification: r,
        layoutMode: "side-by-side"
      }
    ) }),
    o !== void 0 && /* @__PURE__ */ n(Z, { event: o })
  ] }) : null;
};
export {
  $n as StreamLayerSDKAdvertisement,
  hn as StreamLayerSDKAdvertisementUI
};
