import { defineComponent, toRefs, ref, watch, unref, openBlock, createElementBlock, toDisplayString, createCommentVNode } from "vue";
import "../../../../adapter-vue.mjs";
import { calculateTimestamp } from "../../utils/utils.mjs";
const _hoisted_1 = {
  key: 0,
  class: "message-timestamp"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "message-timestamp",
  props: {
    currTime: {
      type: Number,
      default: 0
    },
    prevTime: {
      type: Number,
      default: 0
    }
  },
  setup(__props) {
    const props = __props;
    const { currTime, prevTime } = toRefs(props);
    const timestampShowFlag = ref(false);
    const timestampShowContent = ref("");
    const handleItemTime = (currTime2, prevTime2) => {
      timestampShowFlag.value = false;
      if (currTime2 <= 0) {
        return "";
      } else if (!prevTime2 || prevTime2 <= 0) {
        timestampShowFlag.value = true;
        return calculateTimestamp(currTime2 * 1e3);
      } else {
        const minDiffToShow = 10 * 60;
        const diff = currTime2 - prevTime2;
        if (diff >= minDiffToShow) {
          timestampShowFlag.value = true;
          return calculateTimestamp(currTime2 * 1e3);
        }
      }
      return "";
    };
    watch(
      () => [currTime.value, prevTime.value],
      (newVal, oldVal) => {
        if ((newVal == null ? void 0 : newVal.toString()) === (oldVal == null ? void 0 : oldVal.toString())) {
          return;
        } else {
          timestampShowContent.value = handleItemTime(
            currTime.value,
            prevTime.value
          );
        }
      },
      {
        immediate: true
      }
    );
    return (_ctx, _cache) => {
      return unref(timestampShowFlag) ? (openBlock(), createElementBlock("div", _hoisted_1, toDisplayString(unref(timestampShowContent)), 1)) : createCommentVNode("", true);
    };
  }
});
export {
  _sfc_main as default
};
