import { defineComponent, reactive, computed, toRefs, openBlock, createElementBlock, Fragment, renderList, normalizeClass, withModifiers, toDisplayString, ref, watch, createElementVNode, withDirectives, vModelText, createCommentVNode, resolveComponent, createBlock, withCtx, createVNode, mergeProps, renderSlot, unref, pushScopeId, popScopeId } from "vue";
import { _ as _export_sfc, S as Store, a as _sfc_main$a } from "./index2.js";
import { d as defaultAvatar, t as typeDetection, _ as _sfc_main$8 } from "./index4.js";
import { _ as _sfc_main$9 } from "./index5.js";
import { P as POST, p as proxy_api } from "./http.js";
import { Checkbox, CheckboxGroup, Cell, CellGroup, List, ActionSheet } from "vant";
import "@wltech/svg";
var Tab_vue_vue_type_style_index_0_scoped_true_lang = "";
const _sfc_main$7 = defineComponent({
  props: {
    tabTypes: {
      type: Array,
      default: () => {
        return [1, 2, 3];
      }
    }
  },
  setup(props, { emit }) {
    var _a;
    const state = reactive({
      curTab: {
        type: ((_a = props.tabTypes) == null ? void 0 : _a[0]) || 1
      }
    });
    const tabList = computed(() => {
      const tabs = [
        {
          name: "\u4F01\u5FAE\u597D\u53CB",
          type: 1
        },
        {
          name: "\u4E2A\u5FAE\u4EBA\u8109",
          type: 2
        },
        {
          name: "\u8054\u7CFB\u4EBA",
          type: 3
        }
      ];
      return tabs.filter((e) => {
        var _a2;
        return (_a2 = props.tabTypes) == null ? void 0 : _a2.includes(e.type);
      });
    });
    const onClick = (res) => {
      state.curTab = res;
      emit("onTabChange", res);
    };
    return {
      ...toRefs(state),
      tabList,
      onClick
    };
  }
});
const _hoisted_1$6 = { class: "flex-row" };
const _hoisted_2$6 = ["onClick"];
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
  return openBlock(), createElementBlock("ul", _hoisted_1$6, [
    (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.tabList, (item) => {
      return openBlock(), createElementBlock("li", {
        class: normalizeClass({ active: item.type == _ctx.curTab.type }),
        key: item.type,
        onClick: withModifiers(($event) => _ctx.onClick(item), ["stop"])
      }, toDisplayString(item.name), 11, _hoisted_2$6);
    }), 128))
  ]);
}
var TabMulte = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$6], ["__scopeId", "data-v-12fe7249"]]);
const formatCosUrl = (url) => {
  return `https://wlmvp-cos.weiling.cn${url}`;
};
var VSearch_vue_vue_type_style_index_0_scoped_true_lang = "";
const _sfc_main$6 = defineComponent({
  name: "Search",
  props: {
    value: {
      type: String,
      default: ""
    },
    icon: {
      type: String,
      default: formatCosUrl("/worktable-h5/icon/search-icon.png")
    },
    placeholder: {
      type: String,
      default: "\u641C\u7D22"
    },
    closable: {
      type: Boolean,
      default: true
    }
  },
  setup(props, { emit }) {
    const fieldValue = ref("");
    const delIcon = ref(formatCosUrl("/worktable-h5/icon/search_delete01.png"));
    const onInput = () => {
      if (!fieldValue.value)
        return;
      emit("update:value", fieldValue.value);
    };
    const onClear = () => {
      fieldValue.value = "";
      emit("onClear");
    };
    watch(
      () => props.value,
      (val) => fieldValue.value = val,
      { immediate: true }
    );
    watch(
      () => fieldValue.value,
      (val) => {
        emit("update:value", val);
        emit("onChange", val);
      }
    );
    return {
      fieldValue,
      onInput,
      onClear,
      delIcon
    };
  }
});
const _hoisted_1$5 = { class: "common-search" };
const _hoisted_2$5 = ["src"];
const _hoisted_3$5 = { class: "search-input" };
const _hoisted_4$5 = ["placeholder"];
const _hoisted_5$5 = ["src"];
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
  return openBlock(), createElementBlock("div", _hoisted_1$5, [
    createElementVNode("img", {
      class: "search-icon",
      src: _ctx.icon,
      alt: ""
    }, null, 8, _hoisted_2$5),
    createElementVNode("div", _hoisted_3$5, [
      withDirectives(createElementVNode("input", {
        type: "text",
        placeholder: _ctx.placeholder,
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.fieldValue = $event)
      }, null, 8, _hoisted_4$5), [
        [vModelText, _ctx.fieldValue]
      ])
    ]),
    _ctx.closable && _ctx.fieldValue ? (openBlock(), createElementBlock("img", {
      key: 0,
      class: "search-close-icon",
      onClick: _cache[1] || (_cache[1] = (...args) => _ctx.onClear && _ctx.onClear(...args)),
      alt: "",
      src: _ctx.delIcon
    }, null, 8, _hoisted_5$5)) : createCommentVNode("", true)
  ]);
}
var VSearch = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$5], ["__scopeId", "data-v-1793732c"]]);
var Api = {
  getBusinessRelatedCustomerList(paramas) {
    return POST(
      `${proxy_api[Store.node_env]}/crm_v2/web/company/related_customer_list`,
      paramas
    );
  }
};
var CustomerList_vue_vue_type_style_index_0_scoped_true_lang = "";
const _sfc_main$5 = defineComponent({
  components: { VanCheckbox: Checkbox, VanCheckboxGroup: CheckboxGroup, VanCell: Cell, VanCellGroup: CellGroup },
  props: {
    data: {
      type: Array,
      default() {
        return [];
      }
    },
    checkedData: {
      type: Array,
      default() {
        return [];
      }
    },
    isRadio: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    const state = reactive({
      checked: [],
      defaultAvatar,
      qwIcon: formatCosUrl("/worktable-h5/icon/lxx-icon/qw.png"),
      wechatIcon: formatCosUrl("/worktable-h5/icon/lxx-icon/wechat.png"),
      checkboxRefs: null,
      checkedList: []
    });
    const onToggle = (index2, item) => {
      if (props.isRadio) {
        state.checked = [item.id];
        state.checkedList = [item];
        emit("onUserChange", state.checkedList);
        state.checkboxRefs[index2].toggle();
        return;
      }
      if (state.checkedList.find((res) => res.id == item.id)) {
        state.checkedList = state.checkedList.filter(
          (res) => res.id != item.id
        );
      } else {
        state.checkedList.push(item);
      }
      emit("onUserChange", state.checkedList);
      state.checkboxRefs[index2].toggle();
    };
    watch(
      () => props.checkedData,
      (res) => {
        if (!res)
          return;
        state.checked = res.map((item) => item.id);
        state.checkedList = [...res];
      },
      {
        immediate: true
      }
    );
    return {
      ...toRefs(state),
      onToggle
    };
  }
});
const _hoisted_1$4 = { class: "user_wrap flex-row cross-center" };
const _hoisted_2$4 = { class: "user_avatar" };
const _hoisted_3$4 = ["src"];
const _hoisted_4$4 = ["src"];
const _hoisted_5$4 = { class: "user_info" };
const _hoisted_6$1 = { class: "name" };
const _hoisted_7$1 = {
  key: 0,
  class: "company"
};
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_van_checkbox = resolveComponent("van-checkbox");
  const _component_van_cell = resolveComponent("van-cell");
  const _component_van_cell_group = resolveComponent("van-cell-group");
  const _component_van_checkbox_group = resolveComponent("van-checkbox-group");
  return openBlock(), createBlock(_component_van_checkbox_group, {
    modelValue: _ctx.checked,
    "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.checked = $event)
  }, {
    default: withCtx(() => [
      _ctx.data.length ? (openBlock(), createBlock(_component_van_cell_group, {
        key: 0,
        border: false
      }, {
        default: withCtx(() => [
          (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data, (item, index2) => {
            return openBlock(), createBlock(_component_van_cell, {
              clickable: "",
              key: item.id,
              onClick: ($event) => _ctx.onToggle(index2, item)
            }, {
              title: withCtx(() => [
                createElementVNode("div", _hoisted_1$4, [
                  createElementVNode("div", _hoisted_2$4, [
                    createElementVNode("img", {
                      class: "avatar",
                      src: item.head_img_url || _ctx.defaultAvatar,
                      alt: ""
                    }, null, 8, _hoisted_3$4),
                    createElementVNode("img", {
                      class: "icon",
                      src: item.type == 2 ? _ctx.qwIcon : _ctx.wechatIcon,
                      alt: ""
                    }, null, 8, _hoisted_4$4)
                  ]),
                  createElementVNode("div", _hoisted_5$4, [
                    createElementVNode("p", _hoisted_6$1, toDisplayString(item.nick_name), 1),
                    item.corp_name ? (openBlock(), createElementBlock("p", _hoisted_7$1, "@" + toDisplayString(item.corp_name), 1)) : createCommentVNode("", true)
                  ])
                ])
              ]),
              "right-icon": withCtx(() => [
                createVNode(_component_van_checkbox, {
                  name: item.id,
                  ref_for: true,
                  ref: "checkboxRefs"
                }, null, 8, ["name"])
              ]),
              _: 2
            }, 1032, ["onClick"]);
          }), 128))
        ]),
        _: 1
      })) : createCommentVNode("", true)
    ]),
    _: 1
  }, 8, ["modelValue"]);
}
var CustomerList = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$4], ["__scopeId", "data-v-fbab9ade"]]);
var ClueList_vue_vue_type_style_index_0_scoped_true_lang = "";
const _sfc_main$4 = defineComponent({
  components: { VanCheckbox: Checkbox, VanCheckboxGroup: CheckboxGroup, VanCell: Cell, VanCellGroup: CellGroup },
  props: {
    data: {
      type: Array,
      default() {
        return [];
      }
    },
    checkedData: {
      type: Array,
      default() {
        return [];
      }
    },
    isRadio: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    const state = reactive({
      checked: [],
      checkboxRefs: null,
      checkedList: []
    });
    const onToggle = (index2, item) => {
      if (props.isRadio) {
        state.checked = [item.id];
        state.checkedList = [item];
        emit("onUserChange", state.checkedList);
        state.checkboxRefs[index2].toggle();
        return;
      }
      if (state.checkedList.find(
        (res) => (res.clue_id || res.id) == item.clue_id
      )) {
        state.checkedList = state.checkedList.filter(
          (res) => (res.clue_id || res.id) != item.clue_id
        );
      } else {
        state.checkedList.push(item);
      }
      emit("onUserChange", state.checkedList);
      state.checkboxRefs[index2].toggle();
    };
    watch(
      () => props.checkedData,
      (res) => {
        if (!res)
          return;
        state.checked = res.map((item) => item.clue_id || item.id);
        state.checkedList = [...res];
      },
      {
        immediate: true
      }
    );
    return {
      ...toRefs(state),
      onToggle
    };
  }
});
const _hoisted_1$3 = { class: "user_wrap flex-row cross-center" };
const _hoisted_2$3 = { class: "user_avatar flex-center" };
const _hoisted_3$3 = { class: "user_info" };
const _hoisted_4$3 = { class: "name" };
const _hoisted_5$3 = { class: "name" };
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_van_checkbox = resolveComponent("van-checkbox");
  const _component_van_cell = resolveComponent("van-cell");
  const _component_van_cell_group = resolveComponent("van-cell-group");
  const _component_van_checkbox_group = resolveComponent("van-checkbox-group");
  return openBlock(), createBlock(_component_van_checkbox_group, {
    modelValue: _ctx.checked,
    "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.checked = $event)
  }, {
    default: withCtx(() => [
      _ctx.data.length ? (openBlock(), createBlock(_component_van_cell_group, {
        key: 0,
        border: false
      }, {
        default: withCtx(() => [
          (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data, (item, index2) => {
            return openBlock(), createBlock(_component_van_cell, {
              clickable: "",
              key: item.clue_id || item.id,
              onClick: ($event) => _ctx.onToggle(index2, item)
            }, {
              title: withCtx(() => [
                createElementVNode("div", _hoisted_1$3, [
                  createElementVNode("div", _hoisted_2$3, toDisplayString(item.user_name ? item.user_name.substr(0, 1) : "-"), 1),
                  createElementVNode("div", _hoisted_3$3, [
                    createElementVNode("p", _hoisted_4$3, toDisplayString(item.user_name), 1),
                    createElementVNode("p", _hoisted_5$3, toDisplayString(item.mobile), 1)
                  ])
                ])
              ]),
              "right-icon": withCtx(() => [
                createVNode(_component_van_checkbox, {
                  name: item.clue_id || item.id,
                  ref_for: true,
                  ref: "checkboxRefs"
                }, null, 8, ["name"])
              ]),
              _: 2
            }, 1032, ["onClick"]);
          }), 128))
        ]),
        _: 1
      })) : createCommentVNode("", true)
    ]),
    _: 1
  }, 8, ["modelValue"]);
}
var ClueList = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$3], ["__scopeId", "data-v-2118816b"]]);
var WechatList_vue_vue_type_style_index_0_scoped_true_lang = "";
const _sfc_main$3 = defineComponent({
  components: { VanCheckbox: Checkbox, VanCheckboxGroup: CheckboxGroup, VanCell: Cell, VanCellGroup: CellGroup },
  props: {
    data: {
      type: Array,
      default() {
        return [];
      }
    },
    checkedData: {
      type: Array,
      default() {
        return [];
      }
    },
    isRadio: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    const state = reactive({
      checked: [],
      defaultAvatar,
      qwIcon: formatCosUrl("/worktable-h5/icon/lxx-icon/qw.png"),
      wechatIcon: formatCosUrl("/worktable-h5/icon/lxx-icon/wechat.png"),
      checkboxRefs: null,
      checkedList: []
    });
    const onToggle = (index2, item) => {
      if (props.isRadio) {
        state.checked = [item.id];
        state.checkedList = [item];
        emit("onUserChange", state.checkedList);
        state.checkboxRefs[index2].toggle();
        return;
      }
      if (state.checkedList.find((res) => res.id == item.id)) {
        state.checkedList = state.checkedList.filter(
          (res) => res.id != item.id
        );
      } else {
        state.checkedList.push(item);
      }
      emit("onUserChange", state.checkedList);
      state.checkboxRefs[index2].toggle();
    };
    watch(
      () => props.checkedData,
      (res) => {
        if (!res)
          return;
        state.checked = res.map((item) => item.id);
        state.checkedList = [...res];
      },
      {
        immediate: true
      }
    );
    return {
      ...toRefs(state),
      onToggle
    };
  }
});
const _hoisted_1$2 = { class: "user_wrap flex-row cross-center" };
const _hoisted_2$2 = { class: "user_avatar" };
const _hoisted_3$2 = ["src"];
const _hoisted_4$2 = ["src"];
const _hoisted_5$2 = { class: "user_info" };
const _hoisted_6 = { class: "name" };
const _hoisted_7 = {
  key: 0,
  class: "company"
};
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_van_checkbox = resolveComponent("van-checkbox");
  const _component_van_cell = resolveComponent("van-cell");
  const _component_van_cell_group = resolveComponent("van-cell-group");
  const _component_van_checkbox_group = resolveComponent("van-checkbox-group");
  return openBlock(), createBlock(_component_van_checkbox_group, {
    modelValue: _ctx.checked,
    "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.checked = $event)
  }, {
    default: withCtx(() => [
      _ctx.data.length ? (openBlock(), createBlock(_component_van_cell_group, {
        key: 0,
        border: false
      }, {
        default: withCtx(() => [
          (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data, (item, index2) => {
            return openBlock(), createBlock(_component_van_cell, {
              clickable: "",
              key: item.id,
              onClick: ($event) => _ctx.onToggle(index2, item)
            }, {
              title: withCtx(() => [
                createElementVNode("div", _hoisted_1$2, [
                  createElementVNode("div", _hoisted_2$2, [
                    createElementVNode("img", {
                      class: "avatar",
                      src: item.headimgurl || _ctx.defaultAvatar,
                      alt: ""
                    }, null, 8, _hoisted_3$2),
                    createElementVNode("img", {
                      class: "icon",
                      src: item.user_type == 1 ? _ctx.wechatIcon : _ctx.qwIcon,
                      alt: ""
                    }, null, 8, _hoisted_4$2)
                  ]),
                  createElementVNode("div", _hoisted_5$2, [
                    createElementVNode("p", _hoisted_6, toDisplayString(item.nickname), 1),
                    item.corp_name ? (openBlock(), createElementBlock("p", _hoisted_7, "@" + toDisplayString(item.corp_name), 1)) : createCommentVNode("", true)
                  ])
                ])
              ]),
              "right-icon": withCtx(() => [
                createVNode(_component_van_checkbox, {
                  name: item.id,
                  ref_for: true,
                  ref: "checkboxRefs"
                }, null, 8, ["name"])
              ]),
              _: 2
            }, 1032, ["onClick"]);
          }), 128))
        ]),
        _: 1
      })) : createCommentVNode("", true)
    ]),
    _: 1
  }, 8, ["modelValue"]);
}
var WechatList = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$2], ["__scopeId", "data-v-6109b698"]]);
const _sfc_main$2 = defineComponent({
  name: "VLoadMore",
  props: {
    value: {
      type: Boolean,
      default: false
    },
    "finished-text": {
      type: String,
      default: "\u6CA1\u6709\u66F4\u591A\u4E86"
    }
  },
  components: { VanList: List },
  setup(props, { emit }) {
    const loadShow = ref(false);
    watch(
      () => props.value,
      (val) => loadShow.value = val
    );
    watch(
      () => loadShow.value,
      (val) => emit("update:value", val)
    );
    return {
      loadShow
    };
  }
});
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_van_list = resolveComponent("van-list");
  return openBlock(), createBlock(_component_van_list, mergeProps({
    loading: _ctx.loadShow,
    "onUpdate:loading": _cache[0] || (_cache[0] = ($event) => _ctx.loadShow = $event)
  }, _ctx.$attrs, { "finished-text": _ctx.finishedText }), {
    default: withCtx(() => [
      renderSlot(_ctx.$slots, "default")
    ]),
    _: 3
  }, 16, ["loading", "finished-text"]);
}
var VLoadMore = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1]]);
const usePagination = () => {
  const State = reactive({
    limit: 10,
    page_count: 1,
    isLoading: false,
    isFinished: false,
    cursor: ""
  });
  const judgeLoadStatus = (result) => {
    const { data_list, cursor } = result;
    State.isLoading = false;
    State.cursor = cursor || "";
    if ("data_list" in result && data_list && data_list.length < State.limit)
      State.isFinished = true;
    if ("cursor" in result && !cursor) {
      State.isFinished = true;
    }
    State.page_count++;
  };
  return {
    ...toRefs(State),
    judgeLoadStatus
  };
};
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
var freeGlobal$1 = freeGlobal;
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
var root = freeGlobal$1 || freeSelf || Function("return this")();
var root$1 = root;
var Symbol$1 = root$1.Symbol;
var Symbol$2 = Symbol$1;
var objectProto$1 = Object.prototype;
var hasOwnProperty = objectProto$1.hasOwnProperty;
var nativeObjectToString$1 = objectProto$1.toString;
var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : void 0;
function getRawTag(value) {
  var isOwn = hasOwnProperty.call(value, symToStringTag$1), tag = value[symToStringTag$1];
  try {
    value[symToStringTag$1] = void 0;
    var unmasked = true;
  } catch (e) {
  }
  var result = nativeObjectToString$1.call(value);
  if (unmasked) {
    if (isOwn) {
      value[symToStringTag$1] = tag;
    } else {
      delete value[symToStringTag$1];
    }
  }
  return result;
}
var objectProto = Object.prototype;
var nativeObjectToString = objectProto.toString;
function objectToString(value) {
  return nativeObjectToString.call(value);
}
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
function baseGetTag(value) {
  if (value == null) {
    return value === void 0 ? undefinedTag : nullTag;
  }
  return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
}
function isObjectLike(value) {
  return value != null && typeof value == "object";
}
var symbolTag = "[object Symbol]";
function isSymbol(value) {
  return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
}
var reWhitespace = /\s/;
function trimmedEndIndex(string) {
  var index2 = string.length;
  while (index2-- && reWhitespace.test(string.charAt(index2))) {
  }
  return index2;
}
var reTrimStart = /^\s+/;
function baseTrim(string) {
  return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
}
function isObject(value) {
  var type = typeof value;
  return value != null && (type == "object" || type == "function");
}
var NAN = 0 / 0;
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
var reIsBinary = /^0b[01]+$/i;
var reIsOctal = /^0o[0-7]+$/i;
var freeParseInt = parseInt;
function toNumber(value) {
  if (typeof value == "number") {
    return value;
  }
  if (isSymbol(value)) {
    return NAN;
  }
  if (isObject(value)) {
    var other = typeof value.valueOf == "function" ? value.valueOf() : value;
    value = isObject(other) ? other + "" : other;
  }
  if (typeof value != "string") {
    return value === 0 ? value : +value;
  }
  value = baseTrim(value);
  var isBinary = reIsBinary.test(value);
  return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
}
var now = function() {
  return root$1.Date.now();
};
var now$1 = now;
var FUNC_ERROR_TEXT = "Expected a function";
var nativeMax = Math.max, nativeMin = Math.min;
function debounce(func, wait, options) {
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
  if (typeof func != "function") {
    throw new TypeError(FUNC_ERROR_TEXT);
  }
  wait = toNumber(wait) || 0;
  if (isObject(options)) {
    leading = !!options.leading;
    maxing = "maxWait" in options;
    maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
    trailing = "trailing" in options ? !!options.trailing : trailing;
  }
  function invokeFunc(time) {
    var args = lastArgs, thisArg = lastThis;
    lastArgs = lastThis = void 0;
    lastInvokeTime = time;
    result = func.apply(thisArg, args);
    return result;
  }
  function leadingEdge(time) {
    lastInvokeTime = time;
    timerId = setTimeout(timerExpired, wait);
    return leading ? invokeFunc(time) : result;
  }
  function remainingWait(time) {
    var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
    return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
  }
  function shouldInvoke(time) {
    var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
    return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
  }
  function timerExpired() {
    var time = now$1();
    if (shouldInvoke(time)) {
      return trailingEdge(time);
    }
    timerId = setTimeout(timerExpired, remainingWait(time));
  }
  function trailingEdge(time) {
    timerId = void 0;
    if (trailing && lastArgs) {
      return invokeFunc(time);
    }
    lastArgs = lastThis = void 0;
    return result;
  }
  function cancel() {
    if (timerId !== void 0) {
      clearTimeout(timerId);
    }
    lastInvokeTime = 0;
    lastArgs = lastCallTime = lastThis = timerId = void 0;
  }
  function flush() {
    return timerId === void 0 ? result : trailingEdge(now$1());
  }
  function debounced() {
    var time = now$1(), isInvoking = shouldInvoke(time);
    lastArgs = arguments;
    lastThis = this;
    lastCallTime = time;
    if (isInvoking) {
      if (timerId === void 0) {
        return leadingEdge(lastCallTime);
      }
      if (maxing) {
        clearTimeout(timerId);
        timerId = setTimeout(timerExpired, wait);
        return invokeFunc(lastCallTime);
      }
    }
    if (timerId === void 0) {
      timerId = setTimeout(timerExpired, wait);
    }
    return result;
  }
  debounced.cancel = cancel;
  debounced.flush = flush;
  return debounced;
}
var index_vue_vue_type_style_index_0_lang = "";
var index_vue_vue_type_style_index_1_scoped_true_lang = "";
const _sfc_main$1 = defineComponent({
  components: { TabMulte, CustomerList, ClueList, WechatList, VSearch, VanActionSheet: ActionSheet, VLoadMore },
  props: {
    value: {
      type: Boolean,
      default: false
    },
    data: {
      type: Array || Object,
      default() {
        return [];
      }
    },
    title: {
      type: String,
      default: "\u9009\u62E9\u5BF9\u63A5\u4EBA"
    },
    env_data: {
      type: Object,
      default: () => {
        return {
          sid: "",
          domain: "",
          corp_id: "",
          node_env: "uat",
          app_id: "",
          token: "",
          card_resource: ""
        };
      }
    },
    tabChangeClear: {
      type: Boolean,
      default: false
    },
    tabTypes: {
      type: Array,
      default: () => {
        return [1, 2, 3];
      }
    },
    isRadio: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    var _a;
    const { limit, page_count, isLoading, isFinished, judgeLoadStatus } = usePagination();
    Store.corp_id = props.env_data.corp_id;
    Store.node_env = props.env_data.node_env;
    Store.sid = props.env_data.sid;
    Store.token = props.env_data.token;
    Store.card_resource = props.env_data.card_resource;
    const state = reactive({
      show: false,
      keyword: "",
      checkCustomer: [],
      checkClue: [],
      type: ((_a = props.tabTypes) == null ? void 0 : _a[0]) || 1,
      checkWechat: [],
      clueList: [],
      wechatList: [],
      customerList: []
    });
    let EnumType;
    ((EnumType2) => {
      EnumType2[EnumType2["customerList"] = 1] = "customerList";
      EnumType2[EnumType2["wechatList"] = 2] = "wechatList";
      EnumType2[EnumType2["clueList"] = 3] = "clueList";
    })(EnumType || (EnumType = {}));
    const Methods = {
      onTabChange(res) {
        const { type } = res;
        state.type = type;
        page_count.value = 1;
        isFinished.value = false;
        Methods.onGetList();
      },
      onGetList: async () => {
        isLoading.value = true;
        const params = {
          type: state.type,
          page: {
            page_count: page_count.value,
            limit: limit.value,
            keyword: state.keyword
          },
          version_flag: 2
        };
        if (page_count.value == 1)
          state[EnumType[params.type]] = [];
        const { data } = await Api.getBusinessRelatedCustomerList(params);
        const data_list = data.data_list || [];
        state[EnumType[params.type]] = [
          ...state[EnumType[params.type]],
          ...data_list
        ];
        judgeLoadStatus({ data_list });
      },
      onCustomerChange(res) {
        console.log(res, "cuatomer");
        if (props.isRadio) {
          state.checkClue = [];
          state.checkWechat = [];
        }
        state.checkCustomer = res;
      },
      onClueChange(res) {
        console.log(res, "clue");
        if (props.isRadio) {
          state.checkCustomer = [];
          state.checkWechat = [];
        }
        state.checkClue = res;
      },
      onWechatChange(res) {
        if (props.isRadio) {
          state.checkCustomer = [];
          state.checkClue = [];
        }
        state.checkWechat = res;
      },
      onInput: debounce((res) => {
        state.keyword = res;
        page_count.value = 1;
        Methods.onGetList();
      }, 300),
      onSub() {
        var _a2, _b, _c;
        let arr1 = (_a2 = state.checkCustomer) == null ? void 0 : _a2.map((item) => {
          return {
            user_type: 1,
            ...item
          };
        });
        let arr2 = (_b = state.checkWechat) == null ? void 0 : _b.map((item) => {
          return {
            ...item,
            user_type: 2
          };
        });
        let arr3 = (_c = state.checkClue) == null ? void 0 : _c.map((item) => {
          return {
            user_type: 3,
            id: item.clue_id,
            ...item
          };
        });
        if (props.isRadio) {
          emit("onHandleChoose", ...[...arr1, ...arr2, ...arr3]);
          state.show = false;
          return;
        }
        if (!props.tabChangeClear) {
          emit("onHandleChoose", [...arr1, ...arr2, ...arr3]);
          state.show = false;
          return;
        }
        if (state.type == 1) {
          emit("onHandleChoose", arr1);
        }
        if (state.type == 2) {
          emit("onHandleChoose", arr2);
        }
        if (state.type == 3) {
          emit("onHandleChoose", arr3);
        }
        state.show = false;
      }
    };
    watch(
      () => props.value,
      (val) => {
        state.show = val;
      }
    );
    watch(
      () => state.show,
      (bol) => {
        if (!bol)
          emit("update:value", false);
      }
    );
    watch(
      () => props.data,
      (res) => {
        let val = res;
        if (typeDetection(res) === "object")
          val = [res];
        state.checkCustomer = val.filter((item) => item.user_type == 1) || [];
        state.checkWechat = val.filter((item) => item.user_type == 2) || [];
        state.checkClue = val.filter((item) => {
          return item.user_type == 3;
        }) || [];
      },
      {
        deep: true,
        immediate: true
      }
    );
    return {
      ...toRefs(state),
      isLoading,
      isFinished,
      ...Methods
    };
  }
});
const _hoisted_1$1 = { class: "content flex-column" };
const _hoisted_2$1 = { class: "search_wrap flex0" };
const _hoisted_3$1 = { class: "tab_wrap flex0" };
const _hoisted_4$1 = { class: "flex1 info_wrap" };
const _hoisted_5$1 = { class: "flex-center flex0" };
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_VSearch = resolveComponent("VSearch");
  const _component_TabMulte = resolveComponent("TabMulte");
  const _component_CustomerList = resolveComponent("CustomerList");
  const _component_WechatList = resolveComponent("WechatList");
  const _component_ClueList = resolveComponent("ClueList");
  const _component_VLoadMore = resolveComponent("VLoadMore");
  const _component_van_action_sheet = resolveComponent("van-action-sheet");
  return openBlock(), createBlock(_component_van_action_sheet, {
    show: _ctx.show,
    "onUpdate:show": _cache[3] || (_cache[3] = ($event) => _ctx.show = $event),
    title: _ctx.title,
    class: "BCMulteTypePersonnerSelect",
    teleport: "body"
  }, {
    default: withCtx(() => [
      createElementVNode("div", _hoisted_1$1, [
        createElementVNode("div", _hoisted_2$1, [
          createVNode(_component_VSearch, {
            placeholder: "\u641C\u7D22",
            modelValue: _ctx.keyword,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.keyword = $event),
            onOnChange: _ctx.onInput,
            closable: ""
          }, null, 8, ["modelValue", "onOnChange"])
        ]),
        createElementVNode("div", _hoisted_3$1, [
          createVNode(_component_TabMulte, {
            tabTypes: _ctx.tabTypes,
            onOnTabChange: _ctx.onTabChange
          }, null, 8, ["tabTypes", "onOnTabChange"])
        ]),
        createElementVNode("div", _hoisted_4$1, [
          createVNode(_component_VLoadMore, {
            value: _ctx.isLoading,
            "onUpdate:value": _cache[1] || (_cache[1] = ($event) => _ctx.isLoading = $event),
            finished: _ctx.isFinished,
            onLoad: _ctx.onGetList
          }, {
            default: withCtx(() => [
              _ctx.type == 1 && _ctx.customerList.length ? (openBlock(), createBlock(_component_CustomerList, {
                key: 0,
                data: _ctx.customerList,
                isRadio: _ctx.isRadio,
                onOnUserChange: _ctx.onCustomerChange,
                checkedData: _ctx.checkCustomer
              }, null, 8, ["data", "isRadio", "onOnUserChange", "checkedData"])) : createCommentVNode("", true),
              _ctx.type == 2 && _ctx.wechatList.length ? (openBlock(), createBlock(_component_WechatList, {
                key: 1,
                data: _ctx.wechatList,
                isRadio: _ctx.isRadio,
                onOnUserChange: _ctx.onWechatChange,
                checkedData: _ctx.checkWechat
              }, null, 8, ["data", "isRadio", "onOnUserChange", "checkedData"])) : createCommentVNode("", true),
              _ctx.type == 3 && _ctx.clueList.length ? (openBlock(), createBlock(_component_ClueList, {
                key: 2,
                data: _ctx.clueList,
                isRadio: _ctx.isRadio,
                onOnUserChange: _ctx.onClueChange,
                checkedData: _ctx.checkClue
              }, null, 8, ["data", "isRadio", "onOnUserChange", "checkedData"])) : createCommentVNode("", true)
            ]),
            _: 1
          }, 8, ["value", "finished", "onLoad"])
        ]),
        createElementVNode("footer", _hoisted_5$1, [
          createElementVNode("p", {
            class: "flex-center",
            onClick: _cache[2] || (_cache[2] = withModifiers((...args) => _ctx.onSub && _ctx.onSub(...args), ["stop"]))
          }, "\u786E\u8BA4\u9009\u62E9")
        ])
      ])
    ]),
    _: 1
  }, 8, ["show", "title"]);
}
var Comp = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__scopeId", "data-v-b1b50190"]]);
Comp.install = (app) => {
  app.component(Comp.name, Comp);
};
var index_vue_vue_type_style_index_0_scoped_true_lang = "";
const _withScopeId = (n) => (pushScopeId("data-v-b192bf94"), n = n(), popScopeId(), n);
const _hoisted_1 = { class: "render-card-friends a-row" };
const _hoisted_2 = ["onClick"];
const _hoisted_3 = ["onClick"];
const _hoisted_4 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", null, "\u6DFB\u52A0", -1));
const _hoisted_5 = { key: 2 };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    data: { default: () => {
    } },
    listItem: { default: () => {
      return {};
    } },
    is_trial: { type: Boolean, default: false },
    env_data: { default: () => {
      return {};
    } }
  },
  emits: ["onPersonChoose", "onItem"],
  setup(__props, { emit }) {
    const props = __props;
    const showPerson = ref(false);
    const onAdd = () => {
      showPerson.value = true;
    };
    const onPersonChoose = (obj) => {
      emit("onPersonChoose", obj);
    };
    const onItem = () => {
      var _a;
      if (!((_a = props.listItem) == null ? void 0 : _a.allowClick))
        return;
      emit("onItem", {
        data: props.data,
        listItem: props.listItem
      });
    };
    return (_ctx, _cache) => {
      var _a, _b, _c, _d, _e;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        ((_a = __props.data) == null ? void 0 : _a.bind_id) ? (openBlock(), createElementBlock("div", {
          key: 0,
          class: "user",
          onClick: withModifiers(onItem, ["stop"])
        }, [
          createVNode(_sfc_main$8, {
            class: "user-img",
            src: ((_b = __props.data) == null ? void 0 : _b.head_img_url) || unref(defaultAvatar),
            alt: ""
          }, null, 8, ["src"]),
          createVNode(_sfc_main$9, {
            class: "user-name a-row",
            name: __props.data.nick_name,
            openid: (_c = __props.data) == null ? void 0 : _c.userid_third,
            is_trial: __props.is_trial
          }, null, 8, ["name", "openid", "is_trial"]),
          ((_d = __props.listItem) == null ? void 0 : _d.allowClick) ? (openBlock(), createBlock(_sfc_main$a, {
            key: 0,
            type: "arrowRight",
            width: "16",
            height: "16",
            color: "#C2C8CC",
            class: "arrow-icon"
          })) : createCommentVNode("", true)
        ], 8, _hoisted_2)) : !((_e = __props.data) == null ? void 0 : _e.bind_id) && __props.listItem.isAdd ? (openBlock(), createElementBlock("div", {
          key: 1,
          class: "friends-add",
          onClick: withModifiers(onAdd, ["stop"])
        }, [
          createVNode(_sfc_main$a, {
            type: "add",
            width: "12",
            height: "12",
            color: "var(--wl-primary-color)"
          }),
          _hoisted_4
        ], 8, _hoisted_3)) : (openBlock(), createElementBlock("div", _hoisted_5, "--")),
        createVNode(unref(Comp), {
          value: showPerson.value,
          "onUpdate:value": _cache[0] || (_cache[0] = ($event) => showPerson.value = $event),
          title: __props.listItem.title || `\u9009\u62E9${__props.listItem.label}`,
          env_data: __props.env_data,
          tabTypes: [1, 2],
          isRadio: "",
          onOnHandleChoose: onPersonChoose
        }, null, 8, ["value", "title", "env_data"])
      ]);
    };
  }
});
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b192bf94"]]);
export { index as default };
