import { type BlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'

const extractCurrentListItems = ({
  list,
  currentIndex,
}: {
  list: BlockObjectResponse[]
  currentIndex: number
}) =>
  list.slice(
    currentIndex,
    list.findIndex(
      ({ type }, finalItemIndex) =>
        type !== 'bulleted_list_item' && finalItemIndex > currentIndex,
    ),
  )

export default extractCurrentListItems
