import { jsxs as p, jsx as e } from "react/jsx-runtime";
import { h as u } from "./index8.js";
import { useState as d, useEffect as f } from "react";
import { s as o, u as y } from "./sl-types.js";
import { e as a } from "./index3.js";
import { d as h } from "./index5.js";
import { m as S } from "./theme.js";
import { B as v } from "./index6.js";
import { F as c } from "./feature.js";
import { S as g } from "./useStreamLayerApp2.js";
import { B as k, z as A } from "./hooks-WfHlJH12.js";
const I = /* @__PURE__ */ o("div")({
  name: "PointsContainer",
  class: "psiob9b",
  propsAsIs: !1
}), P = /* @__PURE__ */ o("div")({
  name: "PointsIcon",
  class: "p1gqe4lh",
  propsAsIs: !1
}), b = () => v, B = /* @__PURE__ */ o(b())({
  name: "PointsSvg",
  class: "p15syg2y",
  propsAsIs: !0
}), F = /* @__PURE__ */ o("div")({
  name: "PointsBody",
  class: "p12n4f2h",
  propsAsIs: !1
}), T = /* @__PURE__ */ o("div")({
  name: "PointsTitle",
  class: "poqmx89",
  propsAsIs: !1
}), x = /* @__PURE__ */ o("div")({
  name: "PointsValue",
  class: "prj9b3v",
  propsAsIs: !1
}), C = ({ points: s, onClick: t }) => /* @__PURE__ */ p(I, { className: S, onClick: t, children: [
  /* @__PURE__ */ e(P, { children: /* @__PURE__ */ e(B, { name: "icon-trophy-solid" }) }),
  /* @__PURE__ */ p(F, { children: [
    /* @__PURE__ */ e(T, { children: "Total points" }),
    /* @__PURE__ */ e(x, { children: /* @__PURE__ */ e(h, { value: s }) })
  ] })
] }), j = ({ gamification: s }) => {
  const t = s.userSummary.$store, [r, l] = d(0);
  return f(() => {
    const n = t.subscribe((i) => {
      var m;
      (m = i == null ? void 0 : i.summary) != null && m.points && l(i.summary.points);
    });
    return () => {
      n();
    };
  }, [t]), /* @__PURE__ */ e(C, { points: r, onClick: () => {
    const n = s.status.get();
    n === c.Suspended ? (s.openFeature(), a.emit("app", {
      action: "open",
      payload: {}
    }), a.emit("interactions", {
      action: "tap",
      payload: {}
    })) : n === c.Ready && (s.closeFeature(!1), a.emit("app", {
      action: "close",
      payload: {}
    }), a.emit("interactions", {
      action: "tap",
      payload: {}
    }));
  } });
}, L = ({ sdk: s }) => {
  if (!y(s.featuresList.getStore()))
    return null;
  const t = s.getFeature(g.GAMES);
  return t ? /* @__PURE__ */ e(j, { gamification: t }) : null;
}, _ = ({ theme: s }) => {
  const t = k(), r = A();
  return t ? /* @__PURE__ */ e("div", { className: "StreamLayerSDK", children: /* @__PURE__ */ e(u, { customTheme: s ?? r.theme, themeMode: r.themeMode, children: /* @__PURE__ */ e(L, { sdk: t }) }) }) : null;
};
export {
  _ as StreamLayerSDKPoints
};
