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

import type {
	AttrVal,
	BorderValue,
	SpacingValue,
	TypographyValue,
} 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 = {
	linkTypography?: FormatBreakpointStateAttr<TypographyValue>;
	linkBg?: FormatBreakpointStateAttr<AttrVal>;
	linkColor?: FormatBreakpointStateAttr<AttrVal>;
	linkIconColor?: FormatBreakpointStateAttr<AttrVal>;
	linkBgHover?: FormatBreakpointStateAttr<AttrVal>;
	linkColorHover?: FormatBreakpointStateAttr<AttrVal>;
	linkIconColorHover?: FormatBreakpointStateAttr<AttrVal>;
	linkAlignment?: FormatBreakpointStateAttr<AttrVal>;
	linkSpacing?: FormatBreakpointStateAttr<SpacingValue>;
	linkBorder?: FormatBreakpointStateAttr<BorderValue>;
	linkBorderColor?: FormatBreakpointStateAttr<AttrVal>;
	linkHoverBorderColor?: FormatBreakpointStateAttr<AttrVal>;
	linkIconPosition?: FormatBreakpointStateAttr<AttrVal>;
	linkIconOrientation?: FormatBreakpointStateAttr<AttrVal>;
	linkIconSize?: FormatBreakpointStateAttr<AttrVal>;
	linkIconGap?: FormatBreakpointStateAttr<AttrVal>;
};

export interface DynamicLinkAttrs 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;
	};

	[key: string]: any;
}

export type DynamicLinkEditProps = ModuleEditProps<DynamicLinkAttrs>;
