import { jsx as n, jsxs as c } from "react/jsx-runtime";
import { useRef as m, useEffect as h } from "react";
import { a as u, x as l, s as f, b as p, u as S, d as I, S as g } from "./index2.js";
import { S as y } from "./useStreamLayerApp2.js";
const Q = () => p, v = /* @__PURE__ */ f(Q())({
  name: "QuestionWrap",
  class: "q10hhsxv",
  propsAsIs: !0
}), L = ({
  gamification: e,
  persistent: i,
  hideHeader: a,
  insightId: t
}) => {
  const s = m(""), o = u(e.openedQuestion.$store);
  return h(() => t ? (!i || e.isOpenedQuestion(t) || (s.current = t, e.getFeedItem(t).then((r) => {
    s.current === t && e.openQuestion(t, r);
  })), () => {
    s.current = "";
  }) : (e.activeQuestionId.subscribe(({
    data: r
  }) => {
    var d;
    r && ((d = r.feedItem) == null ? void 0 : d.type) === "insight" && (!i || e.isOpenedQuestion(r.feedItem.id) || (s.current = r.feedItem.id, e.openQuestion(r.feedItem.id, r.feedItem))), !r && s.current && (e.closeQuestion(s.current), s.current = "");
  }), () => {
  }), [e, i, t]), o ? /* @__PURE__ */ n(l, {
    style: {
      height: "100%"
    },
    children: /* @__PURE__ */ n(v, {
      hideHeader: a,
      gamification: e,
      hideSponsor: !0
    })
  }) : null;
}, x = ({
  sdk: e,
  persistent: i,
  insightId: a,
  hideHeader: t
}) => {
  if (!u(e.featuresList.getStore()))
    return null;
  const s = e.getFeature(y.GAMES);
  return s ? /* @__PURE__ */ n(L, {
    insightId: a,
    persistent: i,
    hideHeader: t,
    gamification: s
  }) : null;
}, b = ({ event: e, hideHeader: i, persistent: a }) => {
  const t = S();
  return t ? /* @__PURE__ */ c("div", { className: "StreamLayerSDK", children: [
    /* @__PURE__ */ n(I, { children: /* @__PURE__ */ n(x, { sdk: t, event: e, hideHeader: i, persistent: a }) }),
    e !== void 0 && /* @__PURE__ */ n(g, { event: e })
  ] }) : null;
};
export {
  b as StreamLayerSDKInsight,
  x as StreamLayerSDKInsightUI
};
