var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/pisellGlobalSearch/providers/orderResultViews.tsx
var orderResultViews_exports = {};
__export(orderResultViews_exports, {
  OrderAdminGrid: () => OrderAdminGrid,
  OrderBusinessDetails: () => OrderBusinessDetails,
  OrderBusinessList: () => OrderBusinessList,
  OrderTableFallbackBoundary: () => OrderTableFallbackBoundary,
  normalizeSalesDeltaItems: () => normalizeSalesDeltaItems,
  patchLoadedSalesItems: () => patchLoadedSalesItems
});
module.exports = __toCommonJS(orderResultViews_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_rc_virtual_list = __toESM(require("rc-virtual-list"));
var import_utils = require("@pisell/utils");
var import_materials = require("@pisell/materials");
var import_date_picker = require("@pisell/date-picker");
var import_AdapterDayjs = require("@pisell/date-picker/es/AdapterDayjs");
var import_pisellSalesGrid = __toESM(require("../../pisellSalesGrid"));
var import_useOrderPerspective = require("../../pisellSalesManagement/hooks/useOrderPerspective");
var import_locales = __toESM(require("../../orderList/locales"));
var import_locales2 = __toESM(require("../../pisellSalesManagement/locales"));
var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
var import_RefreshableSaleDetail = __toESM(require("../components/RefreshableSaleDetail"));
var import_searchService = require("../api/searchService");
var import_detailRefresh = require("../utils/detailRefresh");
var OrderTableFallbackBoundary = class extends import_react.default.Component {
  constructor(props) {
    super(props);
    this.state = { hasError: false };
  }
  static getDerivedStateFromError() {
    return { hasError: true };
  }
  componentDidCatch(error) {
    if (process.env.NODE_ENV !== "production") {
      console.warn(
        "[PisellGlobalSearch] 订单结果渲染失败，可能不在 admin engine 环境：",
        error
      );
    }
  }
  render() {
    if (this.state.hasError) {
      return /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          style: {
            padding: 24,
            border: "1px dashed #e5e7eb",
            borderRadius: 8,
            background: "#fafafa",
            color: "#6b7280",
            fontSize: 13,
            lineHeight: 1.6
          }
        },
        /* @__PURE__ */ import_react.default.createElement("div", { style: { fontWeight: 600, color: "#111827", marginBottom: 4 } }, import_utils.locales.getText("pisell-global-search.order-result-unavailable.title")),
        /* @__PURE__ */ import_react.default.createElement("div", null, import_utils.locales.getText(
          "pisell-global-search.order-result-unavailable.description"
        ))
      );
    }
    return this.props.children;
  }
};
var OrderBusinessDetails = ({ orderIds, loading, keyword, detailRefreshVersions = {} }) => {
  if (loading && orderIds.length === 0) {
    return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-global-search-order-business__status" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Spin, null));
  }
  if (keyword && orderIds.length === 0) {
    return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-global-search-order-business__status pisell-global-search__empty" }, import_utils.locales.getText("pisell-global-search.empty"));
  }
  if (orderIds.length === 0) return null;
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-global-search-order-business" }, orderIds.map((id) => {
    const refreshVersion = (0, import_detailRefresh.getDetailRefreshVersion)(
      detailRefreshVersions,
      "order",
      id
    );
    const osKey = `global-search-business-detail-${id}`;
    return /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        key: osKey,
        className: "pisell-global-search-order-business__item"
      },
      /* @__PURE__ */ import_react.default.createElement(OrderTableFallbackBoundary, null, /* @__PURE__ */ import_react.default.createElement(
        import_RefreshableSaleDetail.default,
        {
          refreshVersion,
          renderType: "current",
          tmpl: "B",
          variant: "tablet",
          summaryTwoColumn: true,
          osProps: {
            osKey,
            orderId: Number(id),
            autoBootstrap: true,
            destroyOnUnmount: true
          }
        }
      ))
    );
  }));
};
var BUSINESS_ROW_ESTIMATED_HEIGHT = 360;
var BUSINESS_PAGE_SIZE = 5;
var BUSINESS_LOAD_MORE_THRESHOLD = BUSINESS_ROW_ESTIMATED_HEIGHT;
var BUSINESS_LOADER_HEIGHT = 44;
var BUSINESS_LIST_VIRTUAL_SCROLL = true;
function normalizeSalesDeltaItems(res) {
  const payload = (res == null ? void 0 : res.data) ?? res;
  if (Array.isArray(payload == null ? void 0 : payload.list)) return payload.list;
  const results = Array.isArray(payload == null ? void 0 : payload.results) ? payload.results : [];
  const salesGroup = results.find((item) => (item == null ? void 0 : item.module) === "sales");
  return Array.isArray(salesGroup == null ? void 0 : salesGroup.list) ? salesGroup.list : [];
}
function patchLoadedSalesItems(currentItems, deltaItems) {
  if (!deltaItems.length) return currentItems;
  const deltaMap = /* @__PURE__ */ new Map();
  deltaItems.forEach((item) => {
    const orderId = (0, import_searchService.getSalesOrderId)(item);
    if (orderId !== void 0) deltaMap.set(String(orderId), item);
  });
  if (deltaMap.size === 0) return currentItems;
  let changed = false;
  const nextItems = currentItems.map((item) => {
    const orderId = (0, import_searchService.getSalesOrderId)(item);
    if (orderId === void 0) return item;
    const next = deltaMap.get(String(orderId));
    if (!next) return item;
    changed = true;
    return { ...item, ...next };
  });
  return changed ? nextItems : currentItems;
}
var OrderBusinessListImpl = ({ keyword }) => {
  const [items, setItems] = (0, import_react.useState)([]);
  const [detailRefreshVersions, setDetailRefreshVersions] = (0, import_react.useState)({});
  const [total, setTotal] = (0, import_react.useState)(0);
  const [loading, setLoading] = (0, import_react.useState)(false);
  const [error, setError] = (0, import_react.useState)(null);
  const pageRef = (0, import_react.useRef)(1);
  const reqIdRef = (0, import_react.useRef)(0);
  const loadingMoreRef = (0, import_react.useRef)(false);
  const subscriberIdRef = (0, import_react.useRef)((0, import_utils.getUniqueId)("global-search-order-business"));
  const applySalesDelta = (0, import_react.useCallback)((res) => {
    const deltaItems = normalizeSalesDeltaItems(res);
    if (deltaItems.length === 0) return;
    setItems((prev) => patchLoadedSalesItems(prev, deltaItems));
    setDetailRefreshVersions(
      (prev) => (0, import_detailRefresh.bumpOrderDetailRefreshVersions)(prev, deltaItems)
    );
  }, []);
  const containerRef = (0, import_react.useRef)(null);
  const [viewportHeight, setViewportHeight] = (0, import_react.useState)(0);
  (0, import_react.useEffect)(() => {
    const el = containerRef.current;
    if (!el) return void 0;
    const measure = () => setViewportHeight(el.clientHeight);
    measure();
    const ro = new ResizeObserver(measure);
    ro.observe(el);
    return () => ro.disconnect();
  }, []);
  const fetchPage = (0, import_react.useCallback)(
    async (targetPage, append) => {
      const kw = (keyword ?? "").trim();
      if (!kw) {
        setItems([]);
        setDetailRefreshVersions({});
        setTotal(0);
        void (0, import_searchService.unsubscribeSalesSearch)(subscriberIdRef.current);
        return;
      }
      const reqId = ++reqIdRef.current;
      setLoading(true);
      setError(null);
      try {
        const res = await (0, import_searchService.searchSalesModule)({
          keyword: kw,
          searchMode: "identifier",
          page: targetPage,
          perPage: BUSINESS_PAGE_SIZE,
          subscriberId: subscriberIdRef.current,
          callback: applySalesDelta,
          resetVisibleOrderIds: !append
        });
        if (reqId !== reqIdRef.current) return;
        setTotal(res.total);
        setItems((prev) => append ? [...prev, ...res.items] : res.items);
        if (!append) setDetailRefreshVersions({});
        pageRef.current = targetPage;
      } catch (e) {
        if (reqId !== reqIdRef.current) return;
        setError(e);
        if (!append) {
          setItems([]);
          setDetailRefreshVersions({});
          setTotal(0);
        }
      } finally {
        if (reqId === reqIdRef.current) setLoading(false);
        loadingMoreRef.current = false;
      }
    },
    [keyword, applySalesDelta]
  );
  (0, import_react.useEffect)(() => {
    const subscriberId = subscriberIdRef.current;
    return () => {
      void (0, import_searchService.unsubscribeSalesSearch)(subscriberId);
    };
  }, []);
  (0, import_react.useEffect)(() => {
    pageRef.current = 1;
    fetchPage(1, false);
  }, [fetchPage]);
  const hasMore = items.length < total;
  const handleScroll = (0, import_react.useCallback)(
    (e) => {
      const { scrollTop, clientHeight, scrollHeight } = e.currentTarget;
      if (!loading && !loadingMoreRef.current && hasMore && scrollHeight - scrollTop - clientHeight < BUSINESS_LOAD_MORE_THRESHOLD) {
        loadingMoreRef.current = true;
        fetchPage(pageRef.current + 1, true);
      }
    },
    [loading, hasMore, fetchPage]
  );
  const isFirstLoading = loading && items.length === 0;
  const isFirstError = !!error && items.length === 0;
  const isEmpty = !loading && !error && items.length === 0;
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      ref: containerRef,
      className: "pisell-global-search-order-business pisell-global-search-order-business--virtual"
    },
    isFirstLoading && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-global-search-order-business__status" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Spin, null)),
    !isFirstLoading && isFirstError && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-global-search-order-business__status pisell-global-search__empty" }, import_utils.locales.getText("pisell-global-search.error")),
    !isFirstLoading && !isFirstError && isEmpty && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-global-search-order-business__status pisell-global-search__empty" }, import_utils.locales.getText("pisell-global-search.empty")),
    items.length > 0 && viewportHeight === 0 && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-global-search-order-business__status" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Spin, { size: "small" })),
    items.length > 0 && viewportHeight > 0 && /* @__PURE__ */ import_react.default.createElement(
      import_rc_virtual_list.default,
      {
        data: items,
        height: loading && items.length > 0 ? Math.max(viewportHeight - BUSINESS_LOADER_HEIGHT, 0) : viewportHeight,
        itemHeight: BUSINESS_ROW_ESTIMATED_HEIGHT,
        virtual: BUSINESS_LIST_VIRTUAL_SCROLL,
        itemKey: (item) => {
          const id = (0, import_searchService.getSalesOrderId)(item) ?? item.order_id ?? "";
          return `${id}`;
        },
        onScroll: handleScroll
      },
      (item) => {
        const id = (0, import_searchService.getSalesOrderId)(item);
        const refreshVersion = (0, import_detailRefresh.getDetailRefreshVersion)(
          detailRefreshVersions,
          "order",
          id
        );
        const osKey = `global-search-business-detail-${id}`;
        return /* @__PURE__ */ import_react.default.createElement(
          "div",
          {
            key: osKey,
            className: "pisell-global-search-order-business__item",
            style: { marginBottom: 6 }
          },
          /* @__PURE__ */ import_react.default.createElement(OrderTableFallbackBoundary, null, /* @__PURE__ */ import_react.default.createElement(
            import_RefreshableSaleDetail.default,
            {
              refreshVersion,
              renderType: "current",
              tmpl: "B",
              variant: "tablet",
              summaryTwoColumn: true,
              osProps: {
                osKey,
                orderId: Number(id),
                autoBootstrap: true,
                destroyOnUnmount: true
              }
            }
          ))
        );
      }
    ),
    loading && items.length > 0 && /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        style: {
          flex: "0 0 auto",
          height: BUSINESS_LOADER_HEIGHT,
          display: "flex",
          alignItems: "center",
          justifyContent: "center"
        }
      },
      /* @__PURE__ */ import_react.default.createElement(import_antd.Spin, { size: "small" })
    )
  );
};
var OrderBusinessList = import_react.default.memo(OrderBusinessListImpl);
var getAdminGridDefaultSearchParams = () => ({
  filter: { values: {} },
  sort: "created_at:desc"
});
var OrderAdminGridImpl = ({ keyword, onOpenDetail, onRealtimePatchItems, previewLimit }) => {
  var _a, _b;
  const context = (0, import_useEngineContext.default)();
  const localeProp = (_b = (_a = context == null ? void 0 : context.engine) == null ? void 0 : _a.props) == null ? void 0 : _b.locale;
  const mergedLocales = {
    en: { ...import_locales.default.en, ...import_locales2.default.en },
    "zh-CN": {
      ...import_locales.default["zh-CN"],
      ...import_locales2.default["zh-CN"]
    },
    "zh-HK": {
      ...import_locales.default["zh-HK"],
      ...import_locales2.default["zh-HK"]
    }
  };
  import_utils.locales.init(mergedLocales, localeProp || "en");
  const [searchParams, setSearchParams] = (0, import_react.useState)(
    getAdminGridDefaultSearchParams
  );
  const onSearch = (0, import_react.useCallback)((params) => {
    setSearchParams(params || {});
  }, []);
  const onReset = (0, import_react.useCallback)(() => {
    setSearchParams(getAdminGridDefaultSearchParams());
  }, []);
  const isPreview = typeof previewLimit === "number" && previewLimit > 0;
  const PAGE_SIZE = isPreview ? previewLimit : 20;
  const filters = (0, import_react.useMemo)(
    () => {
      var _a2;
      return (0, import_searchService.mapGridFiltersToEs)((_a2 = searchParams == null ? void 0 : searchParams.filter) == null ? void 0 : _a2.values);
    },
    [searchParams]
  );
  const sort = (0, import_react.useMemo)(() => (0, import_searchService.parseSortKey)(searchParams == null ? void 0 : searchParams.sort), [searchParams]);
  const [items, setItems] = (0, import_react.useState)([]);
  const [total, setTotal] = (0, import_react.useState)(0);
  const [loading, setLoading] = (0, import_react.useState)(false);
  const [error, setError] = (0, import_react.useState)(null);
  const [pagination, setPagination] = (0, import_react.useState)({
    pageNumber: 1,
    pageSize: PAGE_SIZE
  });
  const reqIdRef = (0, import_react.useRef)(0);
  const subscriberIdRef = (0, import_react.useRef)((0, import_utils.getUniqueId)("global-search-order-admin"));
  const [activeId, setActiveId] = (0, import_react.useState)(
    void 0
  );
  const applySalesDelta = (0, import_react.useCallback)(
    (res) => {
      const deltaItems = normalizeSalesDeltaItems(res);
      if (deltaItems.length === 0) return;
      const deltaIds = deltaItems.map((item) => (0, import_searchService.getSalesOrderId)(item) ?? (item == null ? void 0 : item.order_id) ?? (item == null ? void 0 : item.id)).filter((id) => id !== void 0 && id !== null);
      onRealtimePatchItems == null ? void 0 : onRealtimePatchItems("order", deltaItems);
      setItems((prev) => patchLoadedSalesItems(prev, deltaItems));
    },
    [onRealtimePatchItems]
  );
  const fetchPage = (0, import_react.useCallback)(
    async (targetPage, append) => {
      const kw = (keyword ?? "").trim();
      if (!kw) {
        setItems([]);
        setTotal(0);
        void (0, import_searchService.unsubscribeSalesSearch)(subscriberIdRef.current);
        return;
      }
      const reqId = ++reqIdRef.current;
      setLoading(true);
      setError(null);
      try {
        const res = await (0, import_searchService.searchSalesModule)({
          keyword: kw,
          searchMode: "fuzzy",
          filters,
          sort,
          page: targetPage,
          perPage: PAGE_SIZE,
          subscriberId: subscriberIdRef.current,
          callback: applySalesDelta,
          resetVisibleOrderIds: !append
        });
        if (reqId !== reqIdRef.current) return;
        setTotal(res.total);
        setItems((prev) => append ? [...prev, ...res.items] : res.items);
        setPagination({ pageNumber: targetPage, pageSize: PAGE_SIZE });
      } catch (e) {
        if (reqId !== reqIdRef.current) return;
        setError(e);
        if (!append) {
          setItems([]);
          setTotal(0);
        }
      } finally {
        if (reqId === reqIdRef.current) setLoading(false);
      }
    },
    [keyword, filters, sort, applySalesDelta]
  );
  (0, import_react.useEffect)(() => {
    const subscriberId = subscriberIdRef.current;
    return () => {
      void (0, import_searchService.unsubscribeSalesSearch)(subscriberId);
    };
  }, []);
  const prevKeywordRef = (0, import_react.useRef)(keyword);
  (0, import_react.useEffect)(() => {
    if (prevKeywordRef.current === keyword) return;
    prevKeywordRef.current = keyword;
    setSearchParams((prev) => {
      var _a2;
      const next = getAdminGridDefaultSearchParams();
      const isDefault = !!prev && prev.sort === next.sort && !!((_a2 = prev.filter) == null ? void 0 : _a2.values) && Object.keys(prev.filter.values).length === 0;
      return isDefault ? prev : next;
    });
  }, [keyword]);
  (0, import_react.useEffect)(() => {
    setPagination({ pageNumber: 1, pageSize: PAGE_SIZE });
    setActiveId(void 0);
    fetchPage(1, false);
  }, [fetchPage]);
  const onPageChange = (0, import_react.useCallback)(
    (pageNumber) => {
      if (isPreview) return;
      if (pageNumber > pagination.pageNumber) {
        fetchPage(pageNumber, true);
      }
    },
    [isPreview, fetchPage, pagination.pageNumber]
  );
  const records = (0, import_react.useMemo)(
    () => items.map((item) => {
      const orderId = (0, import_searchService.getSalesOrderId)(item);
      if (orderId === void 0) return null;
      return { ...item, id: orderId, order_id: orderId };
    }).filter((r) => r !== null),
    [items]
  );
  const handleRowOpenDetail = (0, import_react.useCallback)(
    ({ orderId }) => {
      setActiveId(orderId);
      onOpenDetail == null ? void 0 : onOpenDetail({ providerKey: "order", id: orderId });
    },
    [onOpenDetail]
  );
  const perspectiveBase = (0, import_useOrderPerspective.useOrderPerspective)({
    onOpenDetail: onOpenDetail ? handleRowOpenDetail : void 0
  });
  const perspectiveCore = (0, import_react.useMemo)(() => {
    const originalGet = perspectiveBase.getChildComponentProps;
    const COLUMN_WIDTH_SCALE = 0.8;
    const COLUMN_MIN_WIDTH = 88;
    const COLUMN_SCALE_OVERRIDES = {
      sale_brief: 0.7,
      // 金额两行（Paid/Total/Due）较宽，缩到 0.8 会把数字挤断，单独放宽一点
      payment_info: 1,
      // 支付方式（CASHMANUAL: $x + 时间）较长，放宽避免折断
      payment_method: 1.3,
      // 订单来源（渠道 + 创建人 + 时间）较长，放宽避免折断
      order_origin: 1.2,
      // Updated（编辑人 + 渠道 + 时间）较长，放宽避免折断
      last_edit_account: 1.2
    };
    const ELLIPSIS_COLUMN_KEYS = /* @__PURE__ */ new Set([
      "payment_method",
      "payment_info",
      // order_origin / last_edit_account 同为多行堆叠文本，且本表恒为虚拟表，
      // 旧的 cell-content 选择器在虚拟单元格里不稳，统一走自有 wrapper 才可靠省略。
      "order_origin",
      "last_edit_account"
    ]);
    const wrapEllipsisRender = (col) => {
      const originalRender = col.render;
      if (typeof originalRender !== "function") return col;
      return {
        ...col,
        render: (value, record, index) => /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-global-search-ellipsis-cell" }, originalRender(value, record, index))
      };
    };
    const shrinkColumns = (columns) => Array.isArray(columns) ? columns.map((col) => {
      if (!col) return col;
      const scaled = typeof col.width === "number" ? {
        ...col,
        width: Math.max(
          Math.round(
            col.width * (COLUMN_SCALE_OVERRIDES[col.key] ?? COLUMN_WIDTH_SCALE)
          ),
          COLUMN_MIN_WIDTH
        )
      } : col;
      if (col.key === "payment_status") {
        return {
          ...scaled,
          className: [scaled.className, "pisell-global-search-col-payment-status"].filter(Boolean).join(" ")
        };
      }
      if (ELLIPSIS_COLUMN_KEYS.has(col.key)) {
        return wrapEllipsisRender(scaled);
      }
      return scaled;
    }) : columns;
    return {
      ...perspectiveBase,
      getChildComponentProps: (ctx) => {
        const result = (originalGet ? originalGet(ctx) : perspectiveBase.childComponentProps) || {};
        const grid = result.grid || {};
        const toolBar = result.toolBar || {};
        const filter = toolBar.filter && typeof toolBar.filter === "object" ? toolBar.filter : {};
        return {
          ...result,
          grid: {
            ...grid,
            columns: shrinkColumns(grid.columns),
            // 始终开启无限滚动：RecordBoard 据此隐藏底部翻页器
            // （showGridPagination = showGrid && gridInfiniteScroll !== true）。
            // 预览模式不翻页是靠 onPageChange 里拦截，而非关掉 infiniteScroll，
            // 否则翻页器会重新出现。
            infiniteScroll: true,
            virtual: true
          },
          toolBar: {
            ...toolBar,
            search: false,
            filter: {
              ...filter,
              defaultFilterValue: {
                ...filter.defaultFilterValue || {},
                quickFilter: [],
                values: {}
              }
            }
          }
        };
      }
    };
  }, [perspectiveBase]);
  const perspectives = (0, import_react.useMemo)(() => {
    const coreGet = perspectiveCore.getChildComponentProps;
    return [
      {
        ...perspectiveCore,
        getChildComponentProps: (ctx) => {
          const result = coreGet ? coreGet(ctx) : {};
          const grid = result.grid || {};
          const baseRowClassName = grid.rowClassName;
          return {
            ...result,
            grid: {
              ...grid,
              rowClassName: (record, index, indent) => {
                const prev = typeof baseRowClassName === "function" ? baseRowClassName(record, index, indent) : baseRowClassName || "";
                const isActive = activeId !== void 0 && (record == null ? void 0 : record.id) != null && String(record.id) === String(activeId);
                return [
                  prev,
                  isActive ? "pisell-global-search-order-row--active" : ""
                ].filter(Boolean).join(" ");
              }
            }
          };
        }
      }
    ];
  }, [perspectiveCore, activeId]);
  const adapterLocale = localeProp === "zh-CN" || localeProp === "zh-HK" ? "zh-cn" : localeProp === "en" || localeProp === "en-US" ? "en" : "zh-cn";
  const rawLocale = localeProp || (typeof localStorage !== "undefined" ? localStorage.getItem("umi_locale") : null) || "en-US";
  const materialsLocale = rawLocale === "zh" ? "zh-CN" : rawLocale;
  return /* @__PURE__ */ import_react.default.createElement(OrderTableFallbackBoundary, null, /* @__PURE__ */ import_react.default.createElement(import_materials.PisellConfigProvider, { locale: materialsLocale }, /* @__PURE__ */ import_react.default.createElement(
    import_date_picker.LocalizationProvider,
    {
      dateAdapter: import_AdapterDayjs.AdapterDayjs,
      adapterLocale
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-global-search-order-table" }, error && items.length === 0 && !loading ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-global-search-order-business__status pisell-global-search__empty" }, import_utils.locales.getText("pisell-global-search.error")) : /* @__PURE__ */ import_react.default.createElement(
      import_pisellSalesGrid.default,
      {
        perspectives,
        currentPerspective: "handle",
        data: records,
        loading,
        total,
        pagination,
        onPageChange,
        searchParams,
        onSearch,
        onReset,
        rowKey: "id"
      }
    ))
  )));
};
var OrderAdminGrid = import_react.default.memo(OrderAdminGridImpl);
OrderAdminGrid.displayName = "OrderAdminGrid";
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  OrderAdminGrid,
  OrderBusinessDetails,
  OrderBusinessList,
  OrderTableFallbackBoundary,
  normalizeSalesDeltaItems,
  patchLoadedSalesItems
});
