function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
/**
 * Pro 版资源选择 Modal
 * - 顶部：使用 `PisellTabbarTemplate1` 替换搜索 + 类别筛选
 * - 列表：使用 `Selector` (`@pisell/private-materials/pro/Selector`) 替换 checkbox 列表
 * - Props 与 `FloorMapResourcePickerSlotProps` 兼容，可作为 PisellFloorMapLayout
 *   `renderResourcePickerModal` 槽位实现（通用基础 modal 已下线，统一由此组件承担）
 */
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import classNames from 'classnames';
import { Button, Checkbox } from 'antd';
import { locales } from '@pisell/utils';
import { PisellFind, floorMapLayoutLocales } from '@pisell/materials';
import CompensatedPisellContainer from "../../pro/compensatedPisellContainer";
import Selector from "../../pro/Selector";
import useEngineContext from "../../hooks/useEngineContext";
import { buildTabbarDataSourceFromRecords, defaultGetSearchText, matchesSelection } from "./utils";
import "./PisellProResourcePickerModal.less";
var PREFIX = 'pisell-pro-resource-picker';
var I18N_RP = 'pisell-floor-map-layout.resource-picker';
/**
 * 通用默认卡片 meta：仅依赖 record.title/name + record.subtitle/desc 等常见字段，
 * 不引入业务专属（如 floor map 的人数 badge）。业务场景请显式传 `getCardMeta`。
 */
function defaultGetCardMeta(record) {
  var _ref, _ref2, _ref3, _record$title, _ref4, _record$subtitle;
  var titleRaw = (_ref = (_ref2 = (_ref3 = (_record$title = record.title) !== null && _record$title !== void 0 ? _record$title : record.name) !== null && _ref3 !== void 0 ? _ref3 : record.label) !== null && _ref2 !== void 0 ? _ref2 : record.id) !== null && _ref !== void 0 ? _ref : '';
  var subtitleRaw = (_ref4 = (_record$subtitle = record.subtitle) !== null && _record$subtitle !== void 0 ? _record$subtitle : record.desc) !== null && _ref4 !== void 0 ? _ref4 : record.description;
  var subtitle = subtitleRaw == null ? '' : String(subtitleRaw).trim();
  return {
    title: String(titleRaw).trim(),
    subtitles: subtitle ? [subtitle] : []
  };
}
function formatSelectedCount(count, total) {
  return locales.getText("".concat(I18N_RP, ".selected-count")).replace('{count}', String(count)).replace('{total}', String(total));
}
/**
 * `PisellTabbarTemplate1` 内部会注入以下非分类的特殊按钮：
 * - `level1`: `search` (id=-1) + `all` (id='0')
 * - `level2/3`: `expand` (id=-2) + `all` (id='0')
 * 它们不是真实分类 key，落到 selection 时需还原为 null（不参与过滤），
 * 等价于「显示全部」。
 */
var TABBAR_NON_CATEGORY_IDS = new Set(['-1', '-2', '0']);
function tabbarValueToSelection(value) {
  var out = [null, null, null];
  if (!value) return out;
  for (var i = 0; i < 3; i++) {
    var seg = value[i];
    if (seg == null || seg === '') continue;
    out[i] = String(seg);
  }
  return out;
}
function normalizeIds(value) {
  if (!value) return [];
  return value.map(function (v) {
    return String(v !== null && v !== void 0 ? v : '').trim();
  }).filter(Boolean);
}
export function PisellProResourcePickerModal(props) {
  var _ref5, _engine$props;
  var open = props.open,
    onClose = props.onClose,
    onConfirm = props.onConfirm,
    records = props.records,
    _props$mode = props.mode,
    mode = _props$mode === void 0 ? 'multiple' : _props$mode,
    value = props.value,
    title = props.title,
    disabledIds = props.disabledIds,
    categoryConfig = props.categoryConfig,
    getSearchText = props.getSearchText,
    getCardMeta = props.getCardMeta,
    renderCard = props.renderCard,
    renderFilterBar = props.renderFilterBar,
    _props$selectorValueT = props.selectorValueType,
    selectorValueType = _props$selectorValueT === void 0 ? 'primitive' : _props$selectorValueT,
    _props$selectorShowSt = props.selectorShowStepper,
    selectorShowStepper = _props$selectorShowSt === void 0 ? 'auto' : _props$selectorShowSt,
    getOptionRuleConfig = props.getOptionRuleConfig,
    _props$zIndex = props.zIndex,
    zIndex = _props$zIndex === void 0 ? 1100 : _props$zIndex,
    _props$width = props.width,
    width = _props$width === void 0 ? 880 : _props$width,
    className = props.className,
    _props$platform = props.platform,
    platform = _props$platform === void 0 ? 'pc' : _props$platform;
  var isObjectMode = selectorValueType === 'object';
  var resolveCardMeta = getCardMeta !== null && getCardMeta !== void 0 ? getCardMeta : defaultGetCardMeta;
  var resolveSearchText = getSearchText !== null && getSearchText !== void 0 ? getSearchText : defaultGetSearchText;
  var disabledSet = useMemo(function () {
    return new Set((disabledIds !== null && disabledIds !== void 0 ? disabledIds : []).map(function (id) {
      return String(id);
    }));
  }, [disabledIds]);
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    keyword = _useState2[0],
    setKeyword = _useState2[1];
  /**
   * Tabbar 受控值；默认选中 `PisellTabbarTemplate1` 注入的 `all` 按钮（id='0'），
   * 视觉上有「全部」高亮反馈。`TABBAR_NON_CATEGORY_IDS` 会把 `0/-1/-2`
   * 还原为 null，等价于「不过滤」。切到真实分类后按分类 key 过滤。
   */
  var _useState3 = useState(['0']),
    _useState4 = _slicedToArray(_useState3, 2),
    tabbarValue = _useState4[0],
    setTabbarValue = _useState4[1];
  var _useState5 = useState([]),
    _useState6 = _slicedToArray(_useState5, 2),
    draftSelected = _useState6[0],
    setDraftSelected = _useState6[1];
  var _useState7 = useState([]),
    _useState8 = _slicedToArray(_useState7, 2),
    draftObjectValues = _useState8[0],
    setDraftObjectValues = _useState8[1];
  var prevOpenRef = useRef(false);
  var _useEngineContext = useEngineContext(),
    engine = _useEngineContext.engine;
  var engineLocale = (_ref5 = engine === null || engine === void 0 || (_engine$props = engine.props) === null || _engine$props === void 0 ? void 0 : _engine$props.locale) !== null && _ref5 !== void 0 ? _ref5 : 'zh-CN';

  /**
   * 生产低码产物中 `@pisell/utils` 在 BaseMaterials / PrivateMaterials 各有一份，
   * 须在本包 locales 单例上 init 文案表，不可调用 materials 内的 initFloorMapLayoutLocales。
   */
  useEffect(function () {
    if (open) {
      locales.init(floorMapLayoutLocales, engineLocale);
    }
  }, [open, engineLocale]);
  useEffect(function () {
    if (!open) {
      setKeyword('');
      setTabbarValue(['0']);
      prevOpenRef.current = false;
      return;
    }
    if (!prevOpenRef.current) {
      if (isObjectMode) {
        setDraftObjectValues([]);
      } else {
        setDraftSelected(normalizeIds(value));
      }
      prevOpenRef.current = true;
    }
  }, [open, value, isObjectMode]);
  var tabbarDataSource = useMemo(function () {
    return buildTabbarDataSourceFromRecords(records, categoryConfig);
  }, [records, categoryConfig]);
  var selection = useMemo(function () {
    var sel = tabbarValueToSelection(tabbarValue);
    return sel.map(function (s) {
      return s != null && TABBAR_NON_CATEGORY_IDS.has(s) ? null : s;
    });
  }, [tabbarValue]);
  var filterBarCtx = useMemo(function () {
    return {
      keyword: keyword,
      onKeywordChange: setKeyword,
      tabbarDataSource: tabbarDataSource,
      tabbarValue: tabbarValue,
      onTabbarValueChange: setTabbarValue
    };
  }, [keyword, tabbarDataSource, tabbarValue]);
  var filteredRecords = useMemo(function () {
    var q = keyword.trim().toLowerCase();
    return records.filter(function (record) {
      if (!matchesSelection(record, selection, categoryConfig)) return false;
      if (!q) return true;
      return resolveSearchText(record).includes(q);
    });
  }, [records, selection, categoryConfig, keyword, resolveSearchText]);
  var selectorOptions = useMemo(function () {
    return filteredRecords.map(function (record) {
      var _record$id;
      var id = String((_record$id = record.id) !== null && _record$id !== void 0 ? _record$id : '').trim();
      var meta = resolveCardMeta(record);
      return _objectSpread(_objectSpread({
        id: id,
        title: meta.title,
        label: meta.title,
        value: id,
        disabled: disabledSet.has(id)
      }, getOptionRuleConfig ? {
        ruleConfig: getOptionRuleConfig(record)
      } : {}), {}, {
        __record: record,
        __meta: meta
      });
    });
  }, [filteredRecords, disabledSet, resolveCardMeta, getOptionRuleConfig]);
  var selectableFilteredIds = useMemo(function () {
    return selectorOptions.map(function (o) {
      var _o$id;
      return String((_o$id = o.id) !== null && _o$id !== void 0 ? _o$id : '');
    }).filter(function (id) {
      return id && !disabledSet.has(id);
    });
  }, [selectorOptions, disabledSet]);

  /** 已选「种数」（有数量的条目数），非数量步进器之和 */
  var selectedKindCount = useMemo(function () {
    if (isObjectMode) {
      return draftObjectValues.filter(function (item) {
        return item.quantity > 0;
      }).length;
    }
    return draftSelected.length;
  }, [isObjectMode, draftObjectValues, draftSelected]);
  var allFilteredSelected = useMemo(function () {
    if (selectableFilteredIds.length === 0) return false;
    if (isObjectMode) {
      return selectableFilteredIds.every(function (id) {
        return draftObjectValues.some(function (x) {
          return x.value === id && x.quantity > 0;
        });
      });
    }
    return selectableFilteredIds.every(function (id) {
      return draftSelected.includes(id);
    });
  }, [isObjectMode, selectableFilteredIds, draftObjectValues, draftSelected]);
  var someFilteredSelected = useMemo(function () {
    if (isObjectMode) {
      return draftObjectValues.some(function (x) {
        return selectableFilteredIds.includes(x.value) && x.quantity > 0;
      });
    }
    return draftSelected.some(function (id) {
      return selectableFilteredIds.includes(id);
    });
  }, [isObjectMode, draftObjectValues, draftSelected, selectableFilteredIds]);
  var handleSelectAllFiltered = useCallback(function () {
    if (isObjectMode) {
      setDraftObjectValues(function (prev) {
        var map = new Map(prev.map(function (x) {
          return [x.value, x];
        }));
        var _iterator = _createForOfIteratorHelper(selectableFilteredIds),
          _step;
        try {
          for (_iterator.s(); !(_step = _iterator.n()).done;) {
            var id = _step.value;
            var existing = map.get(id);
            map.set(id, {
              value: id,
              quantity: existing !== null && existing !== void 0 && existing.quantity && existing.quantity > 0 ? existing.quantity : 1
            });
          }
        } catch (err) {
          _iterator.e(err);
        } finally {
          _iterator.f();
        }
        return _toConsumableArray(map.values()).filter(function (x) {
          return x.quantity > 0;
        });
      });
      return;
    }
    setDraftSelected(function (prev) {
      var set = new Set(prev);
      var _iterator2 = _createForOfIteratorHelper(selectableFilteredIds),
        _step2;
      try {
        for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
          var id = _step2.value;
          set.add(id);
        }
      } catch (err) {
        _iterator2.e(err);
      } finally {
        _iterator2.f();
      }
      return _toConsumableArray(set);
    });
  }, [isObjectMode, selectableFilteredIds]);
  var handleDeselectAllFiltered = useCallback(function () {
    if (mode === 'single') {
      if (isObjectMode) setDraftObjectValues([]);else setDraftSelected([]);
      return;
    }
    if (isObjectMode) {
      setDraftObjectValues(function (prev) {
        return prev.filter(function (x) {
          return !selectableFilteredIds.includes(x.value);
        });
      });
      return;
    }
    setDraftSelected(function (prev) {
      return prev.filter(function (id) {
        return !selectableFilteredIds.includes(id);
      });
    });
  }, [mode, isObjectMode, selectableFilteredIds]);
  var parseObjectSelection = useCallback(function (next) {
    if (next == null || next === '') return [];
    if (!Array.isArray(next)) {
      if (_typeof(next) === 'object' && next !== null && 'value' in next) {
        var _next$value, _next$quantity;
        var valueKey = String((_next$value = next.value) !== null && _next$value !== void 0 ? _next$value : '').trim();
        if (!valueKey) return [];
        return [{
          value: valueKey,
          quantity: Math.max(0, Math.floor(Number((_next$quantity = next.quantity) !== null && _next$quantity !== void 0 ? _next$quantity : 0)))
        }];
      }
      var primitive = String(next).trim();
      return primitive ? [{
        value: primitive,
        quantity: 1
      }] : [];
    }
    return next.map(function (v) {
      if (_typeof(v) === 'object' && v !== null && 'value' in v) {
        var _v$value, _v$quantity;
        return {
          value: String((_v$value = v.value) !== null && _v$value !== void 0 ? _v$value : '').trim(),
          quantity: Math.max(0, Math.floor(Number((_v$quantity = v.quantity) !== null && _v$quantity !== void 0 ? _v$quantity : 0)))
        };
      }
      var valueKey = String(v !== null && v !== void 0 ? v : '').trim();
      return valueKey ? {
        value: valueKey,
        quantity: 1
      } : null;
    }).filter(function (x) {
      return Boolean(x === null || x === void 0 ? void 0 : x.value);
    });
  }, []);
  var handleSelectorChange = useCallback(function (next) {
    if (isObjectMode) {
      setDraftObjectValues(parseObjectSelection(next).filter(function (x) {
        return x.quantity > 0;
      }));
      return;
    }
    if (mode === 'single') {
      if (next == null || next === '') {
        setDraftSelected([]);
      } else if (_typeof(next) === 'object' && next !== null && 'value' in next) {
        setDraftSelected([String(next.value)]);
      } else {
        setDraftSelected([String(next)]);
      }
      return;
    }
    if (!Array.isArray(next)) return;
    var visible = new Set(selectableFilteredIds);
    var newVisibleSelection = next.map(function (v) {
      return _typeof(v) === 'object' && v !== null && 'value' in v ? String(v.value) : String(v);
    }).filter(function (id) {
      return visible.has(id);
    });
    setDraftSelected(function (prev) {
      var keptOutsideView = prev.filter(function (id) {
        return !visible.has(id);
      });
      var merged = new Set([].concat(_toConsumableArray(keptOutsideView), _toConsumableArray(newVisibleSelection)));
      return _toConsumableArray(merged);
    });
  }, [isObjectMode, mode, selectableFilteredIds, parseObjectSelection]);
  var selectorValue = useMemo(function () {
    if (isObjectMode) {
      return draftObjectValues;
    }
    if (mode === 'single') {
      var _draftSelected$;
      return (_draftSelected$ = draftSelected[0]) !== null && _draftSelected$ !== void 0 ? _draftSelected$ : '';
    }
    var visible = new Set(selectableFilteredIds);
    return draftSelected.filter(function (id) {
      return visible.has(id);
    });
  }, [isObjectMode, mode, draftObjectValues, draftSelected, selectableFilteredIds]);
  var handleConfirm = useCallback(function () {
    /**
     * TS 在 union of function 上有 contravariance 限制，需要在窄化分支内
     * 把 onConfirm 收敛成具体签名再调用，而不是直接对实参做强转。
     */
    if (isObjectMode) {
      var confirmObject = onConfirm;
      confirmObject(draftObjectValues.filter(function (x) {
        return x.quantity > 0;
      }));
    } else {
      var confirmIds = onConfirm;
      confirmIds(draftSelected.filter(Boolean));
    }
    onClose();
  }, [isObjectMode, draftObjectValues, draftSelected, onConfirm, onClose]);
  var renderSelectorItem = useCallback(function (renderProps) {
    var _option$id, _meta$title, _meta$title2, _meta$subtitles;
    var dataSource = renderProps.dataSource,
      indicator = renderProps.indicator,
      numberSelector = renderProps.numberSelector,
      actions = renderProps.actions;
    var option = dataSource;
    var record = option.__record;
    var meta = option.__meta;
    var id = String((_option$id = option.id) !== null && _option$id !== void 0 ? _option$id : '');
    var selected = isObjectMode ? Boolean(option.selected) : draftSelected.includes(id);
    var disabled = disabledSet.has(id);
    var customCard = record && renderCard ? renderCard(record, {
      selected: selected,
      disabled: disabled
    }) : null;
    var onCardClick = function onCardClick() {
      var _key;
      if (disabled) return;
      var key = (_key = option._key) !== null && _key !== void 0 ? _key : id;
      actions.update(key, {
        quantity: selected ? 0 : 1
      });
    };

    /**
     * 卡片整体竖向排列且水平居中：body（image / title / subtitles / badges）+ 底部 actions。
     * - body：传 renderCard 时完全交给业务；否则按 image / title / subtitles / badges 顺序竖排居中
     * - actions：勾选 indicator 或数量步进器，统一放在卡片底部居中
     */
    var image = meta === null || meta === void 0 ? void 0 : meta.image;
    var imageNode = image == null ? null : typeof image === 'string' ? /*#__PURE__*/React.createElement("img", {
      className: "".concat(PREFIX, "-card-image-img"),
      src: image,
      alt: (_meta$title = meta === null || meta === void 0 ? void 0 : meta.title) !== null && _meta$title !== void 0 ? _meta$title : '',
      draggable: false
    }) : image;
    return /*#__PURE__*/React.createElement("button", {
      type: "button",
      disabled: disabled,
      onClick: onCardClick,
      className: classNames("".concat(PREFIX, "-card"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(PREFIX, "-card--selected"), selected), "".concat(PREFIX, "-card--disabled"), disabled), "".concat(PREFIX, "-card--with-stepper"), Boolean(numberSelector)))
    }, /*#__PURE__*/React.createElement("span", {
      className: "".concat(PREFIX, "-card-body")
    }, customCard ? customCard : /*#__PURE__*/React.createElement(React.Fragment, null, imageNode ? /*#__PURE__*/React.createElement("span", {
      className: "".concat(PREFIX, "-card-image")
    }, imageNode) : null, /*#__PURE__*/React.createElement("span", {
      className: "".concat(PREFIX, "-card-text")
    }, /*#__PURE__*/React.createElement("span", {
      className: "".concat(PREFIX, "-card-title")
    }, (_meta$title2 = meta === null || meta === void 0 ? void 0 : meta.title) !== null && _meta$title2 !== void 0 ? _meta$title2 : option.title), meta === null || meta === void 0 || (_meta$subtitles = meta.subtitles) === null || _meta$subtitles === void 0 ? void 0 : _meta$subtitles.map(function (sub, index) {
      return /*#__PURE__*/React.createElement("span", {
        key: "".concat(id, "-sub-").concat(index),
        className: "".concat(PREFIX, "-card-sub")
      }, sub);
    }), meta !== null && meta !== void 0 && meta.badges && meta.badges.length > 0 ? /*#__PURE__*/React.createElement("span", {
      className: "".concat(PREFIX, "-card-badges")
    }, meta.badges.map(function (badge, index) {
      return /*#__PURE__*/React.createElement("span", {
        key: "".concat(id, "-badge-").concat(index),
        className: "".concat(PREFIX, "-card-badge")
      }, badge.icon ? /*#__PURE__*/React.createElement("span", {
        className: "".concat(PREFIX, "-card-badge-icon")
      }, badge.icon) : null, badge.text);
    })) : null))), /*#__PURE__*/React.createElement("span", {
      className: "".concat(PREFIX, "-card-actions"),
      onClick: function onClick(e) {
        return e.stopPropagation();
      }
    }, numberSelector !== null && numberSelector !== void 0 ? numberSelector : indicator));
  }, [isObjectMode, draftSelected, disabledSet, renderCard]);
  var confirmLabel = useMemo(function () {
    var base = locales.getText("".concat(I18N_RP, ".confirm"));
    return selectedKindCount > 0 ? "".concat(base, " (").concat(selectedKindCount, ")") : base;
  }, [selectedKindCount]);
  return /*#__PURE__*/React.createElement(CompensatedPisellContainer, {
    renderType: "modal",
    props: {
      platform: platform,
      open: open,
      title: title,
      onCancel: onClose,
      destroyOnClose: true,
      width: width,
      zIndex: zIndex,
      wrapClassName: classNames("".concat(PREFIX, "-modal"), className),
      headerDivider: false,
      footerDivider: false,
      footer: /*#__PURE__*/React.createElement("div", {
        className: "".concat(PREFIX, "-footer")
      }, /*#__PURE__*/React.createElement(Button, {
        onClick: onClose
      }, locales.getText("".concat(I18N_RP, ".cancel"))), /*#__PURE__*/React.createElement(Button, {
        type: "primary",
        onClick: handleConfirm,
        disabled: selectedKindCount === 0
      }, confirmLabel))
    }
  }, /*#__PURE__*/React.createElement("div", {
    className: PREFIX
  }, /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "-filter-bar")
  }, renderFilterBar ? renderFilterBar(filterBarCtx) : /*#__PURE__*/React.createElement(PisellFind, {
    triggerType: "input",
    value: keyword,
    onChange: setKeyword,
    onSearch: setKeyword,
    placeholder: locales.getText("".concat(I18N_RP, ".search-ph")),
    showHistory: false,
    showConfirmButton: false
  })), /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "-toolbar")
  }, mode === 'multiple' ? /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "-toolbar-left")
  }, /*#__PURE__*/React.createElement(Checkbox, {
    indeterminate: someFilteredSelected && !allFilteredSelected,
    checked: allFilteredSelected,
    disabled: selectableFilteredIds.length === 0,
    onChange: function onChange(e) {
      if (e.target.checked) handleSelectAllFiltered();else handleDeselectAllFiltered();
    }
  }, locales.getText("".concat(I18N_RP, ".select-all"))), /*#__PURE__*/React.createElement("button", {
    type: "button",
    className: "".concat(PREFIX, "-link"),
    onClick: handleDeselectAllFiltered,
    disabled: selectedKindCount === 0
  }, locales.getText("".concat(I18N_RP, ".deselect-all")))) : /*#__PURE__*/React.createElement("span", {
    className: "".concat(PREFIX, "-hint")
  }, locales.getText("".concat(I18N_RP, ".single-hint"))), /*#__PURE__*/React.createElement("span", {
    className: "".concat(PREFIX, "-count")
  }, formatSelectedCount(selectedKindCount, records.length))), /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "-list")
  }, selectorOptions.length === 0 ? /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "-empty")
  }, locales.getText("".concat(I18N_RP, ".empty"))) : /*#__PURE__*/React.createElement(Selector, {
    dataSource: selectorOptions,
    mode: mode,
    valueType: selectorValueType,
    variant: "card",
    itemLayout: "horizontal",
    showStepper: selectorShowStepper,
    value: selectorValue,
    onChange: handleSelectorChange,
    renderItem: renderSelectorItem,
    layout: {
      type: 'antdGrid',
      responsive: {
        minWidth: 160,
        maxColumns: 4,
        gap: 4,
        defaultColumns: 2
      }
    },
    headerProps: {
      visible: false
    }
  }))));
}
export default PisellProResourcePickerModal;