import { s } from "./sl-types.js";
import { Q as n } from "./useStreamLayerApp2.js";
import { jsxs as a, jsx as i, Fragment as O } from "react/jsx-runtime";
import { memo as b, useMemo as x } from "react";
import { E as C } from "./index13.js";
import { B as H } from "./index6.js";
const ae = {
  [n.TWEET]: { label: "Insight", iconName: "icon-insight" },
  [n.PROMOTION]: { label: "Insight", iconName: "icon-insight" },
  [n.UNSET]: void 0,
  [n.FACTOID]: { label: "Insight", iconName: "icon-insight" },
  [n.POLL]: { label: "Poll", iconName: "icon-poll" },
  [n.TRIVIA]: { label: "Trivia", iconName: "icon-trivia" },
  [n.PREDICTION]: { label: "Prediction", iconName: "icon-prediction" }
}, ne = {
  [n.TWEET]: "Learn more",
  [n.FACTOID]: "Learn more",
  [n.POLL]: "Answer",
  [n.TRIVIA]: "Answer",
  [n.PREDICTION]: "Answer",
  [n.PROMOTION]: "",
  [n.UNSET]: ""
}, le = (t) => t.split(/\s+/).map((l) => l[0]).join("").toUpperCase(), oe = (t) => t ? t.toLocaleString("en-US") : "0", P = (t) => {
  const l = new Date(t);
  if (!l)
    return "";
  const m = /* @__PURE__ */ new Date(), o = Math.floor(m.getTime() - l.getTime());
  return o < 6e4 ? `${Math.floor(o / 1e3)}s` : o < 36e5 ? `${Math.floor(o / 6e4)}m` : o < 864e5 ? `${Math.floor(o / 36e5)}h` : l.getFullYear() === m.getFullYear() ? `${l.toLocaleDateString("en-US", {
    month: "short",
    day: "numeric"
  })}` : `${l.toLocaleDateString("en-US", {
    month: "2-digit",
    day: "2-digit",
    year: "2-digit"
  })}`;
}, M = /* @__PURE__ */ s("div")({
  name: "Container",
  class: "cjq447q",
  propsAsIs: !1
}), R = /* @__PURE__ */ s("div")({
  name: "ImageContainer",
  class: "i14egogb",
  propsAsIs: !1
}), F = /* @__PURE__ */ s("img")({
  name: "Image",
  class: "i2g9g4l",
  propsAsIs: !1
}), j = () => H, V = /* @__PURE__ */ s(j())({
  name: "TwitterIcon",
  class: "t1c454nm",
  propsAsIs: !0
}), _ = /* @__PURE__ */ s("div")({
  name: "Details",
  class: "d11nigc3",
  propsAsIs: !1
}), z = /* @__PURE__ */ s("div")({
  name: "Name",
  class: "nrxa4k8",
  propsAsIs: !1
}), B = /* @__PURE__ */ s("div")({
  name: "UserNameAndDate",
  class: "u1p051g3",
  propsAsIs: !1
}), k = ({ image: t, name: l, userName: m, verified: o, createdTweet: p }) => {
  const r = p && P(p);
  return /* @__PURE__ */ a(M, { children: [
    t && /* @__PURE__ */ a(R, { children: [
      /* @__PURE__ */ i(F, { className: "SL_AccountImage", src: t }),
      /* @__PURE__ */ i(V, { name: "twitter" })
    ] }),
    /* @__PURE__ */ a(_, { children: [
      l && /* @__PURE__ */ a(z, { className: "SL_TweetAccountName", children: [
        l,
        " ",
        o && /* @__PURE__ */ i(H, { name: "icon-twitter-verified" })
      ] }),
      m && /* @__PURE__ */ a(B, { className: "SL_TweetAccountUserName", children: [
        "@",
        m,
        " ",
        r && `･ ${r}`
      ] })
    ] })
  ] });
}, q = /* @__PURE__ */ s("div")({
  name: "Container",
  class: "c1kzqw87",
  propsAsIs: !1
}), Q = /* @__PURE__ */ s("div")({
  name: "Details",
  class: "d9r1hf9",
  propsAsIs: !1
}), W = /* @__PURE__ */ s("div")({
  name: "Body",
  class: "bezygt5",
  propsAsIs: !1
}), d = /* @__PURE__ */ s("div")({
  name: "ImagesContainer",
  class: "i1y8f7ym",
  propsAsIs: !1
}), v = /* @__PURE__ */ s("div")({
  name: "ImagesBlock",
  class: "i18gwonx",
  propsAsIs: !1
}), L = /* @__PURE__ */ s("img")({
  name: "Image",
  class: "i3g0xjd",
  propsAsIs: !1
}), Y = () => L, c = /* @__PURE__ */ s(Y())({
  name: "ImageFullSize",
  class: "io8rt7p",
  propsAsIs: !0
}), G = () => L, I = /* @__PURE__ */ s(G())({
  name: "ImageHalfSize",
  class: "i4hn3ox",
  propsAsIs: !0
}), J = new RegExp("\\s?https?://t.co[^\\s]+(\\s+)?$"), K = (t) => t == null ? void 0 : t.replace(J, ""), re = b(
  ({ image: t, body: l, muted: m, account: o, accountVerified: p, tweet: r, isDetail: h, controlVideo: S }) => {
    var A, f, T, N, U;
    const e = (f = (A = r == null ? void 0 : r.meta) == null ? void 0 : A.extendedEntities) == null ? void 0 : f.media, g = e == null ? void 0 : e.find(({ type: u }) => u === "photo"), $ = x(() => {
      var u, w, D, y;
      return (y = (D = (w = (u = e == null ? void 0 : e[0]) == null ? void 0 : u.videoInfo) == null ? void 0 : w.variants) == null ? void 0 : D.findLast(({ contentType: E }) => E === "video/mp4")) == null ? void 0 : y.url;
    }, [e]);
    return /* @__PURE__ */ a(q, { children: [
      /* @__PURE__ */ a(Q, { children: [
        /* @__PURE__ */ i(
          k,
          {
            image: t,
            name: (T = r == null ? void 0 : r.meta) == null ? void 0 : T.accountName,
            userName: o,
            verified: p,
            createdTweet: r == null ? void 0 : r.date
          }
        ),
        /* @__PURE__ */ i(W, { children: K(l) }),
        !h && g && /* @__PURE__ */ i(d, { children: /* @__PURE__ */ i(c, { src: e == null ? void 0 : e[0].mediaUrlHttps }) }),
        h && g && /* @__PURE__ */ a(O, { children: [
          (e == null ? void 0 : e.length) === 1 && /* @__PURE__ */ i(d, { children: /* @__PURE__ */ i(c, { src: e[0].mediaUrlHttps }) }),
          (e == null ? void 0 : e.length) === 2 && /* @__PURE__ */ a(d, { children: [
            /* @__PURE__ */ i(I, { src: e[0].mediaUrlHttps }),
            /* @__PURE__ */ i(I, { src: e[1].mediaUrlHttps })
          ] }),
          (e == null ? void 0 : e.length) === 3 && /* @__PURE__ */ a(d, { children: [
            /* @__PURE__ */ i(I, { src: e[0].mediaUrlHttps }),
            /* @__PURE__ */ a(v, { children: [
              /* @__PURE__ */ i(c, { src: e[1].mediaUrlHttps }),
              /* @__PURE__ */ i(c, { src: e[2].mediaUrlHttps })
            ] })
          ] }),
          (e == null ? void 0 : e.length) === 4 && /* @__PURE__ */ a(d, { children: [
            /* @__PURE__ */ a(v, { children: [
              /* @__PURE__ */ i(c, { src: e[0].mediaUrlHttps }),
              /* @__PURE__ */ i(c, { src: e[1].mediaUrlHttps })
            ] }),
            /* @__PURE__ */ a(v, { children: [
              /* @__PURE__ */ i(c, { src: e[2].mediaUrlHttps }),
              /* @__PURE__ */ i(c, { src: e[3].mediaUrlHttps })
            ] })
          ] })
        ] })
      ] }),
      !g && (((N = e == null ? void 0 : e[0]) == null ? void 0 : N.type) === "video" || ((U = e == null ? void 0 : e[0]) == null ? void 0 : U.type) === "animated_gif") && $ && /* @__PURE__ */ i(
        C,
        {
          muted: m,
          source: $,
          poster: e[0].mediaUrlHttps,
          controlVideo: S
        }
      )
    ] });
  }
);
export {
  k as D,
  le as I,
  K as a,
  re as b,
  ae as e,
  ne as o,
  oe as s
};
