import { Primitive } from '../../../types/general';
import { EvaluateResult as EvaluateResultBase, ValidationRule } from './validation-rule';
import { VegaFile } from '../../../components/vega-image-uploader/types';
import { VegaSignatureValue } from '../../../components/vega-signature-capture/types';
import { VegaFileUploaderFile } from '../../../components/vega-file-uploader/types';
import { VegaRTEContentBlock } from '../../../components/vega-rich-text-editor/interface';

export type EvaluateResult<T = string> = EvaluateResultBase<T>;

export type FormFieldStatusMeta = {
	touched: boolean;
	modified: boolean;
	disabled: boolean;
	visible: boolean;
};
export interface FormFieldValidationRule<T> extends ValidationRule<T> {
	canEvaluate(
		input: unknown,
		status?: FormFieldStatusMeta,
		statusChanged?: (keyof FormFieldStatusMeta)[],
	): boolean;
	shouldShowError?(status?: FormFieldStatusMeta, statusChanged?: (keyof FormFieldStatusMeta)[]): boolean;
	evaluate(input: T): EvaluateResult | Promise<EvaluateResult>;
}

export type FormFieldValueType =
	| Primitive
	| VegaFile
	| VegaSignatureValue
	| VegaFileUploaderFile
	| VegaRTEContentBlock;
