'use client' import { type AnyNodeId, useScene } from '@pascal-app/core' import { useViewer } from '@pascal-app/viewer' import useEditor from '../../../store/use-editor' import { CeilingPanel } from './ceiling-panel' import { DoorPanel } from './door-panel' import { FencePanel } from './fence-panel' import { ItemPanel } from './item-panel' import { PaintPanel } from './paint-panel' import { ReferencePanel } from './reference-panel' import { RoofPanel } from './roof-panel' import { RoofSegmentPanel } from './roof-segment-panel' import { SlabPanel } from './slab-panel' import { SpawnPanel } from './spawn-panel' import { StairPanel } from './stair-panel' import { StairSegmentPanel } from './stair-segment-panel' import { WallPanel } from './wall-panel' import { WindowPanel } from './window-panel' export function PanelManager() { const selectedIds = useViewer((s) => s.selection.selectedIds) const selectedReferenceId = useEditor((s) => s.selectedReferenceId) const isPaintPanelOpen = useEditor((s) => s.isPaintPanelOpen) const mode = useEditor((s) => s.mode) const activePaintMaterial = useEditor((s) => s.activePaintMaterial) // Only subscribe to the *type* of the single-selected node — string primitive // so we don't re-render on unrelated scene mutations. const selectedNodeType = useScene((s) => { if (selectedIds.length !== 1) return null const id = selectedIds[0] return id ? (s.nodes[id as AnyNodeId]?.type ?? null) : null }) // Show reference panel if a reference is selected if (selectedReferenceId) { return } if ( isPaintPanelOpen && mode === 'material-paint' && activePaintMaterial?.material?.properties && !activePaintMaterial.materialPreset ) { return } // Show appropriate panel based on selected node type if (selectedNodeType) { switch (selectedNodeType) { case 'item': return case 'roof': return case 'roof-segment': return case 'stair': return case 'stair-segment': return case 'slab': return case 'spawn': return case 'ceiling': return case 'wall': return case 'fence': return case 'door': return case 'window': return } } return null }