import { defineComponent, ref, computed, watch, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createCommentVNode, renderSlot, createBlock, watchEffect, Fragment, createElementVNode, createVNode, withDirectives, vModelText, toDisplayString, withCtx, render, renderList } from "vue";
import dayjs from "dayjs";
import qs from "qs";
import WlSvg from "@wltech/svg";
import { List } from "vant";
const domain = "https://wlmvp-cos.weiling.cn";
const loadingPic = domain + "/frontend/weilingMobileUI/loading.png";
const loadingFailPic = domain + "/frontend/weilingMobileUI/loadingFail.png";
const chat_no_result = domain + "/frontend/errorPage/chat_no_result.png";
dayjs().format();
dayjs.locale("zh-cn");
const chatFormatMillisecond = (value, format) => {
  if (!value)
    return "";
  value = parseInt(value);
  let time = new Date().getTime();
  let date = Math.floor((time - value) / 1e3);
  if (date <= 60) {
    return "\u521A\u521A";
  } else if (60 < date && date <= 60 * 60) {
    return Math.floor(date / 60) + "\u5206\u949F\u524D";
  } else if (60 * 60 < date && date <= 60 * 60 * 24) {
    return Math.floor(date / 3600) + "\u5C0F\u65F6\u524D";
  } else if (60 * 60 * 24 < date && date <= 60 * 60 * 48) {
    return dayjs(value).format("[\u6628\u5929] HH:mm:ss");
  } else if (dayjs(value).year() == dayjs().year()) {
    return dayjs().format("MM-DD HH:mm:ss");
  } else {
    return dayjs(value).format(`${format} HH:mm:ss`);
  }
};
const onDebounce = (fn, delay) => {
  let timer;
  return function(...args) {
    if (timer) {
      clearTimeout(timer);
    }
    timer = setTimeout(
      () => {
        typeof fn === "function" && fn.apply(null, [...args]);
        clearTimeout(timer);
      },
      delay > 0 ? delay : 100
    );
  };
};
const getQueryVariable = (variable) => {
  const query = window.location.search.substring(1);
  const vars = query.split("&");
  for (let i = 0; i < vars.length; i++) {
    const pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
  return "";
};
const loadImage = (url) => {
  return new Promise((resolve, reject) => {
    const newImg = new Image();
    newImg.src = url;
    newImg.onerror = () => {
      reject("failure");
    };
    newImg.onload = (e) => {
      resolve(e.target);
    };
  });
};
const isTencentCosPic = (url) => {
  return url.includes("wlmvp-cos.weiling.cn");
};
const isBase64 = (str) => {
  return str.indexOf("data:") != -1 && str.indexOf("base64") != -1;
};
const removeEmptyField = (obj) => {
  let newObj = {};
  if (typeof obj === "string") {
    obj = JSON.parse(obj);
  }
  if (obj instanceof Array) {
    newObj = [];
  }
  if (obj instanceof Object) {
    for (let attr in obj) {
      if (obj[attr] !== "" && obj[attr] !== null && obj[attr] !== void 0) {
        if (obj[attr] instanceof Object) {
          if (JSON.stringify(obj[attr]) === "{}" || JSON.stringify(obj[attr]) === "[]") {
            continue;
          }
          newObj[attr] = removeEmptyField(obj[attr]);
        } else if (typeof obj[attr] === "string" && (obj[attr].indexOf("{") > -1 && obj[attr].indexOf("}") > -1 || obj[attr].indexOf("[") > -1 && obj[attr].indexOf("]") > -1)) {
          try {
            let attrObj = JSON.parse(obj[attr]);
            if (attrObj instanceof Object) {
              newObj[attr] = removeEmptyField(attrObj);
            }
          } catch (e) {
            newObj[attr] = obj[attr];
          }
        } else {
          newObj[attr] = obj[attr];
        }
      }
    }
  }
  return newObj;
};
const _hoisted_1$3 = ["src", "alt"];
const _hoisted_2$3 = ["src"];
const _hoisted_3$2 = ["src"];
var ECosType = /* @__PURE__ */ ((ECosType2) => {
  ECosType2["normal"] = "imageView2/1/q/85";
  ECosType2["thumbnail"] = "imageView2/1/w/100/h/100/q/85";
  return ECosType2;
})(ECosType || {});
const __default__$5 = {
  name: "WlPic"
};
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
  ...__default__$5,
  props: {
    src: { default: "" },
    needCos: { type: Boolean, default: true },
    cosType: { default: "normal" },
    radius: { type: Boolean, default: false },
    round: { type: Boolean, default: false },
    needLoading: { type: Boolean, default: true },
    needMiddleCenter: { type: Boolean, default: true },
    needHeightAuto: { type: Boolean, default: false },
    fit: { default: "fill" }
  },
  setup(__props, { expose }) {
    const props = __props;
    const isLoading = ref(true);
    const isError = ref(false);
    const imgSrc = ref("");
    const imgWrapRef = ref("");
    const imgStyleComputed = computed(() => {
      return {
        "border-radius": props.round ? "50%" : "",
        "object-fit": props.fit
      };
    });
    const imgWrapClassComputed = computed(() => {
      return [
        "wl-img",
        "wh-full",
        "relative",
        "flex-col",
        props.needMiddleCenter ? "flex-middle-center" : ""
      ];
    });
    const onLoadImage = (url) => {
      return new Promise((resolve, reject) => {
        loadImage(url).then((elem) => {
          resolve(elem);
        }).catch((reason) => {
          reject(reason);
        }).finally(() => {
          isLoading.value = false;
        });
      });
    };
    const setImgSrc = (url) => {
      const needCos = isTencentCosPic(url) && props.needCos;
      const file_type = url.split(".").pop();
      let isSvg = file_type === "svg";
      let isBase64Bool = isBase64(url);
      if (isSvg || !needCos || isBase64Bool) {
        imgSrc.value = url;
        onLoadImage(imgSrc.value).catch(() => {
          isError.value = true;
        });
      } else {
        imgSrc.value = `${url}?${ECosType[props.cosType]}`;
        onLoadImage(imgSrc.value).catch(() => {
          imgSrc.value = url;
        });
      }
    };
    watch(
      () => props.src,
      (val) => {
        if (val) {
          isLoading.value = true;
          setImgSrc(props.src);
        }
      },
      { immediate: true }
    );
    expose({
      imgWrapRef
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: normalizeClass(unref(imgWrapClassComputed)),
        ref_key: "imgWrapRef",
        ref: imgWrapRef
      }, [
        !isLoading.value && !isError.value ? (openBlock(), createElementBlock("img", {
          key: 0,
          src: imgSrc.value,
          style: normalizeStyle(unref(imgStyleComputed)),
          class: normalizeClass(`w-full block ${__props.needHeightAuto ? "h-auto" : "h-full"}`),
          alt: imgSrc.value
        }, null, 14, _hoisted_1$3)) : createCommentVNode("", true),
        isLoading.value && __props.needLoading ? (openBlock(), createElementBlock("img", {
          key: 1,
          src: unref(loadingPic),
          alt: "loading",
          class: "w-1/5 uno-min-w-20 uno-min-h-20 uno-max-w-60 uno-max-h-60 absolute-middle-center animate-spin"
        }, null, 8, _hoisted_2$3)) : createCommentVNode("", true),
        isError.value ? (openBlock(), createElementBlock("img", {
          key: 2,
          src: unref(loadingFailPic),
          alt: "failure",
          class: "w-1/5 uno-min-w-20 uno-min-h-20 uno-max-w-60 uno-max-h-60 absolute-middle-center"
        }, null, 8, _hoisted_3$2)) : createCommentVNode("", true),
        renderSlot(_ctx.$slots, "picFooter")
      ], 2);
    };
  }
});
const useGetIdsFromUrl = () => {
  const sid = getQueryVariable("sid");
  const from = getQueryVariable("from");
  const puid = getQueryVariable("puid");
  const order = getQueryVariable("order");
  const app_id = getQueryVariable("app_id");
  const use_tp = getQueryVariable("use_tp");
  const hlt_id = getQueryVariable("hlt_id");
  const token = getQueryVariable("token");
  const corp_id = getQueryVariable("corp_id");
  const user_id = getQueryVariable("user_id");
  const channel = getQueryVariable("channel");
  const hidden_element = getQueryVariable("hidden_element");
  const agent_id = getQueryVariable("agent_id");
  const operation = getQueryVariable("operation");
  const need_auth = getQueryVariable("need_auth");
  const show_back = getQueryVariable("show_back");
  const show_menu = getQueryVariable("show_menu");
  const show_share = getQueryVariable("show_share");
  const show_header = getQueryVariable("show_header");
  const show_company_header = getQueryVariable("show_company_header");
  const external_userid = getQueryVariable("external_userid");
  const external_chatid = getQueryVariable("external_chatid");
  const event_id_for_light = getQueryVariable("event_id_for_light");
  const params = {
    sid,
    puid,
    from,
    order,
    hlt_id,
    app_id,
    use_tp,
    token,
    corp_id,
    user_id,
    channel,
    agent_id,
    operation,
    need_auth,
    show_menu,
    show_back,
    show_share,
    show_header,
    hidden_element,
    external_userid,
    external_chatid,
    event_id_for_light,
    show_company_header
  };
  return Object.keys(params).reduce((acc, item) => {
    if (params[item] !== null && params[item] !== "" && params[item] !== void 0) {
      acc[item] = params[item];
    }
    return acc;
  }, {});
};
const useGetChatDetailUrl = (domain2 = "", id, extra_params = {}) => {
  const params = {
    ...useGetIdsFromUrl(),
    ...extra_params
  };
  const query = {
    id,
    showQuickChat: false
  };
  return `${domain2}/h5/follow-up-record/?${qs.stringify(params)}#/chat-detail?${qs.stringify(query)}`;
};
var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QIEYBoOaAhLGvnZy9wkNBsgLefuvtuDc2C+gLZSr19tQXgxWszyIoAKMAkvlLqu8LfWCyMwnjGzsUgCiA3pzsmBJU/04HBIbjzvfoUyhvTBaQGcpzOixyoSwLmQdMAki7PdX0uu+BaQ9QWYBMKHuhw8PUIRl54nSFPSrbGxZnLCNPvAWAp/WL3iHeAmB2/UD/D8r3RZMAkrl/pANDb9YqYRJACWUZHR6ZoVyRJyECtOtQvGbEw9mQnapJANP6GuRnp4bjj0LxnAIQBWAFOZBRLsehg8+ZfSOwNUpuL9zjoANS4yrAoSihLHi7mZCuoTwoamRbBk3/aEgHgOEgVIWG1Y0C6H+0ECq+2fdkaDqsidmuWx0hjCcp6tLGXHBPe0If04sHoKajMhsuT3BMwpKIuaDPERvaAxyYJbn3xzEHtVYBePtrOgPkXtAHJ43B4Tk0VDyqi+l9xis09vz8POMVQHiULCZYxhabxDdcx55Vem2GoO41mcNSs9SWYGu8Nv0xReIlgCMsxSL80B9ZK+xzICTP+Qgj0zvonJ9UgdAEiaElUMrUNiRcYfES0XkCwSky6OkRbtbe1rl+j6G5PNrLHFgCsjaiRIhKkvKwhIIi8ZE3KIpKuULaoSqySDmxUjyODyBYhOgsMUfSQirmnHTlED9IhJBD0X/YSlqolKPjyRLWcYuGdTk6zMue5d0xhqkrweov0RawjXZPx/gZFJbyYJ14hQY/lGMSvB/QSZomvCyhFgEKdObogNwpbi6MDS/VV1mEWgUo0LM5i9HHBHgJ871w/Ak3ktdzHlbTkC1tVRGSCCCxFXAtrqW+VFW/oYoIjQmQmlgR3o0AjEsE7aXm22XRy+AhwpsiyxI5keaWd2UBBYIlTGD+AzomWAQ4RCtcYzpWYrNHT5w4cTz8Aaz4M79MeVvFAAAAAElFTkSuQmCC";
const __default__$4 = {
  name: "WlSvgIcon"
};
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  ...__default__$4,
  props: {
    type: { default: "" },
    color: { default: "var(--wl-text-color-title-1)" },
    width: { default: "16" },
    height: { default: "16" }
  },
  setup(__props) {
    const sub = location.origin;
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(WlSvg), {
        type: __props.type,
        width: __props.width,
        height: __props.height,
        color: __props.color,
        sub: unref(sub)
      }, null, 8, ["type", "width", "height", "color", "sub"]);
    };
  }
});
var index_vue_vue_type_style_index_0_lang$2 = "";
const _hoisted_1$2 = {
  class: "search-wrap",
  "data-weiling-mobile-ui-wl-search": ""
};
const _hoisted_2$2 = { class: "search-icon" };
const _hoisted_3$1 = { class: "search-input" };
const _hoisted_4$1 = ["placeholder"];
const _hoisted_5$1 = { class: "action" };
const _hoisted_6$1 = { class: "default-search-content" };
const _hoisted_7$1 = { class: "search-text" };
const __default__$3 = {
  name: "WlSearch"
};
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  ...__default__$3,
  props: {
    modelValue: { default: "" },
    icon: { default: searchIcon },
    placeholder: { default: "\u641C\u7D22" },
    closable: { type: Boolean, default: true },
    needBorder: { type: Boolean, default: true },
    showType: { default: "search" }
  },
  emits: ["onClear", "onClickDefault", "onChange", "onBlurChange", "onChinaChange", "update:modelValue"],
  setup(__props, { expose, emit }) {
    const props = __props;
    const fieldValue = ref("");
    const is_focus = ref(false);
    const inputRef = ref(null);
    let isChinaInput = false;
    const searchClass = computed(() => {
      return {
        search: true,
        "search-focus": is_focus.value,
        "search-border": props.needBorder
      };
    });
    const onClickDefault = () => emit("onClickDefault");
    const onClear = () => {
      fieldValue.value = "";
      emit("update:modelValue", "");
      emit("onChange", "");
      emit("onClear");
    };
    const onDebounceSave = onDebounce((event) => {
      if (!isChinaInput) {
        const val = event.target.value;
        emit("update:modelValue", val);
        emit("onChange", val);
      }
    }, 300);
    const onContentChange = onDebounce((event) => {
      var _a;
      const val = (_a = event.target) == null ? void 0 : _a.value;
      emit("update:modelValue", val);
      emit("onBlurChange", val);
    }, 300);
    const compositionend = () => {
      isChinaInput = false;
    };
    const compositionstart = () => {
      isChinaInput = true;
    };
    const onFocus = () => {
      var _a;
      (_a = inputRef.value) == null ? void 0 : _a.focus();
    };
    expose({
      onFocus,
      inputEl: inputRef
    });
    watch(
      () => fieldValue.value,
      (val) => {
        emit("update:modelValue", val);
      }
    );
    watchEffect(() => {
      fieldValue.value = props.modelValue;
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1$2, [
        __props.showType === "search" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
          createElementVNode("div", {
            class: normalizeClass(unref(searchClass))
          }, [
            createElementVNode("div", _hoisted_2$2, [
              createVNode(_sfc_main$5, { src: __props.icon }, null, 8, ["src"])
            ]),
            createElementVNode("div", _hoisted_3$1, [
              withDirectives(createElementVNode("input", {
                type: "text",
                placeholder: __props.placeholder,
                "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => fieldValue.value = $event),
                ref_key: "inputRef",
                ref: inputRef,
                onInput: _cache[1] || (_cache[1] = (...args) => unref(onDebounceSave) && unref(onDebounceSave)(...args)),
                onChange: _cache[2] || (_cache[2] = (...args) => unref(onContentChange) && unref(onContentChange)(...args)),
                onFocus: _cache[3] || (_cache[3] = ($event) => is_focus.value = true),
                onBlur: _cache[4] || (_cache[4] = ($event) => is_focus.value = false),
                onCompositionend: compositionend,
                onCompositionstart: compositionstart
              }, null, 40, _hoisted_4$1), [
                [vModelText, fieldValue.value]
              ])
            ]),
            __props.closable && fieldValue.value ? (openBlock(), createElementBlock("div", {
              key: 0,
              class: "search-close-icon",
              onClick: onClear
            }, [
              createVNode(_sfc_main$5, { src: unref(deleteIcon) }, null, 8, ["src"])
            ])) : createCommentVNode("", true)
          ], 2),
          createElementVNode("div", _hoisted_5$1, [
            renderSlot(_ctx.$slots, "action")
          ])
        ], 64)) : createCommentVNode("", true),
        __props.showType === "default" ? (openBlock(), createElementBlock("div", {
          key: 1,
          class: "default-search",
          onClick: onClickDefault
        }, [
          createElementVNode("div", _hoisted_6$1, [
            createVNode(_sfc_main$4, {
              type: "search",
              width: "18",
              height: "18",
              color: "#c1c1c1"
            }),
            createElementVNode("span", _hoisted_7$1, toDisplayString(__props.placeholder), 1)
          ])
        ])) : createCommentVNode("", true)
      ]);
    };
  }
});
const __default__$2 = {
  name: "WlLoadMore"
};
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  ...__default__$2,
  props: {
    modelValue: { type: Boolean, default: false },
    finished: { type: Boolean, default: false },
    finished_text: { default: "\u6CA1\u6709\u66F4\u591A\u4E86" }
  },
  emits: ["load", "update:modelValue"],
  setup(__props, { emit }) {
    const props = __props;
    const loadShow = ref(false);
    const onLoad = () => emit("load");
    watchEffect(() => {
      loadShow.value = props.modelValue;
    });
    watch(
      () => loadShow.value,
      (val) => {
        emit("update:modelValue", val);
      }
    );
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(List), {
        loading: loadShow.value,
        "onUpdate:loading": _cache[0] || (_cache[0] = ($event) => loadShow.value = $event),
        offset: 50,
        "immediate-check": false,
        finished: __props.finished,
        "finished-text": __props.finished_text,
        onLoad
      }, {
        default: withCtx(() => [
          renderSlot(_ctx.$slots, "default")
        ]),
        _: 3
      }, 8, ["loading", "finished", "finished-text"]);
    };
  }
});
var employeeSelector = {
  employeeData: null,
  topFiveEmployeeData: null,
  organization: null,
  organization_count: null,
  count: 0,
  dept_list: [],
  company_list: [],
  company_list_count: 0,
  companyEmployeeList: [],
  totalCompanyEmployeeList: [],
  totalCompanyEmployeeObjList: []
};
let Store = {
  sid: "",
  app_id: "",
  user_id: "",
  user_name: "",
  corp_id: "",
  node_env: "",
  domain: "",
  token: "",
  card_resource: "",
  employeeSelector
};
var Store$1 = new Proxy(Store, {
  get(target, name, property) {
    return Reflect.get(target, name, property);
  },
  set(target, name, value, property) {
    return Reflect.set(target, name, value, property);
  }
});
const proxy_api = {
  dev_uat: "/uat_api",
  dev_stg: "/stg_api",
  dev_prd: "/prd_api",
  dev_cos_api: "/cos_api",
  dev_uat_xsf: "/xsf_api",
  dev: "/uat_api",
  uat: "",
  stg: "",
  prd: "",
  gray: "",
  production: "",
  uat_xsf: "https://test.xsfapi.weiling.cn",
  stg_xsf: "https://pre-xsfapi.weiling.cn",
  prd_xsf: "https://xsfapi.weiling.cn",
  gray_xsf: "https://xsfapi.weiling.cn"
};
const token_key = {
  dev_uat: "auth-token-mp-test",
  dev_stg: "auth-token-mp",
  dev_prd: "auth-token-mp",
  dev_uat_xsf: "auth-token-se-test",
  dev_stg_xsf: "auth-token-se",
  dev_gray_xsf: "auth-token-se",
  dev_prd_xsf: "auth-token-se",
  uat: "auth-token-mp-test",
  stg: "auth-token-mp",
  prd: "auth-token-mp",
  gray: "auth-token-mp",
  uat_xsf: "auth-token-se-test",
  stg_xsf: "auth-token-se",
  prd_xsf: "auth-token-se",
  gray_xsf: "auth-token-se"
};
var index_vue_vue_type_style_index_0_lang$1 = "";
const _hoisted_1$1 = { class: "icon" };
const _hoisted_2$1 = { class: "text" };
const __default__$1 = {
  name: "WlNotice"
};
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  ...__default__$1,
  props: {
    show_toast: { type: Boolean, default: true },
    message: { default: "" },
    type: { default: "success" },
    duration: { default: 1500 }
  },
  setup(__props) {
    return (_ctx, _cache) => {
      return __props.show_toast ? (openBlock(), createElementBlock("div", {
        key: 0,
        class: normalizeClass(`notice ${__props.type}`),
        "data-weiling-mobile-ui-wl-notice": ""
      }, [
        createElementVNode("div", _hoisted_1$1, [
          __props.type === "success" ? (openBlock(), createBlock(_sfc_main$4, {
            key: 0,
            type: "successFill",
            width: "24",
            height: "24",
            color: "#45ce03"
          })) : __props.type === "warning" ? (openBlock(), createBlock(_sfc_main$4, {
            key: 1,
            type: "warningFill",
            width: "24",
            height: "24",
            color: "#f3a401"
          })) : __props.type === "alert" ? (openBlock(), createBlock(_sfc_main$4, {
            key: 2,
            type: "tipsFill",
            width: "24",
            height: "24",
            color: "#1b9fff"
          })) : __props.type === "error" ? (openBlock(), createBlock(_sfc_main$4, {
            key: 3,
            type: "closeFill",
            width: "24",
            height: "24",
            color: "#ff2a2d"
          })) : createCommentVNode("", true)
        ]),
        createElementVNode("p", _hoisted_2$1, toDisplayString(__props.message), 1)
      ], 2)) : createCommentVNode("", true);
    };
  }
});
let mountNode = null;
var WlNotice = (options) => {
  const duration = options.duration | 2e3;
  if (mountNode) {
    document.body.removeChild(mountNode);
    mountNode = null;
  }
  const app = createVNode(_sfc_main$1, {
    ...options,
    duration,
    show_toast: true
  });
  let timer = setTimeout(() => {
    if (mountNode) {
      document.body.removeChild(mountNode);
      mountNode = null;
    }
    clearTimeout(timer);
  }, duration);
  mountNode = document.createElement("div");
  render(app, mountNode);
  document.body.appendChild(mountNode);
};
function obj2String(obj, arr = [], idx = 0) {
  for (let item in obj) {
    arr[idx++] = [item, obj[item]];
  }
  return new URLSearchParams(arr).toString();
}
function getOptions(options) {
  const { sid = "", corp_id = "", card_resource = "" } = Store$1 != null ? Store$1 : {};
  const params = {
    sid,
    corp_id,
    card_resource,
    ...options
  };
  return obj2String(params);
}
const onHandleUrl = (url) => {
  const { node_env } = Store$1;
  const isPersonMiniApp = node_env.includes("xsf");
  if (isPersonMiniApp) {
    return setPersonMiniAppUrl(url);
  }
  return url;
};
const setPersonMiniAppUrl = (url) => {
  let filterUrl = url;
  if (filterUrl.includes("/api/user/share/path")) {
    filterUrl = filterUrl.replace("/api/user/share/path", "/apise/material/share/path");
  } else if (filterUrl.includes("/interact/")) {
    filterUrl = filterUrl.replace("/interact/", "/apise/");
  } else if (filterUrl.includes("/api/")) {
    filterUrl = filterUrl.replace("/api/", "/apise/");
  } else if (filterUrl.includes("/wx/track")) {
    filterUrl = filterUrl.replace("/wx/track", "/apise/track/wx/track");
  }
  return filterUrl;
};
function request(url, options, method = "GET") {
  const staticOption = {
    sid: Store$1.sid,
    corp_id: Store$1.corp_id,
    tab_change: 0
  };
  const data = {
    ...staticOption,
    ...options
  };
  const searchStr = getOptions(removeEmptyField(data));
  const staticSearchStr = getOptions(removeEmptyField(staticOption));
  let initObj = {};
  let params = "";
  if (method === "GET") {
    initObj = {
      method,
      credentials: "include",
      headers: new Headers({
        [token_key[Store$1.node_env]]: Store$1.token
      })
    };
    params = searchStr;
  } else if (method === "FormPOST") {
    initObj = {
      method: "POST",
      credentials: "include",
      headers: new Headers({
        [token_key[Store$1.node_env]]: Store$1.token
      }),
      body: options
    };
    params = staticSearchStr;
  } else {
    initObj = {
      method,
      credentials: "include",
      headers: new Headers({
        Accept: "application/json, text/plain, */*",
        "Content-Type": "application/json",
        [token_key[Store$1.node_env]]: Store$1.token
      }),
      body: JSON.stringify(data)
    };
    params = staticSearchStr;
  }
  const filterUrl = onHandleUrl(url) + "?" + params;
  return fetch(filterUrl, initObj).then((res) => {
    const isArea = url.includes("region.json");
    return res.json().then((result) => {
      var _a;
      if (result.code === 200 || isArea) {
        return result;
      } else {
        WlNotice({ message: (_a = result.msg) != null ? _a : "\u670D\u52A1\u5668\u5185\u90E8\u9519\u8BEF", type: "error", duration: 3e3 });
        throw Error(result);
      }
    });
  }).then((res) => {
    return res;
  });
}
const GET = (url, options) => {
  return request(url, options, "GET");
};
const getSessionChatList = (paramas, node_env) => {
  return GET(`${proxy_api[node_env || "/dev_uat"]}/interact/dialogue/chat/list/pageable`, paramas);
};
const getInherentDialogueSessionChatList = (paramas, node_env) => {
  return GET(
    `${proxy_api[node_env || "/dev_uat"]}/interact/dialogue/user/chat/inheritDialogueList/pageable`,
    paramas
  );
};
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1 = {
  class: "chat-list",
  "data-weiling-mobile-ui-bc-chat-list": ""
};
const _hoisted_2 = { class: "search-header" };
const _hoisted_3 = { class: "content" };
const _hoisted_4 = ["href"];
const _hoisted_5 = ["onClick"];
const _hoisted_6 = { class: "avatar" };
const _hoisted_7 = { class: "content" };
const _hoisted_8 = { class: "base-wrap" };
const _hoisted_9 = {
  key: 0,
  class: "base"
};
const _hoisted_10 = { class: "name" };
const _hoisted_11 = {
  key: 0,
  class: "position"
};
const _hoisted_12 = {
  key: 1,
  class: "group"
};
const _hoisted_13 = { class: "time" };
const _hoisted_14 = { class: "text" };
const _hoisted_15 = {
  key: 0,
  class: "recall"
};
const _hoisted_16 = { class: "msg" };
const _hoisted_17 = {
  key: 0,
  class: "empty"
};
const _hoisted_18 = { class: "pic" };
const _hoisted_19 = /* @__PURE__ */ createElementVNode("p", { class: "text" }, "\u6CA1\u6709\u627E\u5230\u76F8\u5173\u804A\u5929\u8BB0\u5F55", -1);
const __default__ = {
  name: "BCChatList"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    env_data: { default: () => {
      return {
        sid: "",
        token: "",
        domain: "",
        corp_id: "",
        node_env: "dev",
        app_id: "",
        card_resource: ""
      };
    } },
    type: { default: "inheritDialogueList" },
    keyword: { default: "" },
    user_id: { default: "" },
    need_detail: { type: Boolean, default: true },
    external_userid: { default: "" }
  },
  emits: ["onSearch", "onClick"],
  setup(__props, { emit }) {
    const props = __props;
    const limit = 10;
    const chatInfos = ref([]);
    const page_count = ref(1);
    const search_value = ref("");
    const is_loading = ref(false);
    const is_finished = ref(false);
    const chat_list = computed(() => {
      return chatInfos.value.map((ele) => {
        const {
          last_msg = {},
          chat_type = 1,
          head_img_url = "",
          nick_name = ""
        } = ele;
        const {
          id = "",
          msg_type = "",
          from_user = {},
          msg_detail = "",
          create_time = ""
        } = last_msg;
        const { position = "", nick_name: from_user_name } = from_user;
        let msg_content = "";
        if (msg_type === "text") {
          const { text = {} } = msg_detail;
          const { content = "" } = text;
          msg_content = chat_type === 3 ? `${from_user_name}: ${content}` : content;
        } else if (msg_type === "image") {
          msg_content = "[\u56FE\u7247]";
        } else if (msg_type === "voice") {
          msg_content = "[\u8BED\u97F3]";
        } else if (msg_type === "emotion") {
          msg_content = "[\u8868\u60C5]";
        } else if (msg_type === "recall") {
          const { text = {} } = msg_detail;
          const { content = "" } = text;
          msg_content = content;
        }
        const { domain: domain2 = "" } = props.env_data;
        return {
          msg_type,
          position,
          nick_name,
          msg_id: id,
          msg_content,
          head_img_url,
          origin_data: ele,
          type: chat_type === 3 ? "group" : "single",
          time: chatFormatMillisecond(create_time, "YYYY-MM-DD"),
          href: props.need_detail ? useGetChatDetailUrl(domain2, id) : "javascript:void(0)"
        };
      });
    });
    const getData = () => {
      if (page_count.value === 1)
        chatInfos.value = [];
      const { node_env = "", corp_id, sid } = props.env_data;
      if (props.type === "inheritDialogueList") {
        getInherentDialogueSessionChatList(
          {
            sid,
            corp_id,
            external_userid: props.external_userid,
            user_id: props.user_id,
            keyword: search_value.value,
            page_count: page_count.value,
            limit
          },
          node_env
        ).then((res) => {
          const { data = {} } = res;
          const { chat_infos = [], able_to_page_down = true } = data;
          if (able_to_page_down) {
            is_finished.value = true;
          }
          chatInfos.value = chat_infos;
        });
      } else {
        getSessionChatList(
          {
            sid,
            corp_id,
            external_userid: props.external_userid,
            user_id: props.user_id,
            keyword: search_value.value,
            page_count: page_count.value,
            limit
          },
          node_env
        ).then((res) => {
          const { data = {} } = res;
          const { chat_infos = [], able_to_page_down = true } = data;
          if (able_to_page_down) {
            is_finished.value = true;
          }
          chatInfos.value = chat_infos;
        });
      }
    };
    const onSearchChange = (val) => {
      search_value.value = val;
      getData();
      emit("onSearch", val);
    };
    const onSearchClear = () => {
      onSearchChange("");
    };
    const onClickChat = (item) => {
      const { origin_data = {} } = item;
      emit("onClick", origin_data);
    };
    watch(
      () => props.keyword,
      (val) => {
        search_value.value = val;
        getData();
      },
      {
        immediate: true
      }
    );
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", _hoisted_2, [
          createVNode(_sfc_main$3, {
            class: "search",
            modelValue: search_value.value,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => search_value.value = $event),
            onOnChange: onSearchChange,
            onOnClear: onSearchClear,
            closable: true
          }, null, 8, ["modelValue"]),
          renderSlot(_ctx.$slots, "search_right")
        ]),
        createElementVNode("div", _hoisted_3, [
          createVNode(_sfc_main$2, {
            modelValue: is_loading.value,
            "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => is_loading.value = $event),
            finished: is_finished.value,
            onLoad: getData,
            finished_text: unref(chat_list).length === 0 ? "" : "\u6CA1\u6709\u66F4\u591A\u4E86"
          }, {
            default: withCtx(() => [
              (openBlock(true), createElementBlock(Fragment, null, renderList(unref(chat_list), (item) => {
                return openBlock(), createElementBlock("div", {
                  key: item.msg_id
                }, [
                  createElementVNode("a", {
                    href: item.href
                  }, [
                    createElementVNode("div", {
                      class: "chat-list-item",
                      onClick: ($event) => onClickChat(item)
                    }, [
                      createElementVNode("div", _hoisted_6, [
                        createVNode(_sfc_main$5, {
                          src: item.head_img_url
                        }, null, 8, ["src"])
                      ]),
                      createElementVNode("div", _hoisted_7, [
                        createElementVNode("div", _hoisted_8, [
                          item.nick_name ? (openBlock(), createElementBlock("div", _hoisted_9, [
                            createElementVNode("p", _hoisted_10, toDisplayString(item.nick_name), 1),
                            item.position ? (openBlock(), createElementBlock("div", _hoisted_11, toDisplayString(item.position), 1)) : createCommentVNode("", true),
                            item.type === "group" ? (openBlock(), createElementBlock("div", _hoisted_12, "\u5916\u90E8\u7FA4")) : createCommentVNode("", true)
                          ])) : createCommentVNode("", true),
                          createElementVNode("p", _hoisted_13, toDisplayString(item.time), 1)
                        ]),
                        createElementVNode("div", _hoisted_14, [
                          item.msg_type === "recall" ? (openBlock(), createElementBlock("p", _hoisted_15, " [\u5DF2\u64A4\u56DE] ")) : createCommentVNode("", true),
                          createElementVNode("p", _hoisted_16, toDisplayString(item.msg_content), 1)
                        ])
                      ])
                    ], 8, _hoisted_5)
                  ], 8, _hoisted_4)
                ]);
              }), 128)),
              unref(chat_list).length === 0 ? (openBlock(), createElementBlock("div", _hoisted_17, [
                createElementVNode("div", _hoisted_18, [
                  createVNode(_sfc_main$5, { src: unref(chat_no_result) }, null, 8, ["src"])
                ]),
                _hoisted_19
              ])) : createCommentVNode("", true)
            ]),
            _: 1
          }, 8, ["modelValue", "finished", "finished_text"])
        ])
      ]);
    };
  }
});
var __uno = "";
_sfc_main.install = (app) => {
  app.component(_sfc_main.name, _sfc_main);
};
export { _sfc_main as default };
