"use strict";
const common_vendor = require("../../../../../../common/vendor.js");
require("../../../../../adapter-vue.js");
const common_assets = require("../../../../../../common/assets.js");
if (!Math) {
  (TranslationContent + Icon)();
}
const Icon = () => "../../../../common/Icon.js";
const TranslationContent = () => "./translation-content.js";
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "index",
  props: {
    message: { default: () => ({}) }
  },
  setup(__props) {
    const props = __props;
    const translationVisible = common_vendor.ref(false);
    const hasTranslationError = common_vendor.ref(false);
    const translationWrapperRef = common_vendor.ref();
    let isSingleTranslation = true;
    common_vendor.onMounted(() => {
      common_vendor.Jt.watch(common_vendor.o.CHAT, {
        translateTextInfo: onMessageTranslationUpdated
      });
    });
    common_vendor.onUnmounted(() => {
      common_vendor.Jt.unwatch(common_vendor.o.CHAT, {
        translateTextInfo: onMessageTranslationUpdated
      });
    });
    function toggleErrorStatus(hasError) {
      hasTranslationError.value = hasError;
    }
    function onMessageTranslationUpdated(info) {
      if (info === void 0)
        return;
      isSingleTranslation = false;
      const translationInfoList = info.get(props.message.conversationID) || [];
      for (let i = 0; i < translationInfoList.length; ++i) {
        const { messageID, visible } = translationInfoList[i];
        if (messageID === props.message.ID && visible !== void 0) {
          if (translationInfoList.length === 1 && visible) {
            isSingleTranslation = true;
          }
          hasTranslationError.value = false;
          translationVisible.value = visible;
          break;
        }
      }
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.unref(translationVisible)
      }, common_vendor.unref(translationVisible) ? {
        b: common_vendor.o$1(toggleErrorStatus),
        c: common_vendor.p({
          message: props.message,
          translationContentVisible: common_vendor.unref(translationVisible),
          translationWrapperRef: common_vendor.unref(translationWrapperRef),
          isSingleTranslation: common_vendor.unref(isSingleTranslation)
        }),
        d: common_vendor.p({
          file: common_vendor.unref(common_assets.checkIcon),
          size: "13px"
        }),
        e: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("TUIChat.由IM提供翻译支持")),
        f: props.message.flow === "out" ? 1 : "",
        g: common_vendor.unref(hasTranslationError) ? 1 : ""
      } : {});
    };
  }
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-955a2daf"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../../../.sourcemap/mp-weixin/TUIKit/components/TUIChat/message-list/message-elements/message-translate/index.js.map
