import type { PlateMapEditorState, } from '../types' import { getTemplateData } from './templateEnvelopes' import { validatePlateMapData } from './templateValidators' import type { PlateMapEditorAdapterResult, PlateMapTemplate, PlateMapTemplateData, WellMapAdapterResult, } from './types' /** @deprecated Scheduled for removal from the core SDK in MINT 1.4; the biology templates move to a dedicated package or the owning plugins. */ export function toPlateMapEditorState( template: PlateMapTemplate | PlateMapTemplateData ): PlateMapEditorAdapterResult { const data = getTemplateData(template, 'plate-map') validatePlateMapData(data) const activePlateId = data.activePlateId ?? data.plates[0].id return { plates: data.plates, activePlateId, samples: data.samples, selectedWells: data.selectedWells ?? [], activeSampleId: data.activeSampleId, } satisfies PlateMapEditorState } /** @deprecated Scheduled for removal from the core SDK in MINT 1.4; the biology templates move to a dedicated package or the owning plugins. */ export function toWellPlateWells( template: PlateMapTemplate | PlateMapTemplateData, plateId?: string ): WellMapAdapterResult { const state = toPlateMapEditorState(template) const plate = state.plates.find(candidate => candidate.id === (plateId ?? state.activePlateId)) ?? state.plates[0] return plate.wells }