import { type ReactNode } from 'react'
import { type IPropsWithChildren } from './ReactHelperTypes'
import { type UseFormRegisterReturn } from 'react-hook-form'
import { IButtonClassProps } from '@/Components/Buttons/Types'

interface ILabelProps {
  label?: string | ReactNode
  children?: ReactNode
  defaultClassName?: string
  className?: string
  disabled?: boolean
}

interface IDescriptionProps {
  description?: string
  defaultClassName?: string
  className?: string
  disabled?: boolean
}

interface ISelectOptionProps {
  label: string
  value: string | number
  [key: string]: string | number | boolean | Record<string, unknown>
}

interface IRadioGroupOptionProps {
  label: string | ReactNode
  value: string | number
  [key: string]: string | number | boolean | Record<string, unknown> | ReactNode
}

interface IInputProps extends IPropsWithChildren {
  id: string
  testId: string
  label?: string | ReactNode
  description?: string | ReactNode
  before?: ReactNode
  after?: ReactNode
  size?: string
  defaultClassName?: string
  className?: string
  defaultWrapperClassName?: string
  wrapperClassName?: string
  error?: string
  disabled?: boolean
  validator?: UseFormRegisterReturn<any>
}

interface IValueInputProps {
  value?: string | number
  placeholder?: string
}

interface ICheckboxInputProps extends IInputProps {
  wrapperClassName?: string
  align?: 'left' | 'right' | 'none'
  value: boolean
  onChange?: (v: boolean) => void
}

interface ITextAreaProps extends IInputProps, IValueInputProps {
  onChange?: (v?: string) => void
  cleaner?: (v?: string) => string
  autofocus?: boolean
  onFocus?: () => void
  onBlur?: () => void
}

interface ITextInputProps extends ITextAreaProps {
  onSubmit?: (v?: string | number) => void
  submitOnEnter?: boolean
  type?: 'text' | 'password'
}

interface ISelectProps extends IInputProps, IValueInputProps {
  onChange?: (op?: ISelectOptionProps) => void
  onFocus?: () => void
  onBlur?: () => void
  value?: string | number
  includePrompt?: boolean
  options: ISelectOptionProps[]
  clearable?: boolean
  variant?: IButtonClassProps['variant']

}

interface IRadioGroupProps extends Omit<ISelectProps, 'options' | 'includePrompt' | 'onChange'> {
  options: IRadioGroupOptionProps[]
  onChange?: (op?: IRadioGroupOptionProps) => void
}

type ISliderRangeValues = [number, number]

interface IRangeProps {
  min: number
  max: number
  step: number
}

interface ISliderSharedProps {
  thumbClass?: string
  retainUndefinedOnLoad?: boolean
}

interface ISliderRangeProps extends IInputProps, IRangeProps, ISliderSharedProps {
  range?: ISliderRangeValues
  onChange?: (v: ISliderRangeValues) => void
  onChangeComplete?: (v: ISliderRangeValues) => void
  rangeClass?: string
  startThumbClass?: string
  endThumbClass?: string
}

interface ISliderProps extends IInputProps, IRangeProps, ISliderSharedProps {
  value?: number
  onChange?: (v: number) => void
  onChangeComplete?: (v: number) => void
}

export type {
  IInputProps,
  ILabelProps,
  IDescriptionProps,
  ICheckboxInputProps,
  ITextAreaProps,
  ITextInputProps,
  ISelectOptionProps,
  ISelectProps,
  IRadioGroupOptionProps,
  IRadioGroupProps,
  ISliderProps,
  ISliderRangeProps,
  ISliderRangeValues
}
