/**
 * 列表页筛选区全局规则（与 vehicle-management/style.css 中 .vm-filter-grid 4 列布局一致）
 *
 * 规则：筛选项超过 1 行（默认 4 项）时，其余收入折叠区，通过「更多筛选」展开。
 */
export const VM_FILTER_COLUMNS_PER_ROW = 4;

/** 默认首行展示的筛选项数量（1 行） */
export const VM_FILTER_PRIMARY_VISIBLE_COUNT = VM_FILTER_COLUMNS_PER_ROW;

export function splitFilterFields<T>(
  fields: T[],
  primaryCount: number = VM_FILTER_PRIMARY_VISIBLE_COUNT,
): { primary: T[]; extra: T[] } {
  if (fields.length <= primaryCount) {
    return { primary: fields, extra: [] };
  }
  return {
    primary: fields.slice(0, primaryCount),
    extra: fields.slice(primaryCount),
  };
}

export function shouldShowFilterExpand(
  fieldCount: number,
  primaryCount: number = VM_FILTER_PRIMARY_VISIBLE_COUNT,
): boolean {
  return fieldCount > primaryCount;
}
