import { defineComponent, openBlock, createBlock, unref, createElementBlock, normalizeClass, createElementVNode, createCommentVNode, toDisplayString, createVNode, render, renderSlot, withDirectives, vShow, createTextVNode, ref, watchEffect, isRef, withCtx, reactive, watch, pushScopeId, popScopeId, computed, mergeProps, withKeys, vModelText } from "vue";
import WlSvg from "@wltech/svg";
import vuedraggable from "vuedraggable";
import { showConfirmDialog, closeDialog, ActionSheet, Dialog, Checkbox, Popup } from "vant";
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"
};
const __default__$8 = {
  name: "WlSvgIcon"
};
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
  ...__default__$8,
  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$1 = "";
const _hoisted_1$5 = { class: "icon" };
const _hoisted_2$5 = { class: "text" };
const __default__$7 = {
  name: "WlNotice"
};
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
  ...__default__$7,
  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$5, [
          __props.type === "success" ? (openBlock(), createBlock(_sfc_main$8, {
            key: 0,
            type: "successFill",
            width: "24",
            height: "24",
            color: "#45ce03"
          })) : __props.type === "warning" ? (openBlock(), createBlock(_sfc_main$8, {
            key: 1,
            type: "warningFill",
            width: "24",
            height: "24",
            color: "#f3a401"
          })) : __props.type === "alert" ? (openBlock(), createBlock(_sfc_main$8, {
            key: 2,
            type: "tipsFill",
            width: "24",
            height: "24",
            color: "#1b9fff"
          })) : __props.type === "error" ? (openBlock(), createBlock(_sfc_main$8, {
            key: 3,
            type: "closeFill",
            width: "24",
            height: "24",
            color: "#ff2a2d"
          })) : createCommentVNode("", true)
        ]),
        createElementVNode("p", _hoisted_2$5, 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$7, {
    ...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);
};
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;
};
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 POST = (url, options) => {
  return request(url, options, "POST");
};
var Api = {
  getMaterialList(paramas, type) {
    return POST(`${proxy_api[Store$1.node_env]}/api/${type}/material/list`, paramas);
  },
  getGroupList(params) {
    return POST(`${proxy_api[Store$1.node_env]}/interact/material/group/list`, params);
  },
  getMaterialGroupCount(paramas) {
    return GET(`${proxy_api[Store$1.node_env]}/interact/material/count`, paramas);
  },
  materialGroupAdd(paramas) {
    return POST(`${proxy_api[Store$1.node_env]}/interact/material/group/tree/add`, paramas);
  },
  materialGroupEdit(paramas) {
    return POST(`${proxy_api[Store$1.node_env]}/interact/material/group/edit`, paramas);
  },
  materialGroupDelete(paramas) {
    return POST(`${proxy_api[Store$1.node_env]}/interact/material/group/del`, paramas);
  },
  materialGroupSort(paramas) {
    return POST(`${proxy_api[Store$1.node_env]}/interact/material/group/tree/sort`, paramas);
  }
};
const allChooseItem = {
  id: "",
  level: 0,
  root_id: "0",
  group_name: "\u5168\u90E8",
  parent_id: "",
  is_default: true,
  group_scope: 1,
  child_group: []
};
var base = "";
var index$8 = "";
var index$7 = "";
var index$6 = "";
var index$5 = "";
var index$4 = "";
var index$3 = "";
var index$2 = "";
var index$1 = "";
var index = "";
const useMessage = () => {
  const duration = 3e3;
  const onNotify = (message) => {
    WlNotice({ message, type: "success", duration });
  };
  const onError = (message) => {
    WlNotice({ message, type: "error", duration });
  };
  const onWarning = (message) => {
    WlNotice({ message, type: "warning", duration });
  };
  const onConfirm = (params) => {
    return new Promise((resolve, reject) => {
      const filter_params = {
        className: "vant-confirm-z-index",
        overlayClass: "vant-overlay-z-index",
        ...params
      };
      showConfirmDialog(filter_params).then(resolve, reject);
    });
  };
  const onConfirmCancel = () => {
    closeDialog();
  };
  return {
    onNotify,
    onError,
    onConfirm,
    onWarning,
    onConfirmCancel
  };
};
const _hoisted_1$4 = { class: "z-2 flex uno-min-w-44 uno-max-w-88" };
const _hoisted_2$4 = { class: "uno-elli-1 z-1 box-border flex-middle-center absolute text-center uno-l-44 uno-r-44" };
const _hoisted_3$3 = { class: "relative z-2 flex-middle-center uno-min-w-44" };
const __default__$6 = {
  name: "WlHeader"
};
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
  ...__default__$6,
  props: {
    title: { default: "" },
    showBack: { type: Boolean, default: false },
    showClose: { type: Boolean, default: false },
    needAutoBack: { type: Boolean, default: true },
    needBottomBorder: { type: Boolean, default: false }
  },
  emits: ["onBack", "onClose"],
  setup(__props, { emit }) {
    const props = __props;
    const onBackPage = () => {
      if (props.needAutoBack) {
        history.back();
      } else {
        emit("onBack");
      }
    };
    const onClose = () => {
      emit("onClose");
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: normalizeClass(`uno-fs-16 uno-h-44 relative font-medium box-border text-base-color bg-white flex-between ${__props.needBottomBorder ? "border-bottom" : " "}`)
      }, [
        createElementVNode("div", _hoisted_1$4, [
          renderSlot(_ctx.$slots, "header_part_left", {}, () => [
            withDirectives(createElementVNode("div", {
              class: "box-content flex-middle-center cursor-pointer uno-h-44 uno-w-44",
              onClick: onBackPage
            }, [
              createVNode(_sfc_main$8, {
                type: "arrowTipLeft",
                width: "22",
                height: "22",
                color: "#000"
              })
            ], 512), [
              [vShow, __props.showBack]
            ])
          ])
        ]),
        createElementVNode("div", _hoisted_2$4, [
          renderSlot(_ctx.$slots, "default", {}, () => [
            createTextVNode(toDisplayString(__props.title), 1)
          ])
        ]),
        createElementVNode("div", _hoisted_3$3, [
          renderSlot(_ctx.$slots, "header_part_right", {}, () => [
            withDirectives(createElementVNode("div", {
              class: "box-content flex-middle-center cursor-pointer uno-h-44 uno-w-44",
              onClick: onClose
            }, [
              createVNode(_sfc_main$8, {
                type: "close",
                width: "22",
                height: "22",
                color: "#000"
              })
            ], 512), [
              [vShow, __props.showClose]
            ])
          ])
        ])
      ], 2);
    };
  }
});
var __uno = "";
_sfc_main$6.install = (app) => {
  app.component(_sfc_main$6.name, _sfc_main$6);
};
const __default__$5 = {
  name: "WlActionSheet"
};
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
  ...__default__$5,
  props: {
    title: { default: "" },
    cancelText: { default: "\u53D6\u6D88" },
    modelValue: { type: Boolean, default: false },
    showClose: { type: Boolean, default: true },
    showBack: { type: Boolean, default: false },
    headerVisible: { type: Boolean, default: false },
    actions: { default: () => [] },
    teleport: { default: "" }
  },
  emits: ["update:modelValue", "onClose", "onSelect"],
  setup(__props, { emit }) {
    const props = __props;
    let actionSheetVisible = ref(false);
    const onClose = () => {
      emit("update:modelValue", false);
      emit("onClose");
    };
    const onSelect = (val) => {
      emit("onSelect", val);
      onClose();
    };
    watchEffect(() => {
      actionSheetVisible.value = props.modelValue;
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(ActionSheet), {
        show: unref(actionSheetVisible),
        "onUpdate:show": _cache[0] || (_cache[0] = ($event) => isRef(actionSheetVisible) ? actionSheetVisible.value = $event : actionSheetVisible = $event),
        "cancel-text": __props.cancelText,
        "close-on-click-action": "",
        "close-on-popstate": "",
        actions: __props.actions,
        teleport: __props.teleport,
        onCancel: onClose,
        onClickOverlay: onClose,
        onSelect
      }, {
        default: withCtx(() => [
          __props.headerVisible ? (openBlock(), createBlock(_sfc_main$6, {
            key: 0,
            title: __props.title,
            showClose: __props.showClose,
            showBack: __props.showBack,
            onOnClose: onClose
          }, null, 8, ["title", "showClose", "showBack"])) : createCommentVNode("", true),
          renderSlot(_ctx.$slots, "default")
        ]),
        _: 3
      }, 8, ["show", "cancel-text", "actions", "teleport"]);
    };
  }
});
_sfc_main$5.install = (app) => {
  app.component(_sfc_main$5.name, _sfc_main$5);
};
const __default__$4 = {
  name: "OperationActionSheet"
};
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  ...__default__$4,
  props: {
    modelValue: { type: Boolean, default: false }
  },
  emits: ["update:modelValue", "onChange"],
  setup(__props, { emit }) {
    const props = __props;
    const State = reactive({
      actionsheetData: [
        {
          name: "\u7F16\u8F91",
          value: "edit"
        },
        {
          name: "\u5220\u9664",
          value: "delete"
        }
      ],
      actionSheetVisible: false
    });
    const onCancel = () => {
      emit("update:modelValue", false);
      State.actionSheetVisible = false;
    };
    const onActionsheetChange = (item) => {
      onCancel();
      emit("onChange", item);
    };
    watchEffect(() => {
      State.actionSheetVisible = props.modelValue;
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(_sfc_main$5), {
        "cancel-text": "\u53D6\u6D88",
        modelValue: State.actionSheetVisible,
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => State.actionSheetVisible = $event),
        actions: State.actionsheetData,
        headerVisible: false,
        onSelect: onActionsheetChange,
        onOnClose: onCancel
      }, null, 8, ["modelValue", "actions"]);
    };
  }
});
var index_vue_vue_type_style_index_0_scoped_true_lang$2 = "";
var _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const _withScopeId$1 = (n) => (pushScopeId("data-v-38c39bcc"), n = n(), popScopeId(), n);
const _hoisted_1$3 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createElementVNode("p", { class: "title" }, "\u5220\u9664\u5206\u7EC4\uFF0C\u5206\u7EC4\u4E2D\u7684\u8D44\u6599\u5C06\u5F52\u7C7B\u5230\u9ED8\u8BA4\u5206\u7EC4\u4E2D", -1));
const _hoisted_2$3 = { class: "checkbox-wrap" };
const _hoisted_3$2 = /* @__PURE__ */ createTextVNode("\u540C\u65F6\u5220\u9664\u5206\u7EC4\u4E2D\u7684\u8D44\u6599");
const __default__$3 = {
  name: "DeleteDialog"
};
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  ...__default__$3,
  props: {
    show: { type: Boolean, default: false }
  },
  emits: ["onConfirm", "update:show"],
  setup(__props, { emit }) {
    const props = __props;
    const dialogVisible = ref(false);
    const checkboxValue = ref(false);
    const onComfirm = () => emit("onConfirm", checkboxValue.value);
    watchEffect(() => {
      dialogVisible.value = props.show;
    });
    watch(
      () => dialogVisible.value,
      (val) => {
        dialogVisible.value = val;
        checkboxValue.value = false;
        emit("update:show", val);
      },
      { immediate: true }
    );
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(Dialog), {
        show: dialogVisible.value,
        "onUpdate:show": _cache[1] || (_cache[1] = ($event) => dialogVisible.value = $event),
        "show-cancel-button": "",
        "get-container": "body",
        teleport: "body",
        onConfirm: onComfirm,
        className: "vant-confirm-z-index",
        overlayClass: "vant-overlay-z-index"
      }, {
        title: withCtx(() => [
          _hoisted_1$3
        ]),
        default: withCtx(() => [
          createElementVNode("div", _hoisted_2$3, [
            createVNode(unref(Checkbox), {
              modelValue: checkboxValue.value,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => checkboxValue.value = $event)
            }, {
              default: withCtx(() => [
                _hoisted_3$2
              ]),
              _: 1
            }, 8, ["modelValue"])
          ])
        ]),
        _: 1
      }, 8, ["show"]);
    };
  }
});
var DeleteDialog = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-38c39bcc"]]);
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1$2 = {
  class: "popup-wrap",
  "data-weiling-mobile-ui-wl-popup": ""
};
const _hoisted_2$2 = { class: "popup-content" };
const __default__$2 = {
  name: "WlPopup"
};
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  ...__default__$2,
  props: {
    modelValue: { type: Boolean, default: false },
    teleport: { default: "body" },
    position: { default: "bottom" },
    headerVisible: { type: Boolean, default: false },
    title: { default: "" },
    showRightClose: { type: Boolean, default: true },
    showBack: { type: Boolean, default: false },
    needAutoBack: { type: Boolean, default: true }
  },
  emits: ["update:modelValue", "onClose", "onBack"],
  setup(__props, { emit }) {
    const props = __props;
    const popUpVisible = ref(false);
    const popupStyle = computed(() => {
      return {
        height: "70%"
      };
    });
    const onClose = () => {
      emit("update:modelValue", false);
      emit("onClose");
    };
    const onOpen = () => {
      emit("update:modelValue", true);
    };
    const onBack = () => {
      emit("onBack");
    };
    watchEffect(() => {
      popUpVisible.value = props.modelValue;
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(Popup), mergeProps({
        show: popUpVisible.value,
        "onUpdate:show": _cache[0] || (_cache[0] = ($event) => popUpVisible.value = $event),
        teleport: __props.teleport,
        position: __props.position,
        "close-on-popstate": true,
        style: unref(popupStyle)
      }, _ctx.$attrs, {
        onClose,
        onOpen
      }), {
        default: withCtx(() => [
          createElementVNode("div", _hoisted_1$2, [
            __props.headerVisible ? (openBlock(), createBlock(_sfc_main$6, {
              key: 0,
              title: __props.title,
              showClose: __props.showRightClose,
              onOnClose: onClose,
              onOnBack: onBack,
              showBack: __props.showBack,
              needAutoBack: __props.needAutoBack
            }, {
              header_part_left: withCtx(() => [
                renderSlot(_ctx.$slots, "header_part_left")
              ]),
              _: 3
            }, 8, ["title", "showClose", "showBack", "needAutoBack"])) : createCommentVNode("", true),
            createElementVNode("div", _hoisted_2$2, [
              renderSlot(_ctx.$slots, "default")
            ])
          ])
        ]),
        _: 3
      }, 16, ["show", "teleport", "position", "style"]);
    };
  }
});
var index_vue_vue_type_style_index_0_scoped_true_lang$1 = "";
const _hoisted_1$1 = { class: "form-wrap" };
const _hoisted_2$1 = { class: "form-item-input" };
const _hoisted_3$1 = ["onKeydown"];
const __default__$1 = {
  name: "OperGroupDialog"
};
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  ...__default__$1,
  props: {
    show: { type: Boolean, default: false },
    groupName: { default: "" }
  },
  emits: ["update:show", "update:groupName", "onConfirm"],
  setup(__props, { emit }) {
    const props = __props;
    const { onWarning } = useMessage();
    const dialogVisible = ref(false);
    const groupNameValue = ref("");
    const onClose = () => {
      emit("update:show", false);
      dialogVisible.value = false;
    };
    const onComfirm = () => {
      const groupNameTrim = groupNameValue.value.trim();
      if (!groupNameTrim) {
        onWarning("\u5206\u7EC4\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A");
      } else if (groupNameTrim.length > 30) {
        onWarning("\u5206\u7EC4\u540D\u79F0\u6700\u5927\u4E3A30\u4E2A\u5B57\u7B26");
      } else {
        emit("onConfirm", groupNameTrim);
      }
    };
    const onBeforeClose = (action) => {
      if (action === "confirm") {
        if (dialogVisible.value)
          return false;
      } else {
        return true;
      }
    };
    const onKeyDown = () => {
      onComfirm();
      onClose();
    };
    watchEffect(() => {
      if (props.show)
        groupNameValue.value = "";
      dialogVisible.value = props.show;
      groupNameValue.value = props.groupName;
    });
    watch(
      () => groupNameValue.value,
      (val) => emit("update:groupName", val)
    );
    watch(
      () => dialogVisible.value,
      (val) => emit("update:show", val)
    );
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(Dialog), {
        show: dialogVisible.value,
        "onUpdate:show": _cache[1] || (_cache[1] = ($event) => dialogVisible.value = $event),
        "show-cancel-button": "",
        "get-container": "body",
        "before-close": onBeforeClose,
        onClose,
        onConfirm: onComfirm,
        teleport: "body",
        className: "vant-confirm-z-index",
        overlayClass: "vant-overlay-z-index",
        confirmButtonColor: "var(--wl-primary-color)"
      }, {
        default: withCtx(() => [
          createVNode(unref(_sfc_main$6), { title: "\u5206\u7EC4\u540D\u79F0" }),
          createElementVNode("div", _hoisted_1$1, [
            createElementVNode("div", _hoisted_2$1, [
              withDirectives(createElementVNode("input", {
                "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => groupNameValue.value = $event),
                label: "",
                placeholder: "\u5206\u7EC4\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A",
                maxlength: "50",
                onKeydown: withKeys(onKeyDown, ["enter"])
              }, null, 40, _hoisted_3$1), [
                [vModelText, groupNameValue.value]
              ])
            ])
          ])
        ]),
        _: 1
      }, 8, ["show"]);
    };
  }
});
var OperGroupDialog = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-9f3ddd90"]]);
var index_vue_vue_type_style_index_0_scoped_true_lang = "";
const _withScopeId = (n) => (pushScopeId("data-v-905d2960"), n = n(), popScopeId(), n);
const _hoisted_1 = { class: "material-group" };
const _hoisted_2 = { class: "material-group-main" };
const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("p", { class: "add-text" }, "\u6DFB\u52A0\u5206\u7EC4", -1));
const _hoisted_4 = { class: "operation" };
const _hoisted_5 = { class: "operation-icon sort-icon" };
const _hoisted_6 = ["onClick"];
const __default__ = {
  name: "BCGroupManagePopup"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    show: { type: Boolean, default: false },
    showBack: { type: Boolean, default: false },
    showClose: { type: Boolean, default: true },
    groupList: { default: () => {
      return allChooseItem;
    } },
    group_scope: { default: 1 },
    env_data: { default: () => {
      return {
        sid: "",
        domain: "",
        corp_id: "",
        node_env: "uat",
        app_id: "",
        token: "",
        card_resource: ""
      };
    } }
  },
  emits: ["update:show", "onChange", "onOperSuccess"],
  setup(__props, { emit }) {
    const props = __props;
    Store$1.corp_id = props.env_data.corp_id;
    Store$1.node_env = props.env_data.node_env;
    Store$1.sid = props.env_data.sid;
    Store$1.token = props.env_data.token;
    Store$1.card_resource = props.env_data.card_resource;
    const { onNotify, onWarning } = useMessage();
    const chooseGroupList = ref(null);
    const chosedItem = ref(null);
    const operStatus = ref("pending");
    const hasOperStatus = ref("pending");
    const currentGroupName = ref("");
    const deleteDialogVisible = ref(false);
    const operDialogVisible = ref(false);
    const actionSheetVisible = ref(false);
    const popupVisible = ref(false);
    const groupItemClass = computed(() => {
      return (item) => {
        return {
          "material-group-main-item": true,
          "material-group-main-item-style": true,
          "disabled": item.is_default
        };
      };
    });
    const upperGroupData = computed(() => {
      var _a;
      return (_a = props.groupList[0]) != null ? _a : allChooseItem;
    });
    const onClose = () => {
      emit("update:show", false);
      popupVisible.value = false;
      if (hasOperStatus.value !== "pending") {
        emit("onOperSuccess", {
          status: hasOperStatus.value,
          data: chosedItem.value
        });
      }
    };
    const onGetData = async () => {
      const { parent_id, level } = upperGroupData.value;
      const upperGroupId = level === 1 ? "" : parent_id;
      const res = await Api.getGroupList({
        group_scope: props.group_scope,
        group_id: upperGroupId
      });
      const { data } = res || {};
      const { data_list = [] } = data;
      if (upperGroupId === "") {
        chooseGroupList.value = [allChooseItem, ...data_list];
      } else {
        const { child_group } = data_list[0];
        chooseGroupList.value = child_group;
      }
    };
    const onJudgeBlank = (group_name) => {
      let bool = true;
      if (group_name.length > 30) {
        onWarning("\u5206\u7EC4\u540D\u5B57\u4E0D\u80FD\u5927\u4E8E30\u4E2A\u5B57");
        bool = false;
      }
      return bool;
    };
    const onAddGroup = () => {
      currentGroupName.value = "";
      operDialogVisible.value = true;
      operStatus.value = "add";
    };
    const onActionSheetClick = (item) => {
      chosedItem.value = item;
      actionSheetVisible.value = true;
    };
    const onActionSheetChange = (item) => {
      if (item.value === "delete") {
        deleteDialogVisible.value = true;
      } else if (item.value === "edit") {
        operStatus.value = "edit";
        operDialogVisible.value = true;
        currentGroupName.value = chosedItem.value.group_name;
      }
    };
    const onAddDialogConfirm = (group_name) => {
      if (!onJudgeBlank(group_name))
        return;
      const interfaceDict = {
        add: "materialGroupAdd",
        edit: "materialGroupEdit"
      };
      const toastDict = {
        add: "\u65B0\u5EFA\u5206\u7EC4\u6210\u529F",
        edit: "\u7F16\u8F91\u5206\u7EC4\u6210\u529F"
      };
      const { parent_id, level, root_id } = upperGroupData.value;
      const levelValue = level === 1 ? "1" : level + 1;
      const params = operStatus.value === "add" ? {
        parent_id,
        level: levelValue,
        root_id,
        group_name,
        group_scope: props.group_scope
      } : {
        id: chosedItem.value.id,
        group_name
      };
      Api[interfaceDict[operStatus.value]](params).then(async () => {
        onNotify(toastDict[operStatus.value]);
        hasOperStatus.value = operStatus.value;
        await onGetData();
        if (operStatus.value === "edit") {
          chosedItem.value.group_name = currentGroupName.value;
        }
        operDialogVisible.value = false;
        currentGroupName.value = "";
      });
    };
    const onDeleteDialogConfirm = (delete_all) => {
      const { id, group_scope } = chosedItem.value;
      Api.materialGroupDelete({ id, group_scope, delete_all }).then(() => {
        hasOperStatus.value = "delete";
        onNotify("\u5220\u9664\u6210\u529F");
        onGetData();
      });
    };
    const onGroupSort = (event) => {
      const movedItem = chooseGroupList.value[event.newIndex];
      const targetItem = chooseGroupList.value[event.oldIndex];
      const sortList = chooseGroupList.value.map((res) => res.id).filter((res) => res);
      Api.materialGroupSort({
        moved_id: movedItem.id,
        moved_parent_id: movedItem.parent_id,
        target_id: targetItem.parent_id,
        target_parent_id: targetItem.parent_id,
        group_scope: props.group_scope,
        sort_list: sortList
      }).then(() => {
        hasOperStatus.value = "sort";
        onNotify("\u79FB\u52A8\u5206\u7EC4\u6210\u529F");
        onGetData();
      });
    };
    watchEffect(() => {
      popupVisible.value = props.show;
      if (props.show) {
        onGetData();
      }
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(_sfc_main$2, {
        class: "choose-group-popup",
        "data-weiling-mobile-ui-bc-group-manage-popup": "",
        modelValue: popupVisible.value,
        "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => popupVisible.value = $event),
        overlay: false,
        round: false,
        duration: "0",
        style: { height: "100%" },
        position: "bottom",
        onClosed: onClose
      }, {
        default: withCtx(() => [
          createElementVNode("div", _hoisted_1, [
            createVNode(unref(_sfc_main$6), {
              showBack: __props.showBack,
              showClose: __props.showClose,
              onOnClose: _cache[0] || (_cache[0] = ($event) => popupVisible.value = false),
              title: "\u7BA1\u7406\u5206\u7EC4"
            }, null, 8, ["showBack", "showClose"]),
            createElementVNode("div", _hoisted_2, [
              createElementVNode("div", {
                class: "material-group-main-item-style material-group-main-add-item",
                onClick: onAddGroup
              }, [
                createVNode(_sfc_main$8, {
                  type: "add",
                  width: "24",
                  height: "24",
                  color: "#979797"
                }),
                _hoisted_3
              ]),
              createVNode(unref(vuedraggable), {
                modelValue: chooseGroupList.value,
                "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => chooseGroupList.value = $event),
                handle: ".sort-icon",
                chosenClass: "chosenClass",
                ghostClass: "ghostClass",
                "item-key": "id",
                onUpdate: onGroupSort
              }, {
                item: withCtx(({ element }) => [
                  createElementVNode("div", {
                    class: normalizeClass(unref(groupItemClass)(element))
                  }, [
                    createElementVNode("div", null, toDisplayString(element.group_name), 1),
                    withDirectives(createElementVNode("div", _hoisted_4, [
                      createElementVNode("div", _hoisted_5, [
                        createVNode(_sfc_main$8, {
                          type: "sort",
                          width: "24",
                          height: "24",
                          color: "#1C9FFF"
                        })
                      ]),
                      createElementVNode("div", {
                        class: "operation-icon",
                        onClick: ($event) => onActionSheetClick(element)
                      }, [
                        createVNode(_sfc_main$8, {
                          type: "moreHorizontal",
                          width: "24",
                          height: "24",
                          color: "#1C9FFF"
                        })
                      ], 8, _hoisted_6)
                    ], 512), [
                      [vShow, !element.is_default]
                    ])
                  ], 2)
                ]),
                _: 1
              }, 8, ["modelValue"])
            ]),
            createVNode(_sfc_main$4, {
              modelValue: actionSheetVisible.value,
              "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => actionSheetVisible.value = $event),
              onOnChange: onActionSheetChange
            }, null, 8, ["modelValue"]),
            createVNode(DeleteDialog, {
              show: deleteDialogVisible.value,
              "onUpdate:show": _cache[3] || (_cache[3] = ($event) => deleteDialogVisible.value = $event),
              onOnConfirm: onDeleteDialogConfirm
            }, null, 8, ["show"]),
            createVNode(OperGroupDialog, {
              show: operDialogVisible.value,
              "onUpdate:show": _cache[4] || (_cache[4] = ($event) => operDialogVisible.value = $event),
              groupName: currentGroupName.value,
              "onUpdate:groupName": _cache[5] || (_cache[5] = ($event) => currentGroupName.value = $event),
              onOnConfirm: onAddDialogConfirm
            }, null, 8, ["show", "groupName"])
          ])
        ]),
        _: 1
      }, 8, ["modelValue"]);
    };
  }
});
var Comp = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-905d2960"]]);
Comp.install = (app) => {
  app.component(Comp.name, Comp);
};
export { Comp as default };
