// Divi dependencies.
import { ModuleEditProps } from '@divi/module-library';
import {
	InternalAttrs,
	FormatBreakpointStateAttr,
	type Element,
} from '@divi/types';

// Local dependencies.
import type {
	AttrVal,
	BorderValue,
	TypographyValue,
	SpacingValue,
} from '../custom-types';

type BaseDecoration = Element.Decoration.PickedAttributes<
	| 'animation'
	| 'background'
	| 'border'
	| 'boxShadow'
	| 'disabledOn'
	| 'filters'
	| 'overflow'
	| 'position'
	| 'scroll'
	| 'sizing'
	| 'spacing'
	| 'sticky'
	| 'transform'
	| 'transition'
	| 'zIndex'
>;

type DecorationExtras = {
	selectWidth?: FormatBreakpointStateAttr<AttrVal>;
	selectTypography?: FormatBreakpointStateAttr<TypographyValue>;
	selectColor?: FormatBreakpointStateAttr<AttrVal>;
	selectBackgroundColor?: FormatBreakpointStateAttr<AttrVal>;
	selectPadding?: FormatBreakpointStateAttr<SpacingValue>;
	selectBorder?: FormatBreakpointStateAttr<BorderValue>;
	selectResetAppearance?: FormatBreakpointStateAttr<AttrVal>;

	labelTypography?: FormatBreakpointStateAttr<TypographyValue>;
	labelAlignment?: FormatBreakpointStateAttr<AttrVal>;
	labelColor?: FormatBreakpointStateAttr<AttrVal>;
	labelSpacing?: FormatBreakpointStateAttr<SpacingValue>;
	labelPadding?: FormatBreakpointStateAttr<SpacingValue>;
	labelMargin?: FormatBreakpointStateAttr<SpacingValue>;

	buttonTypography?: FormatBreakpointStateAttr<TypographyValue>;
	buttonNormalColor?: FormatBreakpointStateAttr<AttrVal>;
	buttonNormalBgColor?: FormatBreakpointStateAttr<AttrVal>;
	buttonHoverColor?: FormatBreakpointStateAttr<AttrVal>;
	buttonHoverBgColor?: FormatBreakpointStateAttr<AttrVal>;
	buttonHoverBorderColor?: FormatBreakpointStateAttr<AttrVal>;
	buttonBorder?: FormatBreakpointStateAttr<BorderValue>;
	buttonSpacing?: FormatBreakpointStateAttr<SpacingValue>;
	buttonPadding?: FormatBreakpointStateAttr<SpacingValue>;
	buttonMargin?: FormatBreakpointStateAttr<SpacingValue>;
	buttonAlignment?: FormatBreakpointStateAttr<AttrVal>;
};

export interface SortingAttrs extends InternalAttrs {
	module?: {
		meta?: Element.Meta.Attributes;
		advanced?: {
			link?: Element.Advanced.Link.Attributes;
			htmlAttributes?: Element.Advanced.IdClasses.Attributes;
			text?: Element.Advanced.Text.Attributes;
		};
		decoration?: BaseDecoration & DecorationExtras;
	};

	content_provider?: AttrVal;
	apply_type?: AttrVal;
	apply_on?: AttrVal;
	apply_button?: AttrVal;
	apply_button_text?: AttrVal;
	sorting_label?: AttrVal;
	sorting_placeholder?: AttrVal;
	sorting_list?: any;
	query_id?: AttrVal;
	additional_providers_enabled?: AttrVal;
	additional_providers_list?: AttrVal;

	[key: string]: any;
}

export type SortingEditProps = ModuleEditProps<SortingAttrs>;
