import { Maybe } from '@m4l/core';
import { ChipColorOptions, Sizes } from '@m4l/styles';
import { Theme } from '@mui/material/styles';
import { M4LOverridesStyleRules } from '../../@types/augmentations';
import { RHFAutocompleteAsyncProps } from '../hook-form/RHFAutocompleteAsync/types';
import { RHFSelectProps } from '../hook-form/RHFSelect';
import { DynamicFilterSlots } from './slots';
import { PresentationType } from '../formatters/BooleanFormatter/types';
/**
 * Labels personalizados para valores booleanos
 */
export interface BooleanCustomLabels {
    trueLabel: string;
    falseLabel: string;
}
/**
 * Tipo de presentación para campos booleanos en DynamicFilter
 * Solo incluye las presentaciones de texto del BooleanFormatter más labels personalizados
 */
export type BooleanPresentationType = Extract<PresentationType, 'string_true_false' | 'string_yes_no'> | BooleanCustomLabels;
export type FieldType = 'number' | 'string' | 'boolean' | 'datetime' | 'select' | 'selectAsync';
export type OperandType = number | string | boolean | Date | [] | object;
export type OperandInitialFilterType = number | string | boolean | [] | object;
export type OperatorB = 'b';
export type Operator = OperatorB | 'e' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'c' | 'nc' | 'in' | 'nin';
export type StringOperator = 'c' | 'nc';
export type NumberOperator = OperatorB | 'e' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
export type BooleanOperator = 'e' | 'ne';
export type DateTimeOperator = OperatorB | 'e' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
export type SelectOperator = 'in' | 'nin' | 'e' | 'ne';
export type SelectOperatorAsync = 'in' | 'nin' | 'e' | 'ne';
export type FieldPresence = 'initialized' | 'fixed' | 'optional';
export type OperandSelectAsync = Record<string, any>;
export type OperandSelect = string | number;
/**
 * Posibles valores para el operandsArray para el caso del select o otros fields
 */
export type OperandsArraySelectAsync = Array<OperandSelectAsync>;
export type OperandsSelectArray = Array<OperandSelect>;
export type FieldTypeOperator<T extends FieldType> = T extends 'boolean' ? BooleanOperator : T extends 'datetime' ? DateTimeOperator : T extends 'number' ? NumberOperator : T extends 'select' ? SelectOperator : T extends 'selectAsync' ? SelectOperatorAsync : T extends 'string' ? StringOperator : T;
export type FieldTypeOperand<T extends FieldType> = T extends 'boolean' ? boolean : T extends 'datetime' ? Date : T extends 'number' ? number : T extends 'string' ? string : T extends 'select' ? OperandSelect : T extends 'selectAsync' ? OperandSelectAsync : FieldType;
export type FieldTypeOperandsArray<T extends FieldType> = T extends 'boolean' ? never : T extends 'datetime' ? never : T extends 'number' ? never : T extends 'string' ? never : T extends 'select' ? OperandsSelectArray : T extends 'selectAsync' ? OperandsArraySelectAsync : never;
type SelectAsyncOptions<TOption = any> = Pick<RHFAutocompleteAsyncProps<TOption>, 'type' | 'endPoint' | 'responseToCamelCase' | 'multiple' | 'autoComplete' | 'autoCapitalize' | 'parms' | 'timeout' | 'onChangeFilterParms' | 'getOptionStartAdornment'> & {
    getOptionLabel: (option: TOption) => string;
    isOptionEqualToValue: (options: TOption | TOption[], value: TOption) => boolean;
    getOptionId: (option: TOption) => string | number;
};
type SelectOptions = Omit<RHFSelectProps<any, true>, 'name'>;
export interface FieldBase<T extends FieldType = FieldType, TOption = any> {
    name: string;
    type: T;
    multiple?: boolean;
    presence?: FieldPresence;
    restritcOperatorsTo?: Maybe<FieldTypeOperator<T>[]>;
    urlIcon: string;
    defaultOperator?: Maybe<FieldTypeOperator<T>>;
    defaultOperand1?: Maybe<FieldTypeOperand<T>>;
    defaultOperand2?: Maybe<FieldTypeOperand<T>>;
    defaultOperandsArray?: Maybe<FieldTypeOperandsArray<T>>;
    selectOptions?: SelectOptions;
    selectAsyncOptions?: SelectAsyncOptions<TOption>;
    skipColumnValidation?: boolean;
    /**
     * Tipo de presentación para campos booleanos.
     * Solo aplica cuando type es 'boolean'.
     * - 'string_true_false': "Verdadero" / "Falso" (default)
     * - 'string_yes_no': "Sí" / "No"
     * - { trueLabel: string, falseLabel: string }: Labels personalizados
     * @default 'string_true_false'
     */
    presentationType?: BooleanPresentationType;
    /**
     * Máximo de días permitidos en el intervalo de fechas.
     * Solo aplica cuando type es 'datetime' y el operador es 'between' (b).
     * Si el usuario selecciona un rango que excede este valor, se mostrará un error.
     * @example maxDays: 7 // Máximo 7 días de intervalo
     */
    maxDays?: number;
    /**
     * Color of the applied filter chip when the filter is set (isSet === true).
     * Accepts any of the Chip color options (e.g. 'primary', 'secondary',
     * 'success', 'warning', 'info', 'default').
     * When the filter is not set (isSet === false) the chip always renders as
     * 'error' regardless of this value.
     * @default 'default'
     */
    color?: ChipColorOptions;
}
export interface FieldWithSelectAsync<T extends 'selectAsync', TOption = any> extends FieldBase<T, TOption> {
    selectAsyncOptions: SelectAsyncOptions<TOption>;
}
export interface FieldWithSelect<T extends 'select'> extends FieldBase<T> {
    selectOptions: SelectOptions;
}
export interface FieldDictionaryId<T extends FieldType = FieldType> extends FieldBase<T> {
    dictionaryId: string;
    label?: undefined;
}
export interface Label<T extends FieldType = FieldType> extends FieldBase<T> {
    label: string;
    dictionaryId?: undefined;
}
export type FilterField<T extends FieldType = FieldType, TOption = any> = T extends 'selectAsync' ? FieldWithSelectAsync<T, TOption> & (FieldDictionaryId<T> | Label<T>) : T extends 'select' ? FieldWithSelect<T> & (FieldDictionaryId<T> | Label<T>) : FieldDictionaryId<T> | Label<T>;
export interface BaseApplyFilter<T extends FieldType = FieldType> {
    id: number;
    field: FilterField<T>;
    isSet: boolean;
    fixed: boolean;
}
/**
 * Base para el tipado de overloading de los valores de un filtro
 */
export interface FilterValueBase<T extends FieldType = FieldType> {
    fieldType: T;
    operator: Operator;
    operand1?: Maybe<OperandType>;
    operand2?: Maybe<OperandType>;
    operandsArray?: T extends 'selectAsync' ? OperandsArraySelectAsync : T extends 'select' ? OperandsSelectArray : never;
}
export interface FilterValueBoolean extends FilterValueBase<'boolean'> {
    fieldType: 'boolean';
    operator: BooleanOperator;
    operand1: boolean;
}
export interface FilterValueDateTimeNoB extends FilterValueBase<'datetime'> {
    fieldType: 'datetime';
    operator: Exclude<DateTimeOperator, OperatorB>;
    operand1: Date;
}
export interface FilterValueDateTimeB extends FilterValueBase<'datetime'> {
    fieldType: 'datetime';
    operator: OperatorB;
    operand1: Date;
    operand2: Date;
}
export type FilterValueDateTime = FilterValueDateTimeNoB | FilterValueDateTimeB;
export interface FilterValueNumberNoB extends FilterValueBase<'number'> {
    fieldType: 'number';
    operator: Exclude<NumberOperator, OperatorB>;
    operand1: Maybe<number>;
}
export interface FilterValueNumberB extends FilterValueBase<'number'> {
    fieldType: 'number';
    operator: OperatorB;
    operand1: Maybe<number>;
    operand2: Maybe<number>;
}
export type FilterValueNumber = FilterValueNumberNoB | FilterValueNumberB;
export interface FilterValueString extends FilterValueBase<'string'> {
    fieldType: 'string';
    operator: StringOperator;
    operand1: string;
}
export interface FilterValueSelectMultipleAsync extends FilterValueBase<'selectAsync'> {
    fieldType: 'selectAsync';
    multiple: true;
    operator: SelectOperator;
    operand1: never;
    operandsArray: OperandsArraySelectAsync;
}
export interface FilterValueSelectSingleAsync extends FilterValueBase<'selectAsync'> {
    fieldType: 'selectAsync';
    operator: SelectOperator;
    operand1: OperandSelectAsync;
    operandsArray: never;
}
export type FilterValueSelectAsync = FilterValueSelectMultipleAsync | FilterValueSelectSingleAsync;
export interface FilterValueSelectSingle extends FilterValueBase<'select'> {
    fieldType: 'select';
    multiple: false;
    operator: SelectOperator;
    operand1: OperandSelect;
    operandsArray: never;
}
export interface FilterValueSelectMultiple extends FilterValueBase<'select'> {
    fieldType: 'select';
    multiple: true;
    operator: SelectOperator;
    operand1: never;
    operandsArray: OperandsSelectArray;
}
export type FilterValueSelect = FilterValueSelectSingle | FilterValueSelectMultiple;
/**
 * Valor de un filtro sobrecargado para cada tipo de dato
 */
export type FilterValue = FilterValueBoolean | FilterValueDateTime | FilterValueNumber | FilterValueString | FilterValueSelectAsync | FilterValueSelect;
/**
 * Estado del Filtro + Valor valor del filtro.
 */
export type FilterFieldApplied<T extends FieldType = FieldType> = BaseApplyFilter<T> & FilterValue;
/**
 * RawFilterFieldApply Formato para enviar los filtros a las APIs.
 */
export interface RawFilterFieldApply {
    n: string;
    o: Operator;
    ft: FieldType;
    o1: Maybe<OperandType>;
    o2?: Maybe<OperandType>;
    oa?: Maybe<OperandType[]>;
}
export type FilterToEditApply = FilterFieldApplied;
export interface DataTypeFilerLabels {
    labelField: string;
    labelOperator: string;
    labelOperands: string;
}
/**
 * Tipado de los filtros a inicializar el componente DynamicFilter
 */
export type InitialFilterApplied = {
    name: string;
    operator: Operator;
    operand1?: Maybe<OperandInitialFilterType>;
    operand2?: Maybe<OperandInitialFilterType>;
    operandsArray?: Array<Maybe<OperandInitialFilterType>>;
};
export type FormOperator<T extends Operator = Operator> = {
    id: T;
    label: string;
};
export type FormOperandBoolean = {
    value: boolean;
    label: string;
};
export type FormOperandDateTime = Date;
export type FormOperandNumber = number;
export type FormOperandString = string;
export type FormOperand = FormOperandBoolean | FormOperandDateTime | FormOperandNumber | FormOperandString | OperandSelectAsync | OperandSelect;
/**
 * Base para el tipado de overloading de los valor de un filtro
 */
export interface FormFilterValueBase {
    fieldType: FieldType;
    formValueOperator: FormOperator;
}
export interface FormFilterValueBoolean extends FormFilterValueBase {
    fieldType: 'boolean';
    formValueOperator: FormOperator<BooleanOperator>;
    formValueOperand1: Maybe<FormOperandBoolean>;
}
export interface FormFilterValueDateTime extends FormFilterValueBase {
    fieldType: 'datetime';
    formValueOperator: FormOperator<DateTimeOperator>;
    formValueOperand1: Date;
    formValueOperand2: Date;
}
export interface FormFilterValueNumber {
    fieldType: 'number';
    formValueOperator: FormOperator<NumberOperator>;
    formValueOperand1: Maybe<number>;
    formValueOperand2: Maybe<number>;
}
export interface FormFilterValueString extends FormFilterValueBase {
    fieldType: 'string';
    formValueOperator: FormOperator<StringOperator>;
    formValueOperand1: string;
}
export interface FormFilterValueSelectAsyncMultiple extends FormFilterValueBase {
    fieldType: 'selectAsync';
    multiple: true;
    formValueOperator: FormOperator<SelectOperatorAsync>;
    formValueOperandsArray: OperandsArraySelectAsync;
    formValueOperand1: never;
}
export interface FormFilterValueSelectAsyncSingle extends FormFilterValueBase {
    fieldType: 'selectAsync';
    multiple: false;
    formValueOperator: FormOperator<SelectOperatorAsync>;
    formValueOperand1: OperandSelectAsync;
    formValueOperandsArray: never;
}
export type FormFilterValueSelectAsync = FormFilterValueSelectAsyncMultiple | FormFilterValueSelectAsyncSingle;
export interface FormFilterValueSelectMultiple extends FormFilterValueBase {
    fieldType: 'select';
    multiple: true;
    formValueOperator: FormOperator<SelectOperator>;
    formValueOperand1: never;
    formValueOperandsArray: Array<OperandSelect> | OperandSelect;
}
export interface FormFilterValueSelectSingle extends FormFilterValueBase {
    fieldType: 'select';
    multiple: false;
    formValueOperator: FormOperator<SelectOperator>;
    formValueOperand1: OperandSelect;
    formValueOperandsArray: never;
}
export type FormFilterValueSelect = FormFilterValueSelectMultiple | FormFilterValueSelectSingle;
/**
 * Valor de un filtro sobrecargado para cada tipo de dato
 */
export type FormFilterValue = FormFilterValueBoolean | FormFilterValueDateTime | FormFilterValueNumber | FormFilterValueString | FormFilterValueSelectAsync | FormFilterValueSelect;
/**
 * Estado del Filtro + Valor valor del filtro.
 */
export type FormFilterFieldApplied<T extends FieldType = FieldType> = BaseApplyFilter<T> & FormFilterValue;
/**
 * Tipado del handler cuando se ejecuta el filtro
 */
export type OnChangeFilters = (
/**
 *  "filters" Vector de filtros aplicados, los cuales pueden servir como entrada del campo "i"nitialApplyedFilters" en un refresh,
 */
filters: Array<InitialFilterApplied>, 
/**
 *  "rawFilters" Vector de filtros aplicados, en el formato que puede ser llevado a un endpoint.
 *   ver:  https://www.notion.so/made4labs/Filtrado-de-listas-55afdd8ac92e483abd34e5365b74ee29
 */
rawFilters: Array<RawFilterFieldApply>) => void;
/**
 * Propiedades que recibe el componente DynamicFilter
 */
export interface DynamicFilterProps {
    /**
     *  "className" clase css para el componente
     */
    className?: string;
    /**
     *  "storeId" identificador del store
     */
    storeId?: string;
    /**
     *  "storeDevtoolsEnabled" determina si se debe usar devtools para el store
     */
    storeDevtoolsEnabled?: boolean;
    /**
     *  Define si el filtro se ejecuta automáticamente cuando se agrega o se modifica un filtro.
     *  @default true
     */
    automatic?: boolean;
    /**
     *  Permite tener el filtro tipo `all`, que filtra por todos los campos.
     *  @default true
     */
    withAllField?: boolean;
    /**
     * Array con la configuración de cada campo por el que se podrá filtrar.
     */
    fields: Array<FilterField>;
    /**
     *  Array con la configuración de cada campo por el que se podrá filtrar.
     */
    initialAppliedFilters?: Array<InitialFilterApplied>;
    /**
     *  Handler que se dispara cuando el filtro cambia en automatico, o cuando es manual y se presion el boton de filtrar
     */
    onChangeFilters?: OnChangeFilters;
    /**
     * Handler cuando se marca como dirty
     */
    onDirty?: () => void;
    /**
     *  Key único necesario para las pruebas del componente.
     */
    dataTestId?: string;
    /**
     * Size del componente
     */
    size?: Extract<Sizes, 'small' | 'medium'>;
    /**
     * visibleRefresh: indica si el boton de refresh debe estar visible
     */
    visibleRefresh?: boolean;
}
/**
 * Interface que define la variables que se van a usar en clases del componente
 */
export interface OwnerState extends Pick<DynamicFilterProps, 'visibleRefresh'> {
    /**
     *  "isSkeleton" indica si el componente está estado skeleton.
     */
    isSkeleton: boolean;
    /**
     *  "inEdition" se establece cuando se está en edición.
     */
    inEdition: boolean;
    /**
     *  "isDirty" cuando el componente tiene filtros por aplicar
     */
    isDirty: boolean;
    /**
     *  "isValid" cuando el comnponente está en un estado invalido
     */
    isValid: boolean;
    /**
     *  "isMobile" cuando el navegador está en modo celular
     */
    isMobile: boolean;
    /**
     *  "isEmpty" Define si existen filtros aplicados
     */
    isEmpty: boolean;
    /**
     * Size del componente
     */
    size?: Extract<Sizes, 'small' | 'medium'>;
}
export interface DynamicFilterOwnerState extends DynamicFilterProps, OwnerState {
    /**
     * Marks a chip wrapper as containing a warning-colored chip so the
     * styles file can apply the pulse animation only on those chips.
     */
    isWarning?: boolean;
    /**
     * Marks an overflow popover item as keyboard-selected so the item
     * style can render it with the highlight color.
     */
    selected?: boolean;
}
export type DynamicFilterSlotsType = keyof typeof DynamicFilterSlots;
export type DynamicFilterStyles = M4LOverridesStyleRules<DynamicFilterSlotsType, 'M4LDynamicFilter', Theme>;
export interface DynamicFilterRef {
    fireOnChangeFilter: () => void;
    openPopoverMenuFields: () => void;
    addExternalFilter: (columnKey: string) => void;
    getCurrentFilters: () => FilterFieldApplied[];
}
export {};
//# sourceMappingURL=types.d.ts.map