export interface ProjectDevicePlacementSource { category?: string | null; phaseType: "single_phase" | "three_phase"; } export interface ProjectDevicePlacementSection { key: string; } export type DefaultCircuitSectionKey = "lighting" | "single_phase" | "three_phase"; // Lighting classification takes precedence over the electrical phase because // lighting devices use their dedicated numbering section by default. export function inferProjectDeviceSectionKey( device: ProjectDevicePlacementSource ): DefaultCircuitSectionKey { const category = (device.category ?? "").trim().toLowerCase(); if (category.includes("light") || category.includes("beleuchtung")) { return "lighting"; } return device.phaseType; } export function isProjectDevicePlacementValid( device: ProjectDevicePlacementSource, section: ProjectDevicePlacementSection ): boolean { return section.key === inferProjectDeviceSectionKey(device); }