import type { ObjectTypeDefinition, WhereClause } from "@osdk/api";
import type { ReactNode } from "react";
import type { FilterDefinitionControls, FilterState, FilterStateByComponentType } from "../FilterListItemApi.js";
/**
* Component types that support static values.
* These components can display a fixed list of string values without OSDK aggregation.
*/
export type StaticValuesComponentType = "LISTOGRAM" | "SINGLE_SELECT" | "MULTI_SELECT" | "TEXT_TAGS";
/**
* Filter definition for static (non-OSDK) value lists.
* Renders built-in filter components with user-provided values instead of
* fetching values via OSDK aggregation queries.
*/
export interface StaticValuesFilterDefinition<
	Q extends ObjectTypeDefinition,
	C extends StaticValuesComponentType = StaticValuesComponentType
> extends FilterDefinitionControls {
	type: "STATIC_VALUES";
	/**
	* Optional unique identifier for stable keying across filter reorders.
	* If provided, takes precedence over `key` for state keying.
	*/
	id?: string;
	/**
	* Key used for state management and auto WHERE clause generation.
	* When `toWhereClause` is not provided, this is used as the property key
	* in the generated WHERE clause.
	*/
	key: string;
	/**
	* Display label for the filter
	*/
	label?: string;
	/**
	* The filter component type to render
	*/
	filterComponent: C;
	/**
	* The current state of the filter
	*/
	filterState: FilterStateByComponentType[C];
	/**
	* The static list of values to display in the filter component.
	* These are rendered directly without OSDK aggregation.
	*/
	values: string[];
	/**
	* Custom display function for filter values.
	* Replaces the default string display in dropdown items, chips, and listogram rows.
	* When the function returns a string, that string is also used for search matching
	* within filter dropdowns. When it returns a non-string `ReactNode`, search falls
	* back to the raw value.
	*/
	renderValue?: (value: string) => ReactNode;
	/**
	* Show aggregation counts next to filter option values.
	* Applies to LISTOGRAM, SINGLE_SELECT, and MULTI_SELECT components.
	* @default true for LISTOGRAM and MULTI_SELECT, false for SINGLE_SELECT
	*/
	showCount?: boolean;
	/**
	* Maps filter values to colors for visual differentiation.
	* Used by LISTOGRAM (per-row bar colors).
	*/
	colorMap?: Record<string, string>;
	/**
	* Configuration for LISTOGRAM display mode.
	* Only applies when filterComponent is "LISTOGRAM".
	*/
	listogramConfig?: {
		displayMode?: "full" | "count" | "minimal"
		/**
		* Number of items shown before "View all" link appears
		* @default 5
		*/
		maxVisibleItems?: number
	};
	/**
	* Optional custom WHERE clause generator.
	* When provided, this is used instead of auto-generating a WHERE clause
	* from the `key` and filter state.
	*/
	toWhereClause?: (state: FilterState) => WhereClause<Q> | undefined;
	/**
	* Controls whether this filter is rendered.
	* When false, the filter is hidden but its state is preserved.
	* @default true
	*/
	isVisible?: boolean;
}
