'use client' import { type AnyNode, type GuideNode, type ScanNode, useScene } from '@pascal-app/core' import { Box, Image, X } from 'lucide-react' import { useCallback } from 'react' import useEditor from '@/store/use-editor' import { NumberInput } from '@/components/ui/primitives/number-input' type ReferenceNode = ScanNode | GuideNode export function ReferencePanel() { const selectedReferenceId = useEditor((s) => s.selectedReferenceId) const setSelectedReferenceId = useEditor((s) => s.setSelectedReferenceId) const nodes = useScene((s) => s.nodes) const updateNode = useScene((s) => s.updateNode) const node = selectedReferenceId ? (nodes[selectedReferenceId as AnyNode['id']] as ReferenceNode | undefined) : undefined const handleUpdate = useCallback( (updates: Partial) => { if (!selectedReferenceId) return updateNode(selectedReferenceId as AnyNode['id'], updates) }, [selectedReferenceId, updateNode], ) const handleClose = useCallback(() => { setSelectedReferenceId(null) }, [setSelectedReferenceId]) if (!node || (node.type !== 'scan' && node.type !== 'guide')) return null const isScan = node.type === 'scan' return (
{/* Header */}
{isScan ? ( ) : ( )}

{node.name || (isScan ? '3D Scan' : 'Guide Image')}

{/* Content */}
{/* Position */}
{([0, 1, 2] as const).map((i) => ( { const pos = [...node.position] as [number, number, number] pos[i] = value handleUpdate({ position: pos }) }} precision={2} /> ))}
{/* Rotation Y */}
{ const radians = (degrees * Math.PI) / 180 handleUpdate({ rotation: [node.rotation[0], radians, node.rotation[2]], }) }} precision={0} className="min-w-0 flex-1" /> °
{/* Scale */}
{ if (value > 0) { handleUpdate({ scale: value }) } }} min={0.01} precision={2} />
{/* Opacity */}
{node.opacity}%
handleUpdate({ opacity: Number.parseInt(e.target.value, 10) })} step="1" type="range" value={node.opacity} />
) }