"use strict";
const common_vendor = require("../../../common/vendor.js");
const TUIKit_utils_env = require("../../utils/env.js");
class TUISearchServer {
  constructor() {
    common_vendor.R.registerService(common_vendor.E.TUISearch.SERVICE.NAME, this);
    common_vendor.R.registerExtension(common_vendor.E.TUIChat.EXTENSION.INPUT_MORE.EXT_ID, this);
  }
  onCall(method, params) {
    switch (method) {
      case common_vendor.E.TUISearch.SERVICE.METHOD.SEARCH_GROUP:
        return this.searchGroup(params == null ? void 0 : params.groupID);
      case common_vendor.E.TUISearch.SERVICE.METHOD.SEARCH_USER:
        return this.searchUser(params == null ? void 0 : params.userID);
      case common_vendor.E.TUISearch.SERVICE.METHOD.SEARCH_FRIEND:
        return this.searchFriend(params == null ? void 0 : params.userID);
      case common_vendor.E.TUISearch.SERVICE.METHOD.SEARCH_GROUP_MEMBER:
        return this.searchGroupMember(params == null ? void 0 : params.groupID, params == null ? void 0 : params.userID);
    }
  }
  onGetExtension(extensionID) {
    if (extensionID === common_vendor.E.TUIChat.EXTENSION.INPUT_MORE.EXT_ID) {
      const list = [];
      const searchExtension = {
        weight: 3e3,
        text: "搜索",
        icon: "https://web.sdk.qcloud.com/component/TUIKit/assets/message-search.svg",
        data: {
          name: "search"
        },
        listener: {
          onClicked: () => {
            var _a;
            common_vendor.Jt.update(common_vendor.o.SEARCH, "isShowInConversationSearch", true);
            TUIKit_utils_env.isUniFrameWork && ((_a = common_vendor.i) == null ? void 0 : _a.navigateTo({
              url: "/TUIKit/components/TUISearch/index"
            }));
          }
        }
      };
      list.push(searchExtension);
      return list;
    }
  }
  async searchFriend(userID) {
    return common_vendor.ts.getFriendProfile({ userIDList: [userID] });
  }
  async searchUser(userID) {
    return common_vendor.Zt.getUserProfile({ userIDList: [userID] });
  }
  async searchGroup(groupID) {
    return common_vendor.es.searchGroupByID(groupID);
  }
  async searchGroupMember(groupID, userID) {
    return common_vendor.es.getGroupMemberProfile({
      groupID,
      userIDList: [userID]
    });
  }
}
exports.TUISearchServer = TUISearchServer;
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/TUIKit/components/TUISearch/server.js.map
