import type { Project, Room, Wall, UrlState } from './types'; export function rectangle(id = 'room-1', name = 'Living room', width = 4800, height = 3600): Room { return { id, name, direction: 0, walls: [width, height, width, height].map((length, i) => ({ id: `${id}-w${i + 1}`, length, turn: 90, doors: i === 3 ? [{ id: `${id}-door-1`, offset: 500, width: 826 }] : [], })), }; } export function fireplace(id: string, name: string): Room { const measures = [ [4800, 90], [3600, 90], [1650, 90], [450, -90], [1500, -90], [450, 90], [1650, 90], [3600, 90], ]; const walls: Wall[] = measures.map(([length, turn], i) => ({ id: `${id}-w${i + 1}`, length, turn, doors: i === 7 ? [{ id: `${id}-door-1`, offset: 500, width: 826 }] : [], })); return { id, name, direction: 0, walls }; } export function defaultProject(): Project { return { rooms: [rectangle()], tolerance: 10, completedBoards: [], flooring: { length: 1200, width: 190, gap: 10, pattern: 'random', optimisation: 'cuts', minOffset: 300, maxOffset: 600, minLength: 200, minWidth: 60, kerf: 3, }, skirting: { stockLength: 2400, thickness: 18, minLength: 200, kerf: 3 }, }; } export function defaultState(): UrlState { return { project: defaultProject(), view: { roomId: 'room-1', selectedPiece: null, focus: null, search: '', collapsedSections: [], material: 'flooring', }, }; } export function nextId(prefix: string, existing: string[]): string { let n = 1; while (existing.includes(`${prefix}-${n}`)) n++; return `${prefix}-${n}`; }