import { Asset } from '../molecules/asset.js'
import { PromoText } from '../molecules/promo-text.js'
import h from '../shared/h.js'
import { ValidationError } from '../routing/error-handler.js'

export function PromoFull ({ _model, _variant, ...props }) {
  const { title, text, asset } = _model
  if (!title || !text || !asset.src) {
    throw new ValidationError()
  }

  return h('div', { ...props, className: 'bg-bga text-txa rounded-2xl overflow-hidden lg:grid lg:grid-cols-12' },
    h('div', { className: `col-span-6 row-start-1 ${_variant === 'right' ? '' : 'col-start-7'}` },
      h(Asset, { _model, _tall: true })
    ),
    h('div', { className: 'col-span-6 row-start-1 flex items-center' },
      h(PromoText, { _model })
    )
  )
}
