import { defineComponent as w, computed as f, ref as k, onMounted as S, resolveComponent as C, openBlock as b, createElementBlock as h, normalizeStyle as u, unref as t, withDirectives as M, createElementVNode as n, createVNode as D, toDisplayString as v, vShow as I, createCommentVNode as T, pushScopeId as L, popScopeId as N } from "vue";
import { useMd as E, useUser as R, selectedUser as z, getFirstEmoji as B } from "./composables-5f691338.js";
import { _export_sfc as U } from "./_plugin-vue_export-helper-6a641814.js";
const V = (e) => (L("data-v-c2e33bba"), e = e(), N(), e), $ = ["id", "data-pub"], j = { class: "ml-2 text-sm opacity-20 hover-opacity-80 transition cursor-default text-light-200" }, H = /* @__PURE__ */ V(() => /* @__PURE__ */ n("div", { class: "flex-1" }, null, -1)), P = { class: "ml-2 text-sm opacity-20 hover-opacity-80 transition cursor-default text-dark-200" }, A = ["innerHTML"], F = /* @__PURE__ */ w({
  __name: "ChatMessage",
  props: {
    index: { type: Number, default: 0 },
    source: {
      type: Object,
      default: () => ({
        author: "",
        timestamp: "",
        text: "empty"
      })
    }
  },
  setup(e) {
    const s = e, y = E(), d = f(() => _(Number(s.source.timestamp))), { user: g } = R(), i = f(() => s.source.author == g.pub);
    function _(a) {
      if (!a)
        return;
      const o = new Date(a), r = o.toLocaleDateString("en-CA"), c = o.toLocaleTimeString("ru-RU");
      return {
        full: r + " " + c,
        date: r,
        time: c
        // ms: ms(Date.now() - theDate.getTime()),
      };
    }
    const l = k(!0);
    return S(() => {
      var a, o;
      s.index > 1 && ((o = (a = document.getElementById(`chat-${s.index - 1}`)) == null ? void 0 : a.dataset) == null ? void 0 : o.pub) == s.source.author && (l.value = !1);
    }), (a, o) => {
      var c, m, p, x;
      const r = C("account-badge");
      return b(), h("div", {
        class: "px-1 py-2px flex flex-col w-full gap-1",
        style: u({ alignItems: t(i) ? "end" : "start" })
      }, [
        M(n("div", {
          class: "flex items-center w-full mt-2",
          id: `chat-${e.index}`,
          style: u({ flexDirection: t(i) ? "row-reverse" : "row" }),
          "data-pub": e.source.author
        }, [
          D(r, {
            class: "opacity-50 hover-opacity-90 transition",
            pub: e.source.author,
            "show-name": !0,
            size: 20,
            onClick: o[0] || (o[0] = (O) => t(z).pub = e.source.author)
          }, null, 8, ["pub"]),
          n("div", j, v((c = t(d)) == null ? void 0 : c.time), 1),
          H,
          n("div", P, v((m = t(d)) == null ? void 0 : m.date), 1)
        ], 12, $), [
          [I, l.value]
        ]),
        n("div", {
          class: "px-2 py-1 bg-light-300 dark-bg-dark-200 dark-bg-opacity-80 bg-opacity-80 rounded-b-xl max-w-max break-all overflow-hidden",
          style: u({ borderTopLeftRadius: t(i) ? "12px" : "0px", borderTopRightRadius: t(i) ? "0px" : "12px", fontSize: e.source.text == t(B)(e.source.text) ? "6em" : "1em" })
        }, [
          (p = e.source) != null && p.text ? (b(), h("div", {
            key: 0,
            class: "markdown-body",
            innerHTML: t(y).render((x = e.source) == null ? void 0 : x.text)
          }, null, 8, A)) : T("", !0)
        ], 4)
      ], 4);
    };
  }
});
const K = /* @__PURE__ */ U(F, [["__scopeId", "data-v-c2e33bba"]]);
export {
  K as default
};
//# sourceMappingURL=ChatMessage-e66c5d3e.js.map
