import { _ as _toConsumableArray } from '../_verture/toConsumableArray-81040c9e.js';
import { _ as _slicedToArray } from '../_verture/slicedToArray-76060636.js';
import { r as regenerator } from '../_verture/index-beef914f.js';
import { a as __awaiter, _ as __rest } from '../_verture/tslib.es6-55ed4bd2.js';
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
import { useState, useRef, useEffect, Fragment as Fragment$1 } from 'react';
import { Radio } from '../Radio/index.js';
import { Checkbox } from '../Checkbox/index.js';
import { Popover } from '../Popover/index.js';
import AutoTips from '../AutoTips/index.js';
import { Loading } from '../Loading/index.js';
import CloseIcon from '@iam-com/icons/Close';
import { $ as $prefixCls } from '../_verture/constant-66aa48a1.js';
import { u as useFormatMessage } from '../_verture/useFormatMessage-703f8b20.js';
import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
import { Search } from '../Search/index.js';
import { Breadcrumbs } from '../Breadcrumbs/index.js';
import Empty from '../Empty/index.js';
import SearchIcon from '@iam-com/icons/Search';
import Refresh from '@iam-com/icons/Refresh';
import { ArrayToObject, Get, Post, Cancel } from '@iam-com/lib';
import { u as useGlobalProps } from '../_verture/useGlobalProps-1b846a65.js';
import '../_verture/unsupportedIterableToArray-cb478f24.js';
import '../Label/index.js';
import '../Help/index.js';
import '../Tooltip/index.js';
import 'rc-tooltip';
import 'rc-tooltip/lib/placements';
import 'clsx';
import '@iam-com/icons/Help';
import '../_verture/usePopupContainer-87febeb9.js';
import '@iam-com/icons/LoadingF';
import '@para-ui/core/GlobalContext';
import '../TextField/index.js';
import '../_verture/typeof-498dd2b1.js';
import '@iam-com/icons/PreviewClose';
import '@iam-com/icons/PreviewOpen';
import '@iam-com/icons/CloseCircle';
import '../HelperText/index.js';
import '../_verture/index-fac03ce3.js';
import 'rc-dropdown';
import 'dayjs';
import '../Button/index.js';
import '@iam-com/icons/Forbid';
import '@iam-com/icons/Down';
import '@iam-com/icons/More';
import '@iam-com/icons/Return';

var en = {
  root: 'root',
  selectAll: 'Select all',
  seeMore: 'See more',
  selected: 'Selected',
  pleaseEnter: 'Please enter',
  searchResult: 'Search result',
  detail: 'Details',
  child: 'Level'
};

var zh = {
  root: '根',
  selectAll: '全选',
  seeMore: '查看更多',
  selected: '已选',
  pleaseEnter: '请输入',
  searchResult: '搜索结果',
  detail: '详情',
  child: '下级'
};

var localeJson = {
  zh: zh,
  en: en
};

var css_248z$3 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-selector-node {\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n  cursor: pointer;\n}\n.paraui-v3-selector-node:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-selector-node > .selector-node-left {\n  display: flex;\n  align-items: center;\n  flex: 1;\n  overflow: hidden;\n  padding-right: 16px;\n}\n.paraui-v3-selector-node > .selector-node-left > .selector-node-radio {\n  margin-right: 8px;\n  display: flex;\n  align-items: center;\n  padding: 0;\n}\n.paraui-v3-selector-node > .selector-node-left > .selector-node-radio .radio-box {\n  top: 0;\n}\n.paraui-v3-selector-node > .selector-node-left > .selector-node-check {\n  margin-right: 8px;\n  display: flex;\n  align-items: center;\n  padding: 0;\n}\n.paraui-v3-selector-node > .selector-node-left > .selector-node-check .checkbox-box {\n  top: 0;\n}\n.paraui-v3-selector-node > .selector-node-left > .node-img {\n  display: inline-block;\n  width: 30px;\n  height: 30px;\n  margin-right: 8px;\n}\n.paraui-v3-selector-node > .selector-node-left > .node-img img {\n  width: 30px;\n  height: 30px;\n  border-radius: 50%;\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-branch {\n  height: 36px;\n  padding: 0 16px;\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-branch > .selector-node-left > .main-title {\n  font-size: 14px;\n  color: rgb(46, 55, 67);\n  white-space: nowrap;\n  height: 20px;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-branch > .selector-node-left > .sub-title {\n  margin-left: 8px;\n  font-size: 14px;\n  color: rgba(46, 55, 67, 0.4);\n  white-space: nowrap;\n  height: 20px;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-branch > .selector-node-left > .tag {\n  margin-left: 8px;\n  background-color: rgba(54, 102, 214, 0.05);\n  color: rgb(54, 102, 214);\n  border-radius: 2px;\n  font-size: 12px;\n  padding: 0px 6px;\n  white-space: nowrap;\n  height: 17px;\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-leaf {\n  padding: 6px 16px;\n  height: 48px;\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-leaf > .selector-node-left > .title-box {\n  flex: 1;\n  overflow: hidden;\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-leaf > .selector-node-left > .title-box > .main-title-box {\n  display: flex;\n  white-space: nowrap;\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-leaf > .selector-node-left > .title-box > .main-title-box > .main-title {\n  font-size: 14px;\n  color: rgb(46, 55, 67);\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-leaf > .selector-node-left > .title-box > .main-title-box > .tag {\n  margin-left: 8px;\n  background-color: rgba(54, 102, 214, 0.05);\n  color: rgb(54, 102, 214);\n  border-radius: 2px;\n  font-size: 12px;\n  padding: 1px 6px;\n  white-space: nowrap;\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-leaf > .selector-node-left > .title-box > .sub-title {\n  font-size: 12px;\n  color: rgba(46, 55, 67, 0.4);\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n.paraui-v3-selector-node > .selector-node-right {\n  display: flex;\n  align-items: center;\n  height: 100%;\n}\n.paraui-v3-selector-node > .selector-node-right > .detail {\n  font-size: 14px;\n  color: rgb(54, 102, 214);\n  white-space: nowrap;\n  padding: 0 4px;\n  cursor: pointer;\n  height: 24px;\n  line-height: 24px;\n  border-radius: 2px;\n}\n.paraui-v3-selector-node > .selector-node-right > .detail:hover {\n  background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-v3-selector-node > .selector-node-right > .line {\n  border-left: 1px solid rgba(171, 176, 185, 0.2);\n  margin: 0 8px;\n  content: \"\";\n  display: inline-block;\n  height: 12px;\n}\n.paraui-v3-selector-node > .selector-node-right > .lower-child {\n  font-size: 14px;\n  color: rgb(54, 102, 214);\n  white-space: nowrap;\n  padding: 0 4px;\n  cursor: pointer;\n  height: 24px;\n  line-height: 24px;\n  border-radius: 2px;\n}\n.paraui-v3-selector-node > .selector-node-right > .lower-child:hover {\n  background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-v3-selector-node > .selector-node-right > .close {\n  display: flex;\n  align-items: center;\n  color: rgb(54, 102, 214);\n  white-space: nowrap;\n  padding: 0 4px;\n  cursor: pointer;\n  height: 24px;\n  line-height: 24px;\n  border-radius: 2px;\n}\n.paraui-v3-selector-node > .selector-node-right > .close:hover {\n  background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-v3-selector-node > .selector-node-right > .close:hover > svg {\n  color: rgb(54, 102, 214);\n}\n.paraui-v3-selector-node > .selector-node-right > .close > svg {\n  font-size: 16px;\n  color: rgba(46, 55, 67, 0.7);\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-edit > .selector-node-right > .detail, .paraui-v3-selector-node.paraui-v3-selector-node-edit > .selector-node-right > .lower-child {\n  color: rgba(46, 55, 67, 0.7);\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-edit > .selector-node-right > .detail:hover, .paraui-v3-selector-node.paraui-v3-selector-node-edit > .selector-node-right > .lower-child:hover {\n  color: rgb(54, 102, 214);\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-disabled {\n  cursor: not-allowed;\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-disabled.paraui-v3-selector-node-branch > .selector-node-left > .main-title {\n  color: rgba(46, 55, 67, 0.4);\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-disabled.paraui-v3-selector-node-leaf > .selector-node-left > .title-box > .main-title-box > .main-title {\n  color: rgba(46, 55, 67, 0.4);\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-disabled > .selector-node-right > .lower-child {\n  cursor: not-allowed;\n  color: rgba(46, 55, 67, 0.4);\n}\n.paraui-v3-selector-node.paraui-v3-selector-node-disabled-child > .selector-node-right > .lower-child {\n  cursor: not-allowed;\n  color: rgba(46, 55, 67, 0.4);\n}\n\n.paraui-v3-selector-detail .selector-detail-popover-content.selector-detail-popover-content-loading {\n  min-width: 100px;\n  min-height: 50px;\n}";
styleInject(css_248z$3);

var SelectorNode = function SelectorNode(props) {
  var className = props.className,
    style = props.style,
    _props$nodeMode = props.nodeMode,
    nodeMode = _props$nodeMode === void 0 ? 'branch' : _props$nodeMode,
    _props$useCase = props.useCase,
    useCase = _props$useCase === void 0 ? 'view' : _props$useCase,
    img = props.img,
    selectMode = props.selectMode,
    mainTitle = props.mainTitle,
    subTitle = props.subTitle,
    tag = props.tag,
    tagStyle = props.tagStyle,
    detail = props.detail,
    detailRender = props.detailRender,
    leftRender = props.leftRender,
    child = props.child,
    close = props.close,
    checked = props.checked,
    indeterminate = props.indeterminate,
    disabled = props.disabled,
    disabledChild = props.disabledChild,
    onLevel = props.onLevel,
    onSelect = props.onSelect,
    onClose = props.onClose;
  var intl = useFormatMessage('Selector', localeJson);
  var _useState = useState(),
    _useState2 = _slicedToArray(_useState, 2),
    detailDom = _useState2[0],
    setDetailDom = _useState2[1]; // 详情内容
  var _useState3 = useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    detailDomLoading = _useState4[0],
    setDetailDomLoading = _useState4[1]; // 详情loading
  var detailRef = useRef();
  /** 点击节点 */
  var onClickNode = function onClickNode() {
    if (disabled) return;
    onSelect && onSelect();
  };
  /** 点击下级 */
  var onLevelBtn = function onLevelBtn(e) {
    e.stopPropagation();
    if (disabled || disabledChild) return;
    onLevel && onLevel();
  };
  /** 点击详情 */
  var onClickDetail = function onClickDetail(e) {
    e.stopPropagation();
  };
  /** 点击× */
  var onCloseCom = function onCloseCom(e) {
    e.stopPropagation();
    onClose && onClose();
  };
  /** 详情显示隐藏 */
  var onVisibleChange = function onVisibleChange(bol) {
    return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
      var Dom;
      return regenerator.wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            if (detailRender) {
              _context.next = 2;
              break;
            }
            return _context.abrupt("return");
          case 2:
            setDetailDomLoading(false);
            if (bol) {
              _context.next = 5;
              break;
            }
            return _context.abrupt("return", setDetailDom(null));
          case 5:
            setDetailDomLoading(true);
            detailRef.current && detailRef.current.classList.add('selector-detail-popover-content-loading');
            _context.next = 9;
            return detailRender();
          case 9:
            Dom = _context.sent;
            detailRef.current && detailRef.current.classList.remove('selector-detail-popover-content-loading');
            setDetailDomLoading(false);
            setDetailDom(Dom);
          case 13:
          case "end":
            return _context.stop();
        }
      }, _callee);
    }));
  };
  /** 处理头像 */
  var handImg = function handImg() {
    if (!img) return null;
    var imgDom = img;
    if (typeof img === "string") imgDom = jsx("img", {
      src: img
    });
    return jsx("span", Object.assign({
      className: "node-img"
    }, {
      children: imgDom
    }));
  };
  /** 处理选择框 */
  var handSelectDom = function handSelectDom() {
    if (selectMode === 'radio') return jsx(Radio, {
      size: "small",
      className: 'selector-node-radio',
      checked: checked,
      disabled: disabled
    });
    if (selectMode === 'check') return jsx(Checkbox, {
      size: "small",
      className: 'selector-node-check',
      checked: checked,
      disabled: disabled,
      indeterminate: indeterminate
    });
    return null;
  };
  /** 处理详情弹窗 */
  var handDetailDom = function handDetailDom() {
    return jsxs("div", Object.assign({
      className: "selector-detail-popover-content",
      ref: detailRef
    }, {
      children: [detailDom, detailDomLoading && jsx(Loading, {})]
    }));
  };
  /** 处理详情 */
  var handDetail = function handDetail() {
    if (!detail) return null;
    return jsx(Popover, Object.assign({
      content: handDetailDom(),
      trigger: 'hover',
      placement: 'bottomRight',
      overlayClassName: $prefixCls + '-selector-detail',
      onVisibleChange: onVisibleChange
    }, {
      children: jsx("span", Object.assign({
        className: "detail",
        onClick: onClickDetail
      }, {
        children: intl({
          id: 'detail'
        })
      }))
    }));
  };
  /** 处理标签内容 */
  var handNodeLeft = function handNodeLeft() {
    if (nodeMode === 'branch') {
      return jsxs(Fragment, {
        children: [mainTitle && jsx("span", Object.assign({
          className: "main-title"
        }, {
          children: jsx(AutoTips, {
            children: mainTitle
          })
        })), subTitle && jsx("span", Object.assign({
          className: "sub-title"
        }, {
          children: jsx(AutoTips, {
            children: subTitle
          })
        })), tag && jsx("span", Object.assign({
          className: "tag",
          style: tagStyle
        }, {
          children: tag
        }))]
      });
    }
    if (nodeMode === 'leaf') {
      return jsxs("div", Object.assign({
        className: "title-box"
      }, {
        children: [jsxs("div", Object.assign({
          className: "main-title-box"
        }, {
          children: [mainTitle && jsx("span", Object.assign({
            className: "main-title"
          }, {
            children: jsx(AutoTips, {
              children: mainTitle
            })
          })), tag && jsx("span", Object.assign({
            className: "tag",
            style: tagStyle
          }, {
            children: tag
          }))]
        })), subTitle && jsx("div", Object.assign({
          className: "sub-title"
        }, {
          children: jsx(AutoTips, {
            children: subTitle
          })
        }))]
      }));
    }
  };
  /** 处理左侧内容 */
  var handLeftContent = function handLeftContent() {
    if (leftRender) return leftRender();
    return jsxs(Fragment, {
      children: [handSelectDom(), handImg(), handNodeLeft()]
    });
  };
  /** 处理className */
  var handClass = function handClass() {
    var str = $prefixCls + '-selector-node';
    str += " ".concat($prefixCls, "-selector-node-").concat(useCase);
    str += " ".concat($prefixCls, "-selector-node-").concat(nodeMode);
    if (disabled) str += " ".concat($prefixCls, "-selector-node-disabled");
    if (disabledChild) str += " ".concat($prefixCls, "-selector-node-disabled-child");
    if (className) str += ' ' + className;
    return str;
  };
  return jsxs("div", Object.assign({
    className: handClass(),
    style: style,
    onClick: onClickNode
  }, {
    children: [jsx("div", Object.assign({
      className: "selector-node-left"
    }, {
      children: handLeftContent()
    })), jsxs("div", Object.assign({
      className: "selector-node-right"
    }, {
      children: [handDetail(), detail && child && jsx("span", {
        className: "line"
      }), child && jsx("span", Object.assign({
        className: "lower-child",
        onClick: onLevelBtn
      }, {
        children: intl({
          id: 'child'
        })
      })), detail && close && jsx("span", {
        className: "line"
      }), close && jsx("span", Object.assign({
        className: "close",
        onClick: onCloseCom
      }, {
        children: jsx(CloseIcon, {})
      }))]
    }))]
  }));
};

var css_248z$2 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-selector-main {\n  padding: 16px 0 0 0;\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  width: 100%;\n}\n.paraui-v3-selector-main > .selectot-main-search {\n  padding: 0 16px;\n  margin-bottom: 16px;\n}\n.paraui-v3-selector-main > .selector-main-box {\n  position: relative;\n  width: 100%;\n  height: 100%;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content {\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  width: 100%;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .nav-box {\n  padding: 0 16px;\n  margin-bottom: 12px;\n  line-height: 0;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list-no-data {\n  width: 100%;\n  height: 100%;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  padding-bottom: 16px;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list {\n  overflow-y: hidden;\n  padding-bottom: 16px;\n  display: flex;\n  flex-direction: column;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-all-check {\n  position: relative;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-all-check + .selector-group-title.selector-group-title-first {\n  margin-top: 4px;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-content {\n  overflow-y: hidden;\n  position: relative;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-content:before {\n  content: \"\";\n  position: absolute;\n  height: 36px;\n  width: 100%;\n  pointer-events: none;\n  top: 0;\n  left: 0;\n  z-index: 1;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-content:after {\n  content: \"\";\n  position: absolute;\n  height: 36px;\n  width: 100%;\n  pointer-events: none;\n  bottom: 0;\n  left: 0;\n  z-index: 1;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-content.selector-main-list-scroll-top:after {\n  box-shadow: inset 0px -10px 10px -8px rgba(0, 0, 0, 0.05);\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-content.selector-main-list-scroll-middle:before {\n  box-shadow: inset 0px 10px 10px -8px rgba(0, 0, 0, 0.05);\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-content.selector-main-list-scroll-middle:after {\n  box-shadow: inset 0px -10px 10px -8px rgba(0, 0, 0, 0.05);\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-content.selector-main-list-scroll-bottom:before {\n  box-shadow: inset 0px 10px 10px -8px rgba(0, 0, 0, 0.05);\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-content > .selector-main-list-content-box {\n  height: 100%;\n  overflow-y: auto;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-content > .selector-main-list-content-box > .selector-group-title {\n  padding: 0 12px;\n  margin-top: 24px;\n  margin-bottom: 12px;\n  font-size: 14px;\n  color: rgba(46, 55, 67, 0.4);\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-content > .selector-main-list-content-box > .selector-group-title.selector-group-title-first {\n  margin-top: 0;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-more {\n  padding: 0 16px;\n  cursor: pointer;\n  font-size: 14px;\n  color: rgb(54, 102, 214);\n  line-height: 36px;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-more:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content.selector-main-search-content {\n  /*position: absolute;\n  left: 0;\n  top: 0;*/\n  width: 100%;\n  height: 100%;\n  background-color: white;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content.selector-main-search-content > .selector-main-list {\n  padding-bottom: 16px;\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content.selector-main-content-all-check > .selector-main-list > .selector-main-list-content {\n  max-height: calc(100% - 36px);\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content.selector-main-content-load-more > .selector-main-list > .selector-main-list-content {\n  max-height: calc(100% - 36px);\n}\n.paraui-v3-selector-main > .selector-main-box > .selector-main-content.selector-main-content-all-check.selector-main-content-load-more > .selector-main-list > .selector-main-list-content {\n  max-height: calc(100% - 36px - 36px);\n}\n.paraui-v3-selector-main.paraui-v3-selector-main-select > .selector-main-box > .selector-main-content > .selector-main-list > .selector-main-list-more {\n  padding-left: 38px;\n}\n.paraui-v3-selector-main.paraui-v3-selector-main-show-search > .selector-main-box {\n  height: calc(100% - 52px);\n}\n.paraui-v3-selector-main.paraui-v3-selector-main-show-search > .selector-main-box > .selector-main-content.selector-main-list-box {\n  display: none;\n}\n.paraui-v3-selector-main.paraui-v3-selector-main-search > .selector-main-box {\n  height: calc(100% - 52px);\n}";
styleInject(css_248z$2);

var SelectorMainContent = function SelectorMainContent(props) {
  var className = props.className,
    value = props.value;
    props.rowKey;
    var _props$nodeMode = props.nodeMode,
    nodeMode = _props$nodeMode === void 0 ? 'branch' : _props$nodeMode,
    selectMode = props.selectMode,
    _props$loadMore = props.loadMore,
    loadMore = _props$loadMore === void 0 ? false : _props$loadMore,
    _props$isAllCheck = props.isAllCheck,
    isAllCheck = _props$isAllCheck === void 0 ? false : _props$isAllCheck,
    detail = props.detail,
    detailRender = props.detailRender,
    isLazy = props.isLazy,
    list = props.list,
    groupType = props.groupType,
    breadcrumbs = props.breadcrumbs,
    _props$breadcrumbsSep = props.breadcrumbsSeparator,
    breadcrumbsSeparator = _props$breadcrumbsSep === void 0 ? '-' : _props$breadcrumbsSep,
    _props$breadcrumbsLis = props.breadcrumbsList,
    breadcrumbsList = _props$breadcrumbsLis === void 0 ? [] : _props$breadcrumbsLis,
    fieldConfig = props.fieldConfig,
    disabled = props.disabled,
    disabledChild = props.disabledChild,
    emptyProps = props.emptyProps,
    loading = props.loading,
    onClickBreadcrumbs = props.onClickBreadcrumbs,
    _onLevel = props.onLevel,
    _onSelect = props.onSelect,
    onLoad = props.onLoad,
    onAllCheck = props.onAllCheck;
  var intl = useFormatMessage('Selector', localeJson);
  var _useState = useState({}),
    _useState2 = _slicedToArray(_useState, 2),
    listCom = _useState2[0],
    setListCom = _useState2[1];
  var constData = useRef({
    listTypeJson: {},
    fieldConfig: {},
    resizeTimer: null
  });
  var scrolltRef = useRef(null);
  var contentRef = useRef(null);
  constData.current.listTypeJson = ArrayToObject('value', groupType);
  constData.current.fieldConfig = fieldConfig || {};
  useEffect(function () {
    changeResize();
    return function () {
      clearTimeout(constData.current.resizeTimer);
    };
  }, []);
  useEffect(function () {
    if (list && groupType && groupType.length > 0) {
      var json = {};
      for (var i = 0, l = list.length; i < l; i++) {
        var item = list[i];
        var type = item.type;
        if (!json[type]) json[type] = [];
        json[type].push(item);
      }
      setListCom(json);
    }
  }, [list]);
  /** 屏幕发生改变 */
  var changeResize = function changeResize() {
    clearTimeout(constData.current.resizeTimer);
    constData.current.resizeTimer = setTimeout(function () {
      onScroll();
    }, 100);
  };
  /** 滚动 */
  var onScroll = function onScroll() {
    if (!contentRef.current || !scrolltRef.current) return;
    var scrollBox = scrolltRef.current;
    var contentBox = contentRef.current;
    contentBox.classList.remove('selector-main-list-scroll-top', 'selector-main-list-scroll-bottom', 'selector-main-list-scroll-middle');
    if (scrollBox.scrollHeight <= scrollBox.clientHeight) return;
    // 滚动条初始化
    if (scrollBox.scrollTop === 0) {
      contentBox.classList.add('selector-main-list-scroll-top');
      return;
    }
    // 滚动到底部
    if (scrollBox.clientHeight + scrollBox.scrollTop === scrollBox.scrollHeight) {
      contentBox.classList.add('selector-main-list-scroll-bottom');
      return;
    }
    // 滚动条在中间
    contentBox.classList.add('selector-main-list-scroll-middle');
  };
  /** 判断是否全选,半选 */
  var handAllCheckFunc = function handAllCheckFunc() {
    var json = {
      checked: false,
      indeterminate: false
    };
    // 不存在value, 没有数据, 全选没转态
    if (!value || !list || list.length === 0) return json;
    for (var i = 0, l = list.length; i < l; i++) {
      var item = list[i];
      var key = item.key;
      var disabledItem = handDisabled(item);
      if (disabledItem) {
        if (value[key]) json.checked = true;
        continue;
      }
      if (value[key]) {
        json.checked = true;
      } else {
        json.indeterminate = true;
      }
    }
    // 半选
    if (json.checked && json.indeterminate) {
      json.checked = false;
      return json;
    }
    // 全不选
    if (!json.checked && json.indeterminate) {
      json.indeterminate = false;
      return json;
    }
    return json;
  };
  /** 处理禁用状态 */
  var handDisabled = function handDisabled(item) {
    if (disabled) {
      if (disabled === true) return true;
      if (disabled instanceof Array) {
        if (item.key && disabled.indexOf(item.key) !== -1) {
          return true;
        }
      }
    }
    if (item.disabled) return true;
    return false;
  };
  /** 处理禁用下级状态 */
  var handDisabledChild = function handDisabledChild(item) {
    if (disabledChild) {
      if (disabledChild === true) return true;
      if (disabledChild instanceof Array) {
        if (item.key && disabledChild.indexOf(item.key) !== -1) {
          return true;
        }
      }
    }
    if (item.disabledChild) return true;
    return false;
  };
  /** 全选 */
  var handAllCheck = function handAllCheck() {
    // 只存在复选框模式
    if (!isAllCheck || selectMode !== "check") return null;
    var checkJson = handAllCheckFunc();
    var onAllCheckCom = function onAllCheckCom() {
      var bol = true;
      if (checkJson.checked) bol = false;
      onAllCheck && onAllCheck(bol);
    };
    return jsx(SelectorNode, Object.assign({
      disabled: disabled === true,
      nodeMode: 'branch',
      mainTitle: intl({
        id: 'selectAll'
      }),
      selectMode: 'check'
    }, checkJson, {
      onSelect: onAllCheckCom,
      className: 'selector-all-check'
    }));
  };
  /** 点击查看更多 */
  var clickLoad = function clickLoad() {
    onLoad && onLoad();
  };
  /** 查看更多 */
  var handLoadMore = function handLoadMore() {
    if (!loadMore) return null;
    return jsx("div", Object.assign({
      className: "selector-main-list-more",
      onClick: clickLoad
    }, {
      children: jsx("span", Object.assign({
        className: "more-btn"
      }, {
        children: intl({
          id: 'seeMore'
        })
      }))
    }));
  };
  /** 判断是否选中 */
  var handCheck = function handCheck(item) {
    var bol = false;
    if (value && value[item.key]) bol = true;
    return bol;
  };
  /** 处理每个节点的配置 */
  var handNodeConfig = function handNodeConfig(item) {
    var json = {
      useCase: 'view',
      detail: detail,
      nodeMode: nodeMode,
      disabled: handDisabled(item),
      disabledChild: handDisabledChild(item),
      onLevel: function onLevel() {
        return _onLevel && _onLevel(item);
      },
      onSelect: function onSelect() {
        return _onSelect && _onSelect(item);
      },
      checked: handCheck(item)
    };
    /** 节点类型 */
    if (item.leaf !== undefined) json.nodeMode = item.leaf ? 'leaf' : 'branch';
    /** 渲染字段 */
    var arr = ['img', 'mainTitle', 'subTitle', 'tag', 'tagStyle'];
    for (var i = 0, l = arr.length; i < l; i++) {
      var key = arr[i];
      json[key] = item[key];
    }
    /** 判断是否具有选择 */
    if (item.choice !== false) {
      // 当前节点可选择
      if (selectMode) json.selectMode = selectMode;
    }
    /** 判断是否具有下级 */
    if (isLazy) {
      // 懒加载
      json.child = item.child;
    } else {
      // 全量数据
      var children = item.children || [];
      if (children && children.length > 0) {
        json.child = true;
      }
      // 强制设置下级
      if (item.child !== undefined) json.child = item.child;
    }
    /** 详情render */
    if (detailRender) {
      json.detailRender = function () {
        return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
          var Dom;
          return regenerator.wrap(function _callee$(_context) {
            while (1) switch (_context.prev = _context.next) {
              case 0:
                _context.next = 2;
                return detailRender(item, true);
              case 2:
                Dom = _context.sent;
                return _context.abrupt("return", Dom);
              case 4:
              case "end":
                return _context.stop();
            }
          }, _callee);
        }));
      };
    }
    if (item.detail !== undefined) json.detail = item.detail;
    return json;
  };
  /** 渲染list节点 */
  var handListNode = function handListNode(arr) {
    return arr === null || arr === void 0 ? void 0 : arr.map(function (item, index) {
      return jsx(SelectorNode, Object.assign({}, handNodeConfig(item)), index);
    });
  };
  /** 处理节点dom */
  var handNode = function handNode() {
    // 分组渲染
    if (groupType && groupType.length > 0) {
      return jsx(Fragment, {
        children: groupType.map(function (item, index) {
          var type = item.value;
          var listData = listCom[type] || [];
          var str = 'selector-group-title';
          if (index === 0) str += ' selector-group-title-first';
          return jsxs(Fragment$1, {
            children: [listData.length > 0 && jsx("div", Object.assign({
              className: str
            }, {
              children: item.label || type
            })), handListNode(listData)]
          }, index);
        })
      });
    }
    return handListNode(list || []);
  };
  /** 点击面包屑 */
  var onClickBreadcrums = function onClickBreadcrums(item) {
    onClickBreadcrumbs && onClickBreadcrumbs(item);
  };
  /** 面包屑dom */
  var handBreadcrumbs = function handBreadcrumbs() {
    if (!breadcrumbs || breadcrumbsList.length === 0) return null;
    return jsx("div", Object.assign({
      className: "nav-box"
    }, {
      children: jsx(Breadcrumbs, {
        list: breadcrumbsList,
        separator: breadcrumbsSeparator,
        onClickItem: onClickBreadcrums
      })
    }));
  };
  /** 处理内容 */
  var handContent = function handContent() {
    if ((list === null || list === void 0 ? void 0 : list.length) === 0 && !loading) {
      // 空状态
      return jsx("div", Object.assign({
        className: "selector-main-list-no-data"
      }, {
        children: jsx(Empty, Object.assign({}, emptyProps, {
          size: (emptyProps === null || emptyProps === void 0 ? void 0 : emptyProps.size) || "small"
        }))
      }));
    }
    return jsxs("div", Object.assign({
      className: "selector-main-list"
    }, {
      children: [handAllCheck(), jsx("div", Object.assign({
        className: "selector-main-list-content",
        ref: contentRef
      }, {
        children: jsx("div", Object.assign({
          className: "selector-main-list-content-box",
          ref: scrolltRef,
          onScroll: onScroll
        }, {
          children: handNode()
        }))
      })), handLoadMore()]
    }));
  };
  var handClass = function handClass() {
    var str = 'selector-main-content';
    if (className) str += ' ' + className;
    if (disabled) str += ' selector-main-content-disabled';
    if (isAllCheck && selectMode === "check") str += ' selector-main-content-all-check';
    if (loadMore) str += ' selector-main-content-load-more';
    return str;
  };
  changeResize();
  return jsxs("div", Object.assign({
    className: handClass()
  }, {
    children: [handBreadcrumbs(), handContent()]
  }));
};
var SelectorMain = function SelectorMain(props) {
  var className = props.className,
    style = props.style,
    url = props.url,
    value = props.value,
    _props$rowKey2 = props.rowKey,
    rowKey = _props$rowKey2 === void 0 ? 'key' : _props$rowKey2,
    _props$nodeMode2 = props.nodeMode,
    nodeMode = _props$nodeMode2 === void 0 ? 'branch' : _props$nodeMode2,
    selectMode = props.selectMode,
    _props$loadMore2 = props.loadMore,
    loadMore = _props$loadMore2 === void 0 ? false : _props$loadMore2,
    _props$searchLoadMore = props.searchLoadMore,
    searchLoadMore = _props$searchLoadMore === void 0 ? false : _props$searchLoadMore,
    _props$isAllCheck2 = props.isAllCheck,
    isAllCheck = _props$isAllCheck2 === void 0 ? false : _props$isAllCheck2,
    disabled = props.disabled,
    disabledChild = props.disabledChild,
    detail = props.detail,
    detailRender = props.detailRender,
    isLazy = props.isLazy,
    list = props.list,
    groupType = props.groupType,
    groupRange = props.groupRange,
    search = props.search,
    _props$searchVal = props.searchVal,
    searchVal = _props$searchVal === void 0 ? '' : _props$searchVal,
    searchPlaceholder = props.searchPlaceholder,
    searchTrigger = props.searchTrigger,
    searchLoading = props.searchLoading,
    searchList = props.searchList,
    loading = props.loading,
    breadcrumbs = props.breadcrumbs,
    _props$breadcrumbsSep2 = props.breadcrumbsSeparator,
    breadcrumbsSeparator = _props$breadcrumbsSep2 === void 0 ? '-' : _props$breadcrumbsSep2,
    _props$breadcrumbsLis2 = props.breadcrumbsList,
    breadcrumbsList = _props$breadcrumbsLis2 === void 0 ? [] : _props$breadcrumbsLis2,
    fieldConfig = props.fieldConfig,
    onClickBreadcrumbs = props.onClickBreadcrumbs,
    onLevel = props.onLevel,
    onSelect = props.onSelect,
    onLoad = props.onLoad,
    onAllCheck = props.onAllCheck,
    onSearch = props.onSearch,
    onRefresh = props.onRefresh;
  var intl = useFormatMessage('Selector', localeJson);
  var _useState3 = useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    showSearch = _useState4[0],
    setShowSearch = _useState4[1]; // 显示搜索/
  var _useState5 = useState(''),
    _useState6 = _slicedToArray(_useState5, 2),
    searchStr = _useState6[0],
    setSearchStr = _useState6[1];
  var constData = useRef({
    searchTimer: null,
    searchStr: ''
  });
  useEffect(function () {
    if (!searchVal) return;
    constData.current.searchStr = searchVal.val;
    setSearchStr(searchVal.val);
    if (searchVal.val !== '') setShowSearch(true);
  }, [searchVal]);
  /** 改变搜索框 */
  var changeSearch = function changeSearch(val) {
    setSearchStr(val);
    constData.current.searchStr = val;
    if (searchTrigger !== 'onEnter') onSearchCom();
  };
  /** 搜索框回车事件 */
  var onEnterSearch = function onEnterSearch() {
    onSearchCom(true);
  };
  /** 点击搜索按钮 */
  var onClickRightIcon = function onClickRightIcon() {
    onSearchCom(true);
  };
  /** 点击清除按钮 */
  var onClear = function onClear() {
    onSearchCom();
  };
  /** 向外抛出搜索事件 */
  var onSearchCom = function onSearchCom(bol) {
    clearTimeout(constData.current.searchTimer);
    constData.current.searchTimer = setTimeout(function () {
      setShowSearch(!!constData.current.searchStr);
      onSearch && onSearch(constData.current.searchStr, !!bol);
    }, 300);
  };
  /** 搜索dom */
  var handSearchDom = function handSearchDom() {
    var handSearchIcon = function handSearchIcon() {
      if (!searchStr) {
        // 本地数据且没有自定义刷新事件
        if (!url && !onRefresh) {
          return null;
        }
        return jsx(Refresh, {});
      }
      return jsx(SearchIcon, {});
    };
    return jsx(Fragment, {
      children: search && jsx(Search, {
        className: 'selectot-main-search',
        value: searchStr,
        rightIconExist: true,
        showBtn: false,
        rightIcon: handSearchIcon(),
        btnType: "inside",
        onChange: changeSearch,
        onEnter: onEnterSearch,
        onClear: onClear,
        placeholder: searchPlaceholder || intl({
          id: 'pleaseEnter'
        }),
        onClickRightIcon: onClickRightIcon
      })
    });
  };
  /** 点击下级
   * @param isSearch {boolean}
   * */
  var onLevelCom = function onLevelCom(isSearch) {
    return function (item) {
      if (isSearch) {
        constData.current.searchStr = '';
        setSearchStr('');
        setShowSearch(false);
      }
      onLevel && onLevel(item, isSearch);
    };
  };
  /**
   * 加载更多
   * @param isSearch {boolean} 是否搜索
   * */
  var onLoadCom = function onLoadCom(isSearch) {
    return function () {
      onLoad && onLoad(isSearch);
    };
  };
  /** 渲染列表 */
  var handListDom = function handListDom() {
    return jsx(SelectorMainContent, {
      className: "selector-main-list-box",
      value: value,
      rowKey: rowKey,
      nodeMode: nodeMode,
      selectMode: selectMode,
      loadMore: loadMore,
      isAllCheck: isAllCheck,
      disabled: disabled,
      disabledChild: disabledChild,
      detail: detail,
      detailRender: detailRender,
      isLazy: isLazy,
      list: list,
      loading: loading,
      groupType: groupRange === 'list' || groupRange === 'searchList' ? groupType : undefined,
      breadcrumbs: breadcrumbs,
      breadcrumbsSeparator: breadcrumbsSeparator,
      breadcrumbsList: breadcrumbsList,
      fieldConfig: fieldConfig,
      onClickBreadcrumbs: onClickBreadcrumbs,
      onLevel: onLevelCom(false),
      onSelect: onSelect,
      onLoad: onLoadCom(false),
      onAllCheck: onAllCheck
    }, "list");
  };
  /** 渲染搜索列表 */
  var handSearchList = function handSearchList() {
    if (!showSearch) return;
    return jsx(SelectorMainContent, {
      className: 'selector-main-search-content',
      value: value,
      rowKey: rowKey,
      nodeMode: nodeMode,
      selectMode: selectMode,
      loadMore: searchLoadMore,
      isAllCheck: false,
      disabled: disabled,
      disabledChild: disabledChild,
      detail: detail,
      detailRender: detailRender,
      isLazy: isLazy,
      list: searchList,
      groupType: groupRange === 'search' || groupRange === 'searchList' ? groupType : undefined,
      fieldConfig: fieldConfig,
      loading: searchLoading,
      onSelect: onSelect,
      onLevel: onLevelCom(true),
      onLoad: onLoadCom(true)
    }, "search");
  };
  /** 处理loading */
  var handLoading = function handLoading() {
    if (searchLoading || loading) {
      return jsx(Loading, {});
    }
  };
  // 处理class
  var handClass = function handClass() {
    var str = $prefixCls + '-selector-main';
    if (className) str += ' ' + className;
    if (selectMode === 'check') str += " ".concat($prefixCls, "-selector-main-select");
    if (showSearch) str += " ".concat($prefixCls, "-selector-main-show-search");
    if (search) str += " ".concat($prefixCls, "-selector-main-search");
    if (disabled === true) str += " ".concat($prefixCls, "-selector-main-disabled");
    return str;
  };
  return jsxs("div", Object.assign({
    className: handClass(),
    style: style
  }, {
    children: [handSearchDom(), jsxs("div", Object.assign({
      className: "selector-main-box"
    }, {
      children: [handListDom(), handSearchList(), handLoading()]
    }))]
  }));
};

var css_248z$1 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-selector-data.paraui-v3-selector-data-node > .selector-data-node-box {\n  padding: 24px 0 16px 0;\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n}\n.paraui-v3-selector-data.paraui-v3-selector-data-node > .selector-data-node-box > .title {\n  font-size: 14px;\n  color: rgb(46, 55, 67);\n  padding: 0 16px;\n  margin-bottom: 16px;\n}\n.paraui-v3-selector-data.paraui-v3-selector-data-node > .selector-data-node-box > .title > .title-content {\n  margin-left: 8px;\n}\n.paraui-v3-selector-data.paraui-v3-selector-data-node > .selector-data-node-box > .content {\n  overflow-y: auto;\n}\n.paraui-v3-selector-data.paraui-v3-selector-data-tag > .selector-data-tag-box {\n  padding-top: 12px;\n  height: 100%;\n  display: flex;\n  flex-direction: column;\n}\n.paraui-v3-selector-data.paraui-v3-selector-data-tag > .selector-data-tag-box > .title {\n  font-size: 14px;\n  color: rgb(46, 55, 67);\n  padding: 0 16px;\n}\n.paraui-v3-selector-data.paraui-v3-selector-data-tag > .selector-data-tag-box > .content {\n  padding: 0 16px 12px 16px;\n  overflow: auto;\n}\n.paraui-v3-selector-data.paraui-v3-selector-data-tag > .selector-data-tag-box > .content > .content-tag {\n  display: inline-flex;\n  height: 24px;\n  align-items: center;\n  padding: 0 8px;\n  border-radius: 2px;\n  background-color: rgba(171, 176, 185, 0.2);\n  margin-right: 8px;\n  margin-top: 6px;\n  max-width: calc(100% - 8px);\n}\n.paraui-v3-selector-data.paraui-v3-selector-data-tag > .selector-data-tag-box > .content > .content-tag > span {\n  font-size: 12px;\n  color: rgb(46, 55, 67);\n  overflow: hidden;\n}\n.paraui-v3-selector-data.paraui-v3-selector-data-tag > .selector-data-tag-box > .content > .content-tag > svg {\n  font-size: 16px;\n  margin-left: 4px;\n  color: rgba(46, 55, 67, 0.7);\n  cursor: pointer;\n}";
styleInject(css_248z$1);

var SelectorData = function SelectorData(props) {
  var className = props.className,
    _props$layout = props.layout,
    layout = _props$layout === void 0 ? 'node' : _props$layout,
    style = props.style,
    list = props.list,
    groupType = props.groupType,
    nodeMode = props.nodeMode,
    backDataFieldConfig = props.backDataFieldConfig,
    detail = props.detail,
    detailRender = props.detailRender,
    disabled = props.disabled,
    handSelectorNodeInfo = props.handSelectorNodeInfo,
    selectDataTitleRender = props.selectDataTitleRender,
    selectRenderItem = props.selectRenderItem,
    selectRender = props.selectRender,
    _onClose = props.onClose;
  var intl = useFormatMessage('Selector', localeJson);
  var _useState = useState({}),
    _useState2 = _slicedToArray(_useState, 2),
    listCom = _useState2[0],
    setListCom = _useState2[1];
  var constData = useRef({
    listTypeJson: {},
    backDataFieldConfig: {}
  });
  constData.current.listTypeJson = ArrayToObject('value', groupType);
  constData.current.backDataFieldConfig = backDataFieldConfig || {};
  useEffect(function () {
    if (list && groupType && groupType.length > 0) {
      var json = {};
      for (var i = 0, l = list.length; i < l; i++) {
        var item = list[i];
        var type = item[constData.current.backDataFieldConfig.type || ''];
        if (!json[type]) json[type] = [];
        json[type].push(item);
      }
      setListCom(json);
    }
  }, [list]);
  /** 处理禁用 */
  var handDisabled = function handDisabled(itemConfig) {
    if (disabled) {
      if (disabled === true) return true;
      if (disabled instanceof Array) {
        var keyStr = (backDataFieldConfig === null || backDataFieldConfig === void 0 ? void 0 : backDataFieldConfig.key) || '';
        var val = itemConfig[keyStr];
        if (disabled.indexOf(val) !== -1) {
          return true;
        }
      }
    }
    return false;
  };
  /** 处理每个节点的配置 */
  var handNodeConfig = function handNodeConfig(itemConfig, index) {
    var item = itemConfig;
    if (handSelectorNodeInfo) item = handSelectorNodeInfo(itemConfig);
    var disabledItem = handDisabled(itemConfig);
    var json = {
      useCase: 'edit',
      close: !disabledItem,
      detail: detail,
      data: item,
      nodeMode: nodeMode,
      onClose: function onClose() {
        return _onClose && _onClose(item, index);
      },
      disabled: handDisabled(itemConfig),
      tagStyle: item.tagStyle
    };
    if (selectRenderItem) {
      json.leftRender = function () {
        return selectRenderItem(itemConfig);
      };
    }
    /** 节点类型 */
    if (item.leaf !== undefined) json.nodeMode = item.leaf ? 'leaf' : 'branch';
    /** 渲染字段 */
    var arr = ['img', 'mainTitle', 'subTitle', 'tag'];
    for (var i = 0, l = arr.length; i < l; i++) {
      var key = arr[i] || '';
      var backName = backDataFieldConfig && backDataFieldConfig[key] || '';
      json[key] = item[backName];
    }
    /** 详情render */
    if (detailRender) {
      json.detailRender = function () {
        return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
          var Dom;
          return regenerator.wrap(function _callee$(_context) {
            while (1) switch (_context.prev = _context.next) {
              case 0:
                _context.next = 2;
                return detailRender(item, false);
              case 2:
                Dom = _context.sent;
                return _context.abrupt("return", Dom);
              case 4:
              case "end":
                return _context.stop();
            }
          }, _callee);
        }));
      };
    }
    if (item.detail !== undefined) json.detail = item.detail;
    /** 是否具有删除 */
    if (item.close !== undefined) json.close = item.close;
    return json;
  };
  /** 处理节点 */
  var handNode = function handNode() {
    if (selectRender) {
      return selectRender(list || []);
    }
    return list === null || list === void 0 ? void 0 : list.map(function (item, index) {
      return jsx(SelectorNode, Object.assign({}, handNodeConfig(item, index)), index);
    });
  };
  /** 处理标题 */
  var handTitle = function handTitle() {
    var handTitleTag = function handTitleTag() {
      if (selectDataTitleRender) return selectDataTitleRender(list);
      if (groupType) {
        return jsx(Fragment, {
          children: groupType.map(function (item, index) {
            var num = 0;
            var val = item.value;
            if (listCom[val]) num = listCom[val].length;
            if (num === 0) return;
            return jsxs("span", Object.assign({
              className: "title-content"
            }, {
              children: [num, "\u4E2A", item.label || item.value]
            }), index);
          })
        });
      }
    };
    return jsxs("div", Object.assign({
      className: "title"
    }, {
      children: [jsxs("span", Object.assign({
        className: "title-tip"
      }, {
        children: [intl({
          id: 'selected'
        }), ":"]
      })), handTitleTag()]
    }));
  };
  // 处理节点内容
  var handContentNode = function handContentNode() {
    return jsxs("div", Object.assign({
      className: "selector-data-node-box"
    }, {
      children: [handTitle(), jsx("div", Object.assign({
        className: "content"
      }, {
        children: handNode()
      }))]
    }));
  };
  // 处理内容
  var handDetailTagContent = function handDetailTagContent() {
    if (selectRender) {
      return selectRender(list || []);
    }
    return jsx(Fragment, {
      children: list === null || list === void 0 ? void 0 : list.map(function (item, index) {
        var disabledItem = handDisabled(item);
        return jsxs("span", Object.assign({
          className: "content-tag"
        }, {
          children: [jsx("span", {
            children: selectRenderItem ? selectRenderItem(item) : jsx(AutoTips, {
              children: item[(backDataFieldConfig === null || backDataFieldConfig === void 0 ? void 0 : backDataFieldConfig.mainTitle) || ''] || item[(backDataFieldConfig === null || backDataFieldConfig === void 0 ? void 0 : backDataFieldConfig.key) || '']
            })
          }), !disabledItem && jsx(CloseIcon, {
            onClick: function onClick() {
              return _onClose && _onClose(item, index);
            }
          })]
        }), index);
      })
    });
  };
  // 处理tag内容
  var handContentTag = function handContentTag() {
    return jsxs("div", Object.assign({
      className: "selector-data-tag-box"
    }, {
      children: [handTitle(), jsx("div", Object.assign({
        className: "content"
      }, {
        children: handDetailTagContent()
      }))]
    }));
  };
  var handClass = function handClass() {
    var str = $prefixCls + '-selector-data';
    if (layout) str += " ".concat($prefixCls, "-selector-data-").concat(layout);
    if (disabled === true) str += " ".concat($prefixCls, "-selector-data-disabled");
    if (className) str += ' ' + className;
    return str;
  };
  return jsx("div", Object.assign({
    className: handClass(),
    style: style
  }, {
    children: layout === 'node' ? handContentNode() : handContentTag()
  }));
};

/**
 * 发送请求
 * @param obj {ReqFuncProps} 请求信息
 */
var reqFunc = function reqFunc(obj) {
  var method = obj.method,
    data = obj.data,
    otherProps = __rest(obj, ["method", "data"]);
  if (method === 'Get') {
    return Get(Object.assign({
      params: data
    }, otherProps));
  }
  if (method === 'Post') {
    return Post(Object.assign({
      data: data
    }, otherProps));
  }
};

var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-selector {\n  border: 1px solid rgba(171, 176, 185, 0.4);\n  border-radius: 4px;\n  display: flex;\n  height: 100%;\n  width: 100%;\n}\n.paraui-v3-selector svg {\n  overflow: hidden;\n}\n.paraui-v3-selector.paraui-v3-selector-lr > .paraui-v3-selector-main {\n  width: 50%;\n}\n.paraui-v3-selector.paraui-v3-selector-lr > .paraui-v3-selector-data {\n  width: 50%;\n  border-left: 1px solid rgba(171, 176, 185, 0.4);\n}\n.paraui-v3-selector.paraui-v3-selector-tb {\n  flex-direction: column;\n}\n.paraui-v3-selector.paraui-v3-selector-tb > .paraui-v3-selector-data {\n  border-bottom: 1px solid rgba(171, 176, 185, 0.4);\n  max-height: 106px;\n}\n.paraui-v3-selector.paraui-v3-selector-tb > .paraui-v3-selector-main {\n  overflow-y: auto;\n  height: auto;\n  flex: 1;\n}";
styleInject(css_248z);

var handFieldConfig = function handFieldConfig(fieldConfig, rowKey) {
  var json = Object.assign({
    mainTitle: 'label',
    children: 'children',
    parentId: 'parentId',
    key: rowKey,
    type: 'type'
  }, fieldConfig);
  return json;
};
var Selector = function Selector(props) {
  var _useGlobalProps = useGlobalProps(props, 'Selector'),
    className = _useGlobalProps.className,
    style = _useGlobalProps.style,
    _useGlobalProps$rowKe = _useGlobalProps.rowKey,
    rowKey = _useGlobalProps$rowKe === void 0 ? 'key' : _useGlobalProps$rowKe,
    _useGlobalProps$layou = _useGlobalProps.layout,
    layout = _useGlobalProps$layou === void 0 ? 'lr' : _useGlobalProps$layou,
    _useGlobalProps$nodeM = _useGlobalProps.nodeMode,
    nodeMode = _useGlobalProps$nodeM === void 0 ? 'branch' : _useGlobalProps$nodeM,
    selectMode = _useGlobalProps.selectMode,
    refresh = _useGlobalProps.refresh,
    ctx = _useGlobalProps.ctx,
    url = _useGlobalProps.url,
    _useGlobalProps$metho = _useGlobalProps.method,
    method = _useGlobalProps$metho === void 0 ? 'Get' : _useGlobalProps$metho,
    value = _useGlobalProps.value,
    defaultValue = _useGlobalProps.defaultValue,
    data = _useGlobalProps.data,
    _useGlobalProps$pagin = _useGlobalProps.pagination,
    pagination = _useGlobalProps$pagin === void 0 ? false : _useGlobalProps$pagin,
    _useGlobalProps$size = _useGlobalProps.size,
    size = _useGlobalProps$size === void 0 ? 10 : _useGlobalProps$size,
    _useGlobalProps$isLaz = _useGlobalProps.isLazy,
    isLazy = _useGlobalProps$isLaz === void 0 ? false : _useGlobalProps$isLaz,
    _useGlobalProps$isAll = _useGlobalProps.isAllCheck,
    isAllCheck = _useGlobalProps$isAll === void 0 ? true : _useGlobalProps$isAll,
    disabled = _useGlobalProps.disabled,
    disabledChild = _useGlobalProps.disabledChild,
    detail = _useGlobalProps.detail,
    detailRender = _useGlobalProps.detailRender,
    backDataFieldConfig = _useGlobalProps.backDataFieldConfig,
    search = _useGlobalProps.search,
    searchPlaceholder = _useGlobalProps.searchPlaceholder,
    _useGlobalProps$searc = _useGlobalProps.searchTrigger,
    searchTrigger = _useGlobalProps$searc === void 0 ? 'onChange' : _useGlobalProps$searc,
    _useGlobalProps$bread = _useGlobalProps.breadcrumbs,
    breadcrumbs = _useGlobalProps$bread === void 0 ? true : _useGlobalProps$bread,
    breadcrumbsSeparator = _useGlobalProps.breadcrumbsSeparator,
    breadcrumbsHead = _useGlobalProps.breadcrumbsHead,
    _useGlobalProps$showb = _useGlobalProps.showbreadcrumbsHead,
    showbreadcrumbsHead = _useGlobalProps$showb === void 0 ? true : _useGlobalProps$showb,
    groupType = _useGlobalProps.groupType,
    _useGlobalProps$group = _useGlobalProps.groupRange,
    groupRange = _useGlobalProps$group === void 0 ? 'search' : _useGlobalProps$group,
    emptyProps = _useGlobalProps.emptyProps,
    selectRenderItem = _useGlobalProps.selectRenderItem,
    selectRender = _useGlobalProps.selectRender,
    onChange = _useGlobalProps.onChange,
    onSelect = _useGlobalProps.onSelect,
    onSearch = _useGlobalProps.onSearch,
    onRefresh = _useGlobalProps.onRefresh;
  var intl = useFormatMessage('Selector', localeJson);
  var fieldConfigHand = handFieldConfig(props.fieldConfig, rowKey); // 字段配置,对应数据字段
  var selectorFieldConfigHand = Object.assign(Object.assign({}, fieldConfigHand), backDataFieldConfig); // 选中值字段配置,对应数据字段
  var _useState = useState([]),
    _useState2 = _slicedToArray(_useState, 2),
    currentData = _useState2[0],
    setCurrentData = _useState2[1]; // 当前展示的数据
  var _useState3 = useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    loadMore = _useState4[0],
    setLoadMore = _useState4[1]; // 加载更多
  var _useState5 = useState([]),
    _useState6 = _slicedToArray(_useState5, 2),
    valueCom = _useState6[0],
    setValueCom = _useState6[1]; // 绑定的值
  var _useState7 = useState({}),
    _useState8 = _slicedToArray(_useState7, 2),
    valueJsonCom = _useState8[0],
    setValueJsonCom = _useState8[1]; // 绑定的值,json
  var _useState9 = useState([]),
    _useState10 = _slicedToArray(_useState9, 2),
    breadcrumbsList = _useState10[0],
    setBreadcrumbsList = _useState10[1]; // 面包屑
  var _useState11 = useState(false),
    _useState12 = _slicedToArray(_useState11, 2),
    searchLoading = _useState12[0],
    setSearchLoading = _useState12[1]; // 搜索loading
  var _useState13 = useState({
      val: ''
    }),
    _useState14 = _slicedToArray(_useState13, 2),
    searchVal = _useState14[0],
    setSearchVal = _useState14[1]; // 搜索值
  var _useState15 = useState([]),
    _useState16 = _slicedToArray(_useState15, 2),
    searchList = _useState16[0],
    setSearchList = _useState16[1]; // 搜索数据
  var _useState17 = useState(false),
    _useState18 = _slicedToArray(_useState17, 2),
    searchLoadMore = _useState18[0],
    setSearchLoadMore = _useState18[1]; // 是否显示搜索的加载更多按钮
  var _useState19 = useState(true),
    _useState20 = _slicedToArray(_useState19, 2),
    loadingCom = _useState20[0],
    setLoadingCom = _useState20[1];
  var _useState21 = useState(),
    _useState22 = _slicedToArray(_useState21, 2),
    refreshCom = _useState22[0],
    setRefreshCom = _useState22[1];
  var constData = useRef({
    /** 对象集合 所有的 */
    jsonData: {},
    /** 浅拷贝对象 所有的 */
    jsonDataCopy: {},
    /** 第一层数据 */
    oneDataList: [],
    /** 当前页数据源 本地数据为当前页所有的数据,请求数据为当前展示的数据 */
    currentSourceData: [],
    /** 当前选中值的mapping */
    selectValueJson: {},
    /** 面包屑数据 带根/搜索 */
    breadcrumbsList: [],
    /** 接口id */
    reqId: Math.random().toString(),
    /** 请求数据 */
    reqParams: {
      size: 10,
      pagination: false,
      isLazy: false
    },
    /** 不是懒加载, 是否请求过 */
    noLazyReq: false,
    /** 更改数据定时器 */
    reqTimer: null,
    /** 页数 */
    page: 1,
    /** 搜索值 */
    searchVal: '',
    /** 搜索点了下级,记录搜索前的面包屑,null说明没有储存过 */
    beforeSearchBreadcrumbs: null,
    /** 搜索配置 */
    searchConfig: {
      page: 1,
      size: 10,
      reqId: Math.random().toString(),
      /** 当前页数据源 本地数据为当前页所有的数据,请求数据为当前展示的数据 */
      currentSourceData: []
    }
  }); // 常量
  constData.current.reqParams.size = size;
  constData.current.reqParams.pagination = pagination;
  constData.current.reqParams.isLazy = isLazy;
  // 本地数据 有接口的全量数据 -> 走本地数据逻辑
  var isReqLocalData = props.data || !constData.current.reqParams.isLazy && constData.current.noLazyReq;
  useEffect(function () {
    if (defaultValue !== undefined) handValue(defaultValue);
    return function () {
      clearTimeout(constData.current.reqTimer);
    };
  }, []);
  useEffect(function () {
    if (value !== undefined) handValue(value);
  }, [value]);
  // 处理源数据
  useEffect(function () {
    if (data) {
      var treeData = convertTree(data, false);
      constData.current.oneDataList = treeData;
      constData.current.currentSourceData = treeData;
      setBreadcrumbsList([]);
      handInitCurrent();
    }
  }, [data]);
  useEffect(function () {
    if (url) {
      setBreadcrumbsList([]);
      handInitCurrent();
    }
  }, [url]);
  // 请求数据
  useEffect(function () {
    clearTimeout(constData.current.reqTimer);
    if (props.url) Cancel(constData.current.reqId);
    constData.current.reqTimer = setTimeout(function () {
      // 本地数据 不是懒加载的全量接口数据
      if (isReqLocalData) {
        var currentSourceData = constData.current.currentSourceData;
        if (constData.current.reqParams.pagination) {
          // 分页
          var sliceData = currentSourceData.slice(0, constData.current.page * constData.current.reqParams.size);
          setCurrentData(sliceData);
          // 没有加载更多
          if (constData.current.page * constData.current.reqParams.size >= currentSourceData.length) {
            setLoadMore(false);
          } else {
            setLoadMore(true);
          }
        } else {
          // 不分页
          setCurrentData(currentSourceData);
        }
        setLoadingCom(false);
      }
      // 远程数据
      if (props.url) {
        var obj = {
          method: method,
          url: props.url,
          ctx: ctx,
          uuid: constData.current.reqId,
          data: Object.assign({
            parentId: handParentId()
          }, props.params)
        };
        // 懒加载
        if (constData.current.reqParams.isLazy) {
          // 分页
          if (constData.current.reqParams.pagination) {
            obj.data.size = constData.current.reqParams.size;
            obj.data.page = constData.current.page;
          }
          handReq(props.paramsCallback ? props.paramsCallback(obj) : obj);
        } else {
          // 不是懒加载 全量数据 只请求一次
          if (!constData.current.noLazyReq) handReq(props.paramsCallback ? props.paramsCallback(obj) : obj);
        }
      }
    }, 50);
  }, [refreshCom]);
  useEffect(function () {
    if (refresh) refreshFunc();
  }, [refresh]);
  /** 刷新 */
  var refreshFunc = function refreshFunc() {
    if (!isReqLocalData) {
      constData.current.currentSourceData = [];
    }
    handInitCurrent();
  };
  /**
   * 处理节点数据
   * @param item 节点数据
   * @param bol 是否是搜索
   * */
  var handNodeData = function handNodeData(item, bol) {
    var itemData = {
      key: item[rowKey],
      parentId: item[fieldConfigHand.parentId],
      type: item[fieldConfigHand.type],
      img: item[fieldConfigHand.img],
      mainTitle: item[fieldConfigHand.mainTitle],
      subTitle: item[fieldConfigHand.subTitle],
      tag: item[fieldConfigHand.tag],
      children: [],
      disabled: false,
      disabledChild: false,
      choice: selectMode !== undefined,
      detail: detail,
      leaf: nodeMode === 'leaf',
      //child: false,
      data: item
    };
    // 如果外部存在节点回调
    if (props.handNodeInfo) itemData = props.handNodeInfo(itemData, bol);
    return itemData;
  };
  /**
   * 转换树结构 记录原始数据,跟处理过的数据
   * @param arr 数据源
   * @param notTree true不生成树
   * @param isSearch 是否搜索
   * */
  var convertTree = function convertTree(arr, notTree, isSearch) {
    var handArr = [];
    var json = {};
    // 生成mappingd对象
    var recurrence = function recurrence(list) {
      for (var i = 0, l = list.length; i < l; i++) {
        var item = list[i];
        var keyStr = item[rowKey];
        var itemData = handNodeData(item, !!isSearch);
        json[keyStr] = itemData;
        var childrenName = fieldConfigHand.children;
        constData.current.jsonDataCopy[keyStr] = item; // 原始数据
        constData.current.jsonData[keyStr] = itemData; // 处理过的数据
        if (item[childrenName]) {
          recurrence(item[childrenName]);
        }
      }
    };
    recurrence(arr);
    // 生成tree数据
    var arrKey = Object.keys(json);
    for (var i = 0, l = arrKey.length; i < l; i++) {
      var keyStr = arrKey[i];
      var item = json[keyStr];
      var parentId = item.parentId || '';
      if (notTree) {
        handArr.push(item);
        continue;
      }
      if (parentId && json[parentId]) {
        if (!json[parentId].children) json[parentId].children = [];
        json[parentId].children.push(item);
      } else {
        handArr.push(item);
      }
    }
    return handArr;
  };
  /** 处理parentId */
  var handParentId = function handParentId() {
    var parentId;
    // 面包屑最后一项做parent
    if (constData.current.breadcrumbsList.length > 0) {
      // 包含了根,所以要多加1
      var item = constData.current.breadcrumbsList[constData.current.breadcrumbsList.length - 1];
      parentId = item.value;
    } else {
      if (props.breadcrumbsHead) parentId = props.breadcrumbsHead.value; // 根
    }
    // 显示首级, 面包屑只有一层, 拿首级
    if (showbreadcrumbsHead && constData.current.breadcrumbsList.length === 1) {
      parentId = undefined;
      if (props.breadcrumbsHead) parentId = props.breadcrumbsHead.value; // 根
    }

    return parentId;
  };
  /** 请求 */
  var handReq = function handReq(obj) {
    return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
      var _yield$reqFunc, data, err;
      return regenerator.wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            setLoadingCom(true);
            _context.next = 3;
            return reqFunc(obj);
          case 3:
            _yield$reqFunc = _context.sent;
            data = _yield$reqFunc.data;
            err = _yield$reqFunc.err;
            if (!err) {
              _context.next = 10;
              break;
            }
            setLoadingCom(false);
            if (constData.current.reqParams.isLazy) {
              // 懒加载
              if (constData.current.reqParams.pagination) {
                // 分页 第一页不处理
                if (constData.current.page !== 1) constData.current.page = constData.current.page - 1;
              }
            }
            return _context.abrupt("return");
          case 10:
            if (!props.requestCallback) {
              _context.next = 13;
              break;
            }
            props.requestCallback(data, function (handData) {
              setLoadingCom(false);
              handReqData(handData);
            });
            return _context.abrupt("return");
          case 13:
            setLoadingCom(false);
            handReqData(data);
          case 15:
          case "end":
            return _context.stop();
        }
      }, _callee);
    }));
  };
  /** 接口回来处理数据 */
  var handReqData = function handReqData(resultData) {
    if (constData.current.reqParams.isLazy) {
      // 懒加载
      if (constData.current.reqParams.pagination) {
        // 分页
        var result = resultData.data || {};
        var arr = result.list || [];
        var total = result.total;
        var arrHand = convertTree(arr, true);
        var currentD = [].concat(_toConsumableArray(constData.current.currentSourceData), _toConsumableArray(arrHand));
        constData.current.currentSourceData = currentD;
        setCurrentData(currentD);
        if (constData.current.page * constData.current.reqParams.size >= total) {
          setLoadMore(false);
        } else {
          setLoadMore(true);
        }
      } else {
        // 不分页 必须返回平铺的数组
        var _arr = resultData.data || [];
        var treeData = convertTree(_arr, true);
        constData.current.currentSourceData = treeData;
        setCurrentData(treeData);
      }
    } else {
      // 不是懒加载 只请求一次
      constData.current.noLazyReq = true;
      var _arr2 = resultData.data || [];
      var _treeData = convertTree(_arr2, false);
      constData.current.oneDataList = _treeData; // 第一层数据
      constData.current.currentSourceData = _treeData;
      handInitCurrent();
    }
  };
  /** 当前页初始更新 */
  var handInitCurrent = function handInitCurrent() {
    constData.current.page = 1;
    setRefreshCom(Math.random());
  };
  /** 处理value */
  var handValue = function handValue(val) {
    var handVal = !val ? [] : [val];
    if (val instanceof Array) {
      handVal = _toConsumableArray(val);
    }
    var json = ArrayToObject(selectorFieldConfigHand.key, handVal);
    constData.current.selectValueJson = json;
    setValueJsonCom(json);
    setValueCom(_toConsumableArray(handVal));
  };
  /** 点击下级,添加面包屑 */
  var onLevelAddBreadcrumbs = function onLevelAddBreadcrumbs(item, isSearch) {
    var arr = _toConsumableArray(breadcrumbsList);
    if (isSearch) {
      arr = [];
      if (constData.current.beforeSearchBreadcrumbs === null) {
        // 记录搜索之前的面包屑
        constData.current.beforeSearchBreadcrumbs = _toConsumableArray(breadcrumbsList);
      }
    }
    arr.push({
      label: item.mainTitle,
      value: item.key || ''
    });
    setBreadcrumbsList(arr);
  };
  /** 点击下级 */
  var onLevelCom = function onLevelCom(item, isSearch) {
    onLevelAddBreadcrumbs(item, isSearch);
    if (isReqLocalData) {
      // 本地数据
      constData.current.currentSourceData = item.children || [];
      handInitCurrent();
    } else {
      // 请求数据
      if (constData.current.reqParams.isLazy) {
        // 懒加载
        if (constData.current.reqParams.pagination) {
          // 分页
          constData.current.currentSourceData = [];
        }
        handInitCurrent();
      }
    }
  };
  /** 处理抛出去的数据 */
  var handEmitValue = function handEmitValue(item) {
    var arr = ['key', 'img', 'mainTitle', 'subTitle', 'tag'];
    if (props.groupType && props.groupType.length > 0) {
      arr.push('type');
    }
    var json = {};
    for (var i = 0, l = arr.length; i < l; i++) {
      var arrItem = arr[i];
      var name = selectorFieldConfigHand[arrItem];
      if (name) json[name] = item[arrItem];
    }
    return json;
  };
  /**
   * 向外触发onchane事件
   * @param val 向外抛的值
   * @param valCom 设置组件的值
   * @param node 处理过的节点数据
   * @param rowData 原始数据节点
   * */
  var onChangeEmit = function onChangeEmit(val, valCom, node, rowData) {
    onChange && onChange(val, node, rowData);
    if (value == undefined) {
      handValue(!val ? [] : val);
    }
  };
  /** 选择数据 */
  var onSelectCom = function onSelectCom(item) {
    return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee2() {
      var keyStr, selectVal, bol, json, arr, node, rowData, i, l, valueComItem, valueComItemId, _json;
      return regenerator.wrap(function _callee2$(_context2) {
        while (1) switch (_context2.prev = _context2.next) {
          case 0:
            keyStr = item.key || ''; // key
            // 单选且选中,点击不触发
            if (!(selectMode === 'radio' && valueJsonCom[keyStr])) {
              _context2.next = 3;
              break;
            }
            return _context2.abrupt("return");
          case 3:
            selectVal = constData.current.selectValueJson[keyStr]; // 存在选中值当中 -> 选中变不选中
            if (!onSelect) {
              _context2.next = 10;
              break;
            }
            _context2.next = 7;
            return onSelect(item, selectMode === 'radio' ? true : !selectVal, false);
          case 7:
            bol = _context2.sent;
            if (!bol) {
              _context2.next = 10;
              break;
            }
            return _context2.abrupt("return");
          case 10:
            // 单选
            if (selectMode === 'radio') {
              json = handEmitValue(item);
              onChangeEmit(json, [json], constData.current.jsonData[keyStr], constData.current.jsonDataCopy[keyStr]);
            }
            // 多选
            if (selectMode === 'check') {
              arr = [];
              node = {}; // 处理过得数据
              rowData = {}; // 原始数据
              // 把即将不选中的值,从valueCom里面拿掉
              for (i = 0, l = valueCom.length; i < l; i++) {
                valueComItem = valueCom[i]; // 选中valueCom都保留
                // 不选中 保留valueCom里面的key不等于当前的key
                if (!selectVal || item.key !== valueComItem[selectorFieldConfigHand.key]) {
                  valueComItemId = valueComItem[selectorFieldConfigHand.key];
                  node[valueComItemId] = constData.current.jsonData[valueComItemId];
                  rowData[valueComItemId] = constData.current.jsonDataCopy[valueComItemId];
                  arr.push(valueComItem);
                }
              }
              // 不选中 -> 选中
              if (!selectVal) {
                _json = handEmitValue(item);
                node[keyStr] = constData.current.jsonData[keyStr];
                rowData[keyStr] = constData.current.jsonDataCopy[keyStr];
                arr.push(_json);
              }
              onChangeEmit(arr, arr, node, rowData);
            }
          case 12:
          case "end":
            return _context2.stop();
        }
      }, _callee2);
    }));
  };
  /** 处理禁用状态 */
  var handDisabled = function handDisabled(item) {
    if (disabled) {
      if (disabled === true) return true;
      if (disabled instanceof Array) {
        if (item.key && disabled.indexOf(item.key) !== -1) {
          return true;
        }
      }
    }
    if (item.disabled) return true;
    return false;
  };
  /**
   * 点击全选
   * @param bol true全选
   * */
  var onAllCheckCom = function onAllCheckCom(bol) {
    return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee3() {
      var arrList, arrVal, arrval1, node, rowData, selectArr, selectEmitData, i, l, item, keyStr, disabledItem, _i, _l, _item, _keyStr, emitArr, flag;
      return regenerator.wrap(function _callee3$(_context3) {
        while (1) switch (_context3.prev = _context3.next) {
          case 0:
            arrList = _toConsumableArray(currentData); // 当前列的数据
            arrVal = _toConsumableArray(valueCom); // 全选 绑定的值
            arrval1 = []; // 全不选 绑定的值
            node = {}; // 处理过得数据
            rowData = {}; // 原始数据
            selectArr = []; // 全不选 - 当前列选中值
            selectEmitData = []; // 选择事件抛出去的值
            // 循环当前列数据
            i = 0, l = arrList.length;
          case 8:
            if (!(i < l)) {
              _context3.next = 18;
              break;
            }
            item = arrList[i];
            keyStr = item.key || '';
            disabledItem = handDisabled(item);
            if (!disabledItem) {
              _context3.next = 14;
              break;
            }
            return _context3.abrupt("continue", 15);
          case 14:
            if (bol) {
              // 全选
              if (!constData.current.selectValueJson[keyStr]) {
                // 不存在选中值中
                arrVal.push(handEmitValue(item));
                selectEmitData.push(item);
              }
            } else {
              // 全不选
              if (constData.current.selectValueJson[keyStr]) {
                // 存在选中值中,拿掉
                selectArr.push(keyStr);
                selectEmitData.push(item);
              }
            }
          case 15:
            i++;
            _context3.next = 8;
            break;
          case 18:
            for (_i = 0, _l = arrVal.length; _i < _l; _i++) {
              _item = arrVal[_i];
              _keyStr = _item[selectorFieldConfigHand.key];
              if (bol) {
                // 全选
                node[_keyStr] = constData.current.jsonData[_keyStr];
                rowData[_keyStr] = constData.current.jsonDataCopy[_keyStr];
              } else {
                // 全不选
                if (selectArr.indexOf(_keyStr) === -1) {
                  // 不存在 全不选 - 当前列选中值
                  node[_keyStr] = constData.current.jsonData[_keyStr];
                  rowData[_keyStr] = constData.current.jsonDataCopy[_keyStr];
                  arrval1.push(_item);
                }
              }
            }
            emitArr = bol ? arrVal : arrval1;
            if (!onSelect) {
              _context3.next = 26;
              break;
            }
            _context3.next = 23;
            return onSelect(selectEmitData, !!bol, false);
          case 23:
            flag = _context3.sent;
            if (!flag) {
              _context3.next = 26;
              break;
            }
            return _context3.abrupt("return");
          case 26:
            onChangeEmit(emitArr, emitArr, node, rowData);
          case 27:
          case "end":
            return _context3.stop();
        }
      }, _callee3);
    }));
  };
  /** 点击查看更多 */
  var onLoadCom = function onLoadCom(isSearch) {
    if (isSearch) {
      // 搜索
      constData.current.searchConfig.page = constData.current.searchConfig.page + 1;
      reqSearch();
      return;
    }
    constData.current.page = constData.current.page + 1;
    setRefreshCom(Math.random());
  };
  /** 处理面包屑数组 */
  var handBreadcrumbsList = function handBreadcrumbsList() {
    var arr = _toConsumableArray(breadcrumbsList);
    // 根路径
    var oneItem = breadcrumbsHead || {
      label: intl({
        id: 'root'
      }),
      value: '_paraui_first_floor'
    };
    // 具有搜索结果的上下级
    if (constData.current.searchVal) {
      arr.unshift({
        label: props.searchBreadcrumbs ? props.searchBreadcrumbs : intl({
          id: 'searchResult'
        }),
        value: '_paraui_search'
      });
    }
    if (showbreadcrumbsHead) arr.unshift(oneItem);
    constData.current.breadcrumbsList = arr;
    return arr;
  };
  /** 截取面包屑数据 */
  var spliceBreadcrumbs = function spliceBreadcrumbs(item) {
    var arr = [];
    for (var i = 0, l = breadcrumbsList.length; i < l; i++) {
      var itemB = breadcrumbsList[i];
      arr.push(itemB);
      if (itemB.value === item.value) {
        break;
      }
    }
    return arr;
  };
  /** 点击面包屑 */
  var onClickBreadcrumbsCom = function onClickBreadcrumbsCom(item) {
    var list = constData.current.breadcrumbsList;
    // 点击最后一层,不触发数据变更
    if (list.length === 0 || item.value === list[list.length - 1].value) {
      return;
    }
    var keyStr = item.value || '';
    var oneValue = breadcrumbsHead ? breadcrumbsHead.value : '_paraui_first_floor';
    // 点击搜索结果,显示上一次的搜索
    if (item.value === '_paraui_search') {
      setSearchVal({
        val: constData.current.searchVal
      });
      setBreadcrumbsList(_toConsumableArray(constData.current.beforeSearchBreadcrumbs || []));
      return;
    }
    // 点击根路径且具有搜索面包屑
    if (constData.current.beforeSearchBreadcrumbs && item.value === oneValue) {
      // 清空搜索态
      constData.current.searchVal = '';
      constData.current.beforeSearchBreadcrumbs = null;
      setSearchVal({
        val: ''
      });
      handBreadcrumbsList();
    }
    // 设置面包屑
    if (keyStr === oneValue) {
      // 第一层
      setBreadcrumbsList([]);
    } else {
      // 除了第一级,最后一级
      setBreadcrumbsList(spliceBreadcrumbs(item));
    }
    if (isReqLocalData) {
      if (keyStr === oneValue) {
        // 第一层
        constData.current.currentSourceData = _toConsumableArray(constData.current.oneDataList);
      } else {
        // 除了第一级,最后一级
        var itemData = constData.current.jsonData[keyStr];
        constData.current.currentSourceData = itemData[fieldConfigHand.children];
      }
    } else {
      // 请求数据
      if (constData.current.reqParams.isLazy) {
        // 懒加载
        if (constData.current.reqParams.pagination) {
          // 分页
          constData.current.currentSourceData = [];
        }
      }
    }
    handInitCurrent();
  };
  /** 处理搜索的请求 */
  var handSearchData = function handSearchData(resultData) {
    var isTree = resultData.isTree;
    if (constData.current.reqParams.pagination) {
      // 分页
      var result = resultData.data || {};
      var arr = result.list || [];
      var total = result.total;
      var arrHand = convertTree(arr, !isTree, true); // 搜索默认不生成树
      var currentD = [].concat(_toConsumableArray(constData.current.searchConfig.currentSourceData), _toConsumableArray(arrHand));
      constData.current.searchConfig.currentSourceData = currentD;
      setSearchList(currentD);
      if (constData.current.searchConfig.page * constData.current.searchConfig.size >= total) {
        setSearchLoadMore(false);
      } else {
        setSearchLoadMore(true);
      }
    } else {
      // 不分页 必须返回平铺的数组
      var _arr3 = resultData.data || [];
      var treeData = convertTree(_arr3, !isTree, true); // 搜索默认不生成树
      constData.current.searchConfig.currentSourceData = treeData;
      setSearchList(treeData);
    }
  };
  /** 处理搜索接口 */
  var handReqSearchResult = function handReqSearchResult(result) {
    var data = result.data,
      err = result.err;
    if (err) {
      setSearchLoading(false);
      if (constData.current.reqParams.pagination) {
        // 分页 第一页不处理
        if (constData.current.searchConfig.page !== 1) constData.current.searchConfig.page = constData.current.searchConfig.page - 1;
      }
      return;
    }
    if (props.requestCallback) {
      props.requestCallback(data, function (handData) {
        setSearchLoading(false);
        handSearchData(handData);
      }, true);
      return;
    }
    setSearchLoading(false);
    handSearchData(data);
  };
  /** 搜索请求 */
  var reqSearch = function reqSearch() {
    return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee4() {
      var _a, reqParams, _result, obj, result;
      return regenerator.wrap(function _callee4$(_context4) {
        while (1) switch (_context4.prev = _context4.next) {
          case 0:
            if (!onSearch) {
              _context4.next = 8;
              break;
            }
            reqParams = {};
            if (constData.current.reqParams.pagination) {
              reqParams.size = constData.current.searchConfig.size;
              reqParams.page = constData.current.searchConfig.page;
            }
            _context4.next = 5;
            return onSearch(constData.current.searchVal, reqParams);
          case 5:
            _result = _context4.sent;
            handReqSearchResult(_result);
            return _context4.abrupt("return");
          case 8:
            obj = {
              method: method,
              url: props.url || '',
              ctx: ctx,
              uuid: constData.current.reqId,
              data: Object.assign({
                searchKey: (_a = constData.current.searchVal) === null || _a === void 0 ? void 0 : _a.trim()
              }, props.params)
            };
            if (constData.current.reqParams.pagination) {
              obj.data.size = constData.current.searchConfig.size;
              obj.data.page = constData.current.searchConfig.page;
            }
            obj = props.paramsCallback ? props.paramsCallback(obj, true) : obj;
            _context4.next = 13;
            return reqFunc(obj);
          case 13:
            result = _context4.sent;
            handReqSearchResult(result);
          case 15:
          case "end":
            return _context4.stop();
        }
      }, _callee4);
    }));
  };
  /**
   * 递归寻找子级
   * */
  var convertChild = function convertChild(id, arr) {
    var arrHnad = arr;
    var recurrence = function recurrence(arrItem) {
      for (var i = 0, l = arrItem.length; i < l; i++) {
        var item = arrItem[i];
        var rowId = item[rowKey];
        var arrChild = item.children || [];
        if (rowId === id) {
          arrHnad = arrChild;
          return;
        }
        recurrence(arrChild);
      }
    };
    recurrence(arr);
    return arrHnad;
  };
  /** 搜索回调
   * @param bol 搜索框为空的情况下,触发搜索
   * */
  var onSearchCom = function onSearchCom(val, bol) {
    return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee5() {
      var parentId, arr;
      return regenerator.wrap(function _callee5$(_context5) {
        while (1) switch (_context5.prev = _context5.next) {
          case 0:
            setSearchLoading(true);
            constData.current.searchVal = val;
            if (!(val === '')) {
              _context5.next = 8;
              break;
            }
            setSearchList([]);
            setSearchLoading(false);
            if (constData.current.beforeSearchBreadcrumbs) {
              // 从搜索恢复到正常列表
              constData.current.breadcrumbsList = _toConsumableArray(constData.current.beforeSearchBreadcrumbs);
              setBreadcrumbsList(_toConsumableArray(constData.current.beforeSearchBreadcrumbs));
              constData.current.beforeSearchBreadcrumbs = null;
              if (isReqLocalData) {
                // 本地全量数据
                // 搜索点过下级,修改了当前显示的数据
                // 从搜索恢复到正常列表, 需要从原始数据,取出当前层级对应的数据
                parentId = handParentId();
                arr = convertChild(parentId, constData.current.oneDataList);
                constData.current.currentSourceData = arr;
              }
              refreshFunc();
            }
            if (bol) {
              // 当前页刷新
              refreshFunc();
              onRefresh && onRefresh();
            }
            return _context5.abrupt("return");
          case 8:
            constData.current.searchConfig.page = 1;
            constData.current.searchConfig.currentSourceData = [];
            reqSearch();
          case 11:
          case "end":
            return _context5.stop();
        }
      }, _callee5);
    }));
  };
  /** 删除数据 */
  var onCloseCom = function onCloseCom(item, index) {
    if (selectMode === 'radio') {
      onChangeEmit(null, [], {}, {});
    }
    if (selectMode === 'check') {
      var arr = _toConsumableArray(valueCom);
      arr.splice(index, 1);
      var node = {}; // 处理过得数据
      var rowData = {}; // 原始数据
      for (var i = 0, l = arr.length; i < l; i++) {
        var _item2 = arr[i];
        var keyStr = _item2[selectorFieldConfigHand.key];
        node[keyStr] = constData.current.jsonData[keyStr];
        rowData[keyStr] = constData.current.jsonDataCopy[keyStr];
      }
      onChangeEmit(arr, arr, node, rowData);
    }
  };
  /** 处理返回数据dom配置 */
  var handSelectorData = function handSelectorData() {
    return jsx(SelectorData, {
      layout: layout === 'tb' ? 'tag' : 'node',
      backDataFieldConfig: selectorFieldConfigHand,
      groupType: groupType,
      handSelectorNodeInfo: props.handSelectorNodeInfo,
      list: valueCom,
      nodeMode: nodeMode,
      detail: detail,
      detailRender: detailRender,
      emptyProps: emptyProps,
      onClose: onCloseCom,
      selectDataTitleRender: props.selectDataTitleRender,
      selectRenderItem: selectRenderItem,
      selectRender: selectRender,
      disabled: disabled
    });
  };
  // 处理className
  var handClass = function handClass() {
    var str = "".concat($prefixCls, "-selector");
    if (className) str += ' ' + className;
    if (layout) str += " ".concat($prefixCls, "-selector-").concat(layout);
    if (selectMode) str += " ".concat($prefixCls, "-selector-").concat(selectMode);
    if (disabled === true) str += " ".concat($prefixCls, "-selector-disabled");
    return str;
  };
  return jsxs("div", Object.assign({
    className: handClass(),
    style: style
  }, {
    children: [layout === 'tb' && handSelectorData(), jsx(SelectorMain, {
      url: url,
      rowKey: rowKey,
      value: valueJsonCom,
      loadMore: loadMore,
      isAllCheck: isAllCheck,
      list: currentData,
      groupType: groupType,
      groupRange: groupRange,
      fieldConfig: fieldConfigHand,
      nodeMode: nodeMode,
      selectMode: selectMode,
      isLazy: isLazy,
      detail: detail,
      detailRender: detailRender,
      search: search,
      searchTrigger: searchTrigger,
      searchPlaceholder: searchPlaceholder,
      searchLoading: searchLoading,
      searchVal: searchVal,
      disabled: disabled,
      disabledChild: disabledChild,
      loading: loadingCom,
      searchLoadMore: searchLoadMore,
      searchList: searchList,
      breadcrumbs: breadcrumbs,
      breadcrumbsSeparator: breadcrumbsSeparator,
      breadcrumbsList: handBreadcrumbsList(),
      emptyProps: emptyProps,
      onLevel: onLevelCom,
      onSelect: onSelectCom,
      onLoad: onLoadCom,
      onAllCheck: onAllCheckCom,
      onClickBreadcrumbs: onClickBreadcrumbsCom,
      onSearch: onSearchCom,
      onRefresh: onRefresh
    }), layout === 'lr' && handSelectorData()]
  }));
};

export { Selector as default, handFieldConfig };
