import { toDoseConditions, toDoseLayoutState, } from './adapters' import { activePlateFromState, sampleColorsFromPlateState, } from './componentPlateHelpers' import { propsBinding } from './componentPropsFactory' import type { BioTemplateComponentPropsBinding } from './componentBindings' import type { DoseResponseTemplate } from './types' export function doseResponseProps(template: DoseResponseTemplate): BioTemplateComponentPropsBinding[] { const conditions = toDoseConditions(template) const layout = toDoseLayoutState(template) const targetWells = layout ? Object.keys(activePlateFromState(layout).wells) : [] const props = [ propsBinding('dose-response', 'DoseCalculator', { mode: 'serial', targetWells, disabled: conditions.length === 0, }), ] if (layout) { const plate = activePlateFromState(layout) props.push(propsBinding('dose-response', 'WellPlate', { format: plate.format, wells: plate.wells, sampleColors: sampleColorsFromPlateState(layout), legendItems: conditions.map(condition => ({ type: condition.label, label: condition.label, color: condition.color, })), showLegend: true, })) } return props }