var ge = Object.defineProperty;
var me = (e, s, n) => s in e ? ge(e, s, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[s] = n;
var g = (e, s, n) => me(e, typeof s != "symbol" ? s + "" : s, n);
import { jsx as t, jsxs as m, Fragment as L } from "react/jsx-runtime";
import { a3 as V, u, F as fe, s as h, T as re, i as ke, x as ye, a as Ne, N as be, k as Se, M as Ie, b as Ee, e as we, C as Ae, g as Ce, O as ae, m as P, l as $e, h as Le, j as De, n as le, o as Te, p as xe, q as Oe, r as M, t as Re, v as de, w as U, y as Ve, z as Pe, I as Q, c as ce, B as Qe, D as _e, E as qe, G as Fe, H as x, J as G, K as Ke, L as Me, P as Ue, Q as ze, U as Be, V as We, W as _, _ as Ge, f as q, $ as He, a0 as je, X as Xe, Y as Ye, Z as Ze, a4 as Je, a1 as pe, a2 as H } from "./index2.js";
import { createContext as es, useContext as z, useRef as $, useState as E, useEffect as k, useTransition as ss, lazy as ns, useMemo as C, Suspense as ts, forwardRef as os, useLayoutEffect as is, useCallback as R } from "react";
import { C as A, c as j, Q as O, S as D } from "./useStreamLayerApp2.js";
window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));
function rs(e) {
  return e instanceof DOMException && // everything except Firefox
  (e.code === 22 || // Firefox
  e.code === 1014 || // test name field too, because code might not be present
  // everything except Firefox
  e.name === "QuotaExceededError" || // Firefox
  e.name === "NS_ERROR_DOM_QUOTA_REACHED");
}
class as {
  constructor(s = "main", n = window.localStorage) {
    g(this, "delimiter", ":");
    g(this, "prefix");
    g(this, "storage");
    g(this, "clear", () => {
      for (const s in window.localStorage)
        s.startsWith(this.prefix) && this.storage.removeItem(s);
    });
    g(this, "generateKey", (s) => `${this.prefix}${this.delimiter}${s.join(this.delimiter)}`);
    g(this, "write", (...s) => {
      const n = s.pop() || "", o = this.generateKey(s);
      try {
        this.storage.setItem(o, n);
      } catch (i) {
        rs(i) && this.storage === window.sessionStorage && (window.sessionStorage.removeItem("slstreamlogs"), this.storage.setItem(o, n));
      }
    });
    g(this, "read", (...s) => {
      const n = this.storage.getItem(this.generateKey(s));
      return n === null ? void 0 : n;
    });
    g(this, "remove", (...s) => {
      this.storage.removeItem(this.generateKey(s));
    });
    this.prefix = `sl-sdk${this.delimiter}${s}`, this.storage = n;
  }
}
var X;
(function(e) {
  e.Init = "init", e.Ready = "ready", e.Connecting = "connecting", e.Connected = "connected", e.Disconnected = "disconnected", e.Failed = "failed", e.Reconnect = "reconnect", e.Reconnecting = "reconnecting";
})(X || (X = {}));
A.Unknown, A.Internal, A.DeadlineExceeded, A.ResourceExhausted, A.FailedPrecondition, A.Unavailable, A.DataLoss;
V("grpc:retry");
j(10, { description: "Number of attempts to retry" }), j(3e4, { description: "Max delay between retries in milliseconds" });
var I;
(function(e) {
  e.SCHEMA = "schema", e.EXTERNAL_TOKEN = "eToken", e.TOKEN = "token";
})(I || (I = {}));
class ls extends as {
  constructor() {
    super("user");
    // Schema
    g(this, "setSchema", (n) => {
      this.write(I.SCHEMA, n);
    });
    g(this, "getSchema", () => this.read(I.SCHEMA));
    // Token
    g(this, "setToken", (n) => {
      this.write(I.TOKEN, n);
    });
    g(this, "getToken", () => this.read(I.TOKEN));
    // External Token
    g(this, "setExternalToken", (n) => {
      this.write(I.EXTERNAL_TOKEN, n);
    });
    g(this, "getExternalToken", () => this.read(I.EXTERNAL_TOKEN));
    g(this, "removeToken", () => {
      this.remove(I.TOKEN);
    });
  }
}
var Y;
(function(e) {
  e.DISABLED = "disabled", e.INITIALIZATION = "initialization", e.READY = "ready", e.FAILED = "failed", e.SUSPENDED = "suspended";
})(Y || (Y = {}));
V("deep_link");
V("bypass");
new ls();
V("video_player");
var Z;
(function(e) {
  e.SHOWED = "showed";
})(Z || (Z = {}));
var J;
(function(e) {
  e.ALLOWED = "allowed", e.DISALLOWED = "disallowed";
})(J || (J = {}));
var ee;
(function(e) {
  e.UNKNOWN = "unknown", e.ALREADY_VOTED = "already_voted";
})(ee || (ee = {}));
var se;
(function(e) {
  e.ONBOARDING = "onboarding", e.ONBOARDING_IO = "onboarding_io";
})(se || (se = {}));
var ne;
(function(e) {
  e.Unset = "unset", e.Required = "required", e.Optional = "optional", e.Completed = "completed", e.Disabled = "disabled", e.Unavailable = "unavailable";
})(ne || (ne = {}));
O.POLL, O.PREDICTION, O.TRIVIA;
const ds = {
  [D.GAMES]: !0
}, F = /* @__PURE__ */ h("div")({
  name: "LoadingContainer",
  class: "lclc0ej",
  propsAsIs: !1
}), cs = ({
  feature: e,
  sdk: s,
  children: n,
  className: o,
  noWait: i
}) => {
  const a = u(e.status), l = u(s.sdkStore.slStreamId);
  if (!i) {
    if (l != null && l.loading && !l.data)
      return /* @__PURE__ */ t(F, {
        className: o,
        children: "Event is loading..."
      });
    if (!(l != null && l.data))
      return /* @__PURE__ */ t(F, {
        className: o,
        children: "Event is forbidden..."
      });
    if (a !== fe.Ready)
      return /* @__PURE__ */ t(F, {
        className: o,
        children: "Wait feature..."
      });
  }
  return n;
}, ue = es({
  sdk: null
}), B = () => z(ue), ps = /* @__PURE__ */ h("div")({
  name: "QuestionContainer",
  class: "q14ckf9e",
  propsAsIs: !1
}), us = ({
  openedQuestion: e
}) => {
  var s, n;
  const {
    sdk: o
  } = B();
  return ((s = e == null ? void 0 : e.attributes) == null ? void 0 : s.attributes.case) === "insight" ? /* @__PURE__ */ t(ye, {
    ...e.attributes.attributes.value,
    controlVideo: o == null ? void 0 : o.controlVideoPlayer
  }) : ((n = e == null ? void 0 : e.attributes) == null ? void 0 : n.attributes.case) === "tweet" ? /* @__PURE__ */ t(Ne, {
    ...e.attributes.attributes.value,
    controlVideo: o == null ? void 0 : o.controlVideoPlayer
  }) : null;
}, hs = ({
  extendedQuestion: e,
  vote: s,
  close: n
}) => {
  const {
    loading: o,
    data: i
  } = e;
  return i ? /* @__PURE__ */ t(be, {
    vote: s,
    close: n,
    openedQuestion: i,
    isLoading: !!o
  }) : /* @__PURE__ */ t(Se, {});
}, vs = ({
  gamification: e
}) => {
  var s, n, o;
  const i = u(e.openedQuestion.$store), a = u(e.openedQuestion.$extendedStore);
  if (!i)
    return null;
  const l = i.type;
  return /* @__PURE__ */ m(ps, {
    children: [/* @__PURE__ */ t(re, {
      close: e.closeQuestion,
      type: ((s = i.attributes) == null ? void 0 : s.type) || O.UNSET
    }), l === "question" && /* @__PURE__ */ t(hs, {
      vote: e.submitAnswer,
      close: e.closeQuestion,
      extendedQuestion: a
    }), l !== "question" && /* @__PURE__ */ t(us, {
      openedQuestion: i
    }), /* @__PURE__ */ t(ke, {
      sponsorLogo: (o = (n = a.data) == null ? void 0 : n.sponsorship) == null ? void 0 : o.logo
    })]
  });
}, gs = /* @__PURE__ */ h("div")({
  name: "InviteFriendsContainer",
  class: "i1c9dygq",
  propsAsIs: !1
}), ms = ({
  deepLink: e
}) => /* @__PURE__ */ t(gs, {
  children: /* @__PURE__ */ t(Ie, {
    inviteLink: e,
    inviteCardTitle: "It’s More Fun With Friends",
    inviteCardSubtext: "Invite and compete against your friends for the top spot on the leaderboard."
  })
}), fs = /* @__PURE__ */ h("div")({
  name: "InviteLinkContainer",
  class: "i1odbhm4",
  propsAsIs: !1
}), ks = ({
  gamification: e,
  scrollNode: s,
  scrollStore: n
}) => {
  const o = $(null), {
    data: i,
    hasMore: a,
    loading: l,
    key: d
  } = u(e.leaderboardList.$store), {
    data: r
  } = u(e.deepLink.$store), [p, c] = Ee(o);
  return !i.length && !l ? /* @__PURE__ */ t(ms, {
    deepLink: r
  }) : /* @__PURE__ */ m(L, {
    children: [/* @__PURE__ */ t(we, {
      items: i,
      scrollNode: s,
      scrollStore: n,
      fetchMore: e.leaderboardList.fetchMore,
      hasMore: a,
      openItemDetail: e.openUser,
      currentUserId: e.currentUserId.get()
    }, d), r && /* @__PURE__ */ t(fs, {
      ref: o,
      children: /* @__PURE__ */ t(Ae, {
        onClick: () => p(r),
        title: "Invite Friends",
        description: "Challenge them now!"
      })
    }), c]
  });
}, ys = ({ store: e, openQuestion: s }) => {
  const { sdk: n } = B(), o = u(e);
  return /* @__PURE__ */ t(Ce, { openQuestion: s, questions: o.data, controlVideo: n == null ? void 0 : n.controlVideoPlayer });
}, Ns = ({ userSummary: e }) => {
  var s;
  const [n, o] = E(void 0);
  return k(() => {
    const i = e.$store.subscribe((a) => {
      a && o(a);
    });
    return () => {
      i();
    };
  }, [e]), /* @__PURE__ */ t(ae, { loading: !(n != null && n.summary), ...n == null ? void 0 : n.summary, successRate: (s = n == null ? void 0 : n.percentage) == null ? void 0 : s.correct });
}, bs = ({ gamification: e, className: s, scrollStore: n, scrollNode: o, appNode: i, style: a, responsiveStore: l }) => {
  const { tabsShown: d } = u(n, { keys: ["tabsShown"] }), [r, p] = E(P.HOME), [, c] = ss(), { sdkInDesktopView: v, screen: f } = u(l, { keys: ["sdkInDesktopView"] }), N = (S) => {
    c(() => {
      var y;
      p(S), v === !1 && (((y = i.current) == null ? void 0 : y.getBoundingClientRect().y) || 0) < 0 && M(i, f.size, { behavior: "instant" });
    });
  };
  k(() => n.subscribe((S) => {
    if (S.scrollPosition === 0) {
      n.setKey("tabsShown", !0);
      return;
    }
    l.get().sdkInDesktopView ? n.setKey("tabsShown", S.scrollDirection === "backward") : n.setKey("tabsShown", S.scrollDirection === "forward");
  }), [n, l]);
  let b = "0px";
  return v ? b = d ? "0px" : "calc(8px - var(--header-height) - var(--header-offset))" : b = d ? "calc(var(--header-height) + var(--header-offset) - 2px)" : "0px", /* @__PURE__ */ m($e, { className: s, style: a, children: [
    /* @__PURE__ */ t(
      Le,
      {
        style: {
          top: b
        },
        children: /* @__PURE__ */ t(De, { activePage: r, toggleActivePage: N })
      }
    ),
    r === P.HOME && /* @__PURE__ */ m(L, { children: [
      /* @__PURE__ */ t(le, { style: { paddingTop: "8px" }, children: /* @__PURE__ */ t(Te, { children: /* @__PURE__ */ t(Ns, { userSummary: e.userSummary }) }) }),
      /* @__PURE__ */ t(xe, { style: { flex: 1 }, children: /* @__PURE__ */ t(ys, { openQuestion: e.openQuestion, store: e.feedList.getStore() }) })
    ] }),
    r === P.LEADERBOARD && /* @__PURE__ */ t(Oe, { children: /* @__PURE__ */ t(ks, { scrollStore: n, scrollNode: o, gamification: e }) })
  ] });
}, Ss = () => U, te = /* @__PURE__ */ h(Ss())({
  name: "OpenedContainer",
  class: "ouvguos",
  propsAsIs: !0
}), Is = /* @__PURE__ */ h("div")({
  name: "UserContainer",
  class: "u1eu4lbg",
  propsAsIs: !1
}), Es = ({
  correct: e,
  incorrect: s
}) => {
  const n = e + s;
  return n === 0 ? 0 : Math.round(e / n * 100);
}, mn = ({
  gamification: e,
  scrollStore: s,
  className: n,
  appNode: o,
  scrollNode: i,
  responsiveStore: a
}) => /* @__PURE__ */ t(bs, {
  appNode: o,
  scrollStore: s,
  scrollNode: i,
  className: n,
  gamification: e,
  responsiveStore: a
}), ws = ({
  gamification: e,
  className: s,
  appNode: n,
  responsiveStore: o
}) => {
  const i = u(e.openedQuestion.$store), a = u(e.openedUser), {
    sdkInDesktopView: l
  } = u(o, {
    keys: ["sdkInDesktopView"]
  }), {
    hiding: d,
    onAnimationEnd: r
  } = Re();
  if (!n.current || !i && !a)
    return null;
  const p = i ? /* @__PURE__ */ t(te, {
    className: s,
    hiding: d,
    onAnimationEnd: r,
    children: /* @__PURE__ */ t(vs, {
      gamification: e
    })
  }) : a ? /* @__PURE__ */ t(te, {
    className: s,
    hiding: d,
    onAnimationEnd: r,
    children: /* @__PURE__ */ m(Is, {
      children: [/* @__PURE__ */ t(re, {
        label: "Friend's Rank",
        close: e.closeUser
      }), /* @__PURE__ */ t(le, {
        children: /* @__PURE__ */ t(ae, {
          ...a,
          successRate: Es(a)
        })
      })]
    })
  }) : null;
  return /* @__PURE__ */ t(de, {
    container: n,
    useContainer: !l,
    children: p
  });
}, As = ns(() => import("./gamification-feature.js")), Cs = ({ sdk: e, feature: s, className: n, scrollStore: o, appNode: i, scrollNode: a, responsiveStore: l }) => {
  const d = C(() => s && s.featureConfig.get().type === D.GAMES ? /* @__PURE__ */ t(cs, { className: n, sdk: e, feature: s, children: /* @__PURE__ */ t(
    As,
    {
      appNode: i,
      scrollStore: o,
      scrollNode: a,
      className: n,
      responsiveStore: l,
      gamification: s
    }
  ) }) : null, [e, s, n, l, o, a, i]);
  return /* @__PURE__ */ t(
    ts,
    {
      fallback: /* @__PURE__ */ t("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", width: "100%", height: "100%" }, children: "page loading..." }),
      children: d
    }
  );
}, $s = ({ feature: e, className: s, appNode: n, responsiveStore: o }) => e && e.featureConfig.get().type === D.GAMES ? /* @__PURE__ */ t(
  ws,
  {
    className: s,
    appNode: n,
    responsiveStore: o,
    gamification: e
  }
) : null, Ls = () => ce, Ds = /* @__PURE__ */ h(Ls())({
  name: "ButtonIcon",
  class: "b11wpe79",
  propsAsIs: !0
}), Ts = os(({
  sdk: e,
  className: s
}, n) => {
  const o = u(e.sdkStore.organizationSettings), i = u(e.sdkStore.streamSettings), a = u(e.getActiveFeature()), l = C(() => {
    const r = (i == null ? void 0 : i.data) || (o == null ? void 0 : o.data);
    return r != null && r.overlays ? r.overlays : [];
  }, [o, i]), d = C(() => [...l.filter(({
    enableSdkButton: r
  }) => r).map((r) => ({
    id: r.type,
    onClick: () => e.openFeature(r.type),
    disabled: !(r.type in ds),
    label: r.name,
    icon: /* @__PURE__ */ t("img", {
      src: r.icon,
      alt: ""
    }),
    /** multiplied by 10 to add the ability to insert custom buttons between our buttons */
    position: r.position * 10
  }))].sort((r, p) => r.position - p.position), [l, e]);
  return /* @__PURE__ */ m(Ve, {
    className: s,
    children: [/* @__PURE__ */ t(Pe, {
      children: [/* @__PURE__ */ t(Q, {
        id: "Channels",
        onClick: () => e.closeFeature(),
        label: "Channels",
        active: a === 0
      }, "Channels"), ...d.map((r) => r.id === D.GAMES ? /* @__PURE__ */ t(Q, {
        ...r,
        active: r.id === a,
        label: "StreamLayer +",
        id: "featuredGroups",
        icon: /* @__PURE__ */ t(Ds, {
          name: "icon-btn-feature-groups",
          "data-selected": r.id === a
        })
      }, r.id) : /* @__PURE__ */ t(Q, {
        ...r,
        icon: void 0,
        active: r.id === a
      }, r.id))]
    }), /* @__PURE__ */ t("div", {
      ref: n
    })]
  });
}), xs = /* @__PURE__ */ h("div")({
  name: "Container",
  class: "c1qjj4d4",
  propsAsIs: !1
}), Os = /* @__PURE__ */ h("div")({
  name: "CloseIconWrap",
  class: "c1lg6b8a",
  propsAsIs: !1
}), Rs = () => ce, Vs = /* @__PURE__ */ h(Rs())({
  name: "CloseIcon",
  class: "c159el66",
  propsAsIs: !0
}), Ps = /* @__PURE__ */ h("div")({
  name: "Title",
  class: "t16xmufv",
  propsAsIs: !1
}), Qs = /* @__PURE__ */ h("img")({
  name: "SponsorLogo",
  class: "s83lc21",
  propsAsIs: !1
}), _s = /* @__PURE__ */ h("div")({
  name: "PresentsTitle",
  class: "p1p7igia",
  propsAsIs: !1
}), qs = /* @__PURE__ */ h("div")({
  name: "Subtitle",
  class: "s1eftsbu",
  propsAsIs: !1
}), Fs = /* @__PURE__ */ h("div")({
  name: "Description",
  class: "d8uezec",
  propsAsIs: !1
}), Ks = /* @__PURE__ */ h("button")({
  name: "ActionButton",
  class: "a1h1bk90",
  propsAsIs: !1
}), oe = ({ close: e, action: s, onboarding: n }) => {
  var o, i, a, l, d, r, p, c;
  return /* @__PURE__ */ m(xs, { children: [
    /* @__PURE__ */ t(Os, { onClick: e, children: /* @__PURE__ */ t(Vs, { name: "icon-cross" }) }),
    ((i = (o = n == null ? void 0 : n.titleCard) == null ? void 0 : o.media) == null ? void 0 : i.sponsorLogo) && /* @__PURE__ */ m(Ps, { children: [
      /* @__PURE__ */ t(Qs, { alt: "sponsor-logo", src: (l = (a = n == null ? void 0 : n.titleCard) == null ? void 0 : a.media) == null ? void 0 : l.sponsorLogo }),
      /* @__PURE__ */ t(_s, { children: "PRESENTS" })
    ] }),
    ((d = n == null ? void 0 : n.titleCard) == null ? void 0 : d.title) && /* @__PURE__ */ t(qs, { children: (r = n == null ? void 0 : n.titleCard) == null ? void 0 : r.title }),
    ((p = n == null ? void 0 : n.titleCard) == null ? void 0 : p.subtitle) && /* @__PURE__ */ t(Fs, { children: (c = n == null ? void 0 : n.titleCard) == null ? void 0 : c.subtitle }),
    /* @__PURE__ */ t(Ks, { onClick: s, children: "Play Now" })
  ] });
}, K = [{
  graphicSrc: "https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_0.png",
  tagline: "",
  headline: /* @__PURE__ */ m(L, {
    children: ["Welcome to ", /* @__PURE__ */ t("br", {}), " StreamLayer +"]
  })
}, {
  graphicSrc: "https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_2.png",
  headline: "Get real-time insights"
}, {
  graphicSrc: "https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_3.png",
  headline: "Predictions, trivia & polls synced to match play"
}, {
  graphicSrc: "https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_4.png",
  headline: "Win points for every answer you get right"
}, {
  graphicSrc: "https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_5.png",
  headline: "Compete against friends on the leaderboard"
}], Ms = /* @__PURE__ */ h("div")({
  name: "OnboardingContainer",
  class: "o1xni1kr",
  propsAsIs: !1
}), Us = () => U, zs = /* @__PURE__ */ h(Us())({
  name: "OnboardingNotificationContainer",
  class: "o1vnouv7",
  propsAsIs: !0
}), ie = /* @__PURE__ */ h("div")({
  name: "InnerContainer",
  class: "i59uefw",
  propsAsIs: !1
}), Bs = ({
  deepLink: e,
  onboardingOpts: s,
  notification: n,
  gamification: o,
  loading: i,
  sdk: a
}) => {
  var l, d, r, p, c, v, f;
  const N = u(o.friends.getStore()), [b, S] = E(void 0), y = C(() => {
    var w, T;
    const W = a.getInviter();
    return W ? (T = (w = N.data) == null ? void 0 : w.find(({
      slId: ve
    }) => ve === W)) == null ? void 0 : T.name : "";
  }, [N.data, a]);
  return k(() => {
    const w = e.$store.subscribe((T) => {
      T && S(T.data);
    });
    return () => {
      w();
    };
  }, [e.$store]), /* @__PURE__ */ t(Ms, {
    children: /* @__PURE__ */ t(_e, {
      loading: i,
      rules: [{
        label: "Answer as many questions as you like.",
        icon: "icon-btn-feature-groups"
      }, {
        label: "Win points for each correct trivia or prediction answer.",
        icon: "icon-thumb-up"
      }, {
        label: "Top the leader board and best your friends.",
        icon: "icon-trophy"
      }],
      rulesBtnLabel: (l = s.rules) == null ? void 0 : l.buttonLabel,
      rulesTitle: (d = s.rules) == null ? void 0 : d.heading,
      termsTitle: "Terms and Conditions",
      termsText: (r = s.rules) == null ? void 0 : r.terms,
      steps: K,
      primaryColor: (p = s.inviteCard) == null ? void 0 : p.iconColor,
      inviteLink: b,
      inviteCardTitle: (c = s.inviteCard) == null ? void 0 : c.heading,
      inviteCardSubtext: (v = s.inviteCard) == null ? void 0 : v.subtext,
      inviteCardBtnLabel: (f = s.inviteCard) == null ? void 0 : f.buttonLabel,
      onClose: () => {
        var w;
        (w = n.close) == null || w.call(n);
      },
      gamification: o,
      sdk: a,
      inviterName: y
    })
  });
}, Ws = ({
  sdk: e,
  notification: s,
  saveHeight: n,
  style: o,
  appNode: i,
  sdkInDesktopView: a,
  responsiveStore: l
}) => {
  const d = $(null), r = s.data.onboarding, [p, c] = E(r == null ? void 0 : r.instantOpen), v = e.getFeature(D.GAMES), f = C(() => K == null ? void 0 : K.map(({
    graphicSrc: y
  }) => y), []), {
    screen: N
  } = u(l, {
    keys: ["screen"]
  });
  is(() => {
    var y;
    n(((y = d.current) == null ? void 0 : y.getBoundingClientRect().height) || 0);
  }, [n]);
  const {
    loading: b,
    throttled: S
  } = Qe(f);
  return p && v && r && i.current && !S ? /* @__PURE__ */ t(de, {
    container: i,
    useContainer: !a,
    children: /* @__PURE__ */ t(Bs, {
      notification: s,
      setOpened: c,
      gamification: v,
      onboardingOpts: r,
      deepLink: v.deepLink,
      loading: b,
      renderToNode: i,
      sdk: e
    })
  }) : /* @__PURE__ */ m(L, {
    children: [/* @__PURE__ */ t(ie, {
      ref: d,
      style: {
        position: "absolute",
        visibility: "hidden"
      },
      children: /* @__PURE__ */ t(oe, {
        close: () => {
        },
        action: () => {
        },
        onboarding: r
      })
    }), /* @__PURE__ */ t(zs, {
      style: o,
      hiding: s.hiding,
      children: /* @__PURE__ */ t(ie, {
        children: /* @__PURE__ */ t(oe, {
          close: s.close,
          action: () => {
            var y;
            c(!0), (((y = i.current) == null ? void 0 : y.getBoundingClientRect().y) || 0) < 0 && M(i, N.size, {
              behavior: "smooth"
            });
          },
          onboarding: r
        })
      })
    })]
  });
}, Gs = () => U, Hs = /* @__PURE__ */ h(Gs())({
  name: "Container",
  class: "c8ol1ve",
  propsAsIs: !0
}), he = /* @__PURE__ */ h("div")({
  name: "InnerContainer",
  class: "iqfywam",
  propsAsIs: !1
}), js = () => he, Xs = /* @__PURE__ */ h(js())({
  name: "HiddenContainer",
  class: "hokmtod",
  propsAsIs: !0
}), Ys = /* @__PURE__ */ h("div")({
  name: "NotificationRefreshing",
  class: "n192d1q8",
  propsAsIs: !1
}), Zs = () => qe, Js = /* @__PURE__ */ h(Zs())({
  name: "Pill",
  class: "p1lha68t",
  propsAsIs: !0
}), en = (e) => {
  const [s, n] = E(0), o = $(null), i = R((l) => {
    o.current = l;
  }, []);
  k(() => {
    var l;
    const d = (l = o.current) == null ? void 0 : l.getBoundingClientRect();
    d && n(d.height);
  }, [e]);
  const a = R((l) => {
    n(l);
  }, []);
  return [i, s, a];
}, sn = ({
  sdk: e,
  notification: s,
  appNode: n,
  responsiveStore: o
}) => {
  var i, a;
  const {
    sdkInDesktopView: l
  } = u(o, {
    keys: ["sdkInDesktopView"]
  }), {
    sdk: d
  } = B(), [r, p, c] = en(s.id);
  return s.type === x.QUESTION ? /* @__PURE__ */ m(L, {
    children: [/* @__PURE__ */ t(Xs, {
      ref: r,
      children: /* @__PURE__ */ t(G, {
        ...s
      })
    }), /* @__PURE__ */ m(Hs, {
      style: {
        height: s.hiding ? 0 : p
      },
      hiding: s.hiding,
      children: [/* @__PURE__ */ t(he, {
        style: {
          height: "100%"
        },
        children: /* @__PURE__ */ t(G, {
          ...s,
          controlVideo: d == null ? void 0 : d.controlVideoPlayer
        })
      }), /* @__PURE__ */ t(Ys, {}, s.id)]
    })]
  }) : s.type === x.QUESTION_RESOLVED && (a = (i = s.data) == null ? void 0 : i.question) != null && a.predictionResult ? /* @__PURE__ */ t(Ke, {
    style: {
      height: s.hiding ? 0 : p
    },
    saveHeight: c,
    close: s.close,
    hiding: s.hiding,
    ...s.data.question
  }) : s.type === x.ONBOARDING ? /* @__PURE__ */ t(Ws, {
    style: {
      height: s.hiding ? 0 : p
    },
    saveHeight: c,
    sdk: e,
    notification: s,
    sdkInDesktopView: l,
    appNode: n,
    responsiveStore: o
  }) : null;
}, nn = "p7vfi6t", tn = ({
  pill: e,
  setPill: s,
  appNode: n,
  headerNode: o,
  scrollNode: i,
  responsiveStore: a,
  scrollStore: l
}) => {
  var d, r;
  const {
    screen: p
  } = u(a, {
    keys: ["screen"]
  }), {
    tabsShown: c,
    scrollPosition: v
  } = u(l, {
    keys: ["tabsShown", "scrollPosition"]
  });
  k(() => {
    a.get().sdkInDesktopView ? v < 50 && s(null) : v > -50 && s(null);
  }, [v, a, s]);
  const f = a.get().sdkInDesktopView ? n : o;
  return !e || !f.current ? null : Me.createPortal(/* @__PURE__ */ t(Js, {
    title: e.type === x.QUESTION_RESOLVED ? "Prediction result" : `New ${((r = Ue[(d = e.data) == null ? void 0 : d.questionType]) == null ? void 0 : r.label) || "notification"}`,
    onClick: () => {
      var N;
      a.get().sdkInDesktopView ? (N = i.current) == null || N.scrollTo({
        top: 0,
        behavior: "smooth"
      }) : M(n, p.size, {
        behavior: "smooth"
      }), s(null);
    },
    className: ze(c && nn, "sl-pill-button")
  }), f.current);
}, on = ({
  sdk: e,
  headerNode: s,
  scrollNode: n,
  responsiveStore: o,
  appNode: i,
  scrollStore: a
}) => {
  const [l] = E(e.getNotificationsStore()), d = u(l), [r, p] = E(null), c = C(() => e.getActiveNotification(), [e, d]);
  return k(() => {
    c && Fe.emit("notification", {
      action: "rendered",
      payload: {
        questionId: c.data.questionId,
        questionType: c.data.questionType
      }
    });
  }, [c]), k(() => {
    c && (o.get().sdkInDesktopView || o.get().sdkInView) && (!o.get().sdkInDesktopView && o.get().sdkInView && p(c), o.get().sdkInDesktopView && window.requestAnimationFrame(() => {
      a.get().scrollPosition !== 0 && p(c);
    }));
  }, [c]), k(() => {
    c || p(null);
  }, [c]), /* @__PURE__ */ m(L, {
    children: [!r && c && /* @__PURE__ */ t(sn, {
      headerNode: s,
      appNode: i,
      sdk: e,
      notification: c,
      responsiveStore: o
    }), r && /* @__PURE__ */ t(tn, {
      pill: r,
      setPill: p,
      appNode: i,
      notification: c,
      headerNode: s,
      scrollNode: n,
      scrollStore: a,
      responsiveStore: o
    })]
  });
}, rn = (e) => {
  const s = $(""), [n, o] = E(!1), i = u(e.status), a = u(e.sdkStore.slStreamId), l = u(e.userId()), d = u(e.getActiveFeature()), r = i === "ready" && !!a.data;
  k(() => {
    const v = e.getFeature(D.GAMES);
    v && (v.closeQuestion(), v.closeUser());
  }, [d, e]);
  const p = R(
    (v) => {
      s.current = v, o(!0), e.initializeApp({ skipOrganizationSettings: !0 }).then(({ enabled: f, err: N }) => {
        if (!N && f) {
          e.isUserAuthorized().then((b) => {
            b || e.disableApp();
          });
          return;
        }
      });
    },
    [e]
  ), c = R(() => {
    o(!1), e.disableApp();
  }, [e]);
  return k(() => {
    if (!l) {
      r && e.disableApp();
      return;
    }
    if (l && s.current && n) {
      e.initializeApp({ skipOrganizationSettings: !0 }).then(() => {
        e.createEventSession(s.current);
      });
      return;
    }
  }, [l]), k(() => () => {
    o(!1), e.disableApp();
  }, [o, e]), {
    sdkEnabled: n,
    sdkReady: r,
    activateEventWithId: p,
    deactivate: c,
    isLogged: !!l
  };
}, an = ({ sdk: e, className: s, scrollStore: n, appNode: o, scrollNode: i, responsiveStore: a }) => {
  const [, l] = je(e);
  return /* @__PURE__ */ t(
    Cs,
    {
      className: s,
      scrollNode: i,
      appNode: o,
      scrollStore: n,
      feature: l,
      responsiveStore: a,
      sdk: e
    }
  );
}, ln = ({ sdk: e, className: s, appNode: n, responsiveStore: o }) => {
  const i = u(e.featuresList.getStore());
  return i ? Array.from(i, (a) => {
    const l = e.getFeature(a);
    return l ? /* @__PURE__ */ t(
      $s,
      {
        className: s,
        appNode: n,
        feature: l,
        responsiveStore: o,
        sdk: e
      },
      a
    ) : null;
  }) : null;
}, dn = ({ sdk: e, event: s }) => {
  const n = $(null), o = $(null), [i] = Be(n), [a, l] = We(n, i), { sdkEnabled: d, sdkReady: r, activateEventWithId: p, deactivate: c, isLogged: v } = rn(e);
  k(() => {
    s ? (e.createEventSession(s), p(s)) : c();
  }, [s, p, c, e]), _(n, { enabled: d, event: "click", listener: Xe }), _(a, {
    enabled: d,
    event: "scrollend",
    listener: Ye,
    useDomNode: !0
  }), _(a, {
    enabled: d,
    event: "click",
    listener: Ze,
    useDomNode: !0
  });
  const f = C(() => ({ sdk: e }), [e]);
  return k(() => {
    import("./gamification-feature.js");
  }, []), /* @__PURE__ */ t(ue.Provider, { value: f, children: /* @__PURE__ */ m(Ge, { ref: n, children: [
    d && /* @__PURE__ */ t(Ts, { className: q, sdk: e, ref: o }),
    /* @__PURE__ */ m(He, { className: "sl-hide-on-modal", ref: a, "data-nav": d.toString(), children: [
      r && /* @__PURE__ */ t(
        on,
        {
          sdk: e,
          scrollNode: a,
          headerNode: o,
          appNode: n,
          scrollStore: l,
          responsiveStore: i
        }
      ),
      r && /* @__PURE__ */ t(
        an,
        {
          scrollStore: l,
          responsiveStore: i,
          scrollNode: a,
          appNode: n,
          className: q,
          sdk: e
        }
      ),
      r && /* @__PURE__ */ t(ln, { responsiveStore: i, appNode: n, className: q, sdk: e })
    ] }),
    d && !v && /* @__PURE__ */ t(
      "div",
      {
        style: { display: "flex", alignItems: "center", justifyContent: "center", width: "100%", height: "100%" },
        children: "You are not logged in."
      }
    )
  ] }) });
}, cn = ({ children: e, style: s }) => /* @__PURE__ */ t("div", { className: "StreamLayerSDKTheme", children: /* @__PURE__ */ t("div", { className: Je, style: s, children: e }) }), fn = () => {
  const { sdk: e } = z(pe);
  return e;
}, kn = ({ event: e }) => {
  const { sdk: s, status: n } = z(pe);
  if (n === H.UNSET)
    throw new Error("Wrap app in `StreamLayerProvider`");
  return n === H.CONNECTED ? /* @__PURE__ */ t("div", { className: "StreamLayerSDK", children: "wait" }) : s === null ? /* @__PURE__ */ t("div", { className: "StreamLayerSDK", children: "sdk not initialized" }) : /* @__PURE__ */ t("div", { className: "StreamLayerSDK", children: /* @__PURE__ */ t(cn, { children: /* @__PURE__ */ t(dn, { sdk: s, event: e }) }) });
};
export {
  mn as E,
  kn as S,
  cn as i,
  fn as u
};
