import { Group, Rect, Line } from 'react-konva';

interface ShelfSilhouetteProps {
  readonly x: number;
  readonly y: number;
  readonly width: number;
  readonly depth: number;
  readonly rotation: number;
  readonly color: string;
  readonly fillColor: string;
}

/** Top-down shelf/bookcase silhouette: rectangle with horizontal shelf lines. */
export function ShelfSilhouette({ x, y, width, depth, rotation, color, fillColor }: ShelfSilhouetteProps) {
  const halfW = width / 2;
  const halfD = depth / 2;
  const shelfCount = 3;

  const shelfLines: number[] = [];
  for (let i = 1; i <= shelfCount; i++) {
    const yPos = -halfD + (depth / (shelfCount + 1)) * i;
    shelfLines.push(yPos);
  }

  return (
    <Group x={x} y={y} rotation={rotation}>
      <Rect
        x={-halfW}
        y={-halfD}
        width={width}
        height={depth}
        stroke={color}
        strokeWidth={1.5}
        fill={fillColor}
        listening={false}
      />
      {shelfLines.map((sy, idx) => (
        <Line
          key={idx}
          points={[-halfW, sy, halfW, sy]}
          stroke={color}
          strokeWidth={0.8}
          listening={false}
        />
      ))}
    </Group>
  );
}
