import { EffectCallback, MutableRefObject } from 'react'
import { OnchainItemSection } from 'uniswap/src/components/TokenSelector/types'
import { SectionHeaderProps } from 'uniswap/src/components/lists/SectionHeader'
import { FocusedRowControl } from 'uniswap/src/components/lists/items/OptionItem'
import { OnchainItemListType } from 'uniswap/src/components/lists/items/types'
import { PlatformSplitStubError } from 'utilities/src/errors'

export interface OnchainItemListRef {
  scrollToLocation: (params: { itemIndex: number; sectionIndex: number; animated: boolean }) => void
}

export type SectionRowInfo = { section: SectionHeaderProps }

export interface ItemRowInfo<T extends OnchainItemListType> {
  item: T
  section: OnchainItemSection<T>
  index: number
  rowIndex: number
  expanded?: boolean
}

export interface OnchainItemListProps<T extends OnchainItemListType> {
  sectionListRef?: MutableRefObject<OnchainItemListRef | undefined>
  ListEmptyComponent?: JSX.Element
  focusHook?: (callback: EffectCallback) => void
  keyExtractor?: (item: T, index: number) => string
  renderItem: (info: ItemRowInfo<T>) => JSX.Element | null
  renderSectionHeader?: (info: SectionRowInfo) => JSX.Element
  sections: OnchainItemSection<T>[]
  expandedItems?: string[]
  focusedRowControl?: Omit<FocusedRowControl, 'rowIndex'>
}

export function OnchainItemList<T extends OnchainItemListType>(_props: OnchainItemListProps<T>): JSX.Element {
  throw new PlatformSplitStubError('OnchainItemList')
}
