"use strict";
const common_vendor = require("../../../../../common/vendor.js");
const common_assets = require("../../../../../common/assets.js");
if (!Math) {
  Icon();
}
const Icon = () => "../../../common/Icon.js";
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "message-file",
  props: {
    content: { default: () => ({}) },
    messageItem: { default: () => ({}) }
  },
  setup(__props) {
    const props = __props;
    const download = () => {
      if (props.messageItem.hasRiskContent) {
        return;
      }
      const option = {
        mode: "cors",
        headers: new Headers({
          "Content-Type": "application/x-www-form-urlencoded"
        })
      };
      if (window == null ? void 0 : window.fetch) {
        fetch(props.content.url, option).then((res) => res.blob()).then((blob) => {
          const a = document.createElement("a");
          const url = window.URL.createObjectURL(blob);
          a.href = url;
          a.download = props.content.name;
          a.click();
        });
      } else {
        const a = document.createElement("a");
        a.href = props.content.url;
        a.target = "_blank";
        a.download = props.content.name;
        a.click();
      }
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.p({
          file: common_vendor.unref(common_assets.files)
        }),
        b: common_vendor.t(props.content.name),
        c: common_vendor.t(props.content.size),
        d: common_vendor.unref(common_vendor.Wt).t("TUIChat.单击下载"),
        e: common_vendor.o$1(download)
      };
    };
  }
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-f3d5b3bc"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/TUIKit/components/TUIChat/message-list/message-elements/message-file.js.map
