"use strict";
const common_vendor = require("../../../../../common/vendor.js");
require("../../../../adapter-vue.js");
const TUIKit_utils_env = require("../../../../utils/env.js");
const common_assets = require("../../../../../common/assets.js");
const TUIKit_components_TUIChat_utils_utils = require("../../utils/utils.js");
const TUIKit_components_TUIChat_offlinePushInfoManager_index = require("../../offlinePushInfoManager/index.js");
const TUIKit_components_TUIChat_config = require("../../config.js");
if (!Math) {
  ToolbarItemContainer();
}
const ToolbarItemContainer = () => "../toolbar-item-container/index.js";
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "index",
  props: {
    // Video source, only valid for uni-app version, web version only supports selecting videos from files
    // album: Select from files
    // camera: Take a video using the camera
    videoSourceType: {
      type: String,
      default: "album"
    }
  },
  setup(__props) {
    const props = __props;
    const inputRef = common_vendor.ref();
    const currentConversation = common_vendor.ref();
    common_vendor.Jt.watch(common_vendor.o.CONV, {
      currentConversation: (conversation) => {
        currentConversation.value = conversation;
      }
    });
    const handleIcon = () => {
      if (TUIKit_utils_env.isUniFrameWork) {
        switch (props.videoSourceType) {
          case "album":
            return common_assets.videoUniIcon;
          case "camera":
            return common_assets.cameraUniIcon;
          default:
            return common_assets.videoUniIcon;
        }
      } else {
        const videoIcon = TUIKit_components_TUIChat_config.ChatConfig.getTheme() === "dark" ? common_assets.videoIconDark : common_assets.videoIconLight;
        return videoIcon;
      }
    };
    const handleTitle = () => {
      if (TUIKit_utils_env.isUniFrameWork && props.videoSourceType === "camera") {
        return "录制";
      } else {
        return "视频";
      }
    };
    const onIconClick = () => {
      var _a, _b, _c, _d, _e;
      if (TUIKit_utils_env.isUniFrameWork) {
        if (TUIKit_utils_env.isWeChat && ((_a = common_vendor.i) == null ? void 0 : _a.chooseMedia)) {
          (_b = common_vendor.i) == null ? void 0 : _b.chooseMedia({
            mediaType: ["video"],
            count: 1,
            sourceType: [props.videoSourceType],
            maxDuration: 60,
            success: function(res) {
              sendVideoMessage(res);
            }
          });
        } else {
          (_c = common_vendor.i) == null ? void 0 : _c.chooseVideo({
            count: 1,
            sourceType: [props.videoSourceType],
            compressed: false,
            success: function(res) {
              sendVideoMessage(res);
            }
          });
        }
      } else {
        ((_d = inputRef == null ? void 0 : inputRef.value) == null ? void 0 : _d.click) && ((_e = inputRef == null ? void 0 : inputRef.value) == null ? void 0 : _e.click());
      }
    };
    const sendVideoInWeb = (e) => {
      var _a, _b;
      if (((_b = (_a = e == null ? void 0 : e.target) == null ? void 0 : _a.files) == null ? void 0 : _b.length) <= 0) {
        return;
      }
      sendVideoMessage(e == null ? void 0 : e.target);
      e.target.value = "";
    };
    const sendVideoMessage = (file) => {
      var _a, _b, _c, _d, _e;
      if (!file) {
        return;
      }
      const options = {
        to: ((_b = (_a = currentConversation == null ? void 0 : currentConversation.value) == null ? void 0 : _a.groupProfile) == null ? void 0 : _b.groupID) || ((_d = (_c = currentConversation == null ? void 0 : currentConversation.value) == null ? void 0 : _c.userProfile) == null ? void 0 : _d.userID),
        conversationType: (_e = currentConversation == null ? void 0 : currentConversation.value) == null ? void 0 : _e.type,
        payload: {
          file
        },
        needReadReceipt: TUIKit_components_TUIChat_utils_utils.isEnabledMessageReadReceiptGlobal()
      };
      const offlinePushInfoCreateParams = {
        conversation: currentConversation.value,
        payload: options.payload,
        messageType: common_vendor.qt.TYPES.MSG_VIDEO
      };
      const sendMessageOptions = {
        offlinePushInfo: TUIKit_components_TUIChat_offlinePushInfoManager_index.OfflinePushInfoManager.create(offlinePushInfoCreateParams)
      };
      common_vendor.Qt.sendVideoMessage(options, sendMessageOptions);
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.o$1(sendVideoInWeb),
        b: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "video-upload-h5"),
        c: common_vendor.o$1(onIconClick),
        d: common_vendor.p({
          iconFile: handleIcon(),
          title: handleTitle(),
          needDialog: false,
          iconWidth: common_vendor.unref(TUIKit_utils_env.isUniFrameWork) ? "32px" : "20px",
          iconHeight: common_vendor.unref(TUIKit_utils_env.isUniFrameWork) ? props.videoSourceType === "album" ? "20px" : "25px" : "18px"
        })
      };
    };
  }
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-11a33e36"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/TUIKit/components/TUIChat/message-input-toolbar/video-upload/index.js.map
