import { jsxs as o, jsx as e } from "react/jsx-runtime";
import { useState as p, useEffect as u } from "react";
import { s as n, c as m, v as d, e as S, a as f, F as v, u as y, d as h } from "./index2.js";
import { S as g } from "./useStreamLayerApp2.js";
const A = /* @__PURE__ */ n("div")({
  name: "PointsContainer",
  class: "psiob9b",
  propsAsIs: !1
}), I = /* @__PURE__ */ n("div")({
  name: "PointsIcon",
  class: "p1gqe4lh",
  propsAsIs: !1
}), P = () => m, k = /* @__PURE__ */ n(P())({
  name: "PointsSvg",
  class: "p15syg2y",
  propsAsIs: !0
}), b = /* @__PURE__ */ n("div")({
  name: "PointsBody",
  class: "p12n4f2h",
  propsAsIs: !1
}), x = /* @__PURE__ */ n("div")({
  name: "PointsTitle",
  class: "poqmx89",
  propsAsIs: !1
}), C = /* @__PURE__ */ n("div")({
  name: "PointsValue",
  class: "prj9b3v",
  propsAsIs: !1
}), F = ({ points: s, onClick: r }) => /* @__PURE__ */ o(A, { className: d, onClick: r, children: [
  /* @__PURE__ */ e(I, { children: /* @__PURE__ */ e(k, { name: "icon-trophy" }) }),
  /* @__PURE__ */ o(b, { children: [
    /* @__PURE__ */ e(x, { children: "Total points" }),
    /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(S, { value: s }) })
  ] })
] }), L = ({ gamification: s }) => {
  const r = s.userSummary.$store, [i, l] = p(0);
  return u(() => {
    const c = r.subscribe((t) => {
      var a;
      (a = t == null ? void 0 : t.summary) != null && a.points && l(t.summary.points);
    });
    return () => {
      c();
    };
  }, [r]), /* @__PURE__ */ e(F, { points: i, onClick: () => {
    s.status.get() === v.Suspended && s.openFeature();
  } });
}, $ = ({ sdk: s }) => {
  if (!f(s.featuresList.getStore()))
    return null;
  const r = s.getFeature(g.GAMES);
  return r ? /* @__PURE__ */ e(L, { gamification: r }) : null;
}, E = () => {
  const s = y();
  return s ? /* @__PURE__ */ e("div", { className: "StreamLayerSDK", children: /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e($, { sdk: s }) }) }) : null;
};
export {
  E as StreamLayerSDKPoints
};
