import { defineComponent, ref, computed, watch, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createCommentVNode, renderSlot, Fragment, renderList, withModifiers, createElementVNode, createVNode, toDisplayString, createTextVNode, createBlock, resolveDynamicComponent, mergeProps } from "vue";
const domain = "https://wlmvp-cos.weiling.cn";
const loadingPic = domain + "/frontend/weilingMobileUI/loading.png";
const loadingFailPic = domain + "/frontend/weilingMobileUI/loadingFail.png";
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 _hoisted_1$3 = ["src", "alt"];
const _hoisted_2$3 = ["src"];
const _hoisted_3$3 = ["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__ = {
  name: "WlPic"
};
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  ...__default__,
  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$3)) : createCommentVNode("", true),
        renderSlot(_ctx.$slots, "picFooter")
      ], 2);
    };
  }
});
var GloCustomerList_vue_vue_type_style_index_0_scoped_true_lang = "";
var _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const _hoisted_1$2 = ["onClick"];
const _hoisted_2$2 = { class: "customer_user" };
const _hoisted_3$2 = { class: "customer-list-info" };
const _hoisted_4$1 = ["innerHTML"];
const _hoisted_5$1 = {
  key: 1,
  class: "info"
};
const _hoisted_6$1 = { key: 0 };
const _hoisted_7$1 = /* @__PURE__ */ createTextVNode(" \u5907\u6CE8: ");
const _hoisted_8$1 = ["innerHTML"];
const _hoisted_9$1 = { key: 1 };
const _hoisted_10$1 = /* @__PURE__ */ createTextVNode(" \u624B\u673A\u53F7: ");
const _hoisted_11$1 = ["innerHTML"];
const _hoisted_12$1 = { key: 2 };
const _hoisted_13$1 = /* @__PURE__ */ createTextVNode(" \u90AE\u7BB1: ");
const _hoisted_14$1 = ["innerHTML"];
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  __name: "GloCustomerList",
  props: {
    list: { default: () => [] },
    keyword: { default: "" },
    search_type: null
  },
  emits: ["onSearchItemSelect"],
  setup(__props, { emit }) {
    const props = __props;
    const replaceKeyword = (str) => {
      if (!str)
        return "";
      if (!props.keyword)
        return str;
      const reg = new RegExp(props.keyword, "ig");
      return str.replace(reg, function(text) {
        return `<span style="color: var(--wl-primary-color)">${text}</span>`;
      });
    };
    const getImg = ({ type }) => {
      const fromAry = {
        1: "https://wlmvp-cos.weiling.cn/worktable-h5/icon/lxx-icon/wechat.png",
        2: "https://wlmvp-cos.weiling.cn/worktable-h5/icon/lxx-icon/qw.png"
      };
      return fromAry[type] || "";
    };
    const onHandleClick = (item) => {
      emit("onSearchItemSelect", {
        ...item,
        search_type: props.search_type
      });
    };
    return (_ctx, _cache) => {
      return openBlock(true), createElementBlock(Fragment, null, renderList(__props.list, (data) => {
        return openBlock(), createElementBlock("div", {
          class: "customer-list",
          "data-weiling-mobile-ui-customer-list": "",
          key: data.external_userid,
          onClick: withModifiers(($event) => onHandleClick(data), ["stop"])
        }, [
          createElementVNode("div", _hoisted_2$2, [
            createVNode(_sfc_main$4, {
              class: "head-img avatar",
              src: data.head_img_url || "https://wlmvp-cos.weiling.cn/worktable-h5/icon/lxx-icon/default_head.png",
              alt: ""
            }, null, 8, ["src"]),
            createVNode(_sfc_main$4, {
              class: "from-type",
              src: getImg(data)
            }, null, 8, ["src"])
          ]),
          createElementVNode("div", _hoisted_3$2, [
            createElementVNode("p", {
              class: "name",
              innerHTML: replaceKeyword((data == null ? void 0 : data.nick_name) || "-")
            }, null, 8, _hoisted_4$1),
            data.corp_name ? (openBlock(), createElementBlock("p", {
              key: 0,
              class: "crop_name",
              style: normalizeStyle({
                color: data.type == 1 ? "var(--wl-success-color)" : "var(--wl-warning-color)"
              })
            }, toDisplayString(data.corp_name), 5)) : createCommentVNode("", true),
            (data == null ? void 0 : data.remark_name) || (data == null ? void 0 : data.mobile) || (data == null ? void 0 : data.email) ? (openBlock(), createElementBlock("div", _hoisted_5$1, [
              (data == null ? void 0 : data.remark_name) ? (openBlock(), createElementBlock("p", _hoisted_6$1, [
                _hoisted_7$1,
                createElementVNode("span", {
                  innerHTML: replaceKeyword(data == null ? void 0 : data.remark_name)
                }, null, 8, _hoisted_8$1)
              ])) : createCommentVNode("", true),
              (data == null ? void 0 : data.mobile) ? (openBlock(), createElementBlock("p", _hoisted_9$1, [
                _hoisted_10$1,
                createElementVNode("span", {
                  innerHTML: replaceKeyword(data == null ? void 0 : data.mobile)
                }, null, 8, _hoisted_11$1)
              ])) : createCommentVNode("", true),
              (data == null ? void 0 : data.email) ? (openBlock(), createElementBlock("p", _hoisted_12$1, [
                _hoisted_13$1,
                createElementVNode("span", {
                  innerHTML: replaceKeyword(data == null ? void 0 : data.email)
                }, null, 8, _hoisted_14$1)
              ])) : createCommentVNode("", true)
            ])) : createCommentVNode("", true)
          ])
        ], 8, _hoisted_1$2);
      }), 128);
    };
  }
});
var GloCustomerList = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-3d393b04"]]);
var GloClueList_vue_vue_type_style_index_0_scoped_true_lang = "";
const _hoisted_1$1 = ["onClick"];
const _hoisted_2$1 = { class: "clue-img" };
const _hoisted_3$1 = ["innerHTML"];
const _hoisted_4 = {
  key: 0,
  class: "corp-name"
};
const _hoisted_5 = {
  key: 1,
  class: "info"
};
const _hoisted_6 = { key: 0 };
const _hoisted_7 = /* @__PURE__ */ createTextVNode(" \u5907\u6CE8: ");
const _hoisted_8 = ["innerHTML"];
const _hoisted_9 = { key: 1 };
const _hoisted_10 = /* @__PURE__ */ createTextVNode(" \u624B\u673A\u53F7: ");
const _hoisted_11 = ["innerHTML"];
const _hoisted_12 = { key: 2 };
const _hoisted_13 = /* @__PURE__ */ createTextVNode(" \u90AE\u7BB1: ");
const _hoisted_14 = ["innerHTML"];
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  __name: "GloClueList",
  props: {
    list: { default: () => [] },
    keyword: { default: "" },
    search_type: null
  },
  emits: ["onSearchItemSelect"],
  setup(__props, { emit }) {
    const props = __props;
    const replaceKeyword = (str) => {
      if (!str)
        return "";
      if (!props.keyword)
        return str;
      const reg = new RegExp(props.keyword, "ig");
      return str.replace(reg, function(text) {
        return `<span style="color: var(--wl-primary-color)">${text}</span>`;
      });
    };
    const onHandleClick = (item) => {
      emit("onSearchItemSelect", {
        ...item,
        search_type: props.search_type
      });
    };
    return (_ctx, _cache) => {
      return openBlock(true), createElementBlock(Fragment, null, renderList(__props.list, (data) => {
        var _a;
        return openBlock(), createElementBlock("div", {
          class: "clue-list",
          "data-weiling-mobile-ui-clue-list": "",
          key: data.clue_id,
          onClick: withModifiers(($event) => onHandleClick(data), ["stop"])
        }, [
          createElementVNode("div", _hoisted_2$1, toDisplayString((_a = data == null ? void 0 : data.nick_name) == null ? void 0 : _a[0]), 1),
          createElementVNode("div", null, [
            createElementVNode("p", {
              class: "nick-name",
              innerHTML: replaceKeyword((data == null ? void 0 : data.nick_name) || "-")
            }, null, 8, _hoisted_3$1),
            data.corp_name ? (openBlock(), createElementBlock("p", _hoisted_4, toDisplayString(data.corp_name), 1)) : createCommentVNode("", true),
            (data == null ? void 0 : data.remark_name) || (data == null ? void 0 : data.mobile) || (data == null ? void 0 : data.email) ? (openBlock(), createElementBlock("div", _hoisted_5, [
              (data == null ? void 0 : data.remark_name) ? (openBlock(), createElementBlock("p", _hoisted_6, [
                _hoisted_7,
                createElementVNode("span", {
                  innerHTML: replaceKeyword(data == null ? void 0 : data.remark_name)
                }, null, 8, _hoisted_8)
              ])) : createCommentVNode("", true),
              (data == null ? void 0 : data.mobile) ? (openBlock(), createElementBlock("p", _hoisted_9, [
                _hoisted_10,
                createElementVNode("span", {
                  innerHTML: replaceKeyword(data == null ? void 0 : data.mobile)
                }, null, 8, _hoisted_11)
              ])) : createCommentVNode("", true),
              (data == null ? void 0 : data.email) ? (openBlock(), createElementBlock("p", _hoisted_12, [
                _hoisted_13,
                createElementVNode("span", {
                  innerHTML: replaceKeyword(data == null ? void 0 : data.email)
                }, null, 8, _hoisted_14)
              ])) : createCommentVNode("", true)
            ])) : createCommentVNode("", true)
          ])
        ], 8, _hoisted_1$1);
      }), 128);
    };
  }
});
var GloClueList = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-70ce0fee"]]);
var GloCompanyList_vue_vue_type_style_index_0_scoped_true_lang = "";
const _hoisted_1 = ["onClick"];
const _hoisted_2 = ["innerHTML"];
const _hoisted_3 = ["innerHTML"];
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  __name: "GloCompanyList",
  props: {
    list: { default: () => [] },
    keyword: { default: "" },
    search_type: null
  },
  emits: ["onSearchItemSelect"],
  setup(__props, { emit }) {
    const props = __props;
    const replaceKeyword = (str) => {
      if (!str)
        return "";
      if (!props.keyword)
        return str;
      const reg = new RegExp(props.keyword, "ig");
      return str.replace(reg, function(text) {
        return `<span style="color: var(--wl-primary-color)">${text}</span>`;
      });
    };
    const onHandleClick = (item) => {
      emit("onSearchItemSelect", {
        ...item,
        search_type: props.search_type
      });
    };
    return (_ctx, _cache) => {
      return openBlock(true), createElementBlock(Fragment, null, renderList(__props.list, (data) => {
        return openBlock(), createElementBlock("div", {
          class: "glo-company-list",
          "data-weiling-mobile-ui-glo-company-list": "",
          key: data.company_id,
          onClick: withModifiers(($event) => onHandleClick(data), ["stop"])
        }, [
          createVNode(_sfc_main$4, {
            class: "company-img",
            src: data.image_url || "https://wlmvp-cos.weiling.cn/website/worktable-erp/images/default/overview-company-icon.png"
          }, null, 8, ["src"]),
          createElementVNode("div", null, [
            data.abbreviation || data.company_name ? (openBlock(), createElementBlock("p", {
              key: 0,
              class: "nick-name",
              innerHTML: replaceKeyword(data.abbreviation || data.company_name)
            }, null, 8, _hoisted_2)) : createCommentVNode("", true),
            data.company_name && data.abbreviation ? (openBlock(), createElementBlock("p", {
              key: 1,
              class: "company-name",
              innerHTML: replaceKeyword("\u5168\u540D: " + data.company_name)
            }, null, 8, _hoisted_3)) : createCommentVNode("", true)
          ])
        ], 8, _hoisted_1);
      }), 128);
    };
  }
});
var GloCompanyList = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-aea344c4"]]);
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    search_type: { default: 1 }
  },
  setup(__props) {
    const props = __props;
    const SearchTypeEnum = {
      2: GloClueList,
      5: GloCompanyList,
      1: GloCustomerList,
      4: GloCustomerList
    };
    const com_name = computed(() => {
      return SearchTypeEnum[props.search_type];
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(resolveDynamicComponent(unref(com_name)), mergeProps(_ctx.$attrs, { search_type: __props.search_type }), null, 16, ["search_type"]);
    };
  }
});
_sfc_main.install = (app) => {
  app.component(_sfc_main.name, _sfc_main);
};
export { _sfc_main as default };
