import { Box } from '../atoms/box.js'
import { Heading } from '../atoms/heading.js'
import { Links } from '../molecules/links.js'
import { ValidationError } from '../routing/error-handler.js'
import h from '../shared/h.js'

export function FooterItem ({ _model, ...props }) {
  const { title, links } = _model
  if (!title || links.length === 0) {
    throw new ValidationError()
  }

  return h(Box, { ...props, className: 'text-sm' },
    h(Heading, { _level: 2, _size: 3 }, title),
    h(Links, { _model, _variant: 'simple' })
  )
}
