const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_useEngineContext = require("../../hooks/useEngineContext.js");
const require_index = require("../../utils/index.js");
const require_serve = require("./serve.js");
const require_index$1 = require("../pisellSalesGrid/index.js");
const require_locales = require("../orderList/locales.js");
const require_locales$1 = require("./locales.js");
const require_usePerspectives = require("./hooks/usePerspectives.js");
const require_useSalesGridData = require("./hooks/useSalesGridData.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
let ahooks = require("ahooks");
let _pisell_date_picker = require("@pisell/date-picker");
let _pisell_date_picker_es_AdapterDayjs = require("@pisell/date-picker/es/AdapterDayjs");
//#region src/plus/pisellSalesManagement/index.tsx
const PisellSalesManagement = (props) => {
	var _context$appHelper, _context$engine, _window, _context$engine2, _context$engine3, _context$engine4, _context$engine5, _context$engine6;
	const { perspective, __id } = props;
	const context = require_useEngineContext.default();
	const utils = (context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {};
	require_index.request.setRequest(utils === null || utils === void 0 ? void 0 : utils.request);
	const _getRelationTables = (0, ahooks.useRequest)(require_serve.getRelationTables);
	const mergedLocales = {
		en: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, require_locales.default.en), require_locales$1.default.en),
		"zh-CN": require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, require_locales.default["zh-CN"]), require_locales$1.default["zh-CN"]),
		"zh-HK": require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, require_locales.default["zh-HK"]), require_locales$1.default["zh-HK"])
	};
	_pisell_utils.locales.init(mergedLocales, (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || "en");
	(0, react.useEffect)(() => {
		if (perspective === "monitor") setTimeout(() => {
			utils.action({ type: "pisell1.registerBookingPlugin" });
		}, 300);
	}, [perspective, utils]);
	const useParams = (_window = window) === null || _window === void 0 || (_window = _window.app) === null || _window === void 0 || (_window = _window.history) === null || _window === void 0 ? void 0 : _window.useParams;
	const params = useParams === null || useParams === void 0 ? void 0 : useParams();
	const queryBusinessCode = (0, react.useMemo)(() => {
		if (typeof window === "undefined") return void 0;
		return new URLSearchParams(window.location.search || "").get("business_code") || void 0;
	}, []);
	const extParams = (0, react.useMemo)(() => {
		return { list: { business_code: props.biz || (params === null || params === void 0 ? void 0 : params.biz) || queryBusinessCode } };
	}, [
		props.biz,
		params === null || params === void 0 ? void 0 : params.biz,
		queryBusinessCode
	]);
	const perspectives = require_usePerspectives.default({ relationTables: _getRelationTables.data || [] });
	const gridDataProps = require_useSalesGridData.useSalesGridData({
		perspective,
		extParams
	});
	const adapterLocale = (context === null || context === void 0 || (_context$engine2 = context.engine) === null || _context$engine2 === void 0 || (_context$engine2 = _context$engine2.props) === null || _context$engine2 === void 0 ? void 0 : _context$engine2.locale) === "zh-CN" || (context === null || context === void 0 || (_context$engine3 = context.engine) === null || _context$engine3 === void 0 || (_context$engine3 = _context$engine3.props) === null || _context$engine3 === void 0 ? void 0 : _context$engine3.locale) === "zh-HK" ? "zh-cn" : (context === null || context === void 0 || (_context$engine4 = context.engine) === null || _context$engine4 === void 0 || (_context$engine4 = _context$engine4.props) === null || _context$engine4 === void 0 ? void 0 : _context$engine4.locale) === "en" || (context === null || context === void 0 || (_context$engine5 = context.engine) === null || _context$engine5 === void 0 || (_context$engine5 = _context$engine5.props) === null || _context$engine5 === void 0 ? void 0 : _context$engine5.locale) === "en-US" ? "en" : "zh-cn";
	const rawLocale = (context === null || context === void 0 || (_context$engine6 = context.engine) === null || _context$engine6 === void 0 || (_context$engine6 = _context$engine6.props) === null || _context$engine6 === void 0 ? void 0 : _context$engine6.locale) || (typeof localStorage !== "undefined" ? localStorage.getItem("umi_locale") : null) || "en-US";
	const materialsLocale = rawLocale === "zh" ? "zh-CN" : rawLocale;
	return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellConfigProvider, { locale: materialsLocale }, /* @__PURE__ */ react.default.createElement(_pisell_date_picker.LocalizationProvider, {
		dateAdapter: _pisell_date_picker_es_AdapterDayjs.AdapterDayjs,
		adapterLocale
	}, /* @__PURE__ */ react.default.createElement("div", { style: Object.assign({}, { height: 0 }, props === null || props === void 0 ? void 0 : props.style) }, /* @__PURE__ */ react.default.createElement(require_index$1.default, {
		perspectives,
		currentPerspective: perspective,
		extParams,
		__id,
		data: gridDataProps.data,
		loading: gridDataProps.loading,
		total: gridDataProps.total,
		pagination: gridDataProps.pagination,
		onPageChange: gridDataProps.onPageChange,
		searchParams: gridDataProps.searchParams,
		onSearch: gridDataProps.onSearch,
		onReset: gridDataProps.onReset,
		selectedKeys: gridDataProps.selectedKeys,
		selectedRows: gridDataProps.selectedRows,
		onSelectionChange: gridDataProps.onSelectionChange,
		rowKey: gridDataProps.rowKey,
		onRefresh: gridDataProps.onRefresh,
		refreshAsync: gridDataProps.refreshAsync
	}))));
};
//#endregion
exports.default = PisellSalesManagement;
