import type { ObjectSet, ObjectTypeDefinition, WhereClause } from "@osdk/api";
import type { ReactNode } from "react";
import type { BaseFilterState, FilterDefinitionControls } from "../FilterListItemApi.js";
/**
* State for custom filter
*/
export interface CustomFilterState<T = Record<string, unknown>> extends BaseFilterState {
	type: "custom";
	customState: T;
}
/**
* Props passed to custom filter input renderer
*/
export interface CustomFilterInputRendererProps<
	Q extends ObjectTypeDefinition,
	State extends BaseFilterState
> {
	objectType: Q;
	objectSet?: ObjectSet<Q>;
	filterState: State;
	onFilterStateChanged: (newState: State) => void;
}
/**
* Props passed to custom filter item renderer
* Includes full item context in addition to input renderer props
*/
export interface CustomFilterItemRendererProps<
	Q extends ObjectTypeDefinition,
	State extends BaseFilterState
> extends CustomFilterInputRendererProps<Q, State> {
	label: string;
	onRemove?: () => void;
}
/**
* Filter definition for custom filters
* Provides full control over rendering and filter logic
*/
export interface CustomFilterDefinition<
	Q extends ObjectTypeDefinition,
	State extends BaseFilterState = CustomFilterState
> extends FilterDefinitionControls {
	type: "CUSTOM";
	/**
	* Optional unique identifier for stable keying across filter reorders.
	* If provided, takes precedence over `key` for state keying.
	*/
	id?: string;
	/**
	* Unique key for this custom filter
	*/
	key: string;
	label?: string;
	filterComponent: "CUSTOM";
	filterState: State;
	defaultFilterState?: State;
	/**
	* Render the input portion of the filter
	* Used when rendering within a filter item wrapper
	*/
	renderInput?: (props: CustomFilterInputRendererProps<Q, State>) => ReactNode;
	/**
	* Render the complete filter item
	* Used when you need full control over the item appearance
	*/
	renderItem?: (props: CustomFilterItemRendererProps<Q, State>) => ReactNode;
	/**
	* Convert filter state to a WhereClause for filtering
	* Required for the filter to affect the object set
	*/
	toWhereClause: (state: State) => WhereClause<Q> | undefined;
	/**
	* Controls whether this filter is rendered.
	* When false, the filter is hidden but its state is preserved.
	* @default true
	*/
	isVisible?: boolean;
}
