// F8-10 fleets table — module-level filter / sort rune.
// Mirrors `table-planets-state.svelte.ts`. See that file for the
// rationale.

export type FleetsSortColumn = "name" | "groupCount" | "state" | "location" | "speed";
export type FleetsSortDirection = "asc" | "desc";

export interface FleetsTableState {
	sortColumn: FleetsSortColumn;
	sortDirection: FleetsSortDirection;
	planetFilter: string;
}

const DEFAULT_STATE: FleetsTableState = {
	sortColumn: "name",
	sortDirection: "asc",
	planetFilter: "",
};

export const fleetsTableState: FleetsTableState = $state({ ...DEFAULT_STATE });

export function resetFleetsTableState(): void {
	Object.assign(fleetsTableState, DEFAULT_STATE);
}
