import React from 'react'
import { getSession } from '@jbrowse/core/util'
import { observer } from 'mobx-react'
import { hasHoverPosition, useStyles } from './util'
import { isMsaView } from '../MsaViewPanel/model'
import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
type LGV = LinearGenomeViewModel
const MsaToGenomeHighlight = observer(function MsaToGenomeHighlight2({
model,
}: {
model: LGV
}) {
const { views, hovered } = getSession(model)
const msaView = views
.filter(isMsaView)
.find(v => v.connectedViewId === model.id)
// The persistent click selection always shows. The hover codon is suppressed
// while hovering the LGV — GenomeMouseoverHighlight handles the single-bp
// display in that case, so we don't stack a wider codon band on top of it.
const clickHighlight = msaView?.connectedClickHighlight
const hoverHighlight = hasHoverPosition(hovered)
? undefined
: msaView?.connectedHoverHighlight
const highlights = [clickHighlight, hoverHighlight].filter(
(r): r is { refName: string; start: number; end: number } =>
r !== undefined,
)
return highlights.length ? (