import { ReactNode } from 'react';

export interface TableColumn<T = Record<string, unknown>> {
  id: string;
  header: string;
  accessorKey?: keyof T;
  accessorFn?: (row: T) => unknown;
  cell?: (props: { getValue: () => unknown; row: { original: T } }) => ReactNode;
  sortable?: boolean;
  filterable?: boolean;
  groupable?: boolean;
  width?: number;
  minWidth?: number;
  maxWidth?: number;
  enableResizing?: boolean;
}

export interface TableConfig {
  enableSorting?: boolean;
  enableFiltering?: boolean;
  enableGrouping?: boolean;
  enableColumnResizing?: boolean;
  enableRowSelection?: boolean;
  manualPagination?: boolean;
  pageSize?: number;
}

export interface VirtualTableProps<T> {
  data: T[];
  columns: TableColumn<T>[];
  height?: number;
  width?: number;
  rowHeight?: number;
  headerHeight?: number;
  config?: TableConfig;
  loading?: boolean;
  onRowClick?: (row: T) => void;
  className?: string;
}

export interface FilterCondition {
  column: string;
  operator:
    | 'equals'
    | 'contains'
    | 'startsWith'
    | 'endsWith'
    | 'gt'
    | 'lt'
    | 'gte'
    | 'lte'
    | 'between'
    | 'in';
  value: string | number | boolean | null;
  value2?: string | number | boolean | null; // For 'between' operator
}

export interface SortingState {
  id: string;
  desc: boolean;
}

export interface GroupingState {
  groupBy: string[];
  aggregations?: Record<string, 'sum' | 'avg' | 'count' | 'min' | 'max'>;
}
