const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_objectWithoutProperties = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
//#region src/plus/pisellSalesGrid/mobileTable/applySalesPhoneGridColumns.ts
const _excluded = ["x"];
/** 手机 Table 根 class，限定列内容样式作用域 */
const MOBILE_SALES_TABLE_GRID_CLASS = "pisell-sales-grid-mobile-table-grid";
/** 纵向多行 render：由列 CSS 对子行单独省略 */
const MOBILE_STACK_CELL_CLASS = "pisell-sales-grid-mobile-table-col--stack";
/** 居中 Tag / PisellTags 列 */
const MOBILE_TAG_CELL_CLASS = "pisell-sales-grid-mobile-table-col--tag";
/** 订单 Table（handle perspective）手机列宽 */
const MOBILE_ORDER_COLUMN_WIDTHS = {
	sale_brief: 156,
	customer: 108,
	contacts_info: 108,
	payment_info: 108,
	product_quantity: 80,
	order_origin: 132,
	payment_status: 108,
	delivery_type: 108,
	status: 104,
	shipping_status: 108,
	last_edit_account: 128,
	order_id: 72
};
/** 预约 Monitor Table 手机列宽（未列出的列按桌面 width × 比例回退） */
const MOBILE_BOOKING_COLUMN_WIDTHS = {
	booking_brief: 136,
	relation_form_name: 72,
	service_time: 120,
	customer: 88,
	contact: 108,
	holder_data: 88,
	services: 88,
	number: 80,
	appointment_form: 96,
	order_info: 92,
	booking_id: 72,
	order_origin: 100,
	updated: 96
};
/** 含自定义多行内容的列 key */
const MOBILE_STACK_COLUMN_KEYS = new Set([
	"sale_brief",
	"booking_brief",
	"customer",
	"contacts_info",
	"contact",
	"holder_data",
	"services",
	"payment_info",
	"order_info",
	"order_origin",
	"last_edit_account",
	"updated"
]);
const MOBILE_TAG_COLUMN_KEYS = new Set([
	"payment_status",
	"delivery_type",
	"status",
	"shipping_status"
]);
const MOBILE_WIDTH_SCALE_FALLBACK = .72;
const MOBILE_MIN_COLUMN_WIDTH = 64;
function getColumnKey(column) {
	var _ref, _column$key;
	return String((_ref = (_column$key = column.key) !== null && _column$key !== void 0 ? _column$key : column.dataIndex) !== null && _ref !== void 0 ? _ref : "");
}
function toCellClassName(key) {
	return `pisell-sales-grid-mobile-table-col--${key.replace(/_/g, "-")}`;
}
function resolvePhoneWidth(key, desktopWidth) {
	if (MOBILE_ORDER_COLUMN_WIDTHS[key] != null) return MOBILE_ORDER_COLUMN_WIDTHS[key];
	if (MOBILE_BOOKING_COLUMN_WIDTHS[key] != null) return MOBILE_BOOKING_COLUMN_WIDTHS[key];
	if (typeof desktopWidth === "number" && desktopWidth > 0) return Math.max(MOBILE_MIN_COLUMN_WIDTH, Math.round(desktopWidth * MOBILE_WIDTH_SCALE_FALLBACK));
}
function withCellClass(column, cellClassNames) {
	const merged = (0, classnames.default)(typeof column.className === "string" ? column.className : void 0, ...cellClassNames);
	return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, column), {}, {
		className: merged,
		onCell: () => ({ className: merged })
	});
}
function adaptPhoneColumn(column) {
	const key = getColumnKey(column);
	if (!key) return column;
	const phoneWidth = resolvePhoneWidth(key, column.width);
	if (phoneWidth == null) return column;
	const cellClassNames = [toCellClassName(key)];
	if (MOBILE_STACK_COLUMN_KEYS.has(key)) cellClassNames.push(MOBILE_STACK_CELL_CLASS);
	if (MOBILE_TAG_COLUMN_KEYS.has(key)) cellClassNames.push(MOBILE_TAG_CELL_CLASS);
	const useAntdEllipsis = !MOBILE_STACK_COLUMN_KEYS.has(key) && !MOBILE_TAG_COLUMN_KEYS.has(key);
	return withCellClass(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, column), {}, {
		width: phoneWidth,
		ellipsis: useAntdEllipsis
	}), cellClassNames);
}
/**
* 将 grid.columns 适配为手机 Table：按列收窄宽度，多行/标签列附加 class。
*/
function applySalesPhoneGridColumns(columns) {
	if (!Array.isArray(columns)) return columns;
	return columns.map((column) => adaptPhoneColumn(column));
}
/**
* 合并手机 Table 的 grid className。
*/
function mergeSalesPhoneGridClassName(className) {
	return (0, classnames.default)(className, MOBILE_SALES_TABLE_GRID_CLASS);
}
/**
* 手机 Table：去掉横向 scroll.x（尤其 max-content），避免列宽收窄后仍可滚出右侧空白。
* 与预约 buildReservationMobileTableGridConfig 一致，仅保留 autoCalc 等纵向滚动配置。
*/
function buildSalesPhoneGridScroll(scroll) {
	var _autoCalc;
	const base = scroll && typeof scroll === "object" ? require_objectSpread2._objectSpread2({}, scroll) : {};
	const { x: _dropHorizontalScroll } = base;
	return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, require_objectWithoutProperties._objectWithoutProperties(base, _excluded)), {}, { autoCalc: (_autoCalc = base.autoCalc) !== null && _autoCalc !== void 0 ? _autoCalc : true });
}
/**
* 手机 Table：取消多选列 fixed，避免横向滚动时固定列与表体错位。
*/
function buildSalesPhoneRowSelection(rowSelection) {
	if (!rowSelection || typeof rowSelection !== "object") return rowSelection;
	return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, rowSelection), {}, { fixed: false });
}
//#endregion
exports.applySalesPhoneGridColumns = applySalesPhoneGridColumns;
exports.buildSalesPhoneGridScroll = buildSalesPhoneGridScroll;
exports.buildSalesPhoneRowSelection = buildSalesPhoneRowSelection;
exports.mergeSalesPhoneGridClassName = mergeSalesPhoneGridClassName;
