"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
require("../../../adapter-vue.js");
const TUIChatEngine = require("@tencentcloud/chat-uikit-engine");
const Icon = require("../Icon.vue.js");
const selected = require("../../../assets/icon/selected.svg.js");
const back = require("../../../assets/icon/back.svg.js");
const cancel = require("../../../assets/icon/cancel.svg.js");
const env = require("../../../utils/env.js");
const _hoisted_1 = {
  key: 0,
  class: "transfer-header transfer-h5-header"
};
const _hoisted_2 = { class: "title" };
const _hoisted_3 = { class: "main" };
const _hoisted_4 = { class: "left" };
const _hoisted_5 = { class: "transfer-header" };
const _hoisted_6 = ["value", "placeholder"];
const _hoisted_7 = ["placeholder", "value"];
const _hoisted_8 = { class: "transfer-left-main" };
const _hoisted_9 = { class: "transfer-list" };
const _hoisted_10 = {
  key: 1,
  class: "icon-unselected"
};
const _hoisted_11 = { class: "select-all" };
const _hoisted_12 = ["onClick"];
const _hoisted_13 = ["src"];
const _hoisted_14 = { class: "name" };
const _hoisted_15 = { key: 0 };
const _hoisted_16 = { class: "right" };
const _hoisted_17 = {
  key: 0,
  class: "transfer-header"
};
const _hoisted_18 = {
  key: 1,
  class: "transfer-list"
};
const _hoisted_19 = {
  key: 0,
  class: "transfer-text"
};
const _hoisted_20 = { class: "transfer-list-item-content" };
const _hoisted_21 = ["src"];
const _hoisted_22 = {
  key: 0,
  class: "name"
};
const _hoisted_23 = ["onClick"];
const _hoisted_24 = { class: "transfer-right-footer" };
const _sfc_main = /* @__PURE__ */ Vue.defineComponent({
  __name: "index",
  props: {
    list: {
      type: Array,
      default: () => []
    },
    selectedList: {
      type: Array,
      default: () => []
    },
    isSearch: {
      type: Boolean,
      default: true
    },
    isRadio: {
      type: Boolean,
      default: false
    },
    isCustomItem: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: ""
    },
    type: {
      type: String,
      default: ""
    },
    resultShow: {
      type: Boolean,
      default: true
    },
    total: {
      type: Number,
      default: 0
    },
    isHiddenBackIcon: {
      type: Boolean,
      default: false
    }
  },
  emits: ["search", "submit", "cancel", "getMore"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const transferList = Vue.ref([]);
    const transferTotal = Vue.ref(0);
    const transferSelectedList = Vue.ref([]);
    const isTransferSearch = Vue.ref(true);
    const isTransferCustomItem = Vue.ref(false);
    const transferTitle = Vue.ref("");
    const searchValue = Vue.ref("");
    Vue.watchEffect(() => {
      if (props.isCustomItem) {
        for (let index = 0; index < props.list.length; index++) {
          if (props.list[index].conversationID.indexOf("@TIM#SYSTEM") > -1) {
            props.list.splice(index, 1);
          }
          transferList.value = props.list;
        }
      } else {
        transferList.value = props.list;
      }
      transferTotal.value = props.total ? props.total : props.list.length;
      transferSelectedList.value = props.selectedList && props.selectedList.length > 0 ? props.selectedList : transferSelectedList.value;
      isTransferSearch.value = props.isSearch;
      isTransferCustomItem.value = props.isCustomItem;
      transferTitle.value = props.title;
    });
    const emit = __emit;
    const optional = Vue.computed(
      () => transferList.value.filter((item) => !item.isDisabled)
    );
    const handleInput = (e) => {
      searchValue.value = e.target.value || e.detail.value;
      emit("search", searchValue.value);
    };
    const selected$1 = (item) => {
      if (item.isDisabled) {
        return;
      }
      let list = transferSelectedList.value;
      const index = list.indexOf(item);
      if (index > -1) {
        return transferSelectedList.value.splice(index, 1);
      }
      if (props.isRadio) {
        list = [];
      }
      list.push(item);
      transferSelectedList.value = list;
    };
    const selectedAll = () => {
      if (transferSelectedList.value.length === optional.value.length) {
        transferSelectedList.value = [];
      } else {
        transferSelectedList.value = [...optional.value];
      }
    };
    const submit = () => {
      emit("submit", transferSelectedList.value);
      searchValue.value = "";
    };
    const cancel$1 = () => {
      emit("cancel");
      searchValue.value = "";
    };
    const getMore = () => {
      emit("getMore");
    };
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createElementBlock("div", {
        class: Vue.normalizeClass(["transfer", [!Vue.unref(env.isPC) ? "transfer-h5" : "", Vue.unref(env.isMobile) ? "transfer-h5-wechat" : ""]])
      }, [
        !Vue.unref(env.isPC) ? (Vue.openBlock(), Vue.createElementBlock("header", _hoisted_1, [
          !props.isHiddenBackIcon ? (Vue.openBlock(), Vue.createElementBlock("div", {
            key: 0,
            onClick: cancel$1
          }, [
            Vue.createVNode(Icon.default, {
              class: "icon",
              file: Vue.unref(back.default),
              width: "18px",
              height: "18px"
            }, null, 8, ["file"])
          ])) : Vue.createCommentVNode("", true),
          Vue.createElementVNode("span", _hoisted_2, Vue.toDisplayString(Vue.unref(transferTitle)), 1),
          _cache[0] || (_cache[0] = Vue.createElementVNode("span", { class: "space" }, null, -1))
        ])) : Vue.createCommentVNode("", true),
        Vue.createElementVNode("main", _hoisted_3, [
          Vue.createElementVNode("div", _hoisted_4, [
            Vue.createElementVNode("header", _hoisted_5, [
              Vue.unref(env.isPC) && Vue.unref(isTransferSearch) ? (Vue.openBlock(), Vue.createElementBlock("input", {
                key: 0,
                type: "text",
                value: Vue.unref(searchValue),
                placeholder: Vue.unref(TUIChatEngine.TUITranslateService).t("component.请输入userID"),
                enterkeyhint: "search",
                class: Vue.normalizeClass([Vue.unref(env.isUniFrameWork) ? "left-uniapp-input" : ""]),
                onKeyup: Vue.withKeys(handleInput, ["enter"])
              }, null, 42, _hoisted_6)) : Vue.createCommentVNode("", true),
              !Vue.unref(env.isPC) && Vue.unref(isTransferSearch) ? (Vue.openBlock(), Vue.createElementBlock("input", {
                key: 1,
                type: "text",
                placeholder: Vue.unref(TUIChatEngine.TUITranslateService).t("component.请输入userID"),
                enterkeyhint: "search",
                value: Vue.unref(searchValue),
                class: Vue.normalizeClass([Vue.unref(env.isUniFrameWork) ? "left-uniapp-input" : ""]),
                onBlur: handleInput,
                onConfirm: handleInput
              }, null, 42, _hoisted_7)) : Vue.createCommentVNode("", true)
            ]),
            Vue.createElementVNode("main", _hoisted_8, [
              Vue.createElementVNode("ul", _hoisted_9, [
                Vue.unref(optional).length > 1 && !__props.isRadio ? (Vue.openBlock(), Vue.createElementBlock("li", {
                  key: 0,
                  class: "transfer-list-item",
                  onClick: selectedAll
                }, [
                  Vue.unref(transferSelectedList).length === Vue.unref(optional).length ? (Vue.openBlock(), Vue.createBlock(Icon.default, {
                    key: 0,
                    file: Vue.unref(selected.default),
                    width: "18px",
                    height: "18px"
                  }, null, 8, ["file"])) : (Vue.openBlock(), Vue.createElementBlock("i", _hoisted_10)),
                  Vue.createElementVNode("span", _hoisted_11, Vue.toDisplayString(Vue.unref(TUIChatEngine.TUITranslateService).t("component.全选")), 1)
                ])) : Vue.createCommentVNode("", true),
                (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(transferList), (item) => {
                  return Vue.openBlock(), Vue.createElementBlock("li", {
                    key: item.userID,
                    class: "transfer-list-item",
                    onClick: ($event) => selected$1(item)
                  }, [
                    Vue.unref(transferSelectedList).indexOf(item) > -1 ? (Vue.openBlock(), Vue.createBlock(Icon.default, {
                      key: 0,
                      file: Vue.unref(selected.default),
                      class: Vue.normalizeClass([item.isDisabled && "disabled"]),
                      width: "18px",
                      height: "18px"
                    }, null, 8, ["file", "class"])) : (Vue.openBlock(), Vue.createElementBlock("i", {
                      key: 1,
                      class: Vue.normalizeClass([item.isDisabled && "disabled", "icon-unselected"])
                    }, null, 2)),
                    !Vue.unref(isTransferCustomItem) ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 2 }, [
                      Vue.createElementVNode("img", {
                        class: "avatar",
                        src: item.avatar || "https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png",
                        onerror: "this.onerror=null;this.src='https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'"
                      }, null, 8, _hoisted_13),
                      Vue.createElementVNode("span", _hoisted_14, Vue.toDisplayString(item.nick || item.userID), 1),
                      item.isDisabled ? (Vue.openBlock(), Vue.createElementBlock("span", _hoisted_15, "（" + Vue.toDisplayString(Vue.unref(TUIChatEngine.TUITranslateService).t("component.已在群中")) + "）", 1)) : Vue.createCommentVNode("", true)
                    ], 64)) : Vue.renderSlot(_ctx.$slots, "left", {
                      key: 3,
                      data: item
                    }, void 0, true)
                  ], 8, _hoisted_12);
                }), 128)),
                Vue.unref(transferTotal) > Vue.unref(transferList).length ? (Vue.openBlock(), Vue.createElementBlock("li", {
                  key: 1,
                  class: "transfer-list-item more",
                  onClick: getMore
                }, Vue.toDisplayString(Vue.unref(TUIChatEngine.TUITranslateService).t("component.查看更多")), 1)) : Vue.createCommentVNode("", true)
              ])
            ])
          ]),
          Vue.createElementVNode("div", _hoisted_16, [
            Vue.unref(env.isPC) ? (Vue.openBlock(), Vue.createElementBlock("header", _hoisted_17, Vue.toDisplayString(Vue.unref(transferTitle)), 1)) : Vue.createCommentVNode("", true),
            __props.resultShow ? (Vue.openBlock(), Vue.createElementBlock("ul", _hoisted_18, [
              Vue.unref(transferSelectedList).length > 0 && Vue.unref(env.isPC) ? (Vue.openBlock(), Vue.createElementBlock("p", _hoisted_19, Vue.toDisplayString(Vue.unref(TUIChatEngine.TUITranslateService).t("component.已选中")) + Vue.toDisplayString(Vue.unref(transferSelectedList).length) + Vue.toDisplayString(Vue.unref(TUIChatEngine.TUITranslateService).t("component.人")), 1)) : Vue.createCommentVNode("", true),
              (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(transferSelectedList), (item, index) => {
                return Vue.openBlock(), Vue.createElementBlock("li", {
                  key: index,
                  class: "transfer-list-item space-between"
                }, [
                  Vue.createElementVNode("aside", _hoisted_20, [
                    !Vue.unref(isTransferCustomItem) ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
                      Vue.createElementVNode("img", {
                        class: "avatar",
                        src: item.avatar || "https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png",
                        onerror: "this.onerror=null;this.src='https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'"
                      }, null, 8, _hoisted_21),
                      Vue.unref(env.isPC) ? (Vue.openBlock(), Vue.createElementBlock("span", _hoisted_22, Vue.toDisplayString(item.nick || item.userID), 1)) : Vue.createCommentVNode("", true)
                    ], 64)) : Vue.renderSlot(_ctx.$slots, "right", {
                      key: 1,
                      data: item
                    }, void 0, true)
                  ]),
                  Vue.unref(env.isPC) ? (Vue.openBlock(), Vue.createElementBlock("span", {
                    key: 0,
                    onClick: ($event) => selected$1(item)
                  }, [
                    Vue.createVNode(Icon.default, {
                      file: Vue.unref(cancel.default),
                      width: "18px",
                      height: "18px"
                    }, null, 8, ["file"])
                  ], 8, _hoisted_23)) : Vue.createCommentVNode("", true)
                ]);
              }), 128))
            ])) : Vue.createCommentVNode("", true),
            Vue.createElementVNode("footer", _hoisted_24, [
              Vue.createElementVNode("button", {
                class: "btn btn-cancel",
                onClick: cancel$1
              }, Vue.toDisplayString(Vue.unref(TUIChatEngine.TUITranslateService).t("component.取消")), 1),
              Vue.unref(transferSelectedList).length > 0 ? (Vue.openBlock(), Vue.createElementBlock("button", {
                key: 0,
                class: "btn",
                onClick: submit
              }, Vue.toDisplayString(Vue.unref(TUIChatEngine.TUITranslateService).t("component.完成")), 1)) : (Vue.openBlock(), Vue.createElementBlock("button", {
                key: 1,
                class: "btn btn-no",
                onClick: submit
              }, Vue.toDisplayString(Vue.unref(TUIChatEngine.TUITranslateService).t("component.完成")), 1))
            ])
          ])
        ])
      ], 2);
    };
  }
});
exports.default = _sfc_main;
