@mgamadeus/ddd-design-studio 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/canvas/DesignStudioCanvasScreen.tsx","../../src/canvas/BoardComments.tsx","../../src/canvas/BoardFocusView.tsx","../../src/canvas/BoardNode.tsx","../../src/canvas/boardStatus.ts","../../src/canvas/boardDetail.ts","../../src/canvas/boardKey.ts","../../src/canvas/canvasLayout.ts","../../src/canvas/canvasLiveUpdate.ts","../../src/canvas/canvasView.ts","../../src/canvas/useCheckedContentUrl.ts","../../src/canvas/useDeferredMount.ts","../../src/canvas/stableContentUrl.ts","../../src/canvas/BoardStatusChips.tsx","../../src/canvas/DesignCanvasFlow.tsx","../../src/canvas/SectionNode.tsx"],"sourcesContent":["'use client';\n\nimport { normalizeDddError } from '@mgamadeus/ddd-web/api';\nimport {\n ClipboardCopy,\n ImageDown,\n ListFilter,\n LoaderCircle,\n Maximize,\n Maximize2,\n MessageSquare,\n Minimize,\n Moon,\n PanelRightClose,\n PanelRightOpen,\n RefreshCw,\n Sun,\n} from 'lucide-react';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport type { DesignStudioBoardView, DesignStudioComment } from '../api/types';\nimport { useDesignStudio, useDesignStudioComponents, useDesignStudioTexts } from '../provider/DesignStudioProvider';\nimport type { DesignStudioShell } from '../provider/types';\nimport { cx } from '../utils/cx';\nimport { BoardComments, buildCommentThreads, type CommentThread } from './BoardComments';\nimport { BoardFocusView } from './BoardFocusView';\nimport { BoardStatusChips } from './BoardStatusChips';\nimport { LIVE_MIN_RENDERED_WIDTH_RATIO, LIVE_MIN_RENDERED_WIDTH_RATIO_WITHOUT_THUMBNAILS } from './boardDetail';\nimport { boardStatusLabel } from './boardStatus';\nimport { computeCanvasLayout } from './canvasLayout';\nimport {\n type CanvasViewport,\n formatViewportParam,\n mergeRefetchedBoards,\n parseViewportParam,\n shortContentHash,\n} from './canvasLiveUpdate';\nimport { isContentUrlExpiring } from './stableContentUrl';\nimport {\n buildBoardDeepLink,\n buildDesignReference,\n copyTextToClipboard,\n type DesignReferenceInput,\n} from './designReference';\nimport { boardNodeId, CanvasViewContext, type CanvasViewState, sectionNodeId } from './canvasView';\nimport { buildThemeReference, splitThemeReference, type ThemeMode } from './designTheme';\nimport { type CanvasFitRequest, type CanvasTool, DesignCanvasFlow } from './DesignCanvasFlow';\n\n/** URL parameters of the canvas state (search, section, status, theme, theme mode, viewport `x,y,zoom`). */\nconst CANVAS_STATE_KEYS = ['q', 'section', 'status', 'theme', 'mode', 'vp'] as const;\n/** Keys that are not \"filters\" (filter badge counts section and status only). */\nconst UNCOUNTED_CANVAS_STATE_KEYS: readonly string[] = ['q', 'theme', 'mode', 'vp'];\n\n/** Live update: how often the canvas revision is polled while the tab is visible (ms). */\nconst LIVE_UPDATE_POLL_MS = 15_000;\n\n/** Poll interval of the canvas while a thumbnail render request runs (images swap in as they arrive). */\nconst THUMBNAIL_RENDER_POLL_MS = 3_000;\n\n/** Render request statuses that are still being worked on. */\nconst OPEN_RENDER_STATUSES: ReadonlySet<string> = new Set(['QUEUED', 'RUNNING', 'WAITING_FOR_RENDERER']);\n\n/** At most this many boards on screen are named as priority of a render request. */\nconst MAX_PRIORITY_BOARDS = 200;\n\n/** Toast id of the live update (a newer update replaces the toast). */\nconst LIVE_UPDATE_TOAST_ID = 'design-canvas-live-update';\n\n/** The boards as shown: merged in place from each canvas response (canvasLiveUpdate.ts). */\ninterface ShownBoards {\n /** The response elements they were merged from (undefined = nothing loaded yet). */\n source: readonly DesignStudioBoardView[] | undefined;\n /** Theme reference of that response ('' = no theme): another one starts over like a first load. */\n themeReference: string;\n boards: DesignStudioBoardView[];\n /** When the delivery URLs of unchanged boards were taken over (ms since epoch). */\n urlsAdoptedAt: number;\n /** Keys of the boards with a new version (or new) in the last merge; empty for the first load and a new theme. */\n changedBoardKeys: string[];\n /** Counts merges (effects key on it). */\n serial: number;\n}\n\nconst usePageVisible = (): boolean => {\n const [isVisible, setIsVisible] = useState(true);\n useEffect(() => {\n const update = () => setIsVisible(document.visibilityState === 'visible');\n update();\n document.addEventListener('visibilitychange', update);\n return () => document.removeEventListener('visibilitychange', update);\n }, []);\n return isVisible;\n};\n\n/** URL parameter of the board open in focus view (deep links from the overview and from comments). */\nconst BOARD_PARAM = 'board';\n\nconst TOOL_BUTTON_CLASS =\n 'relative flex size-8 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-tint hover:text-foreground disabled:pointer-events-none disabled:opacity-40 motion-reduce:transition-none';\n\n/** Room the canvas toolbar takes above the content when a view is fitted (px). */\nconst CANVAS_TOOLBAR_HEIGHT = 96;\n\nconst TOOLBAR_GROUP_CLASS = 'surface-glass-strong flex items-center gap-1 rounded-2xl p-1 ring-1 ring-foreground/5';\n\n/** Without a shell sidebar there is nothing to collapse: \"already collapsed\", the toggle does nothing. */\nconst NO_SIDEBAR = [true, () => undefined] as const;\nconst useNoSidebar = () => NO_SIDEBAR;\n\n/**\n * The canvas route wants the room: the shell's sidebar is collapsed while the canvas is open and returns to how it was\n * when the page is left or the tab is closed / reloaded (only if this page collapsed it).\n */\nconst useCollapsedSidebarWhileMounted = (useSidebarCollapsed: DesignStudioShell['useSidebarCollapsed'] = useNoSidebar) => {\n const [isCollapsed, toggleCollapsed] = useSidebarCollapsed();\n const collapsedByCanvasRef = useRef(false);\n const toggleRef = useRef(toggleCollapsed);\n toggleRef.current = toggleCollapsed;\n // biome-ignore lint/correctness/useExhaustiveDependencies: once on mount: collapse; on unmount / tab close: restore\n useEffect(() => {\n if (!isCollapsed) {\n collapsedByCanvasRef.current = true;\n toggleRef.current();\n }\n const restore = () => {\n if (!collapsedByCanvasRef.current) return;\n collapsedByCanvasRef.current = false;\n toggleRef.current();\n };\n window.addEventListener('pagehide', restore);\n return () => {\n window.removeEventListener('pagehide', restore);\n restore();\n };\n }, []);\n};\n\nexport interface DesignStudioCanvasScreenProps {\n projectKey: string;\n canvasKey: string;\n}\n\n/** The selected board's side panel on the canvas: status, current version, comments, open in focus view. */\nconst SelectedBoardPanel = ({\n projectKey,\n canvasKey,\n board,\n statuses,\n sectionTitle,\n threads,\n writesAllowed,\n onOpen,\n onStatusChanged,\n onCopyThreadReference,\n}: {\n projectKey: string;\n canvasKey: string;\n board: DesignStudioBoardView;\n statuses: readonly string[];\n sectionTitle: string | null;\n threads: CommentThread[];\n writesAllowed: boolean;\n onOpen: () => void;\n onStatusChanged: (status: string) => void;\n onCopyThreadReference: (thread: CommentThread) => void;\n}) => {\n const { Button } = useDesignStudioComponents();\n const [showResolved, setShowResolved] = useState(false);\n return (\n <div className=\"space-y-5\">\n <div className=\"space-y-1\">\n <h2 className=\"text-title-card font-semibold break-words\">{board.title}</h2>\n <p className=\"text-xs text-muted-foreground\">\n {sectionTitle ? `${sectionTitle} · ` : ''}\n {board.boardKey}\n </p>\n </div>\n <BoardStatusChips\n projectKey={projectKey}\n canvasKey={canvasKey}\n board={board}\n statuses={statuses}\n writesAllowed={writesAllowed}\n onStatusChanged={onStatusChanged}\n />\n <Button variant=\"outline\" className=\"w-full\" onClick={onOpen}>\n <Maximize2 /> Open focus view\n </Button>\n {board.contentHash && (\n <p className=\"text-xs text-muted-foreground\" title={`Content hash of the board file: ${board.contentHash}`}>\n Version <span className=\"font-mono\">{shortContentHash(board.contentHash)}</span>\n </p>\n )}\n <BoardComments\n projectKey={projectKey}\n canvasKey={canvasKey}\n board={board}\n threads={threads}\n pendingPin={null}\n onClearPendingPin={() => undefined}\n highlightedCommentId={null}\n onHighlightComment={() => undefined}\n writesAllowed={writesAllowed}\n showResolved={showResolved}\n onShowResolvedChange={setShowResolved}\n pinHint=\"open the focus view to pin it to a spot\"\n onCopyThreadReference={onCopyThreadReference}\n />\n </div>\n );\n};\n\n/**\n * Design studio canvas: every board of a canvas laid out per section (a bold title\n * line, then rows of nine boards with a header each), a toolbar on the canvas (select / hand, theme + light / dark\n * mode, comments panel, present, zoom), search and filters by section and status, a collapsible comments panel and\n * the focus view. Rendering stays proportional to what is on screen (boardDetail.ts):\n * only nodes in the viewport mount, far zoom uses the 120 px thumbnails, live HTML only for ≤ 6 large boards after a\n * pan / zoom ends.\n */\nexport const DesignStudioCanvasScreen = ({ projectKey, canvasKey }: DesignStudioCanvasScreenProps) => {\n const {\n api,\n components,\n notify,\n router,\n shell,\n statuses: statusDefinitions,\n storage,\n useCanWrite,\n } = useDesignStudio();\n const texts = useDesignStudioTexts();\n const {\n Button,\n Combobox,\n Popover,\n PopoverContent,\n PopoverTrigger,\n QuickFilterPills,\n SearchField,\n Skeleton,\n StatusCallout,\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n } = components;\n const searchParams = router.useSearchParams();\n const writeSearchParams = router.useSearchParamsWriter();\n const writesAllowed = useCanWrite();\n const isPageVisible = usePageVisible();\n\n const [statusOverrides, setStatusOverrides] = useState<ReadonlyMap<string, string>>(new Map());\n const [liveBoardIds, setLiveBoardIds] = useState<ReadonlySet<string>>(new Set());\n const [selectedBoardId, setSelectedBoardId] = useState<string | null>(null);\n const [selectedBoardIds, setSelectedBoardIds] = useState<ReadonlySet<string>>(new Set());\n const [focusedBoardId, setFocusedBoardId] = useState<string | null>(null);\n const [presentSectionId, setPresentSectionId] = useState<string | null>(null);\n const [fitRequest, setFitRequest] = useState<CanvasFitRequest | null>(null);\n // pan by default; the area-select tool is opt-in and kept only for this page visit\n const [tool, setTool] = useState<CanvasTool>('hand');\n const [isCommentsPanelOpen, setIsCommentsPanelOpen] = useState(() => storage.read('commentsPanelOpen') !== '0');\n // Search, filters, theme and theme mode: in the URL (source of truth), saved per canvas in this tab's\n // sessionStorage and restored when the URL has none of them (the application's URL state, `router.useUrlState`).\n // Defaults (no search / filter, the canvas' reference theme and its mode) are never written.\n const canvasState = router.useUrlState(CANVAS_STATE_KEYS, {\n stateId: `designCanvas.${projectKey}.${canvasKey}`,\n debounceMs: 250,\n uncounted: UNCOUNTED_CANVAS_STATE_KEYS,\n });\n const search = canvasState.values.q;\n const sectionFilter = canvasState.values.section;\n const statusFilter = canvasState.values.status;\n const chosenThemeId = canvasState.values.theme || null;\n const chosenMode: ThemeMode | null =\n canvasState.values.mode === 'dark' || canvasState.values.mode === 'light' ? canvasState.values.mode : null;\n const { setValue: setCanvasStateValue } = canvasState;\n const setSearch = useCallback((value: string) => setCanvasStateValue('q', value), [setCanvasStateValue]);\n const setSectionFilter = useCallback((value: string) => setCanvasStateValue('section', value), [setCanvasStateValue]);\n const setStatusFilter = useCallback((value: string) => setCanvasStateValue('status', value), [setCanvasStateValue]);\n const [isFullscreen, setIsFullscreen] = useState(false);\n // aspect ratio of the canvas area: the layout packs the sections for it (\"Fit all\" fills the view)\n const canvasAreaRef = useRef<HTMLDivElement>(null);\n const [canvasAspectRatio, setCanvasAspectRatio] = useState<number | null>(null);\n useCollapsedSidebarWhileMounted(shell?.useSidebarCollapsed);\n const debouncedSearch = canvasState.debounced.q;\n // The viewport as saved (`?vp=`, or this tab's saved canvas state): the first view returns there instead of fitting.\n const [initialViewport] = useState<CanvasViewport | null>(() => parseViewportParam(canvasState.values.vp));\n // A filter present at load with a saved viewport: the saved place wins over fitting the matches once.\n const [hasInitialFilterWithViewport] = useState(\n () =>\n initialViewport !== null &&\n Boolean(canvasState.values.q.trim() || canvasState.values.section || canvasState.values.status)\n );\n const currentViewportRef = useRef<string | null>(initialViewport ? formatViewportParam(initialViewport) : null);\n const commitViewport = useCallback(\n (viewport: CanvasViewport) => {\n const value = formatViewportParam(viewport);\n currentViewportRef.current = value;\n setCanvasStateValue('vp', value);\n },\n [setCanvasStateValue]\n );\n\n // Projects, canvases and whether the application offers themes at all (one cached request for the whole studio).\n const { data: overviewData, isError: isOverviewError } = api.useOverviewQuery();\n const overview = overviewData?.designStudioOverview;\n const projectSummary = overview?.projects?.elements?.find(project => project.projectKey === projectKey);\n const canvasSummary = projectSummary?.canvases?.elements?.find(item => item.canvasKey === canvasKey);\n const hasThemes = Boolean(overview?.hasThemes);\n const {\n data: themesData,\n isLoading: isLoadingThemes,\n isError: isThemesError,\n } = api.useThemesQuery({}, { skip: !hasThemes });\n const themes = useMemo(() => themesData?.designThemes.elements ?? [], [themesData]);\n\n // The look: the canvas' reference theme by default (no `theme` parameter: the backend picks it; without a reference\n // theme the boards are shown as authored), else the chosen theme `<themeId>` / `<themeId>:dark`. Dark only when the\n // theme has a dark look of its own.\n const isDefaultLook = chosenThemeId === null && chosenMode === null;\n // another look needs the theme list (does it support dark?) and, for a mode alone, the canvas' reference theme\n const isLookResolved =\n isDefaultLook ||\n ((overviewData !== undefined || isOverviewError) && (!hasThemes || themesData !== undefined || isThemesError));\n // the canvas' reference theme: from the loaded canvas, before that from the overview (same configuration)\n const [loadedReferenceTheme, setLoadedReferenceTheme] = useState<string | null | undefined>(undefined);\n const referenceTheme = loadedReferenceTheme !== undefined ? loadedReferenceTheme : canvasSummary?.referenceTheme;\n const referenceLook = useMemo(() => splitThemeReference(referenceTheme), [referenceTheme]);\n const referenceThemeId = referenceLook?.themeId ?? null;\n const themeId = chosenThemeId ?? referenceThemeId;\n const selectedTheme = themes.find(theme => theme.themeId === themeId);\n const supportsDark = Boolean(selectedTheme?.supportsDark);\n const defaultMode: ThemeMode = themeId !== null && themeId === referenceThemeId ? (referenceLook?.mode ?? 'light') : 'light';\n const requestedMode: ThemeMode = chosenMode ?? defaultMode;\n const effectiveMode: ThemeMode = requestedMode === 'dark' && (isDefaultLook || supportsDark) ? 'dark' : 'light';\n const themeArgument = isDefaultLook || themeId === null ? undefined : buildThemeReference(themeId, effectiveMode);\n const canvasQueryArgument = useMemo(\n () => ({ projectKey, canvasKey, ...(themeArgument ? { theme: themeArgument } : {}) }),\n [projectKey, canvasKey, themeArgument]\n );\n\n // While a thumbnail render request runs, the canvas itself is polled so the images swap in as they arrive.\n const [isRenderPolling, setIsRenderPolling] = useState(false);\n const {\n data,\n currentData: currentCanvasData,\n isLoading,\n error,\n isFetching: isFetchingCanvas,\n refetch: refetchCanvas,\n } = api.useCanvasQuery(canvasQueryArgument, {\n skip: !isLookResolved,\n pollingInterval: isPageVisible && isRenderPolling ? THUMBNAIL_RENDER_POLL_MS : 0,\n });\n const { data: commentsData, refetch: refetchComments } = api.useCanvasCommentsQuery({ projectKey, canvasKey });\n // Live update: a cheap revision is polled while the tab is visible; it changes with every\n // board file, comment and status, and a change refetches the canvas (changed boards update in place) and the comments.\n const { currentData: currentRevisionData, refetch: refetchRevision } = api.useCanvasRevisionQuery(\n canvasQueryArgument,\n {\n skip: !isLookResolved,\n pollingInterval: isPageVisible ? LIVE_UPDATE_POLL_MS : 0,\n }\n );\n\n // `data` stays the previous look's canvas while another theme loads (the boards stay on screen until it answers)\n const canvas = data?.designStudioCanvasView;\n // the canvas in the requested look (undefined while that look is still loading)\n const currentCanvas = currentCanvasData?.designStudioCanvasView;\n if (canvas && (canvas.referenceTheme ?? null) !== loadedReferenceTheme) {\n setLoadedReferenceTheme(canvas.referenceTheme ?? null);\n }\n // the look the boards on screen are really in (the reference block and the deep links name it)\n const shownLook = useMemo(() => splitThemeReference(canvas?.themeReference), [canvas?.themeReference]);\n const sections = useMemo(() => canvas?.sections?.elements ?? [], [canvas]);\n const statuses = useMemo(() => canvas?.statuses ?? overview?.statuses ?? [], [canvas?.statuses, overview?.statuses]);\n const defaultStatus = statuses[0] ?? null;\n const statusFilterOptions = useMemo(\n () => statuses.map(status => ({ value: status, label: boardStatusLabel(statusDefinitions, status) })),\n [statuses, statusDefinitions]\n );\n // Each canvas response is merged into the shown boards: unchanged boards keep their object and delivery URLs (no\n // re-render, no reload), changed ones take the new version's URLs — in place, the view does not move. The first\n // response of another theme starts over like a first load: every board has new URLs, none of them \"changed\".\n const canvasBoards = canvas?.boards?.elements;\n const [shownBoards, setShownBoards] = useState<ShownBoards>({\n source: undefined,\n themeReference: '',\n boards: [],\n urlsAdoptedAt: 0,\n changedBoardKeys: [],\n serial: 0,\n });\n if (canvasBoards && canvasBoards !== shownBoards.source) {\n const now = Date.now();\n const themeReference = canvas?.themeReference ?? '';\n const isFirstLoad = shownBoards.source === undefined || themeReference !== shownBoards.themeReference;\n // unchanged boards keep their object (and URLs) while the shown content token is good; the elements keep their\n // src across a token change anyway (stableContentUrl.ts), so a later switch only re-renders, never reloads\n const shownTokenUrl = shownBoards.boards.find(board => board.htmlUrl)?.htmlUrl;\n const keepPreviousUrls = !isFirstLoad && (!shownTokenUrl || !isContentUrlExpiring(shownTokenUrl));\n const merged = mergeRefetchedBoards(isFirstLoad ? null : shownBoards.boards, canvasBoards, keepPreviousUrls);\n setShownBoards({\n source: canvasBoards,\n themeReference,\n boards: merged.boards,\n urlsAdoptedAt: keepPreviousUrls ? shownBoards.urlsAdoptedAt : now,\n changedBoardKeys: merged.changedBoardKeys,\n serial: shownBoards.serial + 1,\n });\n }\n const shownBoardList = shownBoards.boards;\n const boards = useMemo<DesignStudioBoardView[]>(\n () =>\n shownBoardList.map(board => {\n const status = statusOverrides.get(boardNodeId(board.boardKey ?? ''));\n return status ? { ...board, status } : board;\n }),\n [shownBoardList, statusOverrides]\n );\n const boardsByNodeId = useMemo(\n () => new Map(boards.map(board => [boardNodeId(board.boardKey ?? ''), board])),\n [boards]\n );\n const sectionTitleByKey = useMemo(\n () => new Map(sections.map(section => [section.sectionKey ?? '', section.title ?? ''])),\n [sections]\n );\n\n // Layout: computed from sections and board order only (status changes do not move anything).\n const layout = useMemo(() => {\n const sectionKeys = new Set(sections.map(section => section.sectionKey ?? ''));\n return computeCanvasLayout(\n sections.map(section => ({\n id: section.sectionKey ?? '',\n title: section.title ?? '',\n displayOrder: section.displayOrder ?? 0,\n })),\n shownBoardList.map(board => ({\n id: boardNodeId(board.boardKey ?? ''),\n sectionId: board.sectionKey && sectionKeys.has(board.sectionKey) ? board.sectionKey : null,\n width: board.width ?? 390,\n height: board.height ?? 844,\n displayOrder: board.displayOrder ?? 0,\n })),\n canvasAspectRatio ?? undefined\n );\n }, [sections, shownBoardList, canvasAspectRatio]);\n\n // Measure the canvas area (and follow big resizes: a change under 15 % keeps the layout).\n const hasCanvas = Boolean(canvas);\n // biome-ignore lint/correctness/useExhaustiveDependencies: the canvas area mounts with the canvas data (`hasCanvas`)\n useEffect(() => {\n const canvasArea = canvasAreaRef.current;\n if (!canvasArea) return;\n const measure = () => {\n if (canvasArea.clientWidth === 0 || canvasArea.clientHeight === 0) return;\n const aspectRatio = canvasArea.clientWidth / Math.max(1, canvasArea.clientHeight - CANVAS_TOOLBAR_HEIGHT);\n setCanvasAspectRatio(current =>\n current === null || Math.abs(aspectRatio / current - 1) > 0.15 ? Math.round(aspectRatio * 10) / 10 : current\n );\n };\n measure();\n const resizeObserver = new ResizeObserver(measure);\n resizeObserver.observe(canvasArea);\n return () => resizeObserver.disconnect();\n }, [hasCanvas]);\n\n // Thumbnails: the canvas view carries one set of URLs for the requested look and says how many boards have none\n // yet. Missing ones are asked for with a render request (boards on screen first); while it is open the canvas is\n // polled fast, so the images swap in as they arrive.\n const isRendererEnabled = Boolean(canvas?.isRendererEnabled);\n const missingThumbnailCount = canvas?.missingThumbnailCount ?? 0;\n const renderStatus = canvas?.renderRequestStatus ?? null;\n const isRenderOpen = renderStatus !== null && OPEN_RENDER_STATUSES.has(renderStatus);\n useEffect(() => setIsRenderPolling(isRenderOpen), [isRenderOpen]);\n const [requestThumbnailRendering] = api.useRequestThumbnailRenderingMutation();\n const visibleBoardIdsRef = useRef<string[]>([]);\n // stable: the canvas re-evaluates its live boards whenever this callback changes\n const rememberVisibleBoardIds = useCallback((visibleBoardIds: string[]) => {\n visibleBoardIdsRef.current = visibleBoardIds;\n }, []);\n const boardsByNodeIdRef = useRef(boardsByNodeId);\n boardsByNodeIdRef.current = boardsByNodeId;\n // Asked for once per look and board version (`<theme>|<boardKey>@<contentHash>`): a board that changed later gets\n // its thumbnail too, a board the renderer could not draw is not asked for again on its own. A request that is\n // already open (by anyone) is not filed again; a failed one can be retried from the toolbar chip.\n const requestedThumbnailsRef = useRef<Set<string>>(new Set());\n const fileRenderRequest = useCallback(\n (isRetry: boolean) => {\n if (!writesAllowed || !currentCanvas) return;\n const missingKeys = (currentCanvas.boards?.elements ?? [])\n .filter(board => !board.thumbnailUrl)\n .map(board => `${themeArgument ?? ''}|${board.boardKey ?? ''}@${board.contentHash ?? ''}`);\n if (missingKeys.length === 0) return;\n if (!isRetry && missingKeys.every(key => requestedThumbnailsRef.current.has(key))) return;\n for (const key of missingKeys) requestedThumbnailsRef.current.add(key);\n const priorityBoardKeys = visibleBoardIdsRef.current\n .map(nodeId => boardsByNodeIdRef.current.get(nodeId)?.boardKey)\n .filter((boardKey): boardKey is string => Boolean(boardKey))\n .slice(0, MAX_PRIORITY_BOARDS);\n // the answer is not needed: the request invalidates the canvas query, which then carries the request status\n void requestThumbnailRendering({\n projectKey,\n canvasKey,\n ...(themeArgument ? { theme: themeArgument } : {}),\n body: {\n theme: themeArgument ?? null,\n priorityBoardKeys,\n },\n });\n },\n [writesAllowed, currentCanvas, themeArgument, projectKey, canvasKey, requestThumbnailRendering]\n );\n useEffect(() => {\n // only for the look that is loaded (never from the previous theme's numbers while another one loads)\n if (!currentCanvas?.isRendererEnabled || !currentCanvas.missingThumbnailCount) return;\n const currentStatus = currentCanvas.renderRequestStatus ?? null;\n if (currentStatus === 'FAILED' || (currentStatus !== null && OPEN_RENDER_STATUSES.has(currentStatus))) return;\n fileRenderRequest(false);\n }, [currentCanvas, fileRenderRequest]);\n const themeOptions = useMemo(\n () => [\n // without a reference theme the default look is the boards as authored\n ...(referenceThemeId === null ? [{ value: '', label: 'As authored' }] : []),\n ...themes.map(theme => ({ value: theme.themeId ?? '', label: theme.label || theme.themeId || 'Theme' })),\n ],\n [themes, referenceThemeId]\n );\n const shownThemeLabel = themes.find(theme => theme.themeId === shownLook?.themeId)?.label ?? texts.thumbnailsFallbackThemeLabel;\n\n const commentsByBoardNodeId = useMemo(() => {\n const comments = new Map<string, DesignStudioComment[]>();\n for (const comment of commentsData?.designStudioComments.elements ?? []) {\n const nodeId = boardNodeId(comment.boardKey ?? '');\n const boardComments = comments.get(nodeId) ?? [];\n boardComments.push(comment);\n comments.set(nodeId, boardComments);\n }\n return comments;\n }, [commentsData]);\n const openThreadCounts = useMemo(() => {\n const counts = new Map<string, number>();\n for (const [nodeId, comments] of commentsByBoardNodeId) {\n const openCount = comments.filter(\n comment => comment.parentDesignStudioCommentId == null && !comment.isResolved\n ).length;\n if (openCount > 0) counts.set(nodeId, openCount);\n }\n return counts;\n }, [commentsByBoardNodeId]);\n const openThreadTotal = useMemo(\n () => [...openThreadCounts.values()].reduce((sum, count) => sum + count, 0),\n [openThreadCounts]\n );\n\n const matchingBoardIds = useMemo(() => {\n const searchText = debouncedSearch.trim().toLowerCase();\n if (!searchText && !sectionFilter && !statusFilter) return null;\n const matching = new Set<string>();\n for (const board of boards) {\n if (sectionFilter && (board.sectionKey ?? '') !== sectionFilter) continue;\n if (statusFilter && board.status !== statusFilter) continue;\n if (\n searchText &&\n !(board.title ?? '').toLowerCase().includes(searchText) &&\n !(board.boardKey ?? '').toLowerCase().includes(searchText)\n ) {\n continue;\n }\n matching.add(boardNodeId(board.boardKey ?? ''));\n }\n return matching;\n }, [boards, debouncedSearch, sectionFilter, statusFilter]);\n\n // Focus navigation order: the presented section, else the layout order (the matches while a filter is active).\n const layoutOrder = useMemo(() => layout.sections.flatMap(section => section.boardIds), [layout]);\n const navigationOrder = useMemo(() => {\n if (presentSectionId) {\n return layout.sections.find(section => section.id === presentSectionId)?.boardIds ?? [];\n }\n return layoutOrder.filter(nodeId => matchingBoardIds === null || matchingBoardIds.has(nodeId));\n }, [layout, layoutOrder, matchingBoardIds, presentSectionId]);\n\n const fitKeyRef = useRef(0);\n const requestFit = useCallback((nodeIds: string[]) => {\n fitKeyRef.current += 1;\n setFitRequest({ nodeIds, key: fitKeyRef.current });\n }, []);\n\n // Fit the view to the matches whenever the filter changes (a section alone fits its row) — only when the filter\n // itself changes, never because the matches were recomputed (a status change, a live update), and not for the filter\n // a reload brings along with its saved viewport.\n const filterKey = matchingBoardIds === null ? null : `${debouncedSearch.trim()}|${sectionFilter}|${statusFilter}`;\n const fittedFilterKeyRef = useRef<string | null>(null);\n const skipInitialFilterFitRef = useRef(hasInitialFilterWithViewport);\n useEffect(() => {\n if (filterKey === null || matchingBoardIds === null) {\n fittedFilterKeyRef.current = null;\n return;\n }\n if (matchingBoardIds.size === 0 || fittedFilterKeyRef.current === filterKey) return;\n fittedFilterKeyRef.current = filterKey;\n if (skipInitialFilterFitRef.current) {\n skipInitialFilterFitRef.current = false;\n return;\n }\n requestFit(\n sectionFilter && !debouncedSearch.trim() && !statusFilter ? [sectionNodeId(sectionFilter)] : [...matchingBoardIds]\n );\n }, [filterKey, matchingBoardIds, sectionFilter, debouncedSearch, statusFilter, requestFit]);\n\n const openBoard = useCallback(\n (nodeId: string) => {\n setSelectedBoardId(nodeId);\n setFocusedBoardId(nodeId);\n const board = boardsByNodeId.get(nodeId);\n if (board?.boardKey) writeSearchParams({ [BOARD_PARAM]: board.boardKey });\n },\n [boardsByNodeId, writeSearchParams]\n );\n const openBoardFromCanvas = useCallback(\n (nodeId: string) => {\n setPresentSectionId(null);\n openBoard(nodeId);\n },\n [openBoard]\n );\n const closeFocus = useCallback(() => {\n setFocusedBoardId(null);\n setPresentSectionId(null);\n writeSearchParams({ [BOARD_PARAM]: null });\n }, [writeSearchParams]);\n const presentSection = useCallback(\n (sectionId: string) => {\n const firstBoardId = layout.sections.find(section => section.id === sectionId)?.boardIds[0];\n if (!firstBoardId) return;\n setPresentSectionId(sectionId);\n openBoard(firstBoardId);\n },\n [layout, openBoard]\n );\n\n // Deep link: ?board=<boardKey> opens that board once the canvas is loaded.\n const boardParam = searchParams.get(BOARD_PARAM);\n const isDeepLinkHandledRef = useRef(false);\n useEffect(() => {\n if (isDeepLinkHandledRef.current || !boardParam || boards.length === 0) return;\n isDeepLinkHandledRef.current = true;\n const nodeId = boardNodeId(boardParam);\n if (!boardsByNodeId.has(nodeId)) return;\n setSelectedBoardId(nodeId);\n setFocusedBoardId(nodeId);\n // a saved viewport (reload, a link with `vp`) keeps its place behind the focus view\n if (!initialViewport) requestFit([nodeId]);\n }, [boardParam, boards.length, boardsByNodeId, requestFit, initialViewport]);\n\n const stepFocus = useCallback(\n (step: number) => {\n if (!focusedBoardId || navigationOrder.length === 0) return;\n const index = navigationOrder.indexOf(focusedBoardId);\n openBoard(navigationOrder[(index + step + navigationOrder.length) % navigationOrder.length]);\n },\n [focusedBoardId, navigationOrder, openBoard]\n );\n\n const setBoardStatus = useCallback((nodeId: string, status: string) => {\n setStatusOverrides(overrides => new Map(overrides).set(nodeId, status));\n }, []);\n\n const toggleCommentsPanel = () => {\n setIsCommentsPanelOpen(isOpen => {\n storage.write('commentsPanelOpen', isOpen ? '0' : '1');\n return !isOpen;\n });\n };\n\n // Selection: a click selects one board (the side panel shows it), shift / cmd / ctrl click toggles it in the\n // selection, a marquee (select tool) selects the boards inside; a pane click clears it.\n const selectBoard = useCallback((nodeId: string, isAdditive: boolean) => {\n setSelectedBoardId(nodeId);\n setSelectedBoardIds(current => {\n if (!isAdditive) return new Set([nodeId]);\n const next = new Set(current);\n if (next.has(nodeId)) next.delete(nodeId);\n else next.add(nodeId);\n return next;\n });\n }, []);\n const selectBoards = useCallback((nodeIds: string[], isAdditive: boolean) => {\n setSelectedBoardIds(current => new Set([...(isAdditive ? current : []), ...nodeIds]));\n setSelectedBoardId(nodeIds[0] ?? null);\n }, []);\n const clearSelection = useCallback(() => {\n setSelectedBoardId(null);\n setSelectedBoardIds(new Set());\n }, []);\n\n // Design references for agents (designReference.ts): one block per board, copied as plain text.\n const projectName = projectSummary?.label ?? projectKey;\n const canvasName = canvas?.label ?? canvasSummary?.label ?? canvasKey;\n const shownThemeReference = canvas?.themeReference ?? null;\n const buildReferenceFor = useCallback(\n (nodeId: string, extra: Partial<DesignReferenceInput> = {}): string | null => {\n const board = boardsByNodeId.get(nodeId);\n if (!board?.boardKey || typeof window === 'undefined') return null;\n return buildDesignReference({\n projectName,\n canvasName,\n projectKey,\n canvasKey,\n boardTitle: board.title ?? board.boardKey,\n boardKey: board.boardKey,\n contentHash: board.contentHash ?? null,\n themeReference: shownThemeReference,\n url: buildBoardDeepLink(\n window.location.href,\n board.boardKey,\n shownLook?.themeId ?? null,\n shownLook?.mode ?? 'light',\n currentViewportRef.current\n ),\n ...extra,\n });\n },\n [boardsByNodeId, projectName, canvasName, projectKey, canvasKey, shownThemeReference, shownLook]\n );\n const copyReferences = useCallback(async (blocks: (string | null)[]) => {\n const text = blocks.filter((block): block is string => block !== null).join('\\n\\n');\n if (!text) return;\n if (await copyTextToClipboard(text)) {\n notify.success(texts.referencesCopied(blocks.length));\n } else {\n notify.error('Could not copy to the clipboard');\n }\n }, [notify, texts]);\n const copySelectedReferences = useCallback(() => {\n const nodeIds = layoutOrder.filter(nodeId => selectedBoardIds.has(nodeId));\n void copyReferences(nodeIds.map(nodeId => buildReferenceFor(nodeId)));\n }, [layoutOrder, selectedBoardIds, copyReferences, buildReferenceFor]);\n const copyThreadReference = useCallback(\n (thread: CommentThread) =>\n void copyReferences([\n buildReferenceFor(boardNodeId(thread.root.boardKey ?? ''), {\n comment: {\n id: thread.root.id ?? '',\n x: thread.root.x ?? null,\n y: thread.root.y ?? null,\n lines: [thread.root, ...thread.replies].map(comment => `${comment.authorName ?? 'Unknown'}: ${comment.text ?? ''}`),\n },\n }),\n ]),\n [copyReferences, buildReferenceFor]\n );\n\n // Live update: one revision for boards, comments and statuses — a change refetches the canvas and the comments.\n // The first revision of a look (first load, another theme) is only remembered.\n const seenRevisionRef = useRef<{ look: string; revision: string } | null>(null);\n const revision = currentRevisionData?.revision;\n const revisionLook = themeArgument ?? '';\n useEffect(() => {\n if (!revision) return;\n const seen = seenRevisionRef.current;\n seenRevisionRef.current = { look: revisionLook, revision };\n if (!seen || seen.look !== revisionLook || seen.revision === revision) return;\n void refetchCanvas();\n void refetchComments();\n }, [revision, revisionLook, refetchCanvas, refetchComments]);\n // Back on the tab: check right away instead of waiting for the next poll.\n useEffect(() => {\n if (isPageVisible && seenRevisionRef.current) void refetchRevision();\n }, [isPageVisible, refetchRevision]);\n\n // Changed boards (live update or reload): a toast names them with a link to the first one in canvas order.\n const showBoard = useCallback(\n (nodeId: string) => {\n setSelectedBoardId(nodeId);\n setSelectedBoardIds(new Set([nodeId]));\n requestFit([nodeId]);\n },\n [requestFit]\n );\n const layoutOrderRef = useRef(layoutOrder);\n layoutOrderRef.current = layoutOrder;\n // biome-ignore lint/correctness/useExhaustiveDependencies: once per merge (`serial`), not when the callbacks change\n useEffect(() => {\n const changedBoardKeys = shownBoards.changedBoardKeys;\n if (changedBoardKeys.length === 0) return;\n const changedNodeIds = new Set(changedBoardKeys.map(boardKey => boardNodeId(boardKey)));\n const firstNodeId =\n layoutOrderRef.current.find(nodeId => changedNodeIds.has(nodeId)) ?? boardNodeId(changedBoardKeys[0]);\n notify.info(texts.boardsUpdated(changedBoardKeys.length), {\n id: LIVE_UPDATE_TOAST_ID,\n action: { label: texts.showUpdatedBoard, onClick: () => showBoard(firstNodeId) },\n });\n }, [shownBoards.serial]);\n\n // Reload (R): canvas, comments and revision again; only changed boards reload, the view, selection, filters, theme\n // and the focus view stay.\n const shownBoardsRef = useRef(shownBoards);\n shownBoardsRef.current = shownBoards;\n const reloadCanvas = useCallback(async () => {\n // nothing to reload before the canvas query started (the look is still being resolved)\n if (shownBoardsRef.current.source === undefined) return;\n const serialBefore = shownBoardsRef.current.serial;\n const [canvasResult] = await Promise.all([refetchCanvas(), refetchComments(), refetchRevision()]);\n const reloadedBoards = canvasResult.data?.designStudioCanvasView.boards?.elements;\n const shown = shownBoardsRef.current;\n if (!reloadedBoards || (shown.serial !== serialBefore && shown.changedBoardKeys.length > 0)) return;\n // the merge announces changed boards itself; a reload without any says so\n if (mergeRefetchedBoards(shown.boards, reloadedBoards, true).changedBoardKeys.length === 0) {\n notify.info(texts.canvasUpToDate, { id: LIVE_UPDATE_TOAST_ID });\n }\n }, [refetchCanvas, refetchComments, refetchRevision, notify, texts]);\n const reloadCanvasRef = useRef(reloadCanvas);\n reloadCanvasRef.current = reloadCanvas;\n\n const canvasView = useMemo<CanvasViewState>(\n () => ({\n liveBoardIds,\n selectedBoardId,\n selectedBoardIds,\n matchingBoardIds,\n openThreadCounts,\n defaultStatus,\n isHandTool: tool === 'hand',\n onSelectBoard: selectBoard,\n onCopyReference: nodeId => void copyReferences([buildReferenceFor(nodeId)]),\n onOpenBoard: openBoardFromCanvas,\n onZoomToSection: sectionId => requestFit([sectionNodeId(sectionId)]),\n }),\n [\n liveBoardIds,\n selectedBoardId,\n selectedBoardIds,\n matchingBoardIds,\n openThreadCounts,\n defaultStatus,\n tool,\n selectBoard,\n copyReferences,\n buildReferenceFor,\n openBoardFromCanvas,\n requestFit,\n ]\n );\n\n const selectedBoard = selectedBoardId ? (boardsByNodeId.get(selectedBoardId) ?? null) : null;\n const focusedBoard = focusedBoardId ? (boardsByNodeId.get(focusedBoardId) ?? null) : null;\n const threadsOf = (nodeId: string | null): CommentThread[] =>\n nodeId ? buildCommentThreads(commentsByBoardNodeId.get(nodeId) ?? []) : [];\n const boardsWithOpenThreads = layoutOrder.filter(nodeId => openThreadCounts.has(nodeId));\n const initialFitNodeIds = useMemo(\n () => (layout.sections[0] ? [sectionNodeId(layout.sections[0].id)] : []),\n [layout]\n );\n const sectionOptions = layout.sections.map(section => ({ value: section.id, label: section.title }));\n const presentedSectionTitle = presentSectionId\n ? (layout.sections.find(section => section.id === presentSectionId)?.title ?? null)\n : null;\n\n const copySelectedRef = useRef(copySelectedReferences);\n copySelectedRef.current = copySelectedReferences;\n // F toggles fullscreen (the application shell hidden), Esc leaves it, C copies the selected boards' references, R reloads\n // the canvas — not while typing or in a dialog.\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement | null;\n if (target && (target.tagName === 'TEXTAREA' || target.tagName === 'INPUT' || target.isContentEditable)) return;\n if (document.querySelector('[role=dialog]') || event.metaKey || event.ctrlKey || event.altKey) return;\n if (event.key === 'f' || event.key === 'F') setIsFullscreen(value => !value);\n else if (event.key === 'c' || event.key === 'C') copySelectedRef.current();\n else if (event.key === 'r' || event.key === 'R') void reloadCanvasRef.current();\n else if (event.key === 'Escape') setIsFullscreen(false);\n };\n window.addEventListener('keydown', onKeyDown);\n return () => window.removeEventListener('keydown', onKeyDown);\n }, []);\n\n const activeFilterCount = (sectionFilter ? 1 : 0) + (statusFilter ? 1 : 0);\n const toolbarStart = (\n <div className={cx(TOOLBAR_GROUP_CLASS, 'min-w-0 pl-3')}>\n <div className=\"min-w-0 pr-1\">\n <h1 className=\"max-w-72 truncate text-sm leading-tight font-semibold\" title={canvasName}>\n {canvasName}\n </h1>\n <p className=\"text-xs leading-tight text-muted-foreground\">\n {boards.length} boards · {layout.sections.length} sections\n {matchingBoardIds !== null ? ` · ${matchingBoardIds.size} matching` : ''}\n </p>\n </div>\n <SearchField\n size=\"sm\"\n value={search}\n onChange={setSearch}\n clearable\n placeholder=\"Search boards…\"\n aria-label=\"Search boards\"\n className=\"w-44\"\n />\n <Popover>\n <PopoverTrigger asChild>\n <button type=\"button\" className={cx(TOOL_BUTTON_CLASS, activeFilterCount > 0 && 'text-brand-emphasis')} aria-label=\"Filters\">\n <ListFilter className=\"size-4\" />\n {activeFilterCount > 0 && (\n <span className=\"absolute -top-1 -right-1 flex size-4 items-center justify-center rounded-full bg-primary text-[10px] font-bold text-primary-foreground\">\n {activeFilterCount}\n </span>\n )}\n </button>\n </PopoverTrigger>\n <PopoverContent align=\"start\" className=\"w-[22rem] space-y-4 p-4\">\n <div className=\"space-y-1.5\">\n <p className=\"text-[12.5px] font-bold text-muted-foreground\">Section</p>\n <Combobox\n size=\"sm\"\n options={[{ value: '', label: 'All sections' }, ...sectionOptions]}\n value={sectionFilter}\n onChange={setSectionFilter}\n placeholder=\"All sections\"\n searchPlaceholder=\"Search sections…\"\n aria-label=\"Section\"\n className=\"w-full\"\n />\n </div>\n <div className=\"space-y-1.5\">\n <p className=\"text-[12.5px] font-bold text-muted-foreground\">Status</p>\n <QuickFilterPills\n options={statusFilterOptions}\n value={statusFilter}\n onChange={setStatusFilter}\n allLabel=\"All\"\n size=\"sm\"\n aria-label=\"Board status\"\n />\n </div>\n {activeFilterCount > 0 && (\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => {\n setSectionFilter('');\n setStatusFilter('');\n }}\n >\n Clear filters\n </Button>\n )}\n </PopoverContent>\n </Popover>\n </div>\n );\n\n const toolbarEnd = (\n <>\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n className={TOOL_BUTTON_CLASS}\n aria-label={texts.reload}\n aria-keyshortcuts=\"r\"\n aria-busy={isFetchingCanvas}\n onClick={() => void reloadCanvas()}\n >\n <RefreshCw className={cx('size-4', isFetchingCanvas && 'animate-spin motion-reduce:animate-none')} />\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{texts.reload}</TooltipContent>\n </Tooltip>\n <Tooltip>\n <TooltipTrigger asChild>\n <span>\n <button\n type=\"button\"\n className={TOOL_BUTTON_CLASS}\n disabled={selectedBoardIds.size === 0}\n aria-label={`Copy reference of ${selectedBoardIds.size} selected board(s) for an agent (C)`}\n onClick={copySelectedReferences}\n >\n <ClipboardCopy className=\"size-4\" />\n {selectedBoardIds.size > 1 && (\n <span className=\"absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-brand px-1 text-[10px] font-bold text-foreground\">\n {selectedBoardIds.size}\n </span>\n )}\n </button>\n </span>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">\n {selectedBoardIds.size === 0 ? 'Select boards to copy their reference' : 'Copy reference for an agent (C)'}\n </TooltipContent>\n </Tooltip>\n {hasThemes && themes.length > 0 && (\n <Combobox\n shape=\"pill\"\n size=\"sm\"\n options={themeOptions}\n value={themeId ?? ''}\n onChange={value => setCanvasStateValue('theme', value === (referenceThemeId ?? '') ? '' : value)}\n isLoading={isLoadingThemes}\n placeholder=\"Theme\"\n searchPlaceholder=\"Search themes…\"\n aria-label=\"Theme\"\n className=\"w-44\"\n />\n )}\n {isRendererEnabled && missingThumbnailCount > 0 && renderStatus !== null && renderStatus !== 'DONE' ? (\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n disabled={renderStatus !== 'FAILED' || !writesAllowed}\n className=\"flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-tint px-3 text-xs font-semibold text-muted-foreground transition-colors enabled:hover:bg-tint-strong enabled:hover:text-foreground\"\n onClick={() => fileRenderRequest(true)}\n >\n {renderStatus === 'FAILED' ? (\n <ImageDown className=\"size-4\" aria-hidden />\n ) : (\n <LoaderCircle className=\"size-4 animate-spin motion-reduce:animate-none\" aria-hidden />\n )}\n {renderStatus === 'FAILED'\n ? texts.thumbnailsFailed\n : renderStatus === 'WAITING_FOR_RENDERER'\n ? texts.thumbnailsWaitingForRenderer(shownThemeLabel)\n : texts.thumbnailsRendering(shownThemeLabel)}{' '}\n · {Math.max(0, shownBoardList.length - missingThumbnailCount)}/{shownBoardList.length}\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\" className=\"max-w-sm\">\n {texts.thumbnailsMissing(missingThumbnailCount)}\n {canvas?.renderRequestError ? ` ${texts.thumbnailsLastError(canvas.renderRequestError)}` : ''}\n </TooltipContent>\n </Tooltip>\n ) : null}\n {hasThemes && themes.length > 0 && (\n <Tooltip>\n <TooltipTrigger asChild>\n <span>\n <button\n type=\"button\"\n className={TOOL_BUTTON_CLASS}\n disabled={!supportsDark}\n aria-label={effectiveMode === 'dark' ? 'Light theme' : 'Dark theme'}\n aria-pressed={effectiveMode === 'dark'}\n onClick={() => {\n const nextMode: ThemeMode = effectiveMode === 'dark' ? 'light' : 'dark';\n setCanvasStateValue('mode', nextMode === defaultMode ? '' : nextMode);\n }}\n >\n {effectiveMode === 'dark' ? <Sun className=\"size-4\" /> : <Moon className=\"size-4\" />}\n </button>\n </span>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">\n {supportsDark ? (effectiveMode === 'dark' ? 'Light theme' : 'Dark theme') : texts.themeWithoutDarkMode}\n </TooltipContent>\n </Tooltip>\n )}\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n className={cx(TOOL_BUTTON_CLASS, isCommentsPanelOpen && 'bg-brand-light text-brand-emphasis')}\n aria-label={isCommentsPanelOpen ? 'Hide comments' : 'Show comments'}\n aria-pressed={isCommentsPanelOpen}\n onClick={toggleCommentsPanel}\n >\n {isCommentsPanelOpen ? <PanelRightClose className=\"size-4\" /> : <PanelRightOpen className=\"size-4\" />}\n {openThreadTotal > 0 && (\n <span className=\"absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-bold text-primary-foreground\">\n {openThreadTotal}\n </span>\n )}\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{isCommentsPanelOpen ? 'Hide comments' : 'Show comments'}</TooltipContent>\n </Tooltip>\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n className={cx(TOOL_BUTTON_CLASS, isFullscreen && 'bg-brand-light text-brand-emphasis')}\n aria-label={isFullscreen ? 'Exit fullscreen (F)' : 'Fullscreen (F)'}\n aria-pressed={isFullscreen}\n onClick={() => setIsFullscreen(value => !value)}\n >\n {isFullscreen ? <Minimize className=\"size-4\" /> : <Maximize className=\"size-4\" />}\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{isFullscreen ? 'Exit fullscreen (F)' : 'Fullscreen (F)'}</TooltipContent>\n </Tooltip>\n </>\n );\n\n return (\n <div\n data-page-frame\n data-canvas-fullscreen={isFullscreen ? '' : undefined}\n className={cx(\n // on the shell's cloud background (transparent); fullscreen covers the shell with the flat sky colour\n 'relative flex h-[calc(100dvh_-_var(--nav-h))] min-h-[560px] flex-col lg:flex-row',\n isFullscreen && 'fixed inset-0 z-40 h-dvh bg-background'\n )}\n >\n {error && (\n <div className=\"p-6\">\n <StatusCallout\n tone=\"destructive\"\n title=\"The canvas could not be loaded\"\n description={normalizeDddError(error, 'Request failed').message}\n />\n </div>\n )}\n {(isLoading || (!isLookResolved && !canvas)) && <Skeleton className=\"m-6 flex-1 rounded-2xl\" />}\n {canvas && (\n <CanvasViewContext.Provider value={canvasView}>\n <div ref={canvasAreaRef} className=\"relative min-h-[480px] min-w-0 flex-1\">\n {canvasAspectRatio !== null && (\n <DesignCanvasFlow\n layout={layout}\n boardsByNodeId={boardsByNodeId}\n fitRequest={fitRequest}\n initialFitNodeIds={initialFitNodeIds}\n initialViewport={initialViewport}\n onViewportCommit={commitViewport}\n tool={tool}\n onToolChange={setTool}\n liveMinRatio={\n !isRendererEnabled || missingThumbnailCount > 0\n ? LIVE_MIN_RENDERED_WIDTH_RATIO_WITHOUT_THUMBNAILS\n : LIVE_MIN_RENDERED_WIDTH_RATIO\n }\n onLiveBoardIdsChange={setLiveBoardIds}\n onVisibleBoardIdsChange={rememberVisibleBoardIds}\n onPaneClick={clearSelection}\n onMarqueeSelect={selectBoards}\n onPresentSection={presentSection}\n toolbarStart={toolbarStart}\n toolbarEnd={toolbarEnd}\n selectedNodeId={selectedBoardId}\n />\n )}\n </div>\n {isCommentsPanelOpen && (\n <aside className=\"surface-glass-strong m-3 shrink-0 overflow-y-auto rounded-3xl p-5 ring-1 ring-foreground/5 lg:my-3 lg:ml-0 lg:w-[380px]\">\n {selectedBoard ? (\n <SelectedBoardPanel\n key={selectedBoard.boardKey ?? ''}\n projectKey={projectKey}\n canvasKey={canvasKey}\n board={selectedBoard}\n statuses={statuses}\n sectionTitle={sectionTitleByKey.get(selectedBoard.sectionKey ?? '') ?? null}\n threads={threadsOf(selectedBoardId)}\n writesAllowed={writesAllowed}\n onOpen={() => selectedBoardId && openBoardFromCanvas(selectedBoardId)}\n onStatusChanged={status => selectedBoardId && setBoardStatus(selectedBoardId, status)}\n onCopyThreadReference={copyThreadReference}\n />\n ) : (\n <div className=\"space-y-4\">\n <div>\n <h2 className=\"text-title-card font-semibold\">Open comments</h2>\n <p className=\"text-sm text-muted-foreground\">\n Click a board to see its status and comments, double-click to open it large.\n </p>\n </div>\n {boardsWithOpenThreads.length === 0 && (\n <p className=\"text-sm text-muted-foreground\">No open comments on this canvas.</p>\n )}\n <ul className=\"space-y-1\">\n {boardsWithOpenThreads.map(nodeId => (\n <li key={nodeId}>\n <button\n type=\"button\"\n className=\"flex w-full items-center justify-between gap-2 rounded-[10px] px-3 py-2 text-left text-sm transition-colors hover:bg-tint\"\n onClick={() => {\n setSelectedBoardId(nodeId);\n requestFit([nodeId]);\n }}\n >\n <span className=\"truncate\">{boardsByNodeId.get(nodeId)?.title}</span>\n <span className=\"inline-flex shrink-0 items-center gap-1 text-xs font-semibold text-muted-foreground\">\n <MessageSquare className=\"size-3.5\" aria-hidden /> {openThreadCounts.get(nodeId)}\n </span>\n </button>\n </li>\n ))}\n </ul>\n </div>\n )}\n </aside>\n )}\n </CanvasViewContext.Provider>\n )}\n <BoardFocusView\n projectKey={projectKey}\n canvasKey={canvasKey}\n board={focusedBoard}\n statuses={statuses}\n sectionTitle={focusedBoard ? (sectionTitleByKey.get(focusedBoard.sectionKey ?? '') ?? null) : null}\n position={{\n index: focusedBoardId ? navigationOrder.indexOf(focusedBoardId) + 1 : 0,\n count: navigationOrder.length,\n }}\n threads={threadsOf(focusedBoardId)}\n writesAllowed={writesAllowed}\n presentLabel={presentedSectionTitle}\n onClose={closeFocus}\n onPrevious={() => stepFocus(-1)}\n onNext={() => stepFocus(1)}\n onStatusChanged={status => focusedBoardId && setBoardStatus(focusedBoardId, status)}\n onCopyReference={({ region, note }) =>\n focusedBoardId && void copyReferences([buildReferenceFor(focusedBoardId, { region, note })])\n }\n onCopyThreadReference={copyThreadReference}\n />\n </div>\n );\n};\n","'use client';\n\nimport { normalizeDddError } from '@mgamadeus/ddd-web/api';\nimport { Bot, CheckCircle2, ClipboardCopy, Flag, History, Hourglass, MapPin, RotateCcw, Trash2 } from 'lucide-react';\nimport { useState } from 'react';\n\nimport type { DesignStudioBoardView, DesignStudioComment } from '../api/types';\nimport { useDesignStudio } from '../provider/DesignStudioProvider';\nimport { cx } from '../utils/cx';\n\n/** A pin position on a board in board pixels. */\nexport interface BoardPin {\n x: number;\n y: number;\n}\n\n/** Thread roots of a board with their replies, oldest first. */\nexport interface CommentThread {\n root: DesignStudioComment;\n replies: DesignStudioComment[];\n /** 1-based number of a pinned root (shown on the board), null for a board-level comment. */\n pinNumber: number | null;\n}\n\n/** Groups a board's comments into threads by `parentDesignStudioCommentId` (null = a thread root). */\nexport const buildCommentThreads = (comments: DesignStudioComment[]): CommentThread[] => {\n const repliesByRootId = new Map<number, DesignStudioComment[]>();\n for (const comment of comments) {\n if (comment.parentDesignStudioCommentId != null) {\n const replies = repliesByRootId.get(comment.parentDesignStudioCommentId) ?? [];\n replies.push(comment);\n repliesByRootId.set(comment.parentDesignStudioCommentId, replies);\n }\n }\n let pinNumber = 0;\n return comments\n .filter(comment => comment.parentDesignStudioCommentId == null)\n .map(root => ({\n root,\n replies: repliesByRootId.get(Number(root.id)) ?? [],\n pinNumber: root.x != null && root.y != null ? ++pinNumber : null,\n }));\n};\n\nconst errorMessage = (error: unknown) => normalizeDddError(error, 'Request failed').message;\n\ninterface CommentLineProps {\n comment: DesignStudioComment;\n isOwn: boolean;\n writesAllowed: boolean;\n}\n\nconst CommentLine = ({ comment, isOwn, writesAllowed }: CommentLineProps) => {\n const { api, components, formatDateTime, notify } = useDesignStudio();\n const { Button } = components;\n const [deleteComment, { isLoading: isDeleting }] = api.useDeleteCommentMutation();\n return (\n <div className=\"space-y-1\">\n <p className=\"flex items-center gap-1.5 text-xs text-muted-foreground\">\n {comment.authorKind === 'AGENT' && <Bot className=\"size-3.5 text-brand-emphasis\" aria-label=\"Agent\" />}\n <span className=\"font-semibold text-foreground\">{comment.authorName ?? 'Unknown'}</span>\n <span>· {formatDateTime(comment.changeHistory?.createdTime)}</span>\n {isOwn && (\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"ml-auto size-6\"\n aria-label=\"Delete comment\"\n disabled={!writesAllowed || isDeleting}\n onClick={() =>\n deleteComment({ designStudioCommentId: Number(comment.id) })\n .unwrap()\n .catch(error => notify.error(errorMessage(error)))\n }\n >\n <Trash2 className=\"size-3.5\" />\n </Button>\n )}\n </p>\n <p className=\"text-sm whitespace-pre-wrap break-words\">{comment.text}</p>\n </div>\n );\n};\n\ninterface ThreadCardProps {\n thread: CommentThread;\n /** \"Copy for agent\": the board reference with this thread (pin + texts). */\n onCopyReference: (thread: CommentThread) => void;\n isHighlighted: boolean;\n onHighlight: () => void;\n authAccountId: number | null;\n writesAllowed: boolean;\n /** The board file is another version than the one the thread was written on. */\n hasBoardChangedSince: boolean;\n /** The thread is deleted soon unless something happens in it (\"Keep\" postpones that). */\n isExpiring: boolean;\n}\n\nconst ThreadCard = ({\n thread,\n onCopyReference,\n isHighlighted,\n onHighlight,\n authAccountId,\n writesAllowed,\n hasBoardChangedSince,\n isExpiring,\n}: ThreadCardProps) => {\n const { root, replies, pinNumber } = thread;\n const [replyText, setReplyText] = useState('');\n const { api, components, notify } = useDesignStudio();\n const { Badge, Button, Textarea } = components;\n const [createReply, { isLoading: isReplying }] = api.useReplyToCommentMutation();\n const [resolveThread, { isLoading: isResolving }] = api.useResolveCommentMutation();\n const [reopenThread, { isLoading: isReopening }] = api.useReopenCommentMutation();\n const [patchComment, { isLoading: isPatching }] = api.usePatchCommentMutation();\n const [keepThread, { isLoading: isKeeping }] = api.useKeepCommentMutation();\n const designStudioCommentId = Number(root.id);\n\n const sendReply = async () => {\n try {\n await createReply({\n designStudioCommentId,\n body: { text: replyText },\n }).unwrap();\n setReplyText('');\n } catch (error) {\n notify.error(errorMessage(error));\n }\n };\n\n return (\n // biome-ignore lint/a11y/useSemanticElements: an article that highlights its pin on hover / focus, not a control\n <article\n className={cx(\n 'space-y-3 rounded-2xl bg-card p-4 shadow-surface-raised ring-1 ring-foreground/5',\n root.isResolved && 'opacity-70',\n isHighlighted && 'ring-2 ring-brand'\n )}\n onMouseEnter={onHighlight}\n onFocus={onHighlight}\n role=\"group\"\n aria-label={`Comment thread${pinNumber ? ` ${pinNumber}` : ''}`}\n >\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {pinNumber !== null ? (\n <Badge className=\"bg-primary text-primary-foreground\">\n <MapPin aria-hidden /> {pinNumber}\n </Badge>\n ) : (\n <Badge variant=\"outline\">Board</Badge>\n )}\n {root.isDecision && (\n <Badge variant=\"outline\" className=\"border-transparent bg-success/15 text-success\">\n <Flag aria-hidden /> Decision\n </Badge>\n )}\n {root.isResolved && (\n <Badge variant=\"outline\" className=\"border-transparent bg-tint text-muted-foreground\">\n Resolved{root.resolvedByName ? ` by ${root.resolvedByName}` : ''}\n </Badge>\n )}\n {hasBoardChangedSince && (\n <Badge\n variant=\"outline\"\n className=\"border-transparent bg-warning/15 text-warning\"\n title=\"The board file is another version than the one this thread was written on\"\n >\n <History aria-hidden /> Board changed since\n </Badge>\n )}\n {isExpiring && (\n <Badge\n variant=\"outline\"\n className=\"border-transparent bg-tint text-muted-foreground\"\n title=\"Idle threads are deleted; “Keep” or any reply postpones that\"\n >\n <Hourglass aria-hidden /> Expires soon\n </Badge>\n )}\n </div>\n <CommentLine comment={root} isOwn={authAccountId !== null && root.authorAccountId === authAccountId} writesAllowed={writesAllowed} />\n {replies.map(reply => (\n <div key={String(reply.id)} className=\"border-l-2 border-border pl-3\">\n <CommentLine\n comment={reply}\n isOwn={authAccountId !== null && reply.authorAccountId === authAccountId}\n writesAllowed={writesAllowed}\n />\n </div>\n ))}\n <Textarea\n value={replyText}\n onChange={event => setReplyText(event.target.value)}\n placeholder=\"Reply…\"\n rows={2}\n aria-label=\"Reply\"\n disabled={!writesAllowed}\n />\n <div className=\"flex flex-wrap items-center gap-2\">\n <Button size=\"sm\" variant=\"outline\" disabled={!writesAllowed || !replyText.trim() || isReplying} onClick={sendReply}>\n Reply\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={!writesAllowed || isPatching}\n aria-pressed={Boolean(root.isDecision)}\n onClick={() =>\n patchComment({\n designStudioCommentId,\n body: { isDecision: !root.isDecision },\n })\n .unwrap()\n .catch(error => notify.error(errorMessage(error)))\n }\n >\n <Flag /> {root.isDecision ? 'Not a decision' : 'Decision'}\n </Button>\n <Button size=\"sm\" variant=\"outline\" onClick={() => onCopyReference(thread)} aria-label=\"Copy for agent\">\n <ClipboardCopy /> Copy for agent\n </Button>\n {isExpiring && (\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={!writesAllowed || isKeeping}\n onClick={() =>\n keepThread({ designStudioCommentId })\n .unwrap()\n .catch(error => notify.error(errorMessage(error)))\n }\n >\n Keep\n </Button>\n )}\n {root.isResolved ? (\n <Button\n size=\"sm\"\n variant=\"outline\"\n className=\"ml-auto\"\n disabled={!writesAllowed || isReopening}\n onClick={() =>\n reopenThread({ designStudioCommentId })\n .unwrap()\n .catch(error => notify.error(errorMessage(error)))\n }\n >\n <RotateCcw /> Reopen\n </Button>\n ) : (\n <Button\n size=\"sm\"\n variant=\"outline\"\n className=\"ml-auto\"\n disabled={!writesAllowed || isResolving}\n onClick={async () => {\n try {\n await resolveThread({\n designStudioCommentId,\n body: { replyText: replyText.trim() ? replyText : null },\n }).unwrap();\n setReplyText('');\n } catch (error) {\n notify.error(errorMessage(error));\n }\n }}\n >\n <CheckCircle2 /> Resolve\n </Button>\n )}\n </div>\n </article>\n );\n};\n\nexport interface BoardCommentsProps {\n projectKey: string;\n canvasKey: string;\n board: DesignStudioBoardView;\n threads: CommentThread[];\n /** A pin placed on the board in focus view, waiting for its comment. */\n pendingPin: BoardPin | null;\n onClearPendingPin: () => void;\n highlightedCommentId: number | null;\n onHighlightComment: (designStudioCommentId: number | null) => void;\n writesAllowed: boolean;\n /** Show resolved threads too. */\n showResolved: boolean;\n onShowResolvedChange: (showResolved: boolean) => void;\n /** How to pin a comment from where the panel is shown (placeholder of the new-comment field). */\n pinHint: string;\n /** \"Copy for agent\" on a thread. */\n onCopyThreadReference: (thread: CommentThread) => void;\n}\n\n/** Comments of one board: new thread (on the board or at a placed pin), threads with replies, resolve, decision. */\nexport const BoardComments = ({\n projectKey,\n canvasKey,\n board,\n threads,\n pendingPin,\n onClearPendingPin,\n highlightedCommentId,\n onHighlightComment,\n writesAllowed,\n showResolved,\n onShowResolvedChange,\n pinHint,\n onCopyThreadReference,\n}: BoardCommentsProps) => {\n const [text, setText] = useState('');\n const [isDecision, setIsDecision] = useState(false);\n const { api, components, notify, useCurrentAccountId } = useDesignStudio();\n const { Button, Checkbox, Label, Textarea } = components;\n const [createComment, { isLoading }] = api.useCreateCommentMutation();\n const authAccountId = useCurrentAccountId();\n // threads that are deleted soon unless something happens in them (all canvases; one cached request)\n const { data: expiringData } = api.useExpiringCommentsQuery();\n const expiringCommentIds = new Set(\n (expiringData?.designStudioComments.elements ?? []).map(comment => Number(comment.id))\n );\n const visibleThreads = showResolved ? threads : threads.filter(thread => !thread.root.isResolved);\n const resolvedCount = threads.length - threads.filter(thread => !thread.root.isResolved).length;\n\n const addComment = async () => {\n try {\n await createComment({\n projectKey,\n canvasKey,\n boardKey: board.boardKey ?? '',\n body: {\n text,\n x: pendingPin?.x ?? null,\n y: pendingPin?.y ?? null,\n isDecision,\n },\n }).unwrap();\n setText('');\n setIsDecision(false);\n onClearPendingPin();\n } catch (error) {\n notify.error(errorMessage(error));\n }\n };\n\n return (\n <div className=\"space-y-4\">\n <div className=\"space-y-2\">\n <Label htmlFor=\"design-comment-text\" className=\"flex items-center gap-1.5\">\n {pendingPin ? (\n <>\n <MapPin className=\"size-4 text-brand-emphasis\" aria-hidden /> Comment at the placed pin\n </>\n ) : (\n 'New comment on the board'\n )}\n </Label>\n <Textarea\n id=\"design-comment-text\"\n value={text}\n onChange={event => setText(event.target.value)}\n placeholder={pendingPin ? 'What should change here?' : `Comment… (${pinHint})`}\n rows={3}\n disabled={!writesAllowed}\n />\n <div className=\"flex flex-wrap items-center gap-3\">\n <div className=\"flex items-center gap-2\">\n <Checkbox\n id=\"design-comment-decision\"\n checked={isDecision}\n onCheckedChange={checked => setIsDecision(checked === true)}\n disabled={!writesAllowed}\n />\n <Label htmlFor=\"design-comment-decision\" className=\"font-normal\">\n Decision\n </Label>\n </div>\n {pendingPin && (\n <Button size=\"sm\" variant=\"ghost\" onClick={onClearPendingPin}>\n Remove pin\n </Button>\n )}\n <Button size=\"sm\" className=\"ml-auto\" disabled={!writesAllowed || !text.trim() || isLoading || !board.boardKey} onClick={addComment}>\n Comment\n </Button>\n </div>\n </div>\n {resolvedCount > 0 && (\n <div className=\"flex items-center gap-2\">\n <Checkbox\n id=\"design-comment-show-resolved\"\n checked={showResolved}\n onCheckedChange={checked => onShowResolvedChange(checked === true)}\n />\n <Label htmlFor=\"design-comment-show-resolved\" className=\"font-normal text-muted-foreground\">\n Show {resolvedCount} resolved\n </Label>\n </div>\n )}\n {visibleThreads.length === 0 && <p className=\"text-sm text-muted-foreground\">No open comments on this board.</p>}\n {visibleThreads.map(thread => (\n <ThreadCard\n key={String(thread.root.id)}\n thread={thread}\n onCopyReference={onCopyThreadReference}\n isHighlighted={highlightedCommentId === Number(thread.root.id)}\n onHighlight={() => onHighlightComment(Number(thread.root.id))}\n authAccountId={authAccountId}\n writesAllowed={writesAllowed}\n hasBoardChangedSince={\n Boolean(thread.root.contentHash && board.contentHash) && thread.root.contentHash !== board.contentHash\n }\n isExpiring={expiringCommentIds.has(Number(thread.root.id))}\n />\n ))}\n </div>\n );\n};\n","'use client';\n\nimport { ChevronLeft, ChevronRight, ClipboardCopy, MapPin, MapPinPlus, SquareDashedMousePointer, X } from 'lucide-react';\nimport { type MouseEvent, type PointerEvent, useEffect, useState } from 'react';\n\nimport type { DesignStudioBoardView } from '../api/types';\nimport { useDesignStudio, useDesignStudioTexts } from '../provider/DesignStudioProvider';\nimport { cx } from '../utils/cx';\nimport { BoardComments, type BoardPin, type CommentThread } from './BoardComments';\nimport { designContentUrl } from './BoardNode';\nimport { shortContentHash } from './canvasLiveUpdate';\nimport type { BoardRegion } from './designReference';\nimport { BoardStatusChips } from './BoardStatusChips';\nimport { useStableContentUrl } from './stableContentUrl';\nimport { useCheckedContentUrl } from './useCheckedContentUrl';\n\n/** Visible height of the device screen (iPhone 15 point height); taller boards scroll inside the device. */\nconst DEVICE_SCREEN_HEIGHT = 844;\n\nexport interface BoardFocusViewProps {\n projectKey: string;\n canvasKey: string;\n board: DesignStudioBoardView | null;\n /** The configured status keys in display order. */\n statuses: readonly string[];\n sectionTitle: string | null;\n /** Position of the board in the navigation order (1-based) and the count. */\n position: { index: number; count: number };\n threads: CommentThread[];\n writesAllowed: boolean;\n /** Present mode: label of the section being presented. */\n presentLabel?: string | null;\n onClose: () => void;\n onPrevious: () => void;\n onNext: () => void;\n onStatusChanged: (status: string) => void;\n /** \"Copy reference\" (button / C): this board, with the marked region and the note when set. */\n onCopyReference: (options: { region: BoardRegion | null; note: string }) => void;\n /** \"Copy for agent\" on a comment thread. */\n onCopyThreadReference: (thread: CommentThread) => void;\n}\n\n/**\n * One board large: the live sandboxed HTML at its native width in a device frame, scrolling through its full length;\n * prev / next through the canvas order (buttons and ← / →); comment pins on the board (“Add pin”, then a click on the\n * spot) and the board's comment threads and status beside it.\n */\nexport const BoardFocusView = ({\n projectKey,\n canvasKey,\n board,\n statuses,\n sectionTitle,\n position,\n threads,\n writesAllowed,\n presentLabel,\n onClose,\n onPrevious,\n onNext,\n onStatusChanged,\n onCopyReference,\n onCopyThreadReference,\n}: BoardFocusViewProps) => {\n const { apiBaseUrl, components } = useDesignStudio();\n const texts = useDesignStudioTexts();\n const { Button, Dialog, DialogContent, DialogDescription, DialogTitle, Textarea } = components;\n const [isPlacingPin, setIsPlacingPin] = useState(false);\n const [pendingPin, setPendingPin] = useState<BoardPin | null>(null);\n const [highlightedCommentId, setHighlightedCommentId] = useState<number | null>(null);\n const [showResolved, setShowResolved] = useState(false);\n // region reference: a rectangle dragged on the board (board pixels) + a note, both for \"Copy reference\"\n const [isMarkingRegion, setIsMarkingRegion] = useState(false);\n const [region, setRegion] = useState<BoardRegion | null>(null);\n const [regionDraft, setRegionDraft] = useState<{ startX: number; startY: number; x: number; y: number } | null>(null);\n const [referenceNote, setReferenceNote] = useState('');\n const [isRegionFlashing, setIsRegionFlashing] = useState(false);\n const boardKey = board?.boardKey ?? null;\n\n // A new board starts without a pending pin.\n useEffect(() => {\n if (boardKey === null) return;\n setPendingPin(null);\n setIsPlacingPin(false);\n setHighlightedCommentId(null);\n setRegion(null);\n setRegionDraft(null);\n setIsMarkingRegion(false);\n setReferenceNote('');\n }, [boardKey]);\n\n useEffect(() => {\n if (!board) return;\n const onKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement | null;\n if (target && (target.tagName === 'TEXTAREA' || target.tagName === 'INPUT' || target.isContentEditable)) return;\n if (event.key === 'c' || event.key === 'C') {\n if (event.metaKey || event.ctrlKey || event.altKey) return;\n event.preventDefault();\n copyReference();\n return;\n }\n if (event.key === 'ArrowLeft') {\n event.preventDefault();\n onPrevious();\n } else if (event.key === 'ArrowRight') {\n event.preventDefault();\n onNext();\n }\n };\n window.addEventListener('keydown', onKeyDown);\n return () => window.removeEventListener('keydown', onKeyDown);\n });\n\n const width = board?.width ?? 390;\n const height = board?.height ?? 844;\n // the iframe mounts only after the HTML answered 2xx: an error keeps the thumbnail, retried in the background\n // stable per content: a rotated content token does not reload the open board\n const htmlUrl = useCheckedContentUrl(useStableContentUrl(designContentUrl(apiBaseUrl, board?.htmlUrl), true));\n const thumbnailUrl = useStableContentUrl(designContentUrl(apiBaseUrl, board?.thumbnailUrl), true);\n const pinnedThreads = threads.filter(thread => thread.pinNumber !== null && (showResolved || !thread.root.isResolved));\n\n const copyReference = () => {\n onCopyReference({ region, note: referenceNote });\n if (region) {\n setIsRegionFlashing(true);\n window.setTimeout(() => setIsRegionFlashing(false), 1200);\n }\n };\n\n const boardPointOf = (event: PointerEvent<HTMLButtonElement>) => {\n const rect = event.currentTarget.getBoundingClientRect();\n return {\n x: Math.max(0, Math.min(width, event.clientX - rect.left)),\n y: Math.max(0, Math.min(height, event.clientY - rect.top)),\n };\n };\n const startRegion = (event: PointerEvent<HTMLButtonElement>) => {\n event.currentTarget.setPointerCapture(event.pointerId);\n const point = boardPointOf(event);\n setRegionDraft({ startX: point.x, startY: point.y, x: point.x, y: point.y });\n };\n const moveRegion = (event: PointerEvent<HTMLButtonElement>) => {\n if (!regionDraft) return;\n const point = boardPointOf(event);\n setRegionDraft({ ...regionDraft, x: point.x, y: point.y });\n };\n const endRegion = () => {\n if (!regionDraft) return;\n const marked = {\n x: Math.min(regionDraft.startX, regionDraft.x),\n y: Math.min(regionDraft.startY, regionDraft.y),\n width: Math.abs(regionDraft.x - regionDraft.startX),\n height: Math.abs(regionDraft.y - regionDraft.startY),\n };\n setRegionDraft(null);\n if (marked.width >= 4 && marked.height >= 4) {\n setRegion(marked);\n setIsMarkingRegion(false);\n }\n };\n const shownRegion: BoardRegion | null = regionDraft\n ? {\n x: Math.min(regionDraft.startX, regionDraft.x),\n y: Math.min(regionDraft.startY, regionDraft.y),\n width: Math.abs(regionDraft.x - regionDraft.startX),\n height: Math.abs(regionDraft.y - regionDraft.startY),\n }\n : region;\n\n const placePin = (event: MouseEvent<HTMLButtonElement>) => {\n const rect = event.currentTarget.getBoundingClientRect();\n setPendingPin({ x: Math.round(event.clientX - rect.left), y: Math.round(event.clientY - rect.top) });\n setIsPlacingPin(false);\n };\n\n return (\n <Dialog open={board !== null} onOpenChange={open => !open && onClose()}>\n <DialogContent\n showCloseButton={false}\n className=\"flex h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] max-w-none flex-col gap-0 overflow-hidden rounded-3xl p-0 sm:max-w-none\"\n >\n {board && (\n <>\n <header className=\"flex flex-wrap items-center gap-3 border-b border-border px-5 py-3\">\n <div className=\"min-w-0 flex-1\">\n <DialogTitle className=\"truncate text-lg font-semibold\">{board.title}</DialogTitle>\n <DialogDescription className=\"truncate text-xs\">\n {presentLabel ? 'Present · ' : ''}\n {sectionTitle ? `${sectionTitle} · ` : ''}\n {board.boardKey} · {shortContentHash(board.contentHash)} · {position.index} / {position.count}\n </DialogDescription>\n </div>\n <BoardStatusChips\n projectKey={projectKey}\n canvasKey={canvasKey}\n board={board}\n statuses={statuses}\n writesAllowed={writesAllowed}\n onStatusChanged={onStatusChanged}\n />\n <div className=\"flex items-center gap-1\">\n <Button variant=\"outline\" size=\"icon\" aria-label=\"Previous board (←)\" onClick={onPrevious}>\n <ChevronLeft />\n </Button>\n <Button variant=\"outline\" size=\"icon\" aria-label=\"Next board (→)\" onClick={onNext}>\n <ChevronRight />\n </Button>\n <Button variant=\"ghost\" size=\"icon\" aria-label=\"Close focus view\" onClick={onClose}>\n <X />\n </Button>\n </div>\n </header>\n <div className=\"flex min-h-0 flex-1 flex-col lg:flex-row\">\n <div className=\"flex min-h-0 flex-1 items-start justify-center overflow-auto bg-tint p-6\">\n <div className=\"rounded-[56px] bg-foreground p-3 shadow-surface-raised\">\n <div\n className=\"relative overflow-y-auto overflow-x-hidden rounded-[44px] bg-card\"\n style={{ width, height: Math.min(height, DEVICE_SCREEN_HEIGHT) }}\n >\n <div className=\"relative\" style={{ width, height }}>\n {thumbnailUrl && (\n // biome-ignore lint/performance/noImgElement: API thumbnail under the live board while it loads\n <img\n src={thumbnailUrl}\n alt=\"\"\n width={width}\n height={height}\n className=\"pointer-events-none absolute inset-0 select-none\"\n />\n )}\n {htmlUrl && (\n <iframe\n key={htmlUrl}\n src={htmlUrl}\n title={board.title ?? board.boardKey ?? 'Board'}\n sandbox=\"\"\n referrerPolicy=\"no-referrer\"\n width={width}\n height={height}\n className=\"absolute inset-0 border-0 bg-transparent\"\n />\n )}\n {isPlacingPin && (\n <button\n type=\"button\"\n aria-label=\"Place the pin here\"\n className=\"absolute inset-0 z-10 cursor-crosshair bg-brand/10\"\n onClick={placePin}\n />\n )}\n {isMarkingRegion && (\n <button\n type=\"button\"\n aria-label=\"Drag a rectangle to mark a region of the board\"\n className=\"absolute inset-0 z-10 cursor-crosshair touch-none bg-brand/5\"\n onPointerDown={startRegion}\n onPointerMove={moveRegion}\n onPointerUp={endRegion}\n />\n )}\n {shownRegion && (\n <span\n aria-hidden\n className={cx(\n 'pointer-events-none absolute z-20 rounded-md border-2 border-dashed border-brand bg-brand/10 transition-shadow motion-reduce:transition-none',\n isRegionFlashing && 'shadow-[0_0_0_6px_var(--brand)]'\n )}\n style={{\n left: shownRegion.x,\n top: shownRegion.y,\n width: shownRegion.width,\n height: shownRegion.height,\n }}\n />\n )}\n {pinnedThreads.map(thread => (\n <button\n key={String(thread.root.id)}\n type=\"button\"\n aria-label={`Comment ${thread.pinNumber}`}\n onMouseEnter={() => setHighlightedCommentId(Number(thread.root.id))}\n onClick={() => setHighlightedCommentId(Number(thread.root.id))}\n className={cx(\n 'absolute z-20 flex size-7 -translate-x-1/2 -translate-y-full items-center justify-center rounded-full rounded-bl-none text-xs font-bold shadow-surface-raised ring-2 ring-card',\n thread.root.isResolved ? 'bg-muted text-muted-foreground' : 'bg-primary text-primary-foreground',\n highlightedCommentId === Number(thread.root.id) && 'ring-brand scale-110'\n )}\n style={{ left: thread.root.x ?? 0, top: thread.root.y ?? 0 }}\n >\n {thread.pinNumber}\n </button>\n ))}\n {pendingPin && (\n <span\n className=\"absolute z-20 flex size-7 -translate-x-1/2 -translate-y-full items-center justify-center rounded-full rounded-bl-none bg-brand text-card shadow-surface-raised ring-2 ring-card\"\n style={{ left: pendingPin.x, top: pendingPin.y }}\n aria-hidden\n >\n <MapPin className=\"size-4\" />\n </span>\n )}\n </div>\n </div>\n </div>\n </div>\n <aside className=\"flex min-h-0 w-full flex-col border-t border-border lg:w-[400px] lg:border-t-0 lg:border-l\">\n <div className=\"space-y-2 border-b border-border px-5 py-4\">\n <p className=\"text-sm font-semibold\">Reference for an agent</p>\n <div className=\"flex flex-wrap items-center gap-2\">\n <Button\n variant={isMarkingRegion ? 'default' : 'outline'}\n size=\"sm\"\n aria-pressed={isMarkingRegion}\n onClick={() => setIsMarkingRegion(marking => !marking)}\n >\n <SquareDashedMousePointer /> {isMarkingRegion ? 'Drag on the board…' : 'Mark region'}\n </Button>\n {region && (\n <Button variant=\"ghost\" size=\"sm\" onClick={() => setRegion(null)}>\n Clear region\n </Button>\n )}\n <Button variant=\"outline\" size=\"sm\" className=\"ml-auto\" onClick={copyReference}>\n <ClipboardCopy /> Copy reference\n </Button>\n </div>\n {region && (\n <p className=\"text-xs text-muted-foreground tabular-nums\">\n Region {Math.round(region.x)},{Math.round(region.y)} · {Math.round(region.width)} ×{' '}\n {Math.round(region.height)} px\n </p>\n )}\n <Textarea\n value={referenceNote}\n onChange={event => setReferenceNote(event.target.value)}\n placeholder={texts.referenceNotePlaceholder}\n rows={2}\n aria-label=\"Note for the reference\"\n />\n </div>\n <div className=\"flex items-center gap-2 px-5 pt-4\">\n <Button\n variant={isPlacingPin ? 'default' : 'outline'}\n size=\"sm\"\n disabled={!writesAllowed}\n aria-pressed={isPlacingPin}\n onClick={() => setIsPlacingPin(placing => !placing)}\n >\n <MapPinPlus /> {isPlacingPin ? 'Click on the board…' : 'Add pin'}\n </Button>\n <span className=\"text-xs text-muted-foreground\">\n {threads.filter(thread => !thread.root.isResolved).length} open\n </span>\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto px-5 py-4\">\n <BoardComments\n projectKey={projectKey}\n canvasKey={canvasKey}\n board={board}\n threads={threads}\n pendingPin={pendingPin}\n onClearPendingPin={() => setPendingPin(null)}\n highlightedCommentId={highlightedCommentId}\n onHighlightComment={setHighlightedCommentId}\n writesAllowed={writesAllowed}\n showResolved={showResolved}\n onShowResolvedChange={setShowResolved}\n pinHint=\"“Add pin” marks a spot on the board\"\n onCopyThreadReference={onCopyThreadReference}\n />\n </div>\n </aside>\n </div>\n </>\n )}\n </DialogContent>\n </Dialog>\n );\n};\n","'use client';\n\nimport { type Node, type NodeProps, useStore } from '@xyflow/react';\nimport { ClipboardCopy, Download, Maximize2, MessageSquare } from 'lucide-react';\nimport { memo, useEffect, useRef, useState } from 'react';\n\nimport type { DesignStudioBoardView } from '../api/types';\nimport { useDesignStudio, useDesignStudioTexts } from '../provider/DesignStudioProvider';\nimport { cx } from '../utils/cx';\nimport { boardStatusDefinition } from './boardStatus';\nimport { thumbnailVariantForZoom } from './boardDetail';\nimport { boardCodeOf } from './boardKey';\nimport { BOARD_HEADER_HEIGHT, MAX_BOARD_CANVAS_HEIGHT } from './canvasLayout';\nimport { withoutContentToken } from './canvasLiveUpdate';\nimport { useCanvasView } from './canvasView';\nimport { useCheckedContentUrl, useImageRetry, wasContentUrlLoaded } from './useCheckedContentUrl';\nimport { useDeferredMount } from './useDeferredMount';\nimport { useStableContentUrl } from './stableContentUrl';\n\nexport type BoardNodeData = { board: DesignStudioBoardView };\nexport type BoardFlowNode = Node<BoardNodeData, 'board'>;\n\n/** Whether two delivery URLs show the same content (they differ at most in the content token). */\nconst isSameContent = (first: string | null | undefined, second: string | null | undefined): boolean =>\n Boolean(first && second) && withoutContentToken(first) === withoutContentToken(second);\n\n/**\n * Absolute URL of a delivery path (`/api/...`; `apiBaseUrl` is `environment.apiBaseUrl`, empty = same origin). The path\n * comes complete from the canvas view: content token, content hash and theme are already in it.\n */\nexport const designContentUrl = (apiBaseUrl: string, path: string | null | undefined): string | undefined =>\n path ? `${apiBaseUrl}${path}` : undefined;\n\n/** File name of a board download (`welcome-2.png`). */\nconst downloadName = (board: DesignStudioBoardView, extension: string) =>\n `${boardCodeOf(board.boardKey ?? 'board')}.${extension}`;\n\n/** A press that moved further than this (px) was a pan, not a click. */\nconst CLICK_MAX_MOVE = 5;\n\n/** Header icon button (canvas px: scales with the zoom like the title). */\nconst HEADER_ICON_BUTTON_CLASS =\n 'nodrag nopan flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-tint-strong hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none motion-reduce:transition-none';\n\n/**\n * One board on the canvas: a header line (title with ellipsis — the full title on hover —,\n * status, open comments, \"expand\" = focus view, \"download\" PNG / HTML) above the board. Far out the board shows the\n * ~120 px thumbnail, closer the board-width thumbnail; when the canvas marks it live (large on screen, inside the\n * viewport, one of the nearest six) the sandboxed board HTML is mounted on top — `sandbox=\"\"`: no scripts, no same\n * origin, no forms, no navigation. A board without a thumbnail in the shown look (not rendered yet) is a neutral\n * card until it is live. Only nodes in the viewport are mounted (`onlyRenderVisibleElements`).\n */\nconst BoardNodeComponent = ({ id, data }: NodeProps<BoardFlowNode>) => {\n const { board } = data;\n const { apiBaseUrl, components, statuses } = useDesignStudio();\n const texts = useDesignStudioTexts();\n const { StatusBadge } = components;\n const statusDefinition = board.status ? boardStatusDefinition(statuses, board.status) : undefined;\n const width = board.width ?? 390;\n const height = board.height ?? 844;\n // the canvas shows at most MAX_BOARD_CANVAS_HEIGHT of a board; the focus view shows it whole\n const visibleHeight = Math.min(height, MAX_BOARD_CANVAS_HEIGHT);\n const isCut = height > visibleHeight;\n const thumbnailVariant = useStore(state => thumbnailVariantForZoom(state.transform[2], width));\n const {\n liveBoardIds,\n selectedBoardIds,\n matchingBoardIds,\n openThreadCounts,\n defaultStatus,\n onSelectBoard,\n onCopyReference,\n onOpenBoard,\n } = useCanvasView();\n const isLive = liveBoardIds.has(id);\n const isSelected = selectedBoardIds.has(id);\n const isDimmed = matchingBoardIds !== null && !matchingBoardIds.has(id);\n const openThreads = openThreadCounts.get(id) ?? 0;\n // mass mounts (a zoom across a level) are spread over frames: a plain placeholder until this node's turn\n const isReady = useDeferredMount();\n // no thumbnail in the shown look (yet): nothing to draw until the board is live\n const isThumbnailMissing = !board.thumbnailUrl;\n const latestThumbnailUrl = designContentUrl(\n apiBaseUrl,\n thumbnailVariant === 'small' ? (board.thumbnailSmallUrl ?? board.thumbnailUrl) : board.thumbnailUrl\n );\n const latestHtmlUrl = designContentUrl(apiBaseUrl, board.htmlUrl);\n // Same content → same URL for the page's lifetime (a rotated content token never reloads an image / iframe, a\n // remount gets the URL the browser cache holds); only a new version or another theme changes the src.\n const [loadedImageUrl, setLoadedImageUrl] = useState<string | null>(null);\n const [loadedFrameUrl, setLoadedFrameUrl] = useState<string | null>(null);\n const thumbnailUrl = useStableContentUrl(latestThumbnailUrl, isSameContent(loadedImageUrl, latestThumbnailUrl));\n const htmlUrl = useStableContentUrl(latestHtmlUrl, isSameContent(loadedFrameUrl, latestHtmlUrl));\n // A board already seen live in this look never falls back to the empty card while it has no thumbnail: it remounts\n // its HTML at once (browser cache, bounded LRU) instead of waiting for the live set.\n const isRememberedLive =\n isThumbnailMissing && thumbnailVariant === 'default' && isReady && wasContentUrlLoaded(htmlUrl);\n const showsLiveHtml = isLive || isRememberedLive;\n // the iframe mounts only after its HTML answered 2xx (never an error body over the thumbnail); retried while live\n const liveHtmlUrl = useCheckedContentUrl(showsLiveHtml && isReady ? htmlUrl : undefined);\n const thumbnailRetry = useImageRetry(thumbnailUrl);\n useEffect(() => {\n if (!liveHtmlUrl) setLoadedFrameUrl(null);\n }, [liveHtmlUrl]);\n const title = board.title ?? board.boardKey ?? '';\n // the board's code (file name without extension) under the title, so a screen can be named unambiguously\n const boardCode = boardCodeOf(board.boardKey ?? '');\n const [isDownloadOpen, setIsDownloadOpen] = useState(false);\n const pressPointRef = useRef<{ x: number; y: number } | null>(null);\n // far out (small thumbnails) the header is only the title: no buttons, no badges to mount per board\n const isCompact = thumbnailVariant === 'small';\n\n if (!isReady) {\n return (\n <div className={cx('h-full w-full', isDimmed && 'opacity-15')} style={{ paddingTop: BOARD_HEADER_HEIGHT }}>\n <div className=\"rounded-[20px] bg-card/70\" style={{ width, height: visibleHeight }} />\n </div>\n );\n }\n\n return (\n <div className={cx('relative h-full w-full', isDimmed && 'opacity-15')}>\n {/* two rows: the full title (up to two lines, never squeezed by the buttons), then the code + the buttons */}\n <div className=\"flex flex-col justify-end gap-0.5 pb-1\" style={{ height: BOARD_HEADER_HEIGHT }}>\n <span className=\"line-clamp-2 text-[19px] leading-6 font-medium text-muted-foreground\" title={title}>\n {title}\n </span>\n <div className=\"flex items-center gap-1\">\n <span className=\"min-w-0 flex-1 truncate text-[15px] leading-5 font-semibold text-foreground/70 tabular-nums\" title={boardCode}>\n {isCompact ? '' : boardCode}\n </span>\n {!isCompact && openThreads > 0 && (\n <span className=\"inline-flex shrink-0 items-center gap-1 rounded-full bg-primary px-2 py-0.5 text-sm font-semibold text-primary-foreground\">\n <MessageSquare className=\"size-3.5\" aria-hidden />\n {openThreads}\n </span>\n )}\n {!isCompact && board.status && board.status !== defaultStatus && (\n <StatusBadge\n tone={statusDefinition?.tone ?? 'neutral'}\n label={statusDefinition?.label ?? board.status}\n icon={statusDefinition?.icon}\n title={statusDefinition?.description}\n className=\"shrink-0\"\n />\n )}\n {!isCompact && (\n <button\n type=\"button\"\n className={HEADER_ICON_BUTTON_CLASS}\n aria-label={`Copy reference of ${title} for an agent`}\n title=\"Copy reference (C)\"\n onClick={() => onCopyReference(id)}\n >\n <ClipboardCopy className=\"size-5\" />\n </button>\n )}\n {!isCompact && (\n <button\n type=\"button\"\n className={HEADER_ICON_BUTTON_CLASS}\n aria-label={`Open ${title} large`}\n title=\"Expand\"\n onClick={() => onOpenBoard(id)}\n >\n <Maximize2 className=\"size-5\" />\n </button>\n )}\n {!isCompact && (\n <div className=\"relative\">\n <button\n type=\"button\"\n className={HEADER_ICON_BUTTON_CLASS}\n aria-label={`Download ${title}`}\n aria-expanded={isDownloadOpen}\n title=\"Download\"\n onClick={() => setIsDownloadOpen(isOpen => !isOpen)}\n >\n <Download className=\"size-5\" />\n </button>\n {isDownloadOpen && (\n // a plain menu instead of a Radix one: mounted only while open, nothing per node at rest\n <div\n className=\"nodrag nopan absolute top-full right-0 z-20 mt-1 flex w-56 flex-col rounded-2xl bg-popover p-1.5 text-[18px] shadow-surface-raised ring-1 ring-foreground/5\"\n >\n {board.thumbnailUrl && (\n <a\n href={designContentUrl(apiBaseUrl, board.thumbnailUrl)}\n download={downloadName(board, 'png')}\n className=\"rounded-[10px] px-3 py-2 hover:bg-tint\"\n onClick={() => setIsDownloadOpen(false)}\n >\n PNG (thumbnail)\n </a>\n )}\n {board.htmlUrl && (\n <a\n href={htmlUrl}\n download={downloadName(board, 'html')}\n className=\"rounded-[10px] px-3 py-2 hover:bg-tint\"\n onClick={() => setIsDownloadOpen(false)}\n >\n HTML\n </a>\n )}\n </div>\n )}\n </div>\n )}\n </div>\n </div>\n <div\n className={cx(\n 'relative overflow-hidden rounded-[20px] bg-card shadow-surface-raised ring-1 ring-foreground/10',\n isSelected && 'ring-4 ring-brand'\n )}\n style={{ width, height: visibleHeight }}\n >\n {thumbnailUrl && (\n // biome-ignore lint/performance/noImgElement: canvas thumbnails are API images at canvas scale, next/image cannot optimise them\n <img\n key={thumbnailRetry.imageKey}\n src={thumbnailUrl}\n alt=\"\"\n width={width}\n height={height}\n loading=\"lazy\"\n decoding=\"async\"\n draggable={false}\n onError={thumbnailRetry.onError}\n onLoad={() => setLoadedImageUrl(thumbnailUrl)}\n className={cx(\n 'pointer-events-none absolute inset-0 h-full w-full object-cover object-top select-none',\n thumbnailRetry.isFailed && 'invisible'\n )}\n />\n )}\n {isThumbnailMissing && !isCompact && !(showsLiveHtml && liveHtmlUrl) && (\n <span className=\"pointer-events-none absolute inset-0 flex items-center justify-center px-6 text-center text-[17px] font-semibold text-muted-foreground\">\n {texts.thumbnailMissing}\n </span>\n )}\n {showsLiveHtml && liveHtmlUrl && (\n <iframe\n src={liveHtmlUrl}\n onLoad={() => setLoadedFrameUrl(liveHtmlUrl)}\n title={title || 'Board'}\n sandbox=\"\"\n referrerPolicy=\"no-referrer\"\n loading=\"lazy\"\n width={width}\n height={height}\n className=\"pointer-events-none absolute inset-0 border-0 bg-transparent\"\n />\n )}\n {isCut && (\n <span className=\"pointer-events-none absolute inset-x-0 bottom-0 flex h-40 items-end justify-center bg-gradient-to-t from-card to-transparent pb-4 text-[16px] font-semibold text-muted-foreground\">\n ↓ {Math.round(height)} px — full length in the focus view\n </span>\n )}\n <button\n type=\"button\"\n className=\"absolute inset-0 z-10 cursor-pointer rounded-[20px] bg-transparent focus-visible:ring-4 focus-visible:ring-ring focus-visible:outline-none\"\n onPointerDown={event => {\n pressPointRef.current = { x: event.clientX, y: event.clientY };\n }}\n onClick={event => {\n // a drag that started on the board panned the canvas: no selection on its release\n const pressPoint = pressPointRef.current;\n if (pressPoint && Math.hypot(event.clientX - pressPoint.x, event.clientY - pressPoint.y) > CLICK_MAX_MOVE) return;\n onSelectBoard(id, event.shiftKey || event.metaKey || event.ctrlKey);\n }}\n onDoubleClick={() => onOpenBoard(id)}\n onKeyDown={event => {\n if (event.key === 'Enter' && event.shiftKey) onOpenBoard(id);\n }}\n aria-label={`${title}: select (double-click or Shift+Enter opens it)`}\n />\n </div>\n </div>\n );\n};\n\nexport const BoardNode = memo(BoardNodeComponent);\n","import type { DesignStudioStatusDefinition, DesignStudioStatuses } from '../provider/types';\n\n/**\n * The review statuses are configured in the backend (`DesignStudioCanvasView.statuses`, the first one is the default),\n * so a board's status is a plain string here; the application's status definitions (`environment.statuses`) know the\n * usual ones, any other key shows as it is.\n */\nexport const boardStatusDefinition = (\n statuses: DesignStudioStatuses,\n status: string\n): DesignStudioStatusDefinition | undefined => statuses[status];\n\nexport const boardStatusLabel = (statuses: DesignStudioStatuses, status: string): string =>\n boardStatusDefinition(statuses, status)?.label ?? status;\n","/**\n * Level of detail of the design canvas (render only what is visible). Pure functions, no React: which image a board shows at a zoom, and which boards may mount their live\n * (sandboxed iframe) HTML.\n */\n\n/** A board's place on the canvas, in canvas pixels. */\nexport interface BoardRect {\n id: string;\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** React Flow's viewport: screen = canvas × zoom + (x, y). */\nexport interface CanvasViewport {\n x: number;\n y: number;\n zoom: number;\n}\n\nexport interface ScreenSize {\n width: number;\n height: number;\n}\n\n/** Image a board shows: the ~120 px thumbnail at far zoom, the board-width thumbnail otherwise. */\nexport type BoardThumbnailVariant = 'small' | 'default';\n\n/** Rendered width (screen px) up to which the small thumbnail is enough (it is 120 px wide). */\nexport const SMALL_THUMBNAIL_MAX_RENDERED_WIDTH = 130;\n\n/** A board shows live HTML only when it is rendered at least this share of its native width. */\nexport const LIVE_MIN_RENDERED_WIDTH_RATIO = 0.6;\n\n/**\n * While boards have no thumbnail in the shown look yet (the renderer is still working, or it is off), they switch to\n * the live HTML earlier.\n */\nexport const LIVE_MIN_RENDERED_WIDTH_RATIO_WITHOUT_THUMBNAILS = 0.35;\n\n/** At most this many live iframes at once (the ones nearest the viewport centre). */\nexport const MAX_LIVE_BOARDS = 6;\n\nexport const thumbnailVariantForZoom = (zoom: number, boardWidth: number): BoardThumbnailVariant =>\n boardWidth * zoom <= SMALL_THUMBNAIL_MAX_RENDERED_WIDTH ? 'small' : 'default';\n\nexport const isZoomLiveCapable = (zoom: number, minRatio: number = LIVE_MIN_RENDERED_WIDTH_RATIO): boolean =>\n zoom >= minRatio;\n\n/**\n * The boards that may show live HTML: inside the viewport, rendered at ≥ `minRatio` of their width,\n * nearest the viewport centre first, at most `maxLiveBoards`.\n */\nexport const selectLiveBoardIds = (\n boards: readonly BoardRect[],\n viewport: CanvasViewport,\n screen: ScreenSize,\n maxLiveBoards: number = MAX_LIVE_BOARDS,\n minRatio: number = LIVE_MIN_RENDERED_WIDTH_RATIO\n): Set<string> => {\n if (!isZoomLiveCapable(viewport.zoom, minRatio) || screen.width <= 0 || screen.height <= 0) {\n return new Set();\n }\n const left = -viewport.x / viewport.zoom;\n const top = -viewport.y / viewport.zoom;\n const right = left + screen.width / viewport.zoom;\n const bottom = top + screen.height / viewport.zoom;\n const centreX = (left + right) / 2;\n const centreY = (top + bottom) / 2;\n const visible: { id: string; distance: number }[] = [];\n for (const board of boards) {\n const isInside =\n board.x < right && board.x + board.width > left && board.y < bottom && board.y + board.height > top;\n if (!isInside) continue;\n const distance = Math.hypot(board.x + board.width / 2 - centreX, board.y + Math.min(board.height, 844) / 2 - centreY);\n visible.push({ id: board.id, distance });\n }\n visible.sort((first, second) => first.distance - second.distance);\n return new Set(visible.slice(0, maxLiveBoards).map(entry => entry.id));\n};\n\n/** The boards inside the viewport, nearest the viewport centre first (render priority of missing thumbnails). */\nexport const selectVisibleBoardIds = (\n boards: readonly BoardRect[],\n viewport: CanvasViewport,\n screen: ScreenSize\n): string[] => {\n if (screen.width <= 0 || screen.height <= 0 || viewport.zoom <= 0) return [];\n const left = -viewport.x / viewport.zoom;\n const top = -viewport.y / viewport.zoom;\n const right = left + screen.width / viewport.zoom;\n const bottom = top + screen.height / viewport.zoom;\n const centreX = (left + right) / 2;\n const centreY = (top + bottom) / 2;\n return boards\n .filter(board => board.x < right && board.x + board.width > left && board.y < bottom && board.y + board.height > top)\n .map(board => ({ id: board.id, distance: Math.hypot(board.x + board.width / 2 - centreX, board.y + board.height / 2 - centreY) }))\n .sort((first, second) => first.distance - second.distance)\n .map(entry => entry.id);\n};\n","/**\n * A board's code: its key (the file name in the canvas folder) without the `.html` extension and without an optional\n * `.dc` before it (`welcome.html` and `welcome.dc.html` both give `welcome`). Shown under the title and used as the\n * base name of downloads. A key without `.html` is returned as it is.\n */\nexport const boardCodeOf = (boardKey: string): string => boardKey.replace(/(?:\\.dc)?\\.html$/, '');\n","/**\n * Auto layout of a design canvas: each section a bold title line above a grid of its\n * boards (rows aligned on their top edge, tall boards allowed), every board with a header line (title + actions) above\n * it. All sections share one row count, so a section's width follows its board count (≤ MAX_COLUMNS per row); the\n * sections are shelf-packed left → right in their order, and the row count and shelf width are chosen so a viewport\n * of TARGET_ASPECT_RATIO shows the whole canvas as large as possible (\"Fit all\" stays readable). Sections without boards are not drawn. The stored x / y of a board\n * (its place in the source canvas.json) only decide its order inside the section. Pure functions, no React.\n */\n\nexport interface LayoutSectionInput {\n id: string;\n title: string;\n displayOrder: number;\n}\n\nexport interface LayoutBoardInput {\n id: string;\n /** Section id, null = no section (\"Weitere Boards\" at the end). */\n sectionId: string | null;\n width: number;\n height: number;\n /** Order inside the section (publish order). */\n displayOrder: number;\n}\n\nexport interface LayoutRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface LayoutSection extends LayoutRect {\n id: string;\n title: string;\n boardCount: number;\n /** Board ids in layout order. */\n boardIds: string[];\n}\n\nexport interface CanvasLayout {\n sections: LayoutSection[];\n /** Board node rect: the header line plus the board (node id = board id). */\n boards: Map<string, LayoutRect>;\n bounds: LayoutRect;\n}\n\n/** Most boards in one row of a section (12–14 per row). */\nexport const MAX_COLUMNS = 14;\n/** Horizontal gap between boards. */\nexport const BOARD_GAP_X = 44;\n/** Vertical gap between board rows (below a board, above the next row's header). */\nexport const BOARD_GAP_Y = 64;\n/** Tallest board height drawn on the canvas; longer boards are cut there (the focus view shows the full length). */\nexport const MAX_BOARD_CANVAS_HEIGHT = 1400;\n/** Height of the header line above each board (title + expand / download). */\nexport const BOARD_HEADER_HEIGHT = 92;\n/** Height of a section's title line plus its gap to the first row. */\nexport const SECTION_TITLE_HEIGHT = 104;\n/** Padding of a section's background around its title and boards. */\nexport const SECTION_PADDING = 48;\n/** Gap between two sections' backgrounds (both directions). */\nexport const SECTION_GAP = 140;\n/** Aspect ratio (width / height) of the canvas area the packing optimises \"Fit all\" for (a laptop canvas area). */\nexport const TARGET_ASPECT_RATIO = 1.4;\n/** Section key of boards without a section. */\nexport const UNSECTIONED_ID = 'unsectioned';\n\ninterface SectionGrid {\n section: LayoutSectionInput;\n boards: LayoutBoardInput[];\n /** Board rects relative to the section's top-left corner. */\n relativeRects: Map<string, LayoutRect>;\n width: number;\n height: number;\n}\n\n/** Rows the layout tries for its sections (all sections share one row count, so shelves stay even). */\nconst ROW_COUNT_CANDIDATES = [1, 2, 3, 4, 5, 6, 7, 8, 10];\n\n/** Fewest columns of a section with enough boards (no single tall column of boards). */\nexport const MIN_COLUMNS = 4;\n\n/**\n * Columns of a section's grid for a shared row count: ⌈n / rows⌉, at least MIN_COLUMNS (fewer only with fewer\n * boards), at most MAX_COLUMNS (then it gets more rows).\n */\nexport const columnsForSection = (boardCount: number, rows: number): number =>\n Math.max(\n Math.min(boardCount, MIN_COLUMNS),\n Math.min(boardCount, MAX_COLUMNS, Math.ceil(boardCount / Math.max(1, rows)))\n );\n\nconst buildSectionGrid = (section: LayoutSectionInput, boards: LayoutBoardInput[], rows: number): SectionGrid => {\n const columns = columnsForSection(boards.length, rows);\n const relativeRects = new Map<string, LayoutRect>();\n let rowTop = SECTION_PADDING + SECTION_TITLE_HEIGHT;\n let right = 0;\n for (let rowStart = 0; rowStart < boards.length; rowStart += columns) {\n const row = boards.slice(rowStart, rowStart + columns);\n let left = SECTION_PADDING;\n let rowHeight = 0;\n for (const board of row) {\n const height = BOARD_HEADER_HEIGHT + Math.min(board.height, MAX_BOARD_CANVAS_HEIGHT);\n relativeRects.set(board.id, { x: left, y: rowTop, width: board.width, height });\n left += board.width + BOARD_GAP_X;\n rowHeight = Math.max(rowHeight, height);\n }\n right = Math.max(right, left - BOARD_GAP_X);\n rowTop += rowHeight + BOARD_GAP_Y;\n }\n return {\n section,\n boards,\n relativeRects,\n width: right + SECTION_PADDING,\n height: rowTop - BOARD_GAP_Y + SECTION_PADDING,\n };\n};\n\n/** Shelf packing in order: sections left → right, a new shelf when the next one passes `maxShelfWidth`. */\nconst packShelves = (grids: SectionGrid[], maxShelfWidth: number): { positions: LayoutRect[]; bounds: LayoutRect } => {\n const positions: LayoutRect[] = [];\n let shelfTop = 0;\n let shelfHeight = 0;\n let x = 0;\n let maxRight = 0;\n for (const grid of grids) {\n if (x > 0 && x + grid.width > maxShelfWidth) {\n shelfTop += shelfHeight + SECTION_GAP;\n shelfHeight = 0;\n x = 0;\n }\n positions.push({ x, y: shelfTop, width: grid.width, height: grid.height });\n maxRight = Math.max(maxRight, x + grid.width);\n shelfHeight = Math.max(shelfHeight, grid.height);\n x += grid.width + SECTION_GAP;\n }\n return { positions, bounds: { x: 0, y: 0, width: maxRight, height: shelfTop + shelfHeight } };\n};\n\nexport const computeCanvasLayout = (\n sections: readonly LayoutSectionInput[],\n boards: readonly LayoutBoardInput[],\n targetAspectRatio: number = TARGET_ASPECT_RATIO\n): CanvasLayout => {\n const boardsBySectionId = new Map<string, LayoutBoardInput[]>();\n for (const board of boards) {\n const sectionId = board.sectionId ?? UNSECTIONED_ID;\n const sectionBoards = boardsBySectionId.get(sectionId) ?? [];\n sectionBoards.push(board);\n boardsBySectionId.set(sectionId, sectionBoards);\n }\n const orderedSections: LayoutSectionInput[] = [...sections].sort(\n (first, second) => first.displayOrder - second.displayOrder\n );\n if (boardsBySectionId.has(UNSECTIONED_ID)) {\n orderedSections.push({ id: UNSECTIONED_ID, title: 'Weitere Boards', displayOrder: Number.MAX_SAFE_INTEGER });\n }\n const sectionsWithBoards = orderedSections\n .map(section => ({\n section,\n boards: [...(boardsBySectionId.get(section.id) ?? [])].sort(\n (first, second) => first.displayOrder - second.displayOrder\n ),\n }))\n .filter(entry => entry.boards.length > 0);\n if (sectionsWithBoards.length === 0) {\n return { sections: [], boards: new Map(), bounds: { x: 0, y: 0, width: 0, height: 0 } };\n }\n\n // Every shared row count × shelf width; keep the packing a viewport of the target aspect ratio shows largest.\n let bestGrids: SectionGrid[] = [];\n let best = { positions: [] as LayoutRect[], bounds: { x: 0, y: 0, width: 1, height: 1 } };\n let bestFitScale = 0;\n for (const rows of ROW_COUNT_CANDIDATES) {\n const grids = sectionsWithBoards.map(entry => buildSectionGrid(entry.section, entry.boards, rows));\n const widestSection = Math.max(...grids.map(grid => grid.width));\n const totalWidth = grids.reduce((sum, grid) => sum + grid.width + SECTION_GAP, -SECTION_GAP);\n for (let step = 0; step <= 32; step++) {\n const packed = packShelves(grids, widestSection + ((totalWidth - widestSection) * step) / 32);\n const fitScale = Math.min(targetAspectRatio / packed.bounds.width, 1 / packed.bounds.height);\n if (fitScale > bestFitScale) {\n bestFitScale = fitScale;\n best = packed;\n bestGrids = grids;\n }\n }\n }\n const grids = bestGrids;\n\n const layoutSections: LayoutSection[] = [];\n const boardRects = new Map<string, LayoutRect>();\n grids.forEach((grid, index) => {\n const position = best.positions[index];\n for (const [boardId, rect] of grid.relativeRects) {\n boardRects.set(boardId, { ...rect, x: position.x + rect.x, y: position.y + rect.y });\n }\n layoutSections.push({\n id: grid.section.id,\n title: grid.section.title,\n ...position,\n boardCount: grid.boards.length,\n boardIds: grid.boards.map(board => board.id),\n });\n });\n return { sections: layoutSections, boards: boardRects, bounds: best.bounds };\n};\n\n/** The section that holds a canvas point, else the one whose centre is nearest. */\nexport const findSectionAt = (\n sections: readonly LayoutSection[],\n x: number,\n y: number\n): LayoutSection | undefined => {\n let nearest: LayoutSection | undefined;\n let nearestDistance = Number.POSITIVE_INFINITY;\n for (const section of sections) {\n if (x >= section.x && x <= section.x + section.width && y >= section.y && y <= section.y + section.height) {\n return section;\n }\n const distance = Math.hypot(x - section.x - section.width / 2, y - section.y - section.height / 2);\n if (distance < nearestDistance) {\n nearest = section;\n nearestDistance = distance;\n }\n }\n return nearest;\n};\n","/**\n * Canvas viewport in the URL (`vp=<x>,<y>,<zoom>`) and the in-place board update of a refetched canvas (reload button,\n * live update). Pure functions, no React (tested in canvasLiveUpdate.test.ts).\n */\n\n/** A React Flow viewport: pan in screen px, zoom factor. */\nexport interface CanvasViewport {\n x: number;\n y: number;\n zoom: number;\n}\n\n/** The smallest / largest zoom a `vp` parameter may carry (the canvas' own limits are 0.005 … 2.5). */\nconst VIEWPORT_MIN_ZOOM = 0.001;\nconst VIEWPORT_MAX_ZOOM = 10;\n\n/** `vp` value: pan rounded to whole px, zoom to 4 decimals without trailing zeros (`-1234,560,0.0762`). */\nexport const formatViewportParam = ({ x, y, zoom }: CanvasViewport): string =>\n `${Math.round(x)},${Math.round(y)},${Number(zoom.toFixed(4))}`;\n\n/** Parses a `vp` value; null when missing or malformed (the canvas then fits its first view). */\nexport const parseViewportParam = (value: string | null | undefined): CanvasViewport | null => {\n if (!value) return null;\n const parts = value.split(',');\n if (parts.length !== 3 || parts.some(part => part.trim() === '')) return null;\n const [x, y, zoom] = parts.map(Number);\n if (![x, y, zoom].every(Number.isFinite) || zoom < VIEWPORT_MIN_ZOOM || zoom > VIEWPORT_MAX_ZOOM) return null;\n return { x, y, zoom };\n};\n\n/** The board fields the in-place update compares (a subset of DesignStudioBoardView). */\nexport interface LiveBoard {\n boardKey?: string | null;\n /** Version of the board file (git blob hash). */\n contentHash?: string | null;\n htmlUrl?: string | null;\n thumbnailUrl?: string | null;\n thumbnailSmallUrl?: string | null;\n}\n\n/** A delivery URL without its content token (the token rotates every 30 min, the content behind it does not). */\nexport const withoutContentToken = (url: string | null | undefined): string => {\n if (!url) return '';\n const [path, query = ''] = url.split('?');\n const params = new URLSearchParams(query);\n params.delete('token');\n const rest = params.toString();\n return rest ? `${path}?${rest}` : path;\n};\n\n/** The first characters of a content hash, as shown for a board's version (`3f9c2ab`). */\nexport const shortContentHash = (contentHash: string | null | undefined): string => (contentHash ?? '').slice(0, 7);\n\n/**\n * The delivery URL to show: the previous one while it shows the same content (same URL without the token) and\n * `keepPreviousUrls`, else the new one (another version, a thumbnail that arrived, a stale token).\n */\nconst pickDeliveryUrl = (\n previous: string | null | undefined,\n next: string | null | undefined,\n keepPreviousUrls: boolean\n): string | null | undefined =>\n keepPreviousUrls && previous && withoutContentToken(previous) === withoutContentToken(next) ? previous : next;\n\n/** Shallow equality of two board objects (every own key, values by identity). */\nconst isSameBoard = (previous: object, next: object): boolean => {\n const previousEntries = Object.entries(previous);\n if (previousEntries.length !== Object.keys(next).length) return false;\n const nextRecord = next as Record<string, unknown>;\n return previousEntries.every(([key, value]) => key in nextRecord && Object.is(nextRecord[key], value));\n};\n\nexport interface BoardMergeResult<T extends LiveBoard> {\n /** The boards to render: unchanged boards keep their previous object (no re-render, no iframe / image reload). */\n boards: T[];\n /** Keys of the boards whose file changed (another content hash) or that are new, in the order of `nextBoards`. */\n changedBoardKeys: string[];\n /** Whether anything differs from `previousBoards` (false → `boards` is `previousBoards` itself). */\n isChanged: boolean;\n}\n\n/**\n * Merges a refetched board list into the shown one, board by board (`boardKey`). A delivery URL that shows the same\n * content keeps its previous value while `keepPreviousUrls` (the previous content token is still valid), so a\n * thumbnail or live iframe is not reloaded just because the token rotated; a board keeps its previous object when\n * nothing else changed either. A URL with other content (a thumbnail that was rendered meanwhile, a new version) is\n * taken over in place. Only a new board or another `contentHash` counts as changed — a thumbnail arriving for the\n * same version does not.\n */\nexport const mergeRefetchedBoards = <T extends LiveBoard>(\n previousBoards: readonly T[] | null,\n nextBoards: readonly T[],\n keepPreviousUrls: boolean\n): BoardMergeResult<T> => {\n if (previousBoards === null) return { boards: [...nextBoards], changedBoardKeys: [], isChanged: true };\n const previousByKey = new Map(previousBoards.map(board => [String(board.boardKey), board]));\n const changedBoardKeys: string[] = [];\n const boards = nextBoards.map(next => {\n const previous = previousByKey.get(String(next.boardKey));\n if (!previous || (previous.contentHash ?? null) !== (next.contentHash ?? null)) {\n changedBoardKeys.push(String(next.boardKey));\n return next;\n }\n const candidate: T = {\n ...next,\n htmlUrl: pickDeliveryUrl(previous.htmlUrl, next.htmlUrl, keepPreviousUrls),\n thumbnailUrl: pickDeliveryUrl(previous.thumbnailUrl, next.thumbnailUrl, keepPreviousUrls),\n thumbnailSmallUrl: pickDeliveryUrl(previous.thumbnailSmallUrl, next.thumbnailSmallUrl, keepPreviousUrls),\n };\n return isSameBoard(previous, candidate) ? previous : candidate;\n });\n const isChanged =\n boards.length !== previousBoards.length || boards.some((board, index) => board !== previousBoards[index]);\n return { boards: isChanged ? boards : (previousBoards as T[]), changedBoardKeys, isChanged };\n};\n","'use client';\n\nimport { createContext, useContext } from 'react';\n\n/**\n * Canvas state the board nodes read without being rebuilt: which boards may show live HTML, the selection, the search\n * / filter matches and the actions. The node array itself only changes when the canvas data changes.\n */\nexport interface CanvasViewState {\n liveBoardIds: ReadonlySet<string>;\n /** The board shown in the side panel (the last one clicked). */\n selectedBoardId: string | null;\n /** Every selected board (shift / cmd click, marquee): \"Copy reference\" copies one block per board. */\n selectedBoardIds: ReadonlySet<string>;\n /** Boards matching search and filters; null = no filter active (everything matches). */\n matchingBoardIds: ReadonlySet<string> | null;\n /** Open threads per board node id. */\n openThreadCounts: ReadonlyMap<string, number>;\n /** The status a board has without a stored one (the first configured status): shown without a badge. */\n defaultStatus: string | null;\n /** Hand tool (the default): every drag pans, a click on a board still selects it. */\n isHandTool: boolean;\n /** `isAdditive`: shift / cmd / ctrl click toggles the board in the selection instead of replacing it. */\n onSelectBoard: (boardId: string, isAdditive: boolean) => void;\n /** Copies the design reference of one board (header button). */\n onCopyReference: (boardId: string) => void;\n onOpenBoard: (boardId: string) => void;\n /** Overview card click: fit the view to that section. */\n onZoomToSection: (sectionId: string) => void;\n}\n\nexport const CanvasViewContext = createContext<CanvasViewState | null>(null);\n\nexport const useCanvasView = (): CanvasViewState => {\n const canvasView = useContext(CanvasViewContext);\n if (!canvasView) {\n throw new Error('useCanvasView needs a CanvasViewContext provider');\n }\n return canvasView;\n};\n\n/** The node id of a board (its `boardKey`, the file name in the canvas folder). */\nexport const boardNodeId = (boardKey: string): string => `board-${boardKey}`;\n\n/** The node id of a section (its `sectionKey`). */\nexport const sectionNodeId = (sectionKey: string): string => `section-${sectionKey}`;\n","'use client';\n\nimport { useEffect, useState } from 'react';\n\n/**\n * Loads a board's delivery URL (HTML) before an iframe shows it. An `<iframe src>` renders whatever the server answers —\n * on a storage error that was the raw error JSON on top of the thumbnail. The URL is fetched first (at most\n * MAX_CONCURRENT_LOADS at once across the canvas, so a zoom does not fire every board at the object storage); only a 2xx\n * answer is handed to the iframe, which then reads it from the browser cache (the endpoint answers `private,\n * immutable`). A failed load leaves the thumbnail in place and is retried with growing delays while the board stays\n * live.\n */\nconst MAX_CONCURRENT_LOADS = 2;\n\n/** Delays (ms) before the next attempt after a failure; the last one repeats. */\nconst RETRY_DELAYS_MS = [2000, 5000, 15000, 30000];\n\n/**\n * URLs already loaded successfully in this page, least recently used first (a remount shows them at once; the browser\n * cache holds the bytes). Bounded: it also decides which boards remount their live HTML outside the live set.\n */\nconst MAX_REMEMBERED_URLS = 24;\nconst loadedUrls = new Set<string>();\n\nconst rememberLoadedUrl = (url: string) => {\n loadedUrls.delete(url);\n loadedUrls.add(url);\n while (loadedUrls.size > MAX_REMEMBERED_URLS) {\n const oldestUrl = loadedUrls.values().next().value;\n if (oldestUrl === undefined) break;\n loadedUrls.delete(oldestUrl);\n }\n};\n\n/** Whether this board HTML URL (content hash + theme in its query) was shown live before in this page. */\nexport const wasContentUrlLoaded = (url: string | undefined): boolean => Boolean(url && loadedUrls.has(url));\n\nlet activeLoads = 0;\nconst waitingLoads: Array<() => void> = [];\n\nconst acquireLoadSlot = (): Promise<void> =>\n new Promise(resolve => {\n if (activeLoads < MAX_CONCURRENT_LOADS) {\n activeLoads += 1;\n resolve();\n return;\n }\n waitingLoads.push(() => {\n activeLoads += 1;\n resolve();\n });\n });\n\nconst releaseLoadSlot = () => {\n activeLoads -= 1;\n waitingLoads.shift()?.();\n};\n\nconst loadUrl = async (url: string, signal: AbortSignal): Promise<boolean> => {\n await acquireLoadSlot();\n try {\n if (signal.aborted) return false;\n const response = await fetch(url, { signal, credentials: 'omit', referrerPolicy: 'no-referrer' });\n if (!response.ok) return false;\n // read the whole body so the browser cache holds the complete answer for the iframe\n await response.blob();\n return true;\n } catch {\n // network error or abort: the caller retries while the board is still live\n return false;\n } finally {\n releaseLoadSlot();\n }\n};\n\n/**\n * @param url the delivery URL, undefined when nothing should load (board not live)\n * @returns the URL once it answered 2xx, else undefined (show the thumbnail)\n */\nexport const useCheckedContentUrl = (url: string | undefined): string | undefined => {\n const [checkedUrl, setCheckedUrl] = useState<string | undefined>(() =>\n url && loadedUrls.has(url) ? url : undefined\n );\n\n useEffect(() => {\n if (!url) {\n setCheckedUrl(undefined);\n return;\n }\n if (loadedUrls.has(url)) {\n rememberLoadedUrl(url);\n setCheckedUrl(url);\n return;\n }\n setCheckedUrl(undefined);\n const abortController = new AbortController();\n let retryTimer: ReturnType<typeof setTimeout> | undefined;\n let attempt = 0;\n const tryLoad = async () => {\n const isLoaded = await loadUrl(url, abortController.signal);\n if (abortController.signal.aborted) return;\n if (isLoaded) {\n rememberLoadedUrl(url);\n setCheckedUrl(url);\n return;\n }\n const delay = RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)];\n attempt += 1;\n retryTimer = setTimeout(tryLoad, delay);\n };\n void tryLoad();\n return () => {\n abortController.abort();\n if (retryTimer) clearTimeout(retryTimer);\n };\n }, [url]);\n\n return checkedUrl;\n};\n\n/**\n * Retries a failed `<img>` (a thumbnail answered with an error): the image is hidden, and after a growing delay it is\n * mounted again under a new key, which requests the URL once more (error answers are not cached).\n * @returns the key for the `<img>`, whether it failed (hide it until the retry) and its `onError` handler\n */\nexport const useImageRetry = (url: string | undefined) => {\n const [attempt, setAttempt] = useState(0);\n const [isFailed, setIsFailed] = useState(false);\n const [previousUrl, setPreviousUrl] = useState(url);\n // a new URL (another theme, a new token window) starts over (state reset during render, no effect needed)\n if (url !== previousUrl) {\n setPreviousUrl(url);\n setAttempt(0);\n setIsFailed(false);\n }\n\n useEffect(() => {\n if (!isFailed) return;\n const retryTimer = setTimeout(\n () => {\n setIsFailed(false);\n setAttempt(previousAttempt => previousAttempt + 1);\n },\n RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)]\n );\n return () => clearTimeout(retryTimer);\n }, [isFailed, attempt]);\n\n return { imageKey: `${url ?? ''}#${attempt}`, isFailed, onError: () => setIsFailed(true) };\n};\n","'use client';\n\nimport { useEffect, useState } from 'react';\n\n/**\n * Spreads mass mounts over frames: a component that uses this hook renders its cheap placeholder first and its full\n * content once its turn comes — at most MOUNTS_PER_FRAME per animation frame, in the order they asked. When a zoom\n * crosses a level and React Flow mounts a hundred board nodes at once, the work lands in many short frames instead of\n * one long task.\n */\nconst MOUNTS_PER_FRAME = 12;\n\nconst queue: Array<() => void> = [];\nlet isScheduled = false;\n\nconst flush = () => {\n isScheduled = false;\n for (const mount of queue.splice(0, MOUNTS_PER_FRAME)) mount();\n if (queue.length > 0) schedule();\n};\n\nconst schedule = () => {\n if (isScheduled) return;\n isScheduled = true;\n requestAnimationFrame(flush);\n};\n\n/** @returns false until this component's turn, then true (stays true for its lifetime). */\nexport const useDeferredMount = (): boolean => {\n const [isMounted, setIsMounted] = useState(false);\n useEffect(() => {\n let isActive = true;\n const mount = () => {\n if (isActive) setIsMounted(true);\n };\n queue.push(mount);\n schedule();\n return () => {\n isActive = false;\n const index = queue.indexOf(mount);\n if (index >= 0) queue.splice(index, 1);\n };\n }, []);\n return isMounted;\n};\n","'use client';\n\nimport { useState } from 'react';\n\nimport { withoutContentToken } from './canvasLiveUpdate.ts';\n\n/**\n * Delivery URLs that stay the same for the page's lifetime. The content behind a board URL is fixed by its path and\n * query (board, content hash, theme, size); only the content token in it rotates (a new token every 30 min).\n * A new token must never reload an image or iframe that already shows that content, and a board that remounts (pan,\n * zoom level) should get the URL the browser cache already holds. So:\n * - one URL per content (the URL without its token) is kept for the page — the first one seen — and handed to every\n * element that shows that content, until its token is about to expire (EXPIRY_MARGIN_SECONDS), then the newest one;\n * - an element that already displays its content keeps its URL even past the expiry (it never requests it again).\n * Pure helpers tested in stableContentUrl.test.ts.\n */\n\n/** A token closer than this to its expiry is not handed to elements that still have to load (seconds). */\nconst EXPIRY_MARGIN_SECONDS = 120;\n\n/** content key (URL without token) → the URL shown for it */\nconst urlByContentKey = new Map<string, string>();\n/** token → its expiry (epoch seconds; 0 = unreadable, treated as expired) */\nconst expiryByToken = new Map<string, number>();\n\n/** The `expiresAt` claim of the URL's content token (epoch seconds), null when the URL has no token. */\nexport const contentTokenExpiry = (url: string): number | null => {\n const query = url.split('?')[1];\n if (!query) return null;\n const token = new URLSearchParams(query).get('token');\n if (!token) return null;\n const known = expiryByToken.get(token);\n if (known !== undefined) return known;\n let expiry = 0;\n try {\n const payload = token.split('.')[1] ?? '';\n const json = JSON.parse(atob(payload.replace(/-/g, '+').replace(/_/g, '/')));\n expiry = Number(json.expiresAt ?? json.exp ?? 0) || 0;\n } catch {\n // not a readable JWT: treated as expired, the newest URL wins\n expiry = 0;\n }\n expiryByToken.set(token, expiry);\n return expiry;\n};\n\n/** Whether the URL's token expires within the margin (URLs without a token never expire). */\nexport const isContentUrlExpiring = (url: string, nowSeconds = Date.now() / 1000): boolean => {\n const expiry = contentTokenExpiry(url);\n return expiry !== null && expiry - EXPIRY_MARGIN_SECONDS <= nowSeconds;\n};\n\n/** The page's URL for this content: the one kept so far while its token is still good, else `url` (kept from now). */\nexport const resolveStableContentUrl = (url: string): string => {\n const contentKey = withoutContentToken(url);\n const kept = urlByContentKey.get(contentKey);\n if (kept !== undefined && (kept === url || !isContentUrlExpiring(kept))) return kept;\n urlByContentKey.set(contentKey, url);\n return url;\n};\n\n/**\n * @param url the current delivery URL (from the latest API answer), undefined = nothing to show\n * @param isDisplayed whether the element already shows this content (then its URL is kept even past the expiry)\n * @returns the URL for the element: unchanged as long as the content is the same\n */\nexport const useStableContentUrl = (url: string | undefined, isDisplayed = false): string | undefined => {\n const [shownUrl, setShownUrl] = useState<string | undefined>(() => (url ? resolveStableContentUrl(url) : undefined));\n if (!url) {\n if (shownUrl !== undefined) setShownUrl(undefined);\n return undefined;\n }\n if (\n shownUrl !== undefined &&\n withoutContentToken(shownUrl) === withoutContentToken(url) &&\n (isDisplayed || !isContentUrlExpiring(shownUrl))\n ) {\n return shownUrl;\n }\n const nextUrl = resolveStableContentUrl(url);\n if (nextUrl !== shownUrl) setShownUrl(nextUrl);\n return nextUrl;\n};\n","'use client';\n\nimport { normalizeDddError } from '@mgamadeus/ddd-web/api';\n\nimport type { DesignStudioBoardView } from '../api/types';\nimport { useDesignStudio } from '../provider/DesignStudioProvider';\nimport { cx } from '../utils/cx';\nimport { boardStatusDefinition, boardStatusLabel } from './boardStatus';\n\nexport interface BoardStatusChipsProps {\n projectKey: string;\n canvasKey: string;\n board: DesignStudioBoardView;\n /** The configured status keys in display order (`DesignStudioCanvasView.statuses`). */\n statuses: readonly string[];\n writesAllowed: boolean;\n /** Called with the saved status (the canvas updates its copy). */\n onStatusChanged: (status: string) => void;\n}\n\n/** The review status of a board as chips (one per configured status); a click saves it. */\nexport const BoardStatusChips = ({\n projectKey,\n canvasKey,\n board,\n statuses,\n writesAllowed,\n onStatusChanged,\n}: BoardStatusChipsProps) => {\n const { api, notify, statuses: statusDefinitions } = useDesignStudio();\n const [patchStatus, { isLoading }] = api.useSetBoardStatusMutation();\n return (\n <fieldset className=\"m-0 flex flex-wrap items-center gap-1.5 border-0 p-0\" aria-label=\"Board status\">\n {statuses.map(status => {\n const Icon = boardStatusDefinition(statusDefinitions, status)?.icon;\n const isActive = board.status === status;\n return (\n <button\n key={status}\n type=\"button\"\n aria-pressed={isActive}\n disabled={!writesAllowed || isLoading || isActive || !board.boardKey}\n onClick={async () => {\n try {\n await patchStatus({\n projectKey,\n canvasKey,\n boardKey: board.boardKey ?? '',\n body: { status },\n }).unwrap();\n onStatusChanged(status);\n } catch (error) {\n notify.error(normalizeDddError(error, 'Request failed').message);\n }\n }}\n className={cx(\n 'inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-xs font-semibold transition-colors motion-reduce:transition-none',\n 'disabled:cursor-default',\n isActive\n ? 'bg-primary text-primary-foreground'\n : 'bg-tint text-muted-foreground hover:bg-tint-strong hover:text-foreground disabled:opacity-60'\n )}\n >\n {Icon && <Icon className=\"size-3.5\" aria-hidden />}\n {boardStatusLabel(statusDefinitions, status)}\n </button>\n );\n })}\n {board.hasChangedSinceStatus && (\n <span className=\"text-xs text-muted-foreground\" title=\"The board file changed after this status was set\">\n changed since\n </span>\n )}\n </fieldset>\n );\n};\n","'use client';\n\nimport '@xyflow/react/dist/style.css';\n\nimport {\n Background,\n BackgroundVariant,\n MiniMap,\n type Node,\n Panel,\n ReactFlow,\n ReactFlowProvider,\n useReactFlow,\n useStore,\n type Viewport,\n} from '@xyflow/react';\nimport { ChevronDown, Hand, MousePointer2, Play } from 'lucide-react';\nimport { type PointerEvent, type ReactNode, type RefObject, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport type { DesignStudioBoardView } from '../api/types';\nimport { useDesignStudio, useDesignStudioComponents } from '../provider/DesignStudioProvider';\nimport { cx } from '../utils/cx';\nimport { type BoardFlowNode, BoardNode } from './BoardNode';\nimport { type BoardRect, selectLiveBoardIds, selectVisibleBoardIds } from './boardDetail';\nimport { type CanvasLayout, findSectionAt, type LayoutRect } from './canvasLayout';\nimport { type CanvasViewport, formatViewportParam, withoutContentToken } from './canvasLiveUpdate';\nimport { sectionNodeId } from './canvasView';\nimport { type SectionFlowNode, SectionNode } from './SectionNode';\nimport { resolveStableContentUrl } from './stableContentUrl';\n\nconst NODE_TYPES = { board: BoardNode, section: SectionNode };\n\nconst ZOOM_PRESETS = [0.25, 0.5, 1];\nconst MIN_ZOOM = 0.005;\nconst MAX_ZOOM = 2.5;\n/** Wheel zoom: ~12 % per mouse notch (100 px); trackpad / Magic Mouse pixel deltas zoom proportionally. */\nconst WHEEL_ZOOM_PER_PIXEL = Math.log(1.12) / 100;\n/** Pinch (the browser sends ctrl + wheel with small deltas) zooms faster per pixel. */\nconst PINCH_ZOOM_PER_PIXEL = 0.012;\n/** deltaMode 1 (lines, e.g. Firefox: 3 lines per notch) and 2 (pages) in pixels. */\nconst WHEEL_LINE_PIXELS = 100 / 3;\nconst WHEEL_PAGE_PIXELS = 800;\n/** One wheel event never zooms by more than this many pixels (fast-spinning wheels, coalesced events). */\nconst WHEEL_MAX_PIXELS = 300;\n/** Per animation frame the zoom closes this share of the gap to its target (log scale): smooth, never springy. */\nconst ZOOM_EASE = 0.35;\n/** The viewport goes into the URL after this rest (a smooth zoom ends a move every frame). */\nconst VIEWPORT_COMMIT_MS = 300;\n/** Fit margins (px): sides / bottom, and the top below the canvas toolbar. */\nconst FIT_PADDING = 24;\nconst FIT_TOP = 72;\n/** Below this zoom the canvas is drawn at the overview level: one card per section, no boards. */\nexport const OVERVIEW_ZOOM = 0.06;\n/** Rest after a pan / zoom before the live boards are recomputed. */\nconst LIVE_BOARDS_SETTLE_MS = 300;\n\n/** Cover thumbnails per overview card. */\nconst OVERVIEW_COVER_COUNT = 4;\n/** Minimap width (px); its height follows the canvas' aspect ratio. */\nconst MINIMAP_WIDTH = 200;\n\n/** Canvas tools (select / hand). */\nexport type CanvasTool = 'select' | 'hand';\n\n/** A request to fit the view to some nodes; `key` changes for every request. */\nexport interface CanvasFitRequest {\n nodeIds: string[];\n key: number;\n}\n\nexport interface DesignCanvasFlowProps {\n layout: CanvasLayout;\n boardsByNodeId: ReadonlyMap<string, DesignStudioBoardView>;\n fitRequest: CanvasFitRequest | null;\n /** Nodes the first view fits (the first section: a whole tall canvas would start unreadably small). */\n initialFitNodeIds: string[];\n /** The first view as saved (`?vp=`): wins over `initialFitNodeIds`. */\n initialViewport?: CanvasViewport | null;\n /** A pan / zoom / fit ended on a new viewport (not called for the first view). */\n onViewportCommit?: (viewport: CanvasViewport) => void;\n tool: CanvasTool;\n onToolChange: (tool: CanvasTool) => void;\n /** Rendered width share from which a board shows live HTML (lower when the thumbnails show another theme). */\n liveMinRatio: number;\n onLiveBoardIdsChange: (liveBoardIds: Set<string>) => void;\n /** The boards in the viewport after a pan / zoom settled, nearest the centre first (node ids). */\n onVisibleBoardIdsChange?: (visibleBoardIds: string[]) => void;\n onPaneClick: () => void;\n /** \"Present\" for the section in the middle of the view. */\n onPresentSection: (sectionId: string) => void;\n /** Left toolbar content after the tools (canvas name, search, filters). */\n toolbarStart: ReactNode;\n /** Controls of the right toolbar group before the zoom (theme, theme mode, comments, fullscreen). */\n toolbarEnd: ReactNode;\n /** The selected board (Shift+2 fits it). */\n selectedNodeId: string | null;\n /** Marquee with the select tool: the boards inside the rectangle (`isAdditive` with shift / cmd / ctrl). */\n onMarqueeSelect: (nodeIds: string[], isAdditive: boolean) => void;\n}\n\n/** A marquee in progress, in container pixels. */\ninterface Marquee {\n startX: number;\n startY: number;\n x: number;\n y: number;\n}\n\n/** A press that moved less than this (px) is a click (selects), a longer one a pan (same as BoardNode). */\nconst CLICK_MAX_MOVE = 5;\n\n/** Below this drag distance (px) a press on the pane is a click, not a marquee. */\nconst MARQUEE_MIN_DRAG = 4;\n\nconst TOOLBAR_GROUP_CLASS = 'surface-glass-strong flex items-center gap-1 rounded-2xl p-1 ring-1 ring-foreground/5';\nconst TOOL_BUTTON_CLASS =\n 'flex size-8 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-tint hover:text-foreground motion-reduce:transition-none';\n\nconst ZoomMenu = ({ onFitAll }: { onFitAll: () => void }) => {\n const { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } =\n useDesignStudioComponents();\n const reactFlow = useReactFlow();\n const zoomPercent = useStore(state => Math.round(state.transform[2] * 100));\n return (\n <DropdownMenu modal={false}>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n className=\"flex h-8 min-w-16 items-center justify-center gap-1 rounded-xl px-2 text-sm font-semibold tabular-nums transition-colors hover:bg-tint\"\n aria-label={`Zoom ${zoomPercent} %`}\n >\n {zoomPercent}%\n <ChevronDown className=\"size-3.5 text-muted-foreground\" aria-hidden />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {ZOOM_PRESETS.map(zoom => (\n <DropdownMenuItem key={zoom} onSelect={() => void reactFlow.zoomTo(zoom, { duration: 250 })}>\n {Math.round(zoom * 100)} %\n </DropdownMenuItem>\n ))}\n <DropdownMenuSeparator />\n <DropdownMenuItem onSelect={() => void reactFlow.zoomIn({ duration: 200 })}>Zoom in</DropdownMenuItem>\n <DropdownMenuItem onSelect={() => void reactFlow.zoomOut({ duration: 200 })}>Zoom out</DropdownMenuItem>\n <DropdownMenuItem onSelect={onFitAll}>Fit all</DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n};\n\nconst buildNodes = (\n layout: CanvasLayout,\n boardsByNodeId: ReadonlyMap<string, DesignStudioBoardView>,\n isOverview: boolean,\n apiBaseUrl: string\n): Node[] => {\n const sectionNodes: SectionFlowNode[] = layout.sections.map(section => ({\n id: sectionNodeId(section.id),\n type: 'section',\n position: { x: section.x, y: section.y },\n width: section.width,\n height: section.height,\n data: {\n sectionId: section.id,\n title: section.title,\n boardCount: section.boardCount,\n isOverview,\n width: section.width,\n coverUrls: isOverview\n ? section.boardIds\n .slice(0, OVERVIEW_COVER_COUNT)\n .map(boardId => boardsByNodeId.get(boardId)?.thumbnailSmallUrl)\n .filter((url): url is string => Boolean(url))\n .map(url => resolveStableContentUrl(`${apiBaseUrl}${url}`))\n : [],\n },\n draggable: false,\n selectable: false,\n focusable: false,\n // overview cards are buttons (click = zoom to the section); React Flow would set pointer-events: none otherwise\n style: isOverview ? { pointerEvents: 'all' } : undefined,\n zIndex: 0,\n }));\n if (isOverview) return sectionNodes;\n const boardNodes: BoardFlowNode[] = [];\n for (const [nodeId, rect] of layout.boards) {\n const board = boardsByNodeId.get(nodeId);\n if (!board) continue;\n boardNodes.push({\n id: nodeId,\n type: 'board',\n position: { x: rect.x, y: rect.y },\n width: rect.width,\n height: rect.height,\n data: { board },\n draggable: false,\n selectable: false,\n // the node's own buttons select / open it; React Flow would set pointer-events: none on a non-selectable node\n style: { pointerEvents: 'all' },\n zIndex: 1,\n });\n }\n return [...sectionNodes, ...boardNodes];\n};\n\n/** Values equal for a node update: same identity, or arrays of URLs showing the same content (token aside). */\nconst isSameNodeValue = (previous: unknown, next: unknown): boolean => {\n if (Object.is(previous, next)) return true;\n if (Array.isArray(previous) && Array.isArray(next)) {\n return (\n previous.length === next.length &&\n previous.every((value, index) =>\n typeof value === 'string' && typeof next[index] === 'string'\n ? withoutContentToken(value) === withoutContentToken(next[index])\n : Object.is(value, next[index])\n )\n );\n }\n return false;\n};\n\n/** Shallow comparison of two flat records with isSameNodeValue (`style` and `position` are compared by content). */\nconst isSameRecord = (previous: object | undefined, next: object | undefined): boolean => {\n if (previous === next) return true;\n if (!previous || !next) return false;\n const previousEntries = Object.entries(previous);\n const nextRecord = next as Record<string, unknown>;\n return (\n previousEntries.length === Object.keys(next).length &&\n previousEntries.every(([key, value]) => key in nextRecord && isSameNodeValue(value, nextRecord[key]))\n );\n};\n\n/** The next node list with every node that equals its shown counterpart replaced by the shown object. */\nexport const reuseUnchangedNodes = (previousNodes: readonly Node[], nextNodes: Node[]): Node[] => {\n if (previousNodes.length === 0) return nextNodes;\n const previousById = new Map(previousNodes.map(node => [node.id, node]));\n let isAnyChanged = previousNodes.length !== nextNodes.length;\n const nodes = nextNodes.map((next, index) => {\n const previous = previousById.get(next.id);\n const isSame =\n previous !== undefined &&\n previous.type === next.type &&\n previous.width === next.width &&\n previous.height === next.height &&\n previous.zIndex === next.zIndex &&\n isSameRecord(previous.position, next.position) &&\n isSameRecord(previous.style, next.style) &&\n isSameRecord(previous.data, next.data);\n if (!isSame || previousNodes[index] !== previous) isAnyChanged = true;\n return isSame ? previous : next;\n });\n return isAnyChanged ? nodes : (previousNodes as Node[]);\n};\n\n/**\n * Wheel zoom towards the cursor for every input: mouse wheel (pixel or line deltas), Magic Mouse and trackpad scroll,\n * pinch (ctrl + wheel; Safari gesture events). The zoom eases to its target over a few frames (calm, no overshoot),\n * so a notch of a mouse wheel and a stream of small trackpad deltas both feel continuous; min / max zoom respected.\n * `nowheel` elements keep their own scrolling.\n */\nconst useWheelZoom = (containerRef: RefObject<HTMLDivElement | null>) => {\n const reactFlow = useReactFlow();\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n const minLogZoom = Math.log(MIN_ZOOM);\n const maxLogZoom = Math.log(MAX_ZOOM);\n let targetLogZoom = 0;\n let anchorX = 0;\n let anchorY = 0;\n let frame: number | null = null;\n let frameCount = 0;\n const step = () => {\n const { x, y, zoom } = reactFlow.getViewport();\n const currentLogZoom = Math.log(zoom);\n const difference = targetLogZoom - currentLogZoom;\n frameCount += 1;\n const isLast = Math.abs(difference) < 0.002 || frameCount > 90;\n const nextZoom = Math.exp(isLast ? targetLogZoom : currentLogZoom + difference * ZOOM_EASE);\n // the canvas point under the cursor stays under the cursor\n void reactFlow.setViewport({\n x: anchorX - ((anchorX - x) / zoom) * nextZoom,\n y: anchorY - ((anchorY - y) / zoom) * nextZoom,\n zoom: nextZoom,\n });\n frame = isLast ? null : requestAnimationFrame(step);\n };\n const zoomBy = (logDelta: number, clientX: number, clientY: number) => {\n const bounds = container.getBoundingClientRect();\n anchorX = clientX - bounds.left;\n anchorY = clientY - bounds.top;\n // a new gesture starts from the current zoom (a pan or fit may have changed it)\n if (frame === null) targetLogZoom = Math.log(reactFlow.getZoom());\n targetLogZoom = Math.min(maxLogZoom, Math.max(minLogZoom, targetLogZoom + logDelta));\n frameCount = 0;\n if (frame === null) frame = requestAnimationFrame(step);\n };\n const onWheel = (event: WheelEvent) => {\n if (event.target instanceof Element && event.target.closest('.nowheel')) return;\n event.preventDefault();\n if (isGesturing && event.ctrlKey) return;\n const unit = event.deltaMode === 1 ? WHEEL_LINE_PIXELS : event.deltaMode === 2 ? WHEEL_PAGE_PIXELS : 1;\n const pixels = Math.max(-WHEEL_MAX_PIXELS, Math.min(WHEEL_MAX_PIXELS, event.deltaY * unit));\n zoomBy(-pixels * (event.ctrlKey ? PINCH_ZOOM_PER_PIXEL : WHEEL_ZOOM_PER_PIXEL), event.clientX, event.clientY);\n };\n // Safari reports a trackpad pinch as gesture events (scale relative to the gesture start)\n let gestureScale = 1;\n let isGesturing = false;\n const onGestureStart = (event: Event) => {\n event.preventDefault();\n gestureScale = 1;\n isGesturing = true;\n };\n const onGestureEnd = () => {\n isGesturing = false;\n };\n const onGestureChange = (event: Event) => {\n event.preventDefault();\n const gesture = event as Event & { scale?: number; clientX?: number; clientY?: number };\n const scale = gesture.scale ?? 1;\n if (scale <= 0) return;\n zoomBy(Math.log(scale / gestureScale), gesture.clientX ?? 0, gesture.clientY ?? 0);\n gestureScale = scale;\n };\n container.addEventListener('wheel', onWheel, { passive: false });\n container.addEventListener('gesturestart', onGestureStart);\n container.addEventListener('gesturechange', onGestureChange);\n container.addEventListener('gestureend', onGestureEnd);\n return () => {\n container.removeEventListener('gestureend', onGestureEnd);\n container.removeEventListener('wheel', onWheel);\n container.removeEventListener('gesturestart', onGestureStart);\n container.removeEventListener('gesturechange', onGestureChange);\n if (frame !== null) cancelAnimationFrame(frame);\n };\n }, [containerRef, reactFlow]);\n};\n\nconst FlowCanvas = ({\n layout,\n boardsByNodeId,\n fitRequest,\n initialFitNodeIds,\n initialViewport = null,\n onViewportCommit,\n tool,\n onToolChange,\n liveMinRatio,\n onLiveBoardIdsChange,\n onVisibleBoardIdsChange,\n onPaneClick,\n onPresentSection,\n toolbarStart,\n toolbarEnd,\n selectedNodeId,\n onMarqueeSelect,\n}: DesignCanvasFlowProps) => {\n const { apiBaseUrl, components, statusColors } = useDesignStudio();\n const { Tooltip, TooltipContent, TooltipTrigger } = components;\n const containerRef = useRef<HTMLDivElement>(null);\n const reactFlow = useReactFlow();\n useWheelZoom(containerRef);\n const isOverview = useStore(state => state.transform[2] < OVERVIEW_ZOOM);\n // Structural update: a rebuilt node equal to the shown one keeps the shown object, so React Flow re-renders only\n // boards / sections whose data really changed (a poll or one changed board never redraws the whole canvas).\n const previousNodesRef = useRef<Node[]>([]);\n const nodes = useMemo(() => {\n const reused = reuseUnchangedNodes(\n previousNodesRef.current,\n buildNodes(layout, boardsByNodeId, isOverview, apiBaseUrl)\n );\n previousNodesRef.current = reused;\n return reused;\n }, [layout, boardsByNodeId, isOverview, apiBaseUrl]);\n // The minimap only helps while part of the canvas is outside the view.\n const isEverythingVisible = useStore(state => {\n const [x, y, zoom] = state.transform;\n return (\n x >= -1 &&\n y >= -1 &&\n x + layout.bounds.width * zoom <= state.width + 1 &&\n y + layout.bounds.height * zoom <= state.height + 1\n );\n });\n const boardRects = useMemo<BoardRect[]>(\n () => [...layout.boards].map(([id, rect]) => ({ id, ...rect })),\n [layout]\n );\n\n // Live boards are recomputed when a pan / zoom ends, never during it: panning stays thumbnail-only. A trackpad pan\n // ends many times (each wheel burst), so the update waits LIVE_BOARDS_SETTLE_MS of rest: passing over boards does\n // not start loads that are thrown away a moment later.\n const liveBoardsTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const cancelLiveBoardsUpdate = useCallback(() => {\n if (liveBoardsTimerRef.current) clearTimeout(liveBoardsTimerRef.current);\n liveBoardsTimerRef.current = null;\n }, []);\n useEffect(() => cancelLiveBoardsUpdate, [cancelLiveBoardsUpdate]);\n const updateLiveBoards = useCallback(\n (viewport: Viewport) => {\n const container = containerRef.current;\n if (!container) return;\n const screen = { width: container.clientWidth, height: container.clientHeight };\n onLiveBoardIdsChange(selectLiveBoardIds(boardRects, viewport, screen, undefined, liveMinRatio));\n onVisibleBoardIdsChange?.(selectVisibleBoardIds(boardRects, viewport, screen));\n },\n [boardRects, onLiveBoardIdsChange, onVisibleBoardIdsChange, liveMinRatio]\n );\n\n // Fit: the content top-aligned under the toolbar, centred horizontally, never above 100 %.\n const hasInitialFitRef = useRef(false);\n const fitRect = useCallback(\n (rect: LayoutRect, duration: number, fitWidthOnly = false): Viewport | null => {\n const container = containerRef.current;\n if (!container || container.clientWidth === 0 || rect.width <= 0 || rect.height <= 0) return null;\n const width = container.clientWidth;\n const height = container.clientHeight;\n // a section is fitted by its width (a tall section then scrolls), everything else whole\n const widthZoom = (width - 2 * FIT_PADDING) / rect.width;\n const heightZoom = fitWidthOnly ? widthZoom : (height - FIT_TOP - FIT_PADDING) / rect.height;\n const zoom = Math.max(MIN_ZOOM, Math.min(widthZoom, heightZoom, 1));\n const viewport = { x: (width - rect.width * zoom) / 2 - rect.x * zoom, y: FIT_TOP - rect.y * zoom, zoom };\n void reactFlow.setViewport(viewport, { duration }).then(() => {\n updateLiveBoards(viewport);\n });\n return viewport;\n },\n [reactFlow, updateLiveBoards]\n );\n const rectOfNodes = useCallback(\n (nodeIds: string[]): LayoutRect | null => {\n const sectionRects = new Map(layout.sections.map(section => [sectionNodeId(section.id), section as LayoutRect]));\n const rects = nodeIds\n .map(nodeId => sectionRects.get(nodeId) ?? layout.boards.get(nodeId))\n .filter((rect): rect is LayoutRect => rect !== undefined);\n if (rects.length === 0) return null;\n const left = Math.min(...rects.map(rect => rect.x));\n const top = Math.min(...rects.map(rect => rect.y));\n const right = Math.max(...rects.map(rect => rect.x + rect.width));\n const bottom = Math.max(...rects.map(rect => rect.y + rect.height));\n return { x: left, y: top, width: right - left, height: bottom - top };\n },\n [layout]\n );\n const fitNodes = useCallback(\n (nodeIds: string[], duration = 400): Viewport | null => {\n const rect = rectOfNodes(nodeIds);\n const isSingleSection = nodeIds.length === 1 && nodeIds[0].startsWith(sectionNodeId(''));\n return rect ? fitRect(rect, duration, isSingleSection) : null;\n },\n [rectOfNodes, fitRect]\n );\n const fitAll = useCallback(() => {\n fitRect(layout.bounds, 400);\n }, [fitRect, layout]);\n\n // Each fit request once (the callbacks change with the live threshold, the request does not).\n const handledFitKeyRef = useRef<number | null>(null);\n useEffect(() => {\n if (!fitRequest || handledFitKeyRef.current === fitRequest.key) return;\n handledFitKeyRef.current = fitRequest.key;\n fitNodes(fitRequest.nodeIds);\n }, [fitRequest, fitNodes]);\n\n // The last viewport reported through onViewportCommit (the first view counts as reported: a fresh page writes no\n // `vp` until the user moves).\n const committedViewportRef = useRef<string | null>(null);\n\n // First view once the layout and the container exist: the saved viewport (`?vp=`, a reload keeps the place), else\n // the first section (a whole tall canvas would start unreadably small). Retried from the resize observer while the\n // container has no size yet.\n const isFlowReadyRef = useRef(false);\n const initialViewportRef = useRef(initialViewport);\n const fitInitialView = useCallback(() => {\n if (!isFlowReadyRef.current || hasInitialFitRef.current || layout.sections.length === 0) return;\n const container = containerRef.current;\n if (!container || container.clientWidth === 0) return;\n const savedViewport = initialViewportRef.current;\n if (savedViewport) {\n hasInitialFitRef.current = true;\n committedViewportRef.current = formatViewportParam(savedViewport);\n void reactFlow.setViewport(savedViewport, { duration: 0 }).then(() => updateLiveBoards(savedViewport));\n return;\n }\n const viewport = initialFitNodeIds.length > 0 ? fitNodes(initialFitNodeIds, 0) : fitRect(layout.bounds, 0);\n if (viewport) {\n hasInitialFitRef.current = true;\n committedViewportRef.current = formatViewportParam(viewport);\n }\n }, [layout, initialFitNodeIds, fitNodes, fitRect, reactFlow, updateLiveBoards]);\n // the URL gets the viewport once the view rests (a smooth zoom ends a move every frame)\n const viewportCommitTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(\n () => () => {\n if (viewportCommitTimerRef.current) clearTimeout(viewportCommitTimerRef.current);\n },\n []\n );\n const commitViewport = (viewport: Viewport) => {\n if (!hasInitialFitRef.current) return;\n if (viewportCommitTimerRef.current) clearTimeout(viewportCommitTimerRef.current);\n viewportCommitTimerRef.current = setTimeout(() => {\n viewportCommitTimerRef.current = null;\n const value = formatViewportParam(viewport);\n if (value === committedViewportRef.current) return;\n committedViewportRef.current = value;\n onViewportCommit?.(viewport);\n }, VIEWPORT_COMMIT_MS);\n };\n useEffect(() => {\n fitInitialView();\n }, [fitInitialView]);\n\n // A different live threshold (thumbnails missing / complete) re-evaluates the live boards of the current view.\n useEffect(() => {\n if (hasInitialFitRef.current) updateLiveBoards(reactFlow.getViewport());\n }, [reactFlow, updateLiveBoards]);\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n const resizeObserver = new ResizeObserver(() => {\n if (hasInitialFitRef.current) updateLiveBoards(reactFlow.getViewport());\n else fitInitialView();\n });\n resizeObserver.observe(container);\n return () => resizeObserver.disconnect();\n }, [reactFlow, updateLiveBoards, fitInitialView]);\n\n // Keys as in common design tools: V select, H hand, + / − zoom, 0 = 100 %, Shift+1 fit all (not while typing).\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement | null;\n if (target && (target.tagName === 'TEXTAREA' || target.tagName === 'INPUT' || target.isContentEditable)) return;\n if (document.querySelector('[role=dialog]')) return;\n if (event.metaKey || event.ctrlKey || event.altKey) return;\n if (event.key === 'v' || event.key === 'V') onToolChange('select');\n else if (event.key === 'h' || event.key === 'H' || event.key === 'Escape') onToolChange('hand');\n else if (event.shiftKey && event.code === 'Digit1') fitAll();\n else if (event.shiftKey && event.code === 'Digit2') fitSelectionOrSection();\n else if (event.key === '+' || event.key === '=') void reactFlow.zoomIn({ duration: 200 });\n else if (event.key === '-' || event.key === '_') void reactFlow.zoomOut({ duration: 200 });\n else if (event.key === '0' && !event.shiftKey) void reactFlow.zoomTo(1, { duration: 250 });\n };\n window.addEventListener('keydown', onKeyDown);\n return () => window.removeEventListener('keydown', onKeyDown);\n });\n\n const sectionInView = () => {\n const container = containerRef.current;\n if (!container || layout.sections.length === 0) return undefined;\n const viewport = reactFlow.getViewport();\n const centreX = (-viewport.x + container.clientWidth / 2) / viewport.zoom;\n const centreY = (-viewport.y + container.clientHeight / 2) / viewport.zoom;\n return findSectionAt(layout.sections, centreX, centreY) ?? layout.sections[0];\n };\n const fitSelectionOrSection = () => {\n if (selectedNodeId && layout.boards.has(selectedNodeId)) {\n fitNodes([selectedNodeId]);\n return;\n }\n const section = sectionInView();\n if (section) fitNodes([sectionNodeId(section.id)]);\n };\n const presentCurrentSection = () => {\n const section = sectionInView();\n if (section) onPresentSection(section.id);\n };\n // Marquee selection with the select tool (Space or the middle button pans meanwhile, React Flow's defaults).\n const [marquee, setMarquee] = useState<Marquee | null>(null);\n const isMarqueeJustEndedRef = useRef(false);\n const startMarquee = (event: PointerEvent<HTMLDivElement>) => {\n const target = event.target as HTMLElement;\n if (tool !== 'select' || event.button !== 0 || !target.classList.contains('react-flow__pane')) return;\n const container = containerRef.current;\n if (!container) return;\n const bounds = container.getBoundingClientRect();\n const startX = event.clientX - bounds.left;\n const startY = event.clientY - bounds.top;\n const isAdditive = event.shiftKey || event.metaKey || event.ctrlKey;\n let current: Marquee = { startX, startY, x: startX, y: startY };\n setMarquee(current);\n const onMove = (moveEvent: globalThis.PointerEvent) => {\n current = { startX, startY, x: moveEvent.clientX - bounds.left, y: moveEvent.clientY - bounds.top };\n setMarquee(current);\n };\n const onUp = () => {\n window.removeEventListener('pointermove', onMove);\n window.removeEventListener('pointerup', onUp);\n setMarquee(null);\n if (Math.abs(current.x - startX) < MARQUEE_MIN_DRAG && Math.abs(current.y - startY) < MARQUEE_MIN_DRAG) return;\n isMarqueeJustEndedRef.current = true;\n const topLeft = reactFlow.screenToFlowPosition({\n x: bounds.left + Math.min(startX, current.x),\n y: bounds.top + Math.min(startY, current.y),\n });\n const bottomRight = reactFlow.screenToFlowPosition({\n x: bounds.left + Math.max(startX, current.x),\n y: bounds.top + Math.max(startY, current.y),\n });\n const nodeIds = [...layout.boards]\n .filter(\n ([, rect]) =>\n rect.x < bottomRight.x &&\n rect.x + rect.width > topLeft.x &&\n rect.y < bottomRight.y &&\n rect.y + rect.height > topLeft.y\n )\n .map(([nodeId]) => nodeId);\n onMarqueeSelect(nodeIds, isAdditive);\n };\n window.addEventListener('pointermove', onMove);\n window.addEventListener('pointerup', onUp);\n };\n const onPaneClickUnlessMarquee = () => {\n if (isMarqueeJustEndedRef.current) {\n isMarqueeJustEndedRef.current = false;\n return;\n }\n onPaneClick();\n };\n\n const minimapHeight = Math.round(\n Math.min(180, Math.max(60, (MINIMAP_WIDTH * layout.bounds.height) / Math.max(1, layout.bounds.width)))\n );\n\n return (\n <div\n ref={containerRef}\n className={cx('relative h-full w-full', tool === 'hand' && 'cursor-grab active:cursor-grabbing')}\n onPointerDownCapture={startMarquee}\n >\n {marquee && (\n <div\n aria-hidden\n className=\"pointer-events-none absolute z-10 rounded-sm border border-brand bg-brand/10\"\n style={{\n left: Math.min(marquee.startX, marquee.x),\n top: Math.min(marquee.startY, marquee.y),\n width: Math.abs(marquee.x - marquee.startX),\n height: Math.abs(marquee.y - marquee.startY),\n }}\n />\n )}\n <ReactFlow\n nodes={nodes}\n edges={[]}\n nodeTypes={NODE_TYPES}\n onlyRenderVisibleElements\n nodesDraggable={false}\n nodesConnectable={false}\n elementsSelectable={false}\n zoomOnDoubleClick={false}\n // every wheel (mouse, Magic Mouse, trackpad scroll and pinch) zooms towards the cursor: our own handler\n // (useWheelZoom), React Flow handles no wheel at all; drag pans (also over boards, they are not draggable)\n panOnScroll={false}\n zoomOnScroll={false}\n zoomOnPinch={false}\n minZoom={MIN_ZOOM}\n maxZoom={MAX_ZOOM}\n defaultViewport={{ x: 0, y: 0, zoom: 0.1 }}\n onInit={() => {\n isFlowReadyRef.current = true;\n fitInitialView();\n }}\n onMoveStart={cancelLiveBoardsUpdate}\n onMoveEnd={(_event, viewport) => {\n cancelLiveBoardsUpdate();\n liveBoardsTimerRef.current = setTimeout(() => updateLiveBoards(viewport), LIVE_BOARDS_SETTLE_MS);\n commitViewport(viewport);\n }}\n onPaneClick={onPaneClickUnlessMarquee}\n panOnDrag={tool === 'hand' ? true : [1, 2]}\n // a press that moved less than this is still a click (d3-zoom otherwise swallows the click after any move)\n paneClickDistance={CLICK_MAX_MOVE}\n selectionOnDrag={false}\n proOptions={{ hideAttribution: true }}\n >\n <Background variant={BackgroundVariant.Dots} gap={32} size={1.5} color=\"var(--tint-strong)\" />\n <Panel position=\"top-left\" className=\"flex max-w-[calc(100%-32rem)] flex-wrap items-center gap-2\">\n <div className={TOOLBAR_GROUP_CLASS} role=\"toolbar\" aria-label=\"Canvas tools\">\n {(\n [\n ['hand', Hand, 'Pan (H / Esc) — drag moves the canvas, click selects a board'],\n ['select', MousePointer2, 'Select area (V) — drag a rectangle to select boards, Space + drag pans'],\n ] as const\n ).map(([toolName, Icon, label]) => (\n <Tooltip key={toolName}>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n aria-label={label}\n aria-pressed={tool === toolName}\n onClick={() => onToolChange(toolName)}\n className={cx(TOOL_BUTTON_CLASS, tool === toolName && 'bg-brand-light text-brand-emphasis')}\n >\n <Icon className=\"size-4\" />\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{label}</TooltipContent>\n </Tooltip>\n ))}\n </div>\n {toolbarStart}\n </Panel>\n <Panel position=\"top-right\">\n <div className={TOOLBAR_GROUP_CLASS}>\n {toolbarEnd}\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n aria-label=\"Present the section in view\"\n onClick={presentCurrentSection}\n className={TOOL_BUTTON_CLASS}\n >\n <Play className=\"size-4\" />\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">Present this section (← / →)</TooltipContent>\n </Tooltip>\n <ZoomMenu onFitAll={fitAll} />\n </div>\n </Panel>\n <Panel position=\"bottom-left\" className=\"pointer-events-none\">\n <p className=\"surface-glass-strong rounded-xl px-3 py-1.5 text-xs text-muted-foreground ring-1 ring-foreground/5\">\n Drag to pan · Scroll or pinch to zoom · Click selects · Double-click opens · + / − / 0 · Shift+1 fits all\n </p>\n </Panel>\n {!isEverythingVisible && (\n <MiniMap\n pannable\n zoomable\n ariaLabel=\"Canvas overview: click or drag to move\"\n style={{ width: MINIMAP_WIDTH, height: minimapHeight }}\n nodeColor={node =>\n node.type === 'section'\n ? 'var(--brand-light)'\n : (statusColors?.[(node as BoardFlowNode).data.board.status ?? ''] ?? 'var(--muted-foreground)')\n }\n nodeStrokeWidth={0}\n nodeBorderRadius={24}\n maskColor=\"rgb(8 9 72 / 0.12)\"\n maskStrokeColor=\"var(--brand)\"\n maskStrokeWidth={3}\n onClick={(_event, position) =>\n void reactFlow.setCenter(position.x, position.y, { zoom: reactFlow.getZoom(), duration: 300 })\n }\n className=\"surface-glass-strong !rounded-xl\"\n />\n )}\n </ReactFlow>\n </div>\n );\n};\n\n/** The infinite canvas (React Flow / xyflow, MIT): auto-laid-out sections and boards, tools, zoom, minimap. */\nexport const DesignCanvasFlow = (props: DesignCanvasFlowProps) => (\n <ReactFlowProvider>\n <FlowCanvas {...props} />\n </ReactFlowProvider>\n);\n","'use client';\n\nimport { type Node, type NodeProps, useStore } from '@xyflow/react';\nimport { memo } from 'react';\n\nimport { SECTION_PADDING } from './canvasLayout';\nimport { useCanvasView } from './canvasView';\n\nexport type SectionNodeData = {\n sectionId: string;\n title: string;\n boardCount: number;\n /** Overview level (far zoom): the section is drawn as a card with cover thumbnails instead of its boards. */\n isOverview: boolean;\n /** Small thumbnails of the first boards (overview card). */\n coverUrls: string[];\n /** Section width in canvas px (overview title size). */\n width: number;\n};\nexport type SectionFlowNode = Node<SectionNodeData, 'section'>;\n\n/** Title size in screen px on an overview card (the card scales with the canvas, the title keeps readable). */\nconst OVERVIEW_TITLE_SCREEN_PX = 15;\n\n/**\n * A section of the canvas. Normally a quiet background exactly around its title and boards (computed by\n * `computeCanvasLayout`) with the title as one bold line above the boards — scaled with the canvas like the boards,\n * never behind them. At the overview level (far zoom) the boards are not drawn; the section becomes a card with its\n * title, board count and a few cover thumbnails, and a click zooms to it.\n */\nconst SectionNodeComponent = ({ data }: NodeProps<SectionFlowNode>) => {\n const { onZoomToSection } = useCanvasView();\n // follows the zoom only at the overview level (a handful of section cards), a constant 1 otherwise\n const zoom = useStore(state => (data.isOverview ? Math.round(state.transform[2] * 1000) / 1000 : 1));\n\n if (!data.isOverview) {\n return (\n <div className=\"pointer-events-none h-full w-full rounded-[64px] bg-card/50 ring-2 ring-foreground/5 backdrop-blur-xl\">\n <div\n className=\"flex items-baseline gap-4 overflow-hidden text-ellipsis whitespace-nowrap\"\n style={{ padding: `${SECTION_PADDING}px ${SECTION_PADDING}px 0` }}\n title={data.title}\n >\n <span className=\"text-[56px] leading-none font-bold tracking-tight text-foreground\">{data.title}</span>\n <span className=\"text-[28px] leading-none text-muted-foreground\">{data.boardCount} boards</span>\n </div>\n </div>\n );\n }\n\n // readable on screen, but never wider than the card allows\n const titleFontSize = Math.min(OVERVIEW_TITLE_SCREEN_PX / zoom, data.width / 7);\n return (\n <button\n type=\"button\"\n onClick={() => onZoomToSection(data.sectionId)}\n aria-label={`${data.title}: ${data.boardCount} boards — zoom in`}\n className=\"flex h-full w-full cursor-zoom-in flex-col overflow-hidden rounded-[64px] bg-card text-left shadow-surface-raised ring-1 ring-foreground/10 transition-shadow hover:ring-[24px] hover:ring-brand/40\"\n style={{ padding: titleFontSize }}\n >\n <span className=\"block w-full\" style={{ fontSize: titleFontSize, lineHeight: 1.2 }}>\n <span className=\"line-clamp-2 font-bold text-foreground\">{data.title}</span>\n <span className=\"block text-muted-foreground\" style={{ fontSize: titleFontSize * 0.8 }}>\n {data.boardCount} boards\n </span>\n </span>\n <span\n className=\"mt-auto grid min-h-0 flex-1 grid-cols-2 content-end\"\n style={{ gap: titleFontSize * 0.6, paddingTop: titleFontSize * 0.6 }}\n >\n {data.coverUrls.map(coverUrl => (\n // biome-ignore lint/performance/noImgElement: small cover thumbnails from the API at canvas scale\n <img\n key={coverUrl}\n src={coverUrl}\n alt=\"\"\n loading=\"lazy\"\n decoding=\"async\"\n draggable={false}\n className=\"pointer-events-none w-full rounded-[24px] object-cover object-top shadow-surface-raised select-none\"\n />\n ))}\n </span>\n </button>\n );\n};\n\nexport const SectionNode = memo(SectionNodeComponent);\n"],"mappings":";;;;;;;;;;;;;;AAEA,SAAS,qBAAAA,0BAAyB;AAClC;AAAA,EACE,iBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAAC;AAAA,EACA,iBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAAC,cAAa,aAAAC,YAAW,WAAAC,UAAS,UAAAC,SAAQ,YAAAC,iBAAgB;;;AChBlE,SAAS,yBAAyB;AAClC,SAAS,KAAK,cAAc,eAAe,MAAM,SAAS,WAAW,QAAQ,WAAW,cAAc;AACtG,SAAS,gBAAgB;AAuDkB,SAqS/B,UArS+B,KAEnC,YAFmC;AAlCpC,IAAM,sBAAsB,CAAC,aAAqD;AACvF,QAAM,kBAAkB,oBAAI,IAAmC;AAC/D,aAAW,WAAW,UAAU;AAC9B,QAAI,QAAQ,+BAA+B,MAAM;AAC/C,YAAM,UAAU,gBAAgB,IAAI,QAAQ,2BAA2B,KAAK,CAAC;AAC7E,cAAQ,KAAK,OAAO;AACpB,sBAAgB,IAAI,QAAQ,6BAA6B,OAAO;AAA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BAAW,CAAC,MAAM,CAAC;AAAA,gBACrB;AAAA,gBAEA;AAAA,kCAAAD,KAAC,UAAK,WAAU,YAAY,yBAAe,IAAI,MAAM,GAAG,OAAM;AAAA,kBAC9D,gBAAAC,MAAC,UAAK,WAAU,uFACd;AAAA,oCAAAD,KAACY,gBAAA,EAAc,WAAU,YAAW,eAAW,MAAC;AAAA,oBAAE;AAAA,oBAAE,iBAAiB,IAAI,MAAM;AAAA,qBACjF;AAAA;AAAA;AAAA,YACF,KAbO,MAcT,CACD,GACH;AAAA,aACF,GAEJ;AAAA,WAEJ;AAAA,QAEF,gBAAAZ;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA,OAAO;AAAA,YACP;AAAA,YACA,cAAc,eAAgB,kBAAkB,IAAI,aAAa,cAAc,EAAE,KAAK,OAAQ;AAAA,YAC9F,UAAU;AAAA,cACR,OAAO,iBAAiB,gBAAgB,QAAQ,cAAc,IAAI,IAAI;AAAA,cACtE,OAAO,gBAAgB;AAAA,YACzB;AAAA,YACA,SAAS,UAAU,cAAc;AAAA,YACjC;AAAA,YACA,cAAc;AAAA,YACd,SAAS;AAAA,YACT,YAAY,MAAM,UAAU,EAAE;AAAA,YAC9B,QAAQ,MAAM,UAAU,CAAC;AAAA,YACzB,iBAAiB,YAAU,kBAAkB,eAAe,gBAAgB,MAAM;AAAA,YAClF,iBAAiB,CAAC,EAAE,QAAQ,KAAK,MAC/B,kBAAkB,KAAK,eAAe,CAAC,kBAAkB,gBAAgB,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC;AAAA,YAE7F,uBAAuB;AAAA;AAAA,QACzB;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["normalizeDddError","ClipboardCopy","Maximize2","MessageSquare","useCallback","useEffect","useMemo","useRef","useState","ClipboardCopy","MapPin","useEffect","useState","ClipboardCopy","useEffect","useState","grids","useState","useEffect","useState","useState","useState","jsx","jsxs","useState","useEffect","ClipboardCopy","normalizeDddError","jsx","jsxs","normalizeDddError","Fragment","jsx","jsxs","useState","useEffect","MapPin","ClipboardCopy","useStore","useEffect","useRef","useState","useStore","memo","jsx","jsxs","useStore","memo","jsx","jsxs","CLICK_MAX_MOVE","useStore","useEffect","useRef","useState","Fragment","jsx","jsxs","useState","useEffect","TOOL_BUTTON_CLASS","TOOLBAR_GROUP_CLASS","useRef","Maximize2","useCallback","useMemo","ClipboardCopy","normalizeDddError","MessageSquare"]}
1
+ {"version":3,"sources":["../../src/canvas/DesignStudioCanvasScreen.tsx","../../src/canvas/BoardComments.tsx","../../src/canvas/BoardFocusView.tsx","../../src/canvas/BoardNode.tsx","../../src/canvas/boardStatus.ts","../../src/canvas/boardDetail.ts","../../src/canvas/canvasLayout.ts","../../src/canvas/canvasLiveUpdate.ts","../../src/canvas/canvasView.ts","../../src/canvas/useCheckedContentUrl.ts","../../src/canvas/useDeferredMount.ts","../../src/canvas/stableContentUrl.ts","../../src/canvas/BoardStatusChips.tsx","../../src/canvas/DesignCanvasFlow.tsx","../../src/canvas/SectionNode.tsx"],"sourcesContent":["'use client';\n\nimport { normalizeDddError } from '@mgamadeus/ddd-web/api';\nimport {\n ClipboardCopy,\n ImageDown,\n Link2,\n ListFilter,\n LoaderCircle,\n Maximize,\n Maximize2,\n MessageSquare,\n Minimize,\n Moon,\n PanelRightClose,\n PanelRightOpen,\n RefreshCw,\n Sun,\n} from 'lucide-react';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport type { DesignStudioBoardView, DesignStudioComment } from '../api/types';\nimport { useDesignStudio, useDesignStudioComponents, useDesignStudioTexts } from '../provider/DesignStudioProvider';\nimport type { DesignStudioShell } from '../provider/types';\nimport { cx } from '../utils/cx';\nimport { BoardComments, buildCommentThreads, type CommentThread } from './BoardComments';\nimport { BoardFocusView } from './BoardFocusView';\nimport { BoardStatusChips } from './BoardStatusChips';\nimport { buildBoardCodeLink, CODE_PARAM, findBoardForCode, normalizeBoardCode } from './boardCode';\nimport { LIVE_MIN_RENDERED_WIDTH_RATIO, LIVE_MIN_RENDERED_WIDTH_RATIO_WITHOUT_THUMBNAILS } from './boardDetail';\nimport { boardStatusLabel } from './boardStatus';\nimport { computeCanvasLayout } from './canvasLayout';\nimport {\n type CanvasViewport,\n formatViewportParam,\n mergeRefetchedBoards,\n parseViewportParam,\n shortContentHash,\n} from './canvasLiveUpdate';\nimport { isContentUrlExpiring } from './stableContentUrl';\nimport {\n buildBoardDeepLink,\n buildDesignReference,\n copyTextToClipboard,\n type DesignReferenceInput,\n} from './designReference';\nimport { boardNodeId, CanvasViewContext, type CanvasViewState, sectionNodeId } from './canvasView';\nimport { buildThemeReference, splitThemeReference, type ThemeMode } from './designTheme';\nimport { type CanvasFitRequest, type CanvasTool, DesignCanvasFlow } from './DesignCanvasFlow';\n\n/** URL parameters of the canvas state (search, section, status, theme, theme mode, viewport `x,y,zoom`). */\nconst CANVAS_STATE_KEYS = ['q', 'section', 'status', 'theme', 'mode', 'vp'] as const;\n/** Keys that are not \"filters\" (filter badge counts section and status only). */\nconst UNCOUNTED_CANVAS_STATE_KEYS: readonly string[] = ['q', 'theme', 'mode', 'vp'];\n\n/** Live update: how often the canvas revision is polled while the tab is visible (ms). */\nconst LIVE_UPDATE_POLL_MS = 15_000;\n\n/** Poll interval of the canvas while a thumbnail render request runs (images swap in as they arrive). */\nconst THUMBNAIL_RENDER_POLL_MS = 3_000;\n\n/** Render request statuses that are still being worked on. */\nconst OPEN_RENDER_STATUSES: ReadonlySet<string> = new Set(['QUEUED', 'RUNNING', 'WAITING_FOR_RENDERER']);\n\n/** At most this many boards on screen are named as priority of a render request. */\nconst MAX_PRIORITY_BOARDS = 200;\n\n/** Toast id of the live update (a newer update replaces the toast). */\nconst LIVE_UPDATE_TOAST_ID = 'design-canvas-live-update';\n\n/** The boards as shown: merged in place from each canvas response (canvasLiveUpdate.ts). */\ninterface ShownBoards {\n /** The response elements they were merged from (undefined = nothing loaded yet). */\n source: readonly DesignStudioBoardView[] | undefined;\n /** Theme reference of that response ('' = no theme): another one starts over like a first load. */\n themeReference: string;\n boards: DesignStudioBoardView[];\n /** When the delivery URLs of unchanged boards were taken over (ms since epoch). */\n urlsAdoptedAt: number;\n /** Keys of the boards with a new version (or new) in the last merge; empty for the first load and a new theme. */\n changedBoardKeys: string[];\n /** Counts merges (effects key on it). */\n serial: number;\n}\n\nconst usePageVisible = (): boolean => {\n const [isVisible, setIsVisible] = useState(true);\n useEffect(() => {\n const update = () => setIsVisible(document.visibilityState === 'visible');\n update();\n document.addEventListener('visibilitychange', update);\n return () => document.removeEventListener('visibilitychange', update);\n }, []);\n return isVisible;\n};\n\n/** URL parameter of the board open in focus view (deep links from the overview and from comments). */\nconst BOARD_PARAM = 'board';\n\nconst TOOL_BUTTON_CLASS =\n 'relative flex size-8 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-tint hover:text-foreground disabled:pointer-events-none disabled:opacity-40 motion-reduce:transition-none';\n\n/** Room the canvas toolbar takes above the content when a view is fitted (px). */\nconst CANVAS_TOOLBAR_HEIGHT = 96;\n\nconst TOOLBAR_GROUP_CLASS = 'surface-glass-strong flex items-center gap-1 rounded-2xl p-1 ring-1 ring-foreground/5';\n\n/** Without a shell sidebar there is nothing to collapse: \"already collapsed\", the toggle does nothing. */\nconst NO_SIDEBAR = [true, () => undefined] as const;\nconst useNoSidebar = () => NO_SIDEBAR;\n\n/**\n * The canvas route wants the room: the shell's sidebar is collapsed while the canvas is open and returns to how it was\n * when the page is left or the tab is closed / reloaded (only if this page collapsed it).\n */\nconst useCollapsedSidebarWhileMounted = (useSidebarCollapsed: DesignStudioShell['useSidebarCollapsed'] = useNoSidebar) => {\n const [isCollapsed, toggleCollapsed] = useSidebarCollapsed();\n const collapsedByCanvasRef = useRef(false);\n const toggleRef = useRef(toggleCollapsed);\n toggleRef.current = toggleCollapsed;\n // biome-ignore lint/correctness/useExhaustiveDependencies: once on mount: collapse; on unmount / tab close: restore\n useEffect(() => {\n if (!isCollapsed) {\n collapsedByCanvasRef.current = true;\n toggleRef.current();\n }\n const restore = () => {\n if (!collapsedByCanvasRef.current) return;\n collapsedByCanvasRef.current = false;\n toggleRef.current();\n };\n window.addEventListener('pagehide', restore);\n return () => {\n window.removeEventListener('pagehide', restore);\n restore();\n };\n }, []);\n};\n\nexport interface DesignStudioCanvasScreenProps {\n projectKey: string;\n canvasKey: string;\n}\n\n/** The selected board's side panel on the canvas: status, current version, comments, open in focus view. */\nconst SelectedBoardPanel = ({\n projectKey,\n canvasKey,\n board,\n statuses,\n sectionTitle,\n threads,\n writesAllowed,\n onOpen,\n onCopyLink,\n onStatusChanged,\n onCopyThreadReference,\n}: {\n projectKey: string;\n canvasKey: string;\n board: DesignStudioBoardView;\n statuses: readonly string[];\n sectionTitle: string | null;\n threads: CommentThread[];\n writesAllowed: boolean;\n onOpen: () => void;\n /** Copies the code link of the board; absent when the board has no code. */\n onCopyLink?: () => void;\n onStatusChanged: (status: string) => void;\n onCopyThreadReference: (thread: CommentThread) => void;\n}) => {\n const { Button } = useDesignStudioComponents();\n const texts = useDesignStudioTexts();\n const [showResolved, setShowResolved] = useState(false);\n return (\n <div className=\"space-y-5\">\n <div className=\"space-y-1\">\n {board.code && <p className=\"text-sm font-semibold tabular-nums text-foreground/70\">{board.code}</p>}\n <h2 className=\"text-title-card font-semibold break-words\">{board.title}</h2>\n <p className=\"text-xs text-muted-foreground\">\n {sectionTitle ? `${sectionTitle} · ` : ''}\n {board.boardKey}\n </p>\n </div>\n <BoardStatusChips\n projectKey={projectKey}\n canvasKey={canvasKey}\n board={board}\n statuses={statuses}\n writesAllowed={writesAllowed}\n onStatusChanged={onStatusChanged}\n />\n <div className=\"flex gap-2\">\n <Button variant=\"outline\" className=\"flex-1\" onClick={onOpen}>\n <Maximize2 /> Open focus view\n </Button>\n {onCopyLink && (\n <Button variant=\"outline\" onClick={onCopyLink} aria-label={`${texts.copyBoardLink}: ${board.code ?? ''}`}>\n <Link2 /> {texts.copyBoardLink}\n </Button>\n )}\n </div>\n {board.contentHash && (\n <p className=\"text-xs text-muted-foreground\" title={`Content hash of the board file: ${board.contentHash}`}>\n Version <span className=\"font-mono\">{shortContentHash(board.contentHash)}</span>\n </p>\n )}\n <BoardComments\n projectKey={projectKey}\n canvasKey={canvasKey}\n board={board}\n threads={threads}\n pendingPin={null}\n onClearPendingPin={() => undefined}\n highlightedCommentId={null}\n onHighlightComment={() => undefined}\n writesAllowed={writesAllowed}\n showResolved={showResolved}\n onShowResolvedChange={setShowResolved}\n pinHint=\"open the focus view to pin it to a spot\"\n onCopyThreadReference={onCopyThreadReference}\n />\n </div>\n );\n};\n\n/**\n * Design studio canvas: every board of a canvas laid out per section (a bold title\n * line, then rows of nine boards with a header each), a toolbar on the canvas (select / hand, theme + light / dark\n * mode, comments panel, present, zoom), search and filters by section and status, a collapsible comments panel and\n * the focus view. Rendering stays proportional to what is on screen (boardDetail.ts):\n * only nodes in the viewport mount, far zoom uses the 120 px thumbnails, live HTML only for ≤ 6 large boards after a\n * pan / zoom ends.\n */\nexport const DesignStudioCanvasScreen = ({ projectKey, canvasKey }: DesignStudioCanvasScreenProps) => {\n const {\n api,\n components,\n notify,\n router,\n shell,\n statuses: statusDefinitions,\n storage,\n useCanWrite,\n } = useDesignStudio();\n const texts = useDesignStudioTexts();\n const {\n Button,\n Combobox,\n Popover,\n PopoverContent,\n PopoverTrigger,\n QuickFilterPills,\n SearchField,\n Skeleton,\n StatusCallout,\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n } = components;\n const searchParams = router.useSearchParams();\n const writeSearchParams = router.useSearchParamsWriter();\n const writesAllowed = useCanWrite();\n const isPageVisible = usePageVisible();\n\n const [statusOverrides, setStatusOverrides] = useState<ReadonlyMap<string, string>>(new Map());\n const [liveBoardIds, setLiveBoardIds] = useState<ReadonlySet<string>>(new Set());\n const [selectedBoardId, setSelectedBoardId] = useState<string | null>(null);\n const [selectedBoardIds, setSelectedBoardIds] = useState<ReadonlySet<string>>(new Set());\n const [focusedBoardId, setFocusedBoardId] = useState<string | null>(null);\n const [presentSectionId, setPresentSectionId] = useState<string | null>(null);\n const [fitRequest, setFitRequest] = useState<CanvasFitRequest | null>(null);\n // pan by default; the area-select tool is opt-in and kept only for this page visit\n const [tool, setTool] = useState<CanvasTool>('hand');\n // a code link shows the board's panel: open from the start, so opening it does not re-pack the layout after the fit\n const [isCommentsPanelOpen, setIsCommentsPanelOpen] = useState(\n () => Boolean(searchParams.get(CODE_PARAM)) || storage.read('commentsPanelOpen') !== '0'\n );\n // Search, filters, theme and theme mode: in the URL (source of truth), saved per canvas in this tab's\n // sessionStorage and restored when the URL has none of them (the application's URL state, `router.useUrlState`).\n // Defaults (no search / filter, the canvas' reference theme and its mode) are never written.\n const canvasState = router.useUrlState(CANVAS_STATE_KEYS, {\n stateId: `designCanvas.${projectKey}.${canvasKey}`,\n debounceMs: 250,\n uncounted: UNCOUNTED_CANVAS_STATE_KEYS,\n });\n const search = canvasState.values.q;\n const sectionFilter = canvasState.values.section;\n const statusFilter = canvasState.values.status;\n const chosenThemeId = canvasState.values.theme || null;\n const chosenMode: ThemeMode | null =\n canvasState.values.mode === 'dark' || canvasState.values.mode === 'light' ? canvasState.values.mode : null;\n const { setValue: setCanvasStateValue } = canvasState;\n const setSearch = useCallback((value: string) => setCanvasStateValue('q', value), [setCanvasStateValue]);\n const setSectionFilter = useCallback((value: string) => setCanvasStateValue('section', value), [setCanvasStateValue]);\n const setStatusFilter = useCallback((value: string) => setCanvasStateValue('status', value), [setCanvasStateValue]);\n const [isFullscreen, setIsFullscreen] = useState(false);\n // aspect ratio of the canvas area: the layout packs the sections for it (\"Fit all\" fills the view)\n const canvasAreaRef = useRef<HTMLDivElement>(null);\n const [canvasAspectRatio, setCanvasAspectRatio] = useState<number | null>(null);\n useCollapsedSidebarWhileMounted(shell?.useSidebarCollapsed);\n const debouncedSearch = canvasState.debounced.q;\n // The viewport as saved (`?vp=`, or this tab's saved canvas state): the first view returns there instead of fitting.\n // A code link (`?code=`) at load: the first view goes to that board instead of the saved place.\n const [codeAtLoad] = useState(() => searchParams.get(CODE_PARAM));\n const [initialViewport] = useState<CanvasViewport | null>(() =>\n codeAtLoad ? null : parseViewportParam(canvasState.values.vp)\n );\n // A filter present at load with a saved viewport: the saved place wins over fitting the matches once.\n const [hasInitialFilterWithViewport] = useState(\n () =>\n initialViewport !== null &&\n Boolean(canvasState.values.q.trim() || canvasState.values.section || canvasState.values.status)\n );\n const currentViewportRef = useRef<string | null>(initialViewport ? formatViewportParam(initialViewport) : null);\n const commitViewport = useCallback(\n (viewport: CanvasViewport) => {\n const value = formatViewportParam(viewport);\n currentViewportRef.current = value;\n setCanvasStateValue('vp', value);\n },\n [setCanvasStateValue]\n );\n\n // Projects, canvases and whether the application offers themes at all (one cached request for the whole studio).\n const { data: overviewData, isError: isOverviewError } = api.useOverviewQuery();\n const overview = overviewData?.designStudioOverview;\n const projectSummary = overview?.projects?.elements?.find(project => project.projectKey === projectKey);\n const canvasSummary = projectSummary?.canvases?.elements?.find(item => item.canvasKey === canvasKey);\n const hasThemes = Boolean(overview?.hasThemes);\n const {\n data: themesData,\n isLoading: isLoadingThemes,\n isError: isThemesError,\n } = api.useThemesQuery({}, { skip: !hasThemes });\n const themes = useMemo(() => themesData?.designThemes.elements ?? [], [themesData]);\n\n // The look: the canvas' reference theme by default (no `theme` parameter: the backend picks it; without a reference\n // theme the boards are shown as authored), else the chosen theme `<themeId>` / `<themeId>:dark`. Dark only when the\n // theme has a dark look of its own.\n const isDefaultLook = chosenThemeId === null && chosenMode === null;\n // another look needs the theme list (does it support dark?) and, for a mode alone, the canvas' reference theme\n const isLookResolved =\n isDefaultLook ||\n ((overviewData !== undefined || isOverviewError) && (!hasThemes || themesData !== undefined || isThemesError));\n // the canvas' reference theme: from the loaded canvas, before that from the overview (same configuration)\n const [loadedReferenceTheme, setLoadedReferenceTheme] = useState<string | null | undefined>(undefined);\n const referenceTheme = loadedReferenceTheme !== undefined ? loadedReferenceTheme : canvasSummary?.referenceTheme;\n const referenceLook = useMemo(() => splitThemeReference(referenceTheme), [referenceTheme]);\n const referenceThemeId = referenceLook?.themeId ?? null;\n const themeId = chosenThemeId ?? referenceThemeId;\n const selectedTheme = themes.find(theme => theme.themeId === themeId);\n const supportsDark = Boolean(selectedTheme?.supportsDark);\n const defaultMode: ThemeMode = themeId !== null && themeId === referenceThemeId ? (referenceLook?.mode ?? 'light') : 'light';\n const requestedMode: ThemeMode = chosenMode ?? defaultMode;\n const effectiveMode: ThemeMode = requestedMode === 'dark' && (isDefaultLook || supportsDark) ? 'dark' : 'light';\n const themeArgument = isDefaultLook || themeId === null ? undefined : buildThemeReference(themeId, effectiveMode);\n const canvasQueryArgument = useMemo(\n () => ({ projectKey, canvasKey, ...(themeArgument ? { theme: themeArgument } : {}) }),\n [projectKey, canvasKey, themeArgument]\n );\n\n // While a thumbnail render request runs, the canvas itself is polled so the images swap in as they arrive.\n const [isRenderPolling, setIsRenderPolling] = useState(false);\n const {\n data,\n currentData: currentCanvasData,\n isLoading,\n error,\n isFetching: isFetchingCanvas,\n refetch: refetchCanvas,\n } = api.useCanvasQuery(canvasQueryArgument, {\n skip: !isLookResolved,\n pollingInterval: isPageVisible && isRenderPolling ? THUMBNAIL_RENDER_POLL_MS : 0,\n });\n const { data: commentsData, refetch: refetchComments } = api.useCanvasCommentsQuery({ projectKey, canvasKey });\n // Live update: a cheap revision is polled while the tab is visible; it changes with every\n // board file, comment and status, and a change refetches the canvas (changed boards update in place) and the comments.\n const { currentData: currentRevisionData, refetch: refetchRevision } = api.useCanvasRevisionQuery(\n canvasQueryArgument,\n {\n skip: !isLookResolved,\n pollingInterval: isPageVisible ? LIVE_UPDATE_POLL_MS : 0,\n }\n );\n\n // `data` stays the previous look's canvas while another theme loads (the boards stay on screen until it answers)\n const canvas = data?.designStudioCanvasView;\n // the canvas in the requested look (undefined while that look is still loading)\n const currentCanvas = currentCanvasData?.designStudioCanvasView;\n if (canvas && (canvas.referenceTheme ?? null) !== loadedReferenceTheme) {\n setLoadedReferenceTheme(canvas.referenceTheme ?? null);\n }\n // the look the boards on screen are really in (the reference block and the deep links name it)\n const shownLook = useMemo(() => splitThemeReference(canvas?.themeReference), [canvas?.themeReference]);\n const sections = useMemo(() => canvas?.sections?.elements ?? [], [canvas]);\n const statuses = useMemo(() => canvas?.statuses ?? overview?.statuses ?? [], [canvas?.statuses, overview?.statuses]);\n const defaultStatus = statuses[0] ?? null;\n const statusFilterOptions = useMemo(\n () => statuses.map(status => ({ value: status, label: boardStatusLabel(statusDefinitions, status) })),\n [statuses, statusDefinitions]\n );\n // Each canvas response is merged into the shown boards: unchanged boards keep their object and delivery URLs (no\n // re-render, no reload), changed ones take the new version's URLs — in place, the view does not move. The first\n // response of another theme starts over like a first load: every board has new URLs, none of them \"changed\".\n const canvasBoards = canvas?.boards?.elements;\n const [shownBoards, setShownBoards] = useState<ShownBoards>({\n source: undefined,\n themeReference: '',\n boards: [],\n urlsAdoptedAt: 0,\n changedBoardKeys: [],\n serial: 0,\n });\n if (canvasBoards && canvasBoards !== shownBoards.source) {\n const now = Date.now();\n const themeReference = canvas?.themeReference ?? '';\n const isFirstLoad = shownBoards.source === undefined || themeReference !== shownBoards.themeReference;\n // unchanged boards keep their object (and URLs) while the shown content token is good; the elements keep their\n // src across a token change anyway (stableContentUrl.ts), so a later switch only re-renders, never reloads\n const shownTokenUrl = shownBoards.boards.find(board => board.htmlUrl)?.htmlUrl;\n const keepPreviousUrls = !isFirstLoad && (!shownTokenUrl || !isContentUrlExpiring(shownTokenUrl));\n const merged = mergeRefetchedBoards(isFirstLoad ? null : shownBoards.boards, canvasBoards, keepPreviousUrls);\n setShownBoards({\n source: canvasBoards,\n themeReference,\n boards: merged.boards,\n urlsAdoptedAt: keepPreviousUrls ? shownBoards.urlsAdoptedAt : now,\n changedBoardKeys: merged.changedBoardKeys,\n serial: shownBoards.serial + 1,\n });\n }\n const shownBoardList = shownBoards.boards;\n const boards = useMemo<DesignStudioBoardView[]>(\n () =>\n shownBoardList.map(board => {\n const status = statusOverrides.get(boardNodeId(board.boardKey ?? ''));\n return status ? { ...board, status } : board;\n }),\n [shownBoardList, statusOverrides]\n );\n const boardsByNodeId = useMemo(\n () => new Map(boards.map(board => [boardNodeId(board.boardKey ?? ''), board])),\n [boards]\n );\n const sectionTitleByKey = useMemo(\n () => new Map(sections.map(section => [section.sectionKey ?? '', section.title ?? ''])),\n [sections]\n );\n\n // Layout: computed from sections and board order only (status changes do not move anything).\n const layout = useMemo(() => {\n const sectionKeys = new Set(sections.map(section => section.sectionKey ?? ''));\n return computeCanvasLayout(\n sections.map(section => ({\n id: section.sectionKey ?? '',\n title: section.title ?? '',\n displayOrder: section.displayOrder ?? 0,\n })),\n shownBoardList.map(board => ({\n id: boardNodeId(board.boardKey ?? ''),\n sectionId: board.sectionKey && sectionKeys.has(board.sectionKey) ? board.sectionKey : null,\n width: board.width ?? 390,\n height: board.height ?? 844,\n displayOrder: board.displayOrder ?? 0,\n })),\n canvasAspectRatio ?? undefined\n );\n }, [sections, shownBoardList, canvasAspectRatio]);\n\n // Measure the canvas area (and follow big resizes: a change under 15 % keeps the layout).\n const hasCanvas = Boolean(canvas);\n // biome-ignore lint/correctness/useExhaustiveDependencies: the canvas area mounts with the canvas data (`hasCanvas`)\n useEffect(() => {\n const canvasArea = canvasAreaRef.current;\n if (!canvasArea) return;\n const measure = () => {\n if (canvasArea.clientWidth === 0 || canvasArea.clientHeight === 0) return;\n const aspectRatio = canvasArea.clientWidth / Math.max(1, canvasArea.clientHeight - CANVAS_TOOLBAR_HEIGHT);\n setCanvasAspectRatio(current =>\n current === null || Math.abs(aspectRatio / current - 1) > 0.15 ? Math.round(aspectRatio * 10) / 10 : current\n );\n };\n measure();\n const resizeObserver = new ResizeObserver(measure);\n resizeObserver.observe(canvasArea);\n return () => resizeObserver.disconnect();\n }, [hasCanvas]);\n\n // Thumbnails: the canvas view carries one set of URLs for the requested look and says how many boards have none\n // yet. Missing ones are asked for with a render request (boards on screen first); while it is open the canvas is\n // polled fast, so the images swap in as they arrive.\n const isRendererEnabled = Boolean(canvas?.isRendererEnabled);\n const missingThumbnailCount = canvas?.missingThumbnailCount ?? 0;\n const renderStatus = canvas?.renderRequestStatus ?? null;\n const isRenderOpen = renderStatus !== null && OPEN_RENDER_STATUSES.has(renderStatus);\n useEffect(() => setIsRenderPolling(isRenderOpen), [isRenderOpen]);\n const [requestThumbnailRendering] = api.useRequestThumbnailRenderingMutation();\n const visibleBoardIdsRef = useRef<string[]>([]);\n // stable: the canvas re-evaluates its live boards whenever this callback changes\n const rememberVisibleBoardIds = useCallback((visibleBoardIds: string[]) => {\n visibleBoardIdsRef.current = visibleBoardIds;\n }, []);\n const boardsByNodeIdRef = useRef(boardsByNodeId);\n boardsByNodeIdRef.current = boardsByNodeId;\n // Asked for once per look and board version (`<theme>|<boardKey>@<contentHash>`): a board that changed later gets\n // its thumbnail too, a board the renderer could not draw is not asked for again on its own. A request that is\n // already open (by anyone) is not filed again; a failed one can be retried from the toolbar chip.\n const requestedThumbnailsRef = useRef<Set<string>>(new Set());\n const fileRenderRequest = useCallback(\n (isRetry: boolean) => {\n if (!writesAllowed || !currentCanvas) return;\n const missingKeys = (currentCanvas.boards?.elements ?? [])\n .filter(board => !board.thumbnailUrl)\n .map(board => `${themeArgument ?? ''}|${board.boardKey ?? ''}@${board.contentHash ?? ''}`);\n if (missingKeys.length === 0) return;\n if (!isRetry && missingKeys.every(key => requestedThumbnailsRef.current.has(key))) return;\n for (const key of missingKeys) requestedThumbnailsRef.current.add(key);\n const priorityBoardKeys = visibleBoardIdsRef.current\n .map(nodeId => boardsByNodeIdRef.current.get(nodeId)?.boardKey)\n .filter((boardKey): boardKey is string => Boolean(boardKey))\n .slice(0, MAX_PRIORITY_BOARDS);\n // the answer is not needed: the request invalidates the canvas query, which then carries the request status\n void requestThumbnailRendering({\n projectKey,\n canvasKey,\n ...(themeArgument ? { theme: themeArgument } : {}),\n body: {\n theme: themeArgument ?? null,\n priorityBoardKeys,\n },\n });\n },\n [writesAllowed, currentCanvas, themeArgument, projectKey, canvasKey, requestThumbnailRendering]\n );\n useEffect(() => {\n // only for the look that is loaded (never from the previous theme's numbers while another one loads)\n if (!currentCanvas?.isRendererEnabled || !currentCanvas.missingThumbnailCount) return;\n const currentStatus = currentCanvas.renderRequestStatus ?? null;\n if (currentStatus === 'FAILED' || (currentStatus !== null && OPEN_RENDER_STATUSES.has(currentStatus))) return;\n fileRenderRequest(false);\n }, [currentCanvas, fileRenderRequest]);\n const themeOptions = useMemo(\n () => [\n // without a reference theme the default look is the boards as authored\n ...(referenceThemeId === null ? [{ value: '', label: 'As authored' }] : []),\n ...themes.map(theme => ({ value: theme.themeId ?? '', label: theme.label || theme.themeId || 'Theme' })),\n ],\n [themes, referenceThemeId]\n );\n const shownThemeLabel = themes.find(theme => theme.themeId === shownLook?.themeId)?.label ?? texts.thumbnailsFallbackThemeLabel;\n\n const commentsByBoardNodeId = useMemo(() => {\n const comments = new Map<string, DesignStudioComment[]>();\n for (const comment of commentsData?.designStudioComments.elements ?? []) {\n const nodeId = boardNodeId(comment.boardKey ?? '');\n const boardComments = comments.get(nodeId) ?? [];\n boardComments.push(comment);\n comments.set(nodeId, boardComments);\n }\n return comments;\n }, [commentsData]);\n const openThreadCounts = useMemo(() => {\n const counts = new Map<string, number>();\n for (const [nodeId, comments] of commentsByBoardNodeId) {\n const openCount = comments.filter(\n comment => comment.parentDesignStudioCommentId == null && !comment.isResolved\n ).length;\n if (openCount > 0) counts.set(nodeId, openCount);\n }\n return counts;\n }, [commentsByBoardNodeId]);\n const openThreadTotal = useMemo(\n () => [...openThreadCounts.values()].reduce((sum, count) => sum + count, 0),\n [openThreadCounts]\n );\n\n const matchingBoardIds = useMemo(() => {\n const searchText = debouncedSearch.trim().toLowerCase();\n // `w2`, `ONB-W2`, `APP ONB-W2` find the board by its code\n const searchCode = normalizeBoardCode(searchText);\n if (!searchText && !sectionFilter && !statusFilter) return null;\n const matching = new Set<string>();\n for (const board of boards) {\n if (sectionFilter && (board.sectionKey ?? '') !== sectionFilter) continue;\n if (statusFilter && board.status !== statusFilter) continue;\n if (\n searchText &&\n !(board.title ?? '').toLowerCase().includes(searchText) &&\n !(board.boardKey ?? '').toLowerCase().includes(searchText) &&\n !(searchCode && normalizeBoardCode(board.code ?? '').includes(searchCode))\n ) {\n continue;\n }\n matching.add(boardNodeId(board.boardKey ?? ''));\n }\n return matching;\n }, [boards, debouncedSearch, sectionFilter, statusFilter]);\n\n // Focus navigation order: the presented section, else the layout order (the matches while a filter is active).\n const layoutOrder = useMemo(() => layout.sections.flatMap(section => section.boardIds), [layout]);\n const navigationOrder = useMemo(() => {\n if (presentSectionId) {\n return layout.sections.find(section => section.id === presentSectionId)?.boardIds ?? [];\n }\n return layoutOrder.filter(nodeId => matchingBoardIds === null || matchingBoardIds.has(nodeId));\n }, [layout, layoutOrder, matchingBoardIds, presentSectionId]);\n\n const fitKeyRef = useRef(0);\n const requestFit = useCallback((nodeIds: string[]) => {\n fitKeyRef.current += 1;\n setFitRequest({ nodeIds, key: fitKeyRef.current });\n }, []);\n\n // Fit the view to the matches whenever the filter changes (a section alone fits its row) — only when the filter\n // itself changes, never because the matches were recomputed (a status change, a live update), and not for the filter\n // a reload brings along with its saved viewport.\n const filterKey = matchingBoardIds === null ? null : `${debouncedSearch.trim()}|${sectionFilter}|${statusFilter}`;\n const fittedFilterKeyRef = useRef<string | null>(null);\n const skipInitialFilterFitRef = useRef(hasInitialFilterWithViewport);\n useEffect(() => {\n if (filterKey === null || matchingBoardIds === null) {\n fittedFilterKeyRef.current = null;\n return;\n }\n if (matchingBoardIds.size === 0 || fittedFilterKeyRef.current === filterKey) return;\n fittedFilterKeyRef.current = filterKey;\n if (skipInitialFilterFitRef.current) {\n skipInitialFilterFitRef.current = false;\n return;\n }\n requestFit(\n sectionFilter && !debouncedSearch.trim() && !statusFilter ? [sectionNodeId(sectionFilter)] : [...matchingBoardIds]\n );\n }, [filterKey, matchingBoardIds, sectionFilter, debouncedSearch, statusFilter, requestFit]);\n\n const openBoard = useCallback(\n (nodeId: string) => {\n setSelectedBoardId(nodeId);\n setFocusedBoardId(nodeId);\n const board = boardsByNodeId.get(nodeId);\n if (board?.boardKey) writeSearchParams({ [BOARD_PARAM]: board.boardKey });\n },\n [boardsByNodeId, writeSearchParams]\n );\n const openBoardFromCanvas = useCallback(\n (nodeId: string) => {\n setPresentSectionId(null);\n openBoard(nodeId);\n },\n [openBoard]\n );\n const closeFocus = useCallback(() => {\n setFocusedBoardId(null);\n setPresentSectionId(null);\n writeSearchParams({ [BOARD_PARAM]: null });\n }, [writeSearchParams]);\n const presentSection = useCallback(\n (sectionId: string) => {\n const firstBoardId = layout.sections.find(section => section.id === sectionId)?.boardIds[0];\n if (!firstBoardId) return;\n setPresentSectionId(sectionId);\n openBoard(firstBoardId);\n },\n [layout, openBoard]\n );\n\n // Deep link: ?board=<boardKey> opens that board once the canvas is loaded.\n const boardParam = searchParams.get(BOARD_PARAM);\n const isDeepLinkHandledRef = useRef(false);\n useEffect(() => {\n if (isDeepLinkHandledRef.current || !boardParam || boards.length === 0) return;\n isDeepLinkHandledRef.current = true;\n const nodeId = boardNodeId(boardParam);\n if (!boardsByNodeId.has(nodeId)) return;\n setSelectedBoardId(nodeId);\n setFocusedBoardId(nodeId);\n // a saved viewport (reload, a link with `vp`) keeps its place behind the focus view\n if (!initialViewport) requestFit([nodeId]);\n }, [boardParam, boards.length, boardsByNodeId, requestFit, initialViewport]);\n\n // Code link: ?code=<board code> (`APP-ONB-W2`, `ONB-W2`, `W2`) moves the view to that board, selects it and shows\n // its panel. The code at load is the first view itself (initialFitNodeIds); a later one (an in-app link) fits now.\n // The parameter is removed once handled: a reload keeps the place the user moved to.\n const codeParam = searchParams.get(CODE_PARAM);\n const handledCodeRef = useRef<string | null>(null);\n useEffect(() => {\n if (!codeParam) {\n // handled and removed: the same code may come again (another link) and is then handled anew\n if (handledCodeRef.current !== null) handledCodeRef.current = '';\n return;\n }\n if (boards.length === 0 || handledCodeRef.current === codeParam) return;\n const isFirstView = handledCodeRef.current === null && codeParam === codeAtLoad;\n handledCodeRef.current = codeParam;\n writeSearchParams({ [CODE_PARAM]: null });\n const board = findBoardForCode(boards, codeParam);\n if (!board?.boardKey) {\n notify.error(texts.boardCodeNotFound(codeParam));\n return;\n }\n const nodeId = boardNodeId(board.boardKey);\n setSelectedBoardId(nodeId);\n setSelectedBoardIds(new Set([nodeId]));\n if (isFirstView) return;\n if (isCommentsPanelOpen) {\n requestFit([nodeId]);\n } else {\n // opening the panel narrows the canvas and re-packs the layout: fit once the new layout is there\n pendingCodeFitRef.current = nodeId;\n setIsCommentsPanelOpen(true);\n }\n }, [codeParam, codeAtLoad, boards, isCommentsPanelOpen, writeSearchParams, notify, texts, requestFit]);\n const pendingCodeFitRef = useRef<string | null>(null);\n useEffect(() => {\n const nodeId = pendingCodeFitRef.current;\n if (!nodeId || layout.sections.length === 0) return;\n pendingCodeFitRef.current = null;\n requestFit([nodeId]);\n }, [layout, requestFit]);\n\n const stepFocus = useCallback(\n (step: number) => {\n if (!focusedBoardId || navigationOrder.length === 0) return;\n const index = navigationOrder.indexOf(focusedBoardId);\n openBoard(navigationOrder[(index + step + navigationOrder.length) % navigationOrder.length]);\n },\n [focusedBoardId, navigationOrder, openBoard]\n );\n\n const setBoardStatus = useCallback((nodeId: string, status: string) => {\n setStatusOverrides(overrides => new Map(overrides).set(nodeId, status));\n }, []);\n\n const toggleCommentsPanel = () => {\n setIsCommentsPanelOpen(isOpen => {\n storage.write('commentsPanelOpen', isOpen ? '0' : '1');\n return !isOpen;\n });\n };\n\n // Selection: a click selects one board (the side panel shows it), shift / cmd / ctrl click toggles it in the\n // selection, a marquee (select tool) selects the boards inside; a pane click clears it.\n const selectBoard = useCallback((nodeId: string, isAdditive: boolean) => {\n setSelectedBoardId(nodeId);\n setSelectedBoardIds(current => {\n if (!isAdditive) return new Set([nodeId]);\n const next = new Set(current);\n if (next.has(nodeId)) next.delete(nodeId);\n else next.add(nodeId);\n return next;\n });\n }, []);\n const selectBoards = useCallback((nodeIds: string[], isAdditive: boolean) => {\n setSelectedBoardIds(current => new Set([...(isAdditive ? current : []), ...nodeIds]));\n setSelectedBoardId(nodeIds[0] ?? null);\n }, []);\n const clearSelection = useCallback(() => {\n setSelectedBoardId(null);\n setSelectedBoardIds(new Set());\n }, []);\n\n // Design references for agents (designReference.ts): one block per board, copied as plain text.\n const projectName = projectSummary?.label ?? projectKey;\n const canvasName = canvas?.label ?? canvasSummary?.label ?? canvasKey;\n const shownThemeReference = canvas?.themeReference ?? null;\n const buildReferenceFor = useCallback(\n (nodeId: string, extra: Partial<DesignReferenceInput> = {}): string | null => {\n const board = boardsByNodeId.get(nodeId);\n if (!board?.boardKey || typeof window === 'undefined') return null;\n return buildDesignReference({\n projectName,\n canvasName,\n projectKey,\n canvasKey,\n boardTitle: board.title ?? board.boardKey,\n boardKey: board.boardKey,\n boardCode: board.code ?? null,\n contentHash: board.contentHash ?? null,\n themeReference: shownThemeReference,\n url: buildBoardDeepLink(\n window.location.href,\n board.boardKey,\n shownLook?.themeId ?? null,\n shownLook?.mode ?? 'light',\n currentViewportRef.current\n ),\n ...extra,\n });\n },\n [boardsByNodeId, projectName, canvasName, projectKey, canvasKey, shownThemeReference, shownLook]\n );\n const copyReferences = useCallback(async (blocks: (string | null)[]) => {\n const text = blocks.filter((block): block is string => block !== null).join('\\n\\n');\n if (!text) return;\n if (await copyTextToClipboard(text)) {\n notify.success(texts.referencesCopied(blocks.length));\n } else {\n notify.error('Could not copy to the clipboard');\n }\n }, [notify, texts]);\n const copySelectedReferences = useCallback(() => {\n const nodeIds = layoutOrder.filter(nodeId => selectedBoardIds.has(nodeId));\n void copyReferences(nodeIds.map(nodeId => buildReferenceFor(nodeId)));\n }, [layoutOrder, selectedBoardIds, copyReferences, buildReferenceFor]);\n const copyThreadReference = useCallback(\n (thread: CommentThread) =>\n void copyReferences([\n buildReferenceFor(boardNodeId(thread.root.boardKey ?? ''), {\n comment: {\n id: thread.root.id ?? '',\n x: thread.root.x ?? null,\n y: thread.root.y ?? null,\n lines: [thread.root, ...thread.replies].map(comment => `${comment.authorName ?? 'Unknown'}: ${comment.text ?? ''}`),\n },\n }),\n ]),\n [copyReferences, buildReferenceFor]\n );\n\n const copyBoardLink = useCallback(\n async (board: DesignStudioBoardView) => {\n if (!board.code || typeof window === 'undefined') return;\n const link = buildBoardCodeLink(window.location.href, board.code, shownLook?.themeId ?? null, shownLook?.mode ?? 'light');\n if (await copyTextToClipboard(link)) {\n notify.success(texts.boardLinkCopied(board.code));\n } else {\n notify.error('Could not copy to the clipboard');\n }\n },\n [shownLook, notify, texts]\n );\n\n // Live update: one revision for boards, comments and statuses — a change refetches the canvas and the comments.\n // The first revision of a look (first load, another theme) is only remembered.\n const seenRevisionRef = useRef<{ look: string; revision: string } | null>(null);\n const revision = currentRevisionData?.revision;\n const revisionLook = themeArgument ?? '';\n useEffect(() => {\n if (!revision) return;\n const seen = seenRevisionRef.current;\n seenRevisionRef.current = { look: revisionLook, revision };\n if (!seen || seen.look !== revisionLook || seen.revision === revision) return;\n void refetchCanvas();\n void refetchComments();\n }, [revision, revisionLook, refetchCanvas, refetchComments]);\n // Back on the tab: check right away instead of waiting for the next poll.\n useEffect(() => {\n if (isPageVisible && seenRevisionRef.current) void refetchRevision();\n }, [isPageVisible, refetchRevision]);\n\n // Changed boards (live update or reload): a toast names them with a link to the first one in canvas order.\n const showBoard = useCallback(\n (nodeId: string) => {\n setSelectedBoardId(nodeId);\n setSelectedBoardIds(new Set([nodeId]));\n requestFit([nodeId]);\n },\n [requestFit]\n );\n const layoutOrderRef = useRef(layoutOrder);\n layoutOrderRef.current = layoutOrder;\n // biome-ignore lint/correctness/useExhaustiveDependencies: once per merge (`serial`), not when the callbacks change\n useEffect(() => {\n const changedBoardKeys = shownBoards.changedBoardKeys;\n if (changedBoardKeys.length === 0) return;\n const changedNodeIds = new Set(changedBoardKeys.map(boardKey => boardNodeId(boardKey)));\n const firstNodeId =\n layoutOrderRef.current.find(nodeId => changedNodeIds.has(nodeId)) ?? boardNodeId(changedBoardKeys[0]);\n notify.info(texts.boardsUpdated(changedBoardKeys.length), {\n id: LIVE_UPDATE_TOAST_ID,\n action: { label: texts.showUpdatedBoard, onClick: () => showBoard(firstNodeId) },\n });\n }, [shownBoards.serial]);\n\n // Reload (R): canvas, comments and revision again; only changed boards reload, the view, selection, filters, theme\n // and the focus view stay.\n const shownBoardsRef = useRef(shownBoards);\n shownBoardsRef.current = shownBoards;\n const reloadCanvas = useCallback(async () => {\n // nothing to reload before the canvas query started (the look is still being resolved)\n if (shownBoardsRef.current.source === undefined) return;\n const serialBefore = shownBoardsRef.current.serial;\n const [canvasResult] = await Promise.all([refetchCanvas(), refetchComments(), refetchRevision()]);\n const reloadedBoards = canvasResult.data?.designStudioCanvasView.boards?.elements;\n const shown = shownBoardsRef.current;\n if (!reloadedBoards || (shown.serial !== serialBefore && shown.changedBoardKeys.length > 0)) return;\n // the merge announces changed boards itself; a reload without any says so\n if (mergeRefetchedBoards(shown.boards, reloadedBoards, true).changedBoardKeys.length === 0) {\n notify.info(texts.canvasUpToDate, { id: LIVE_UPDATE_TOAST_ID });\n }\n }, [refetchCanvas, refetchComments, refetchRevision, notify, texts]);\n const reloadCanvasRef = useRef(reloadCanvas);\n reloadCanvasRef.current = reloadCanvas;\n\n const canvasView = useMemo<CanvasViewState>(\n () => ({\n liveBoardIds,\n selectedBoardId,\n selectedBoardIds,\n matchingBoardIds,\n openThreadCounts,\n defaultStatus,\n isHandTool: tool === 'hand',\n onSelectBoard: selectBoard,\n onCopyReference: nodeId => void copyReferences([buildReferenceFor(nodeId)]),\n onOpenBoard: openBoardFromCanvas,\n onZoomToSection: sectionId => requestFit([sectionNodeId(sectionId)]),\n }),\n [\n liveBoardIds,\n selectedBoardId,\n selectedBoardIds,\n matchingBoardIds,\n openThreadCounts,\n defaultStatus,\n tool,\n selectBoard,\n copyReferences,\n buildReferenceFor,\n openBoardFromCanvas,\n requestFit,\n ]\n );\n\n const selectedBoard = selectedBoardId ? (boardsByNodeId.get(selectedBoardId) ?? null) : null;\n const focusedBoard = focusedBoardId ? (boardsByNodeId.get(focusedBoardId) ?? null) : null;\n const threadsOf = (nodeId: string | null): CommentThread[] =>\n nodeId ? buildCommentThreads(commentsByBoardNodeId.get(nodeId) ?? []) : [];\n const boardsWithOpenThreads = layoutOrder.filter(nodeId => openThreadCounts.has(nodeId));\n const codeAtLoadBoard = useMemo(\n () => (codeAtLoad ? findBoardForCode(boards, codeAtLoad) : null),\n [codeAtLoad, boards]\n );\n const initialFitNodeIds = useMemo(() => {\n if (codeAtLoadBoard?.boardKey) return [boardNodeId(codeAtLoadBoard.boardKey)];\n return layout.sections[0] ? [sectionNodeId(layout.sections[0].id)] : [];\n }, [layout, codeAtLoadBoard]);\n const sectionOptions = layout.sections.map(section => ({ value: section.id, label: section.title }));\n const presentedSectionTitle = presentSectionId\n ? (layout.sections.find(section => section.id === presentSectionId)?.title ?? null)\n : null;\n\n const copySelectedRef = useRef(copySelectedReferences);\n copySelectedRef.current = copySelectedReferences;\n // F toggles fullscreen (the application shell hidden), Esc leaves it, C copies the selected boards' references, R reloads\n // the canvas — not while typing or in a dialog.\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement | null;\n if (target && (target.tagName === 'TEXTAREA' || target.tagName === 'INPUT' || target.isContentEditable)) return;\n if (document.querySelector('[role=dialog]') || event.metaKey || event.ctrlKey || event.altKey) return;\n if (event.key === 'f' || event.key === 'F') setIsFullscreen(value => !value);\n else if (event.key === 'c' || event.key === 'C') copySelectedRef.current();\n else if (event.key === 'r' || event.key === 'R') void reloadCanvasRef.current();\n else if (event.key === 'Escape') setIsFullscreen(false);\n };\n window.addEventListener('keydown', onKeyDown);\n return () => window.removeEventListener('keydown', onKeyDown);\n }, []);\n\n const activeFilterCount = (sectionFilter ? 1 : 0) + (statusFilter ? 1 : 0);\n const toolbarStart = (\n <div className={cx(TOOLBAR_GROUP_CLASS, 'min-w-0 pl-3')}>\n <div className=\"min-w-0 pr-1\">\n <h1 className=\"max-w-72 truncate text-sm leading-tight font-semibold\" title={canvasName}>\n {canvasName}\n </h1>\n <p className=\"text-xs leading-tight text-muted-foreground\">\n {boards.length} boards · {layout.sections.length} sections\n {matchingBoardIds !== null ? ` · ${matchingBoardIds.size} matching` : ''}\n </p>\n </div>\n <SearchField\n size=\"sm\"\n value={search}\n onChange={setSearch}\n clearable\n placeholder=\"Search boards…\"\n aria-label=\"Search boards\"\n className=\"w-44\"\n />\n <Popover>\n <PopoverTrigger asChild>\n <button type=\"button\" className={cx(TOOL_BUTTON_CLASS, activeFilterCount > 0 && 'text-brand-emphasis')} aria-label=\"Filters\">\n <ListFilter className=\"size-4\" />\n {activeFilterCount > 0 && (\n <span className=\"absolute -top-1 -right-1 flex size-4 items-center justify-center rounded-full bg-primary text-[10px] font-bold text-primary-foreground\">\n {activeFilterCount}\n </span>\n )}\n </button>\n </PopoverTrigger>\n <PopoverContent align=\"start\" className=\"w-[22rem] space-y-4 p-4\">\n <div className=\"space-y-1.5\">\n <p className=\"text-[12.5px] font-bold text-muted-foreground\">Section</p>\n <Combobox\n size=\"sm\"\n options={[{ value: '', label: 'All sections' }, ...sectionOptions]}\n value={sectionFilter}\n onChange={setSectionFilter}\n placeholder=\"All sections\"\n searchPlaceholder=\"Search sections…\"\n aria-label=\"Section\"\n className=\"w-full\"\n />\n </div>\n <div className=\"space-y-1.5\">\n <p className=\"text-[12.5px] font-bold text-muted-foreground\">Status</p>\n <QuickFilterPills\n options={statusFilterOptions}\n value={statusFilter}\n onChange={setStatusFilter}\n allLabel=\"All\"\n size=\"sm\"\n aria-label=\"Board status\"\n />\n </div>\n {activeFilterCount > 0 && (\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => {\n setSectionFilter('');\n setStatusFilter('');\n }}\n >\n Clear filters\n </Button>\n )}\n </PopoverContent>\n </Popover>\n </div>\n );\n\n const toolbarEnd = (\n <>\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n className={TOOL_BUTTON_CLASS}\n aria-label={texts.reload}\n aria-keyshortcuts=\"r\"\n aria-busy={isFetchingCanvas}\n onClick={() => void reloadCanvas()}\n >\n <RefreshCw className={cx('size-4', isFetchingCanvas && 'animate-spin motion-reduce:animate-none')} />\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{texts.reload}</TooltipContent>\n </Tooltip>\n <Tooltip>\n <TooltipTrigger asChild>\n <span>\n <button\n type=\"button\"\n className={TOOL_BUTTON_CLASS}\n disabled={selectedBoardIds.size === 0}\n aria-label={`Copy reference of ${selectedBoardIds.size} selected board(s) for an agent (C)`}\n onClick={copySelectedReferences}\n >\n <ClipboardCopy className=\"size-4\" />\n {selectedBoardIds.size > 1 && (\n <span className=\"absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-brand px-1 text-[10px] font-bold text-foreground\">\n {selectedBoardIds.size}\n </span>\n )}\n </button>\n </span>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">\n {selectedBoardIds.size === 0 ? 'Select boards to copy their reference' : 'Copy reference for an agent (C)'}\n </TooltipContent>\n </Tooltip>\n {hasThemes && themes.length > 0 && (\n <Combobox\n shape=\"pill\"\n size=\"sm\"\n options={themeOptions}\n value={themeId ?? ''}\n onChange={value => setCanvasStateValue('theme', value === (referenceThemeId ?? '') ? '' : value)}\n isLoading={isLoadingThemes}\n placeholder=\"Theme\"\n searchPlaceholder=\"Search themes…\"\n aria-label=\"Theme\"\n className=\"w-44\"\n />\n )}\n {isRendererEnabled && missingThumbnailCount > 0 && renderStatus !== null && renderStatus !== 'DONE' ? (\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n disabled={renderStatus !== 'FAILED' || !writesAllowed}\n className=\"flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-tint px-3 text-xs font-semibold text-muted-foreground transition-colors enabled:hover:bg-tint-strong enabled:hover:text-foreground\"\n onClick={() => fileRenderRequest(true)}\n >\n {renderStatus === 'FAILED' ? (\n <ImageDown className=\"size-4\" aria-hidden />\n ) : (\n <LoaderCircle className=\"size-4 animate-spin motion-reduce:animate-none\" aria-hidden />\n )}\n {renderStatus === 'FAILED'\n ? texts.thumbnailsFailed\n : renderStatus === 'WAITING_FOR_RENDERER'\n ? texts.thumbnailsWaitingForRenderer(shownThemeLabel)\n : texts.thumbnailsRendering(shownThemeLabel)}{' '}\n · {Math.max(0, shownBoardList.length - missingThumbnailCount)}/{shownBoardList.length}\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\" className=\"max-w-sm\">\n {texts.thumbnailsMissing(missingThumbnailCount)}\n {canvas?.renderRequestError ? ` ${texts.thumbnailsLastError(canvas.renderRequestError)}` : ''}\n </TooltipContent>\n </Tooltip>\n ) : null}\n {hasThemes && themes.length > 0 && (\n <Tooltip>\n <TooltipTrigger asChild>\n <span>\n <button\n type=\"button\"\n className={TOOL_BUTTON_CLASS}\n disabled={!supportsDark}\n aria-label={effectiveMode === 'dark' ? 'Light theme' : 'Dark theme'}\n aria-pressed={effectiveMode === 'dark'}\n onClick={() => {\n const nextMode: ThemeMode = effectiveMode === 'dark' ? 'light' : 'dark';\n setCanvasStateValue('mode', nextMode === defaultMode ? '' : nextMode);\n }}\n >\n {effectiveMode === 'dark' ? <Sun className=\"size-4\" /> : <Moon className=\"size-4\" />}\n </button>\n </span>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">\n {supportsDark ? (effectiveMode === 'dark' ? 'Light theme' : 'Dark theme') : texts.themeWithoutDarkMode}\n </TooltipContent>\n </Tooltip>\n )}\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n className={cx(TOOL_BUTTON_CLASS, isCommentsPanelOpen && 'bg-brand-light text-brand-emphasis')}\n aria-label={isCommentsPanelOpen ? 'Hide comments' : 'Show comments'}\n aria-pressed={isCommentsPanelOpen}\n onClick={toggleCommentsPanel}\n >\n {isCommentsPanelOpen ? <PanelRightClose className=\"size-4\" /> : <PanelRightOpen className=\"size-4\" />}\n {openThreadTotal > 0 && (\n <span className=\"absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-bold text-primary-foreground\">\n {openThreadTotal}\n </span>\n )}\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{isCommentsPanelOpen ? 'Hide comments' : 'Show comments'}</TooltipContent>\n </Tooltip>\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n className={cx(TOOL_BUTTON_CLASS, isFullscreen && 'bg-brand-light text-brand-emphasis')}\n aria-label={isFullscreen ? 'Exit fullscreen (F)' : 'Fullscreen (F)'}\n aria-pressed={isFullscreen}\n onClick={() => setIsFullscreen(value => !value)}\n >\n {isFullscreen ? <Minimize className=\"size-4\" /> : <Maximize className=\"size-4\" />}\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{isFullscreen ? 'Exit fullscreen (F)' : 'Fullscreen (F)'}</TooltipContent>\n </Tooltip>\n </>\n );\n\n return (\n <div\n data-page-frame\n data-canvas-fullscreen={isFullscreen ? '' : undefined}\n className={cx(\n // on the shell's cloud background (transparent); fullscreen covers the shell with the flat sky colour\n 'relative flex h-[calc(100dvh_-_var(--nav-h))] min-h-[560px] flex-col lg:flex-row',\n isFullscreen && 'fixed inset-0 z-40 h-dvh bg-background'\n )}\n >\n {error && (\n <div className=\"p-6\">\n <StatusCallout\n tone=\"destructive\"\n title=\"The canvas could not be loaded\"\n description={normalizeDddError(error, 'Request failed').message}\n />\n </div>\n )}\n {(isLoading || (!isLookResolved && !canvas)) && <Skeleton className=\"m-6 flex-1 rounded-2xl\" />}\n {canvas && (\n <CanvasViewContext.Provider value={canvasView}>\n <div ref={canvasAreaRef} className=\"relative min-h-[480px] min-w-0 flex-1\">\n {canvasAspectRatio !== null && (\n <DesignCanvasFlow\n layout={layout}\n boardsByNodeId={boardsByNodeId}\n fitRequest={fitRequest}\n initialFitNodeIds={initialFitNodeIds}\n initialViewport={initialViewport}\n onViewportCommit={commitViewport}\n tool={tool}\n onToolChange={setTool}\n liveMinRatio={\n !isRendererEnabled || missingThumbnailCount > 0\n ? LIVE_MIN_RENDERED_WIDTH_RATIO_WITHOUT_THUMBNAILS\n : LIVE_MIN_RENDERED_WIDTH_RATIO\n }\n onLiveBoardIdsChange={setLiveBoardIds}\n onVisibleBoardIdsChange={rememberVisibleBoardIds}\n onPaneClick={clearSelection}\n onMarqueeSelect={selectBoards}\n onPresentSection={presentSection}\n toolbarStart={toolbarStart}\n toolbarEnd={toolbarEnd}\n selectedNodeId={selectedBoardId}\n />\n )}\n </div>\n {isCommentsPanelOpen && (\n <aside className=\"surface-glass-strong m-3 shrink-0 overflow-y-auto rounded-3xl p-5 ring-1 ring-foreground/5 lg:my-3 lg:ml-0 lg:w-[380px]\">\n {selectedBoard ? (\n <SelectedBoardPanel\n key={selectedBoard.boardKey ?? ''}\n projectKey={projectKey}\n canvasKey={canvasKey}\n board={selectedBoard}\n statuses={statuses}\n sectionTitle={sectionTitleByKey.get(selectedBoard.sectionKey ?? '') ?? null}\n threads={threadsOf(selectedBoardId)}\n writesAllowed={writesAllowed}\n onOpen={() => selectedBoardId && openBoardFromCanvas(selectedBoardId)}\n onCopyLink={selectedBoard.code ? () => void copyBoardLink(selectedBoard) : undefined}\n onStatusChanged={status => selectedBoardId && setBoardStatus(selectedBoardId, status)}\n onCopyThreadReference={copyThreadReference}\n />\n ) : (\n <div className=\"space-y-4\">\n <div>\n <h2 className=\"text-title-card font-semibold\">Open comments</h2>\n <p className=\"text-sm text-muted-foreground\">\n Click a board to see its status and comments, double-click to open it large.\n </p>\n </div>\n {boardsWithOpenThreads.length === 0 && (\n <p className=\"text-sm text-muted-foreground\">No open comments on this canvas.</p>\n )}\n <ul className=\"space-y-1\">\n {boardsWithOpenThreads.map(nodeId => (\n <li key={nodeId}>\n <button\n type=\"button\"\n className=\"flex w-full items-center justify-between gap-2 rounded-[10px] px-3 py-2 text-left text-sm transition-colors hover:bg-tint\"\n onClick={() => {\n setSelectedBoardId(nodeId);\n requestFit([nodeId]);\n }}\n >\n <span className=\"truncate\">{boardsByNodeId.get(nodeId)?.title}</span>\n <span className=\"inline-flex shrink-0 items-center gap-1 text-xs font-semibold text-muted-foreground\">\n <MessageSquare className=\"size-3.5\" aria-hidden /> {openThreadCounts.get(nodeId)}\n </span>\n </button>\n </li>\n ))}\n </ul>\n </div>\n )}\n </aside>\n )}\n </CanvasViewContext.Provider>\n )}\n <BoardFocusView\n projectKey={projectKey}\n canvasKey={canvasKey}\n board={focusedBoard}\n statuses={statuses}\n sectionTitle={focusedBoard ? (sectionTitleByKey.get(focusedBoard.sectionKey ?? '') ?? null) : null}\n position={{\n index: focusedBoardId ? navigationOrder.indexOf(focusedBoardId) + 1 : 0,\n count: navigationOrder.length,\n }}\n threads={threadsOf(focusedBoardId)}\n writesAllowed={writesAllowed}\n presentLabel={presentedSectionTitle}\n onClose={closeFocus}\n onPrevious={() => stepFocus(-1)}\n onNext={() => stepFocus(1)}\n onStatusChanged={status => focusedBoardId && setBoardStatus(focusedBoardId, status)}\n onCopyReference={({ region, note }) =>\n focusedBoardId && void copyReferences([buildReferenceFor(focusedBoardId, { region, note })])\n }\n onCopyThreadReference={copyThreadReference}\n />\n </div>\n );\n};\n","'use client';\n\nimport { normalizeDddError } from '@mgamadeus/ddd-web/api';\nimport { Bot, CheckCircle2, ClipboardCopy, Flag, History, Hourglass, MapPin, RotateCcw, Trash2 } from 'lucide-react';\nimport { useState } from 'react';\n\nimport type { DesignStudioBoardView, DesignStudioComment } from '../api/types';\nimport { useDesignStudio } from '../provider/DesignStudioProvider';\nimport { cx } from '../utils/cx';\n\n/** A pin position on a board in board pixels. */\nexport interface BoardPin {\n x: number;\n y: number;\n}\n\n/** Thread roots of a board with their replies, oldest first. */\nexport interface CommentThread {\n root: DesignStudioComment;\n replies: DesignStudioComment[];\n /** 1-based number of a pinned root (shown on the board), null for a board-level comment. */\n pinNumber: number | null;\n}\n\n/** Groups a board's comments into threads by `parentDesignStudioCommentId` (null = a thread root). */\nexport const buildCommentThreads = (comments: DesignStudioComment[]): CommentThread[] => {\n const repliesByRootId = new Map<number, DesignStudioComment[]>();\n for (const comment of comments) {\n if (comment.parentDesignStudioCommentId != null) {\n const replies = repliesByRootId.get(comment.parentDesignStudioCommentId) ?? [];\n replies.push(comment);\n repliesByRootId.set(comment.parentDesignStudioCommentId, replies);\n }\n }\n let pinNumber = 0;\n return comments\n .filter(comment => comment.parentDesignStudioCommentId == null)\n .map(root => ({\n root,\n replies: repliesByRootId.get(Number(root.id)) ?? [],\n pinNumber: root.x != null && root.y != null ? ++pinNumber : null,\n }));\n};\n\nconst errorMessage = (error: unknown) => normalizeDddError(error, 'Request failed').message;\n\ninterface CommentLineProps {\n comment: DesignStudioComment;\n isOwn: boolean;\n writesAllowed: boolean;\n}\n\nconst CommentLine = ({ comment, isOwn, writesAllowed }: CommentLineProps) => {\n const { api, components, formatDateTime, notify } = useDesignStudio();\n const { Button } = components;\n const [deleteComment, { isLoading: isDeleting }] = api.useDeleteCommentMutation();\n return (\n <div className=\"space-y-1\">\n <p className=\"flex items-center gap-1.5 text-xs text-muted-foreground\">\n {comment.authorKind === 'AGENT' && <Bot className=\"size-3.5 text-brand-emphasis\" aria-label=\"Agent\" />}\n <span className=\"font-semibold text-foreground\">{comment.authorName ?? 'Unknown'}</span>\n <span>· {formatDateTime(comment.changeHistory?.createdTime)}</span>\n {isOwn && (\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"ml-auto size-6\"\n aria-label=\"Delete comment\"\n disabled={!writesAllowed || isDeleting}\n onClick={() =>\n deleteComment({ designStudioCommentId: Number(comment.id) })\n .unwrap()\n .catch(error => notify.error(errorMessage(error)))\n }\n >\n <Trash2 className=\"size-3.5\" />\n </Button>\n )}\n </p>\n <p className=\"text-sm whitespace-pre-wrap break-words\">{comment.text}</p>\n </div>\n );\n};\n\ninterface ThreadCardProps {\n thread: CommentThread;\n /** \"Copy for agent\": the board reference with this thread (pin + texts). */\n onCopyReference: (thread: CommentThread) => void;\n isHighlighted: boolean;\n onHighlight: () => void;\n authAccountId: number | null;\n writesAllowed: boolean;\n /** The board file is another version than the one the thread was written on. */\n hasBoardChangedSince: boolean;\n /** The thread is deleted soon unless something happens in it (\"Keep\" postpones that). */\n isExpiring: boolean;\n}\n\nconst ThreadCard = ({\n thread,\n onCopyReference,\n isHighlighted,\n onHighlight,\n authAccountId,\n writesAllowed,\n hasBoardChangedSince,\n isExpiring,\n}: ThreadCardProps) => {\n const { root, replies, pinNumber } = thread;\n const [replyText, setReplyText] = useState('');\n const { api, components, notify } = useDesignStudio();\n const { Badge, Button, Textarea } = components;\n const [createReply, { isLoading: isReplying }] = api.useReplyToCommentMutation();\n const [resolveThread, { isLoading: isResolving }] = api.useResolveCommentMutation();\n const [reopenThread, { isLoading: isReopening }] = api.useReopenCommentMutation();\n const [patchComment, { isLoading: isPatching }] = api.usePatchCommentMutation();\n const [keepThread, { isLoading: isKeeping }] = api.useKeepCommentMutation();\n const designStudioCommentId = Number(root.id);\n\n const sendReply = async () => {\n try {\n await createReply({\n designStudioCommentId,\n body: { text: replyText },\n }).unwrap();\n setReplyText('');\n } catch (error) {\n notify.error(errorMessage(error));\n }\n };\n\n return (\n // biome-ignore lint/a11y/useSemanticElements: an article that highlights its pin on hover / focus, not a control\n <article\n className={cx(\n 'space-y-3 rounded-2xl bg-card p-4 shadow-surface-raised ring-1 ring-foreground/5',\n root.isResolved && 'opacity-70',\n isHighlighted && 'ring-2 ring-brand'\n )}\n onMouseEnter={onHighlight}\n onFocus={onHighlight}\n role=\"group\"\n aria-label={`Comment thread${pinNumber ? ` ${pinNumber}` : ''}`}\n >\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {pinNumber !== null ? (\n <Badge className=\"bg-primary text-primary-foreground\">\n <MapPin aria-hidden /> {pinNumber}\n </Badge>\n ) : (\n <Badge variant=\"outline\">Board</Badge>\n )}\n {root.isDecision && (\n <Badge variant=\"outline\" className=\"border-transparent bg-success/15 text-success\">\n <Flag aria-hidden /> Decision\n </Badge>\n )}\n {root.isResolved && (\n <Badge variant=\"outline\" className=\"border-transparent bg-tint text-muted-foreground\">\n Resolved{root.resolvedByName ? ` by ${root.resolvedByName}` : ''}\n </Badge>\n )}\n {hasBoardChangedSince && (\n <Badge\n variant=\"outline\"\n className=\"border-transparent bg-warning/15 text-warning\"\n title=\"The board file is another version than the one this thread was written on\"\n >\n <History aria-hidden /> Board changed since\n </Badge>\n )}\n {isExpiring && (\n <Badge\n variant=\"outline\"\n className=\"border-transparent bg-tint text-muted-foreground\"\n title=\"Idle threads are deleted; “Keep” or any reply postpones that\"\n >\n <Hourglass aria-hidden /> Expires soon\n </Badge>\n )}\n </div>\n <CommentLine comment={root} isOwn={authAccountId !== null && root.authorAccountId === authAccountId} writesAllowed={writesAllowed} />\n {replies.map(reply => (\n <div key={String(reply.id)} className=\"border-l-2 border-border pl-3\">\n <CommentLine\n comment={reply}\n isOwn={authAccountId !== null && reply.authorAccountId === authAccountId}\n writesAllowed={writesAllowed}\n />\n </div>\n ))}\n <Textarea\n value={replyText}\n onChange={event => setReplyText(event.target.value)}\n placeholder=\"Reply…\"\n rows={2}\n aria-label=\"Reply\"\n disabled={!writesAllowed}\n />\n <div className=\"flex flex-wrap items-center gap-2\">\n <Button size=\"sm\" variant=\"outline\" disabled={!writesAllowed || !replyText.trim() || isReplying} onClick={sendReply}>\n Reply\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={!writesAllowed || isPatching}\n aria-pressed={Boolean(root.isDecision)}\n onClick={() =>\n patchComment({\n designStudioCommentId,\n body: { isDecision: !root.isDecision },\n })\n .unwrap()\n .catch(error => notify.error(errorMessage(error)))\n }\n >\n <Flag /> {root.isDecision ? 'Not a decision' : 'Decision'}\n </Button>\n <Button size=\"sm\" variant=\"outline\" onClick={() => onCopyReference(thread)} aria-label=\"Copy for agent\">\n <ClipboardCopy /> Copy for agent\n </Button>\n {isExpiring && (\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={!writesAllowed || isKeeping}\n onClick={() =>\n keepThread({ designStudioCommentId })\n .unwrap()\n .catch(error => notify.error(errorMessage(error)))\n }\n >\n Keep\n </Button>\n )}\n {root.isResolved ? (\n <Button\n size=\"sm\"\n variant=\"outline\"\n className=\"ml-auto\"\n disabled={!writesAllowed || isReopening}\n onClick={() =>\n reopenThread({ designStudioCommentId })\n .unwrap()\n .catch(error => notify.error(errorMessage(error)))\n }\n >\n <RotateCcw /> Reopen\n </Button>\n ) : (\n <Button\n size=\"sm\"\n variant=\"outline\"\n className=\"ml-auto\"\n disabled={!writesAllowed || isResolving}\n onClick={async () => {\n try {\n await resolveThread({\n designStudioCommentId,\n body: { replyText: replyText.trim() ? replyText : null },\n }).unwrap();\n setReplyText('');\n } catch (error) {\n notify.error(errorMessage(error));\n }\n }}\n >\n <CheckCircle2 /> Resolve\n </Button>\n )}\n </div>\n </article>\n );\n};\n\nexport interface BoardCommentsProps {\n projectKey: string;\n canvasKey: string;\n board: DesignStudioBoardView;\n threads: CommentThread[];\n /** A pin placed on the board in focus view, waiting for its comment. */\n pendingPin: BoardPin | null;\n onClearPendingPin: () => void;\n highlightedCommentId: number | null;\n onHighlightComment: (designStudioCommentId: number | null) => void;\n writesAllowed: boolean;\n /** Show resolved threads too. */\n showResolved: boolean;\n onShowResolvedChange: (showResolved: boolean) => void;\n /** How to pin a comment from where the panel is shown (placeholder of the new-comment field). */\n pinHint: string;\n /** \"Copy for agent\" on a thread. */\n onCopyThreadReference: (thread: CommentThread) => void;\n}\n\n/** Comments of one board: new thread (on the board or at a placed pin), threads with replies, resolve, decision. */\nexport const BoardComments = ({\n projectKey,\n canvasKey,\n board,\n threads,\n pendingPin,\n onClearPendingPin,\n highlightedCommentId,\n onHighlightComment,\n writesAllowed,\n showResolved,\n onShowResolvedChange,\n pinHint,\n onCopyThreadReference,\n}: BoardCommentsProps) => {\n const [text, setText] = useState('');\n const [isDecision, setIsDecision] = useState(false);\n const { api, components, notify, useCurrentAccountId } = useDesignStudio();\n const { Button, Checkbox, Label, Textarea } = components;\n const [createComment, { isLoading }] = api.useCreateCommentMutation();\n const authAccountId = useCurrentAccountId();\n // threads that are deleted soon unless something happens in them (all canvases; one cached request)\n const { data: expiringData } = api.useExpiringCommentsQuery();\n const expiringCommentIds = new Set(\n (expiringData?.designStudioComments.elements ?? []).map(comment => Number(comment.id))\n );\n const visibleThreads = showResolved ? threads : threads.filter(thread => !thread.root.isResolved);\n const resolvedCount = threads.length - threads.filter(thread => !thread.root.isResolved).length;\n\n const addComment = async () => {\n try {\n await createComment({\n projectKey,\n canvasKey,\n boardKey: board.boardKey ?? '',\n body: {\n text,\n x: pendingPin?.x ?? null,\n y: pendingPin?.y ?? null,\n isDecision,\n },\n }).unwrap();\n setText('');\n setIsDecision(false);\n onClearPendingPin();\n } catch (error) {\n notify.error(errorMessage(error));\n }\n };\n\n return (\n <div className=\"space-y-4\">\n <div className=\"space-y-2\">\n <Label htmlFor=\"design-comment-text\" className=\"flex items-center gap-1.5\">\n {pendingPin ? (\n <>\n <MapPin className=\"size-4 text-brand-emphasis\" aria-hidden /> Comment at the placed pin\n </>\n ) : (\n 'New comment on the board'\n )}\n </Label>\n <Textarea\n id=\"design-comment-text\"\n value={text}\n onChange={event => setText(event.target.value)}\n placeholder={pendingPin ? 'What should change here?' : `Comment… (${pinHint})`}\n rows={3}\n disabled={!writesAllowed}\n />\n <div className=\"flex flex-wrap items-center gap-3\">\n <div className=\"flex items-center gap-2\">\n <Checkbox\n id=\"design-comment-decision\"\n checked={isDecision}\n onCheckedChange={checked => setIsDecision(checked === true)}\n disabled={!writesAllowed}\n />\n <Label htmlFor=\"design-comment-decision\" className=\"font-normal\">\n Decision\n </Label>\n </div>\n {pendingPin && (\n <Button size=\"sm\" variant=\"ghost\" onClick={onClearPendingPin}>\n Remove pin\n </Button>\n )}\n <Button size=\"sm\" className=\"ml-auto\" disabled={!writesAllowed || !text.trim() || isLoading || !board.boardKey} onClick={addComment}>\n Comment\n </Button>\n </div>\n </div>\n {resolvedCount > 0 && (\n <div className=\"flex items-center gap-2\">\n <Checkbox\n id=\"design-comment-show-resolved\"\n checked={showResolved}\n onCheckedChange={checked => onShowResolvedChange(checked === true)}\n />\n <Label htmlFor=\"design-comment-show-resolved\" className=\"font-normal text-muted-foreground\">\n Show {resolvedCount} resolved\n </Label>\n </div>\n )}\n {visibleThreads.length === 0 && <p className=\"text-sm text-muted-foreground\">No open comments on this board.</p>}\n {visibleThreads.map(thread => (\n <ThreadCard\n key={String(thread.root.id)}\n thread={thread}\n onCopyReference={onCopyThreadReference}\n isHighlighted={highlightedCommentId === Number(thread.root.id)}\n onHighlight={() => onHighlightComment(Number(thread.root.id))}\n authAccountId={authAccountId}\n writesAllowed={writesAllowed}\n hasBoardChangedSince={\n Boolean(thread.root.contentHash && board.contentHash) && thread.root.contentHash !== board.contentHash\n }\n isExpiring={expiringCommentIds.has(Number(thread.root.id))}\n />\n ))}\n </div>\n );\n};\n","'use client';\n\nimport { ChevronLeft, ChevronRight, ClipboardCopy, MapPin, MapPinPlus, SquareDashedMousePointer, X } from 'lucide-react';\nimport { type MouseEvent, type PointerEvent, useEffect, useState } from 'react';\n\nimport type { DesignStudioBoardView } from '../api/types';\nimport { useDesignStudio, useDesignStudioTexts } from '../provider/DesignStudioProvider';\nimport { cx } from '../utils/cx';\nimport { BoardComments, type BoardPin, type CommentThread } from './BoardComments';\nimport { designContentUrl } from './BoardNode';\nimport { shortContentHash } from './canvasLiveUpdate';\nimport type { BoardRegion } from './designReference';\nimport { BoardStatusChips } from './BoardStatusChips';\nimport { useStableContentUrl } from './stableContentUrl';\nimport { useCheckedContentUrl } from './useCheckedContentUrl';\n\n/** Visible height of the device screen (iPhone 15 point height); taller boards scroll inside the device. */\nconst DEVICE_SCREEN_HEIGHT = 844;\n\nexport interface BoardFocusViewProps {\n projectKey: string;\n canvasKey: string;\n board: DesignStudioBoardView | null;\n /** The configured status keys in display order. */\n statuses: readonly string[];\n sectionTitle: string | null;\n /** Position of the board in the navigation order (1-based) and the count. */\n position: { index: number; count: number };\n threads: CommentThread[];\n writesAllowed: boolean;\n /** Present mode: label of the section being presented. */\n presentLabel?: string | null;\n onClose: () => void;\n onPrevious: () => void;\n onNext: () => void;\n onStatusChanged: (status: string) => void;\n /** \"Copy reference\" (button / C): this board, with the marked region and the note when set. */\n onCopyReference: (options: { region: BoardRegion | null; note: string }) => void;\n /** \"Copy for agent\" on a comment thread. */\n onCopyThreadReference: (thread: CommentThread) => void;\n}\n\n/**\n * One board large: the live sandboxed HTML at its native width in a device frame, scrolling through its full length;\n * prev / next through the canvas order (buttons and ← / →); comment pins on the board (“Add pin”, then a click on the\n * spot) and the board's comment threads and status beside it.\n */\nexport const BoardFocusView = ({\n projectKey,\n canvasKey,\n board,\n statuses,\n sectionTitle,\n position,\n threads,\n writesAllowed,\n presentLabel,\n onClose,\n onPrevious,\n onNext,\n onStatusChanged,\n onCopyReference,\n onCopyThreadReference,\n}: BoardFocusViewProps) => {\n const { apiBaseUrl, components } = useDesignStudio();\n const texts = useDesignStudioTexts();\n const { Button, Dialog, DialogContent, DialogDescription, DialogTitle, Textarea } = components;\n const [isPlacingPin, setIsPlacingPin] = useState(false);\n const [pendingPin, setPendingPin] = useState<BoardPin | null>(null);\n const [highlightedCommentId, setHighlightedCommentId] = useState<number | null>(null);\n const [showResolved, setShowResolved] = useState(false);\n // region reference: a rectangle dragged on the board (board pixels) + a note, both for \"Copy reference\"\n const [isMarkingRegion, setIsMarkingRegion] = useState(false);\n const [region, setRegion] = useState<BoardRegion | null>(null);\n const [regionDraft, setRegionDraft] = useState<{ startX: number; startY: number; x: number; y: number } | null>(null);\n const [referenceNote, setReferenceNote] = useState('');\n const [isRegionFlashing, setIsRegionFlashing] = useState(false);\n const boardKey = board?.boardKey ?? null;\n\n // A new board starts without a pending pin.\n useEffect(() => {\n if (boardKey === null) return;\n setPendingPin(null);\n setIsPlacingPin(false);\n setHighlightedCommentId(null);\n setRegion(null);\n setRegionDraft(null);\n setIsMarkingRegion(false);\n setReferenceNote('');\n }, [boardKey]);\n\n useEffect(() => {\n if (!board) return;\n const onKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement | null;\n if (target && (target.tagName === 'TEXTAREA' || target.tagName === 'INPUT' || target.isContentEditable)) return;\n if (event.key === 'c' || event.key === 'C') {\n if (event.metaKey || event.ctrlKey || event.altKey) return;\n event.preventDefault();\n copyReference();\n return;\n }\n if (event.key === 'ArrowLeft') {\n event.preventDefault();\n onPrevious();\n } else if (event.key === 'ArrowRight') {\n event.preventDefault();\n onNext();\n }\n };\n window.addEventListener('keydown', onKeyDown);\n return () => window.removeEventListener('keydown', onKeyDown);\n });\n\n const width = board?.width ?? 390;\n const height = board?.height ?? 844;\n // the iframe mounts only after the HTML answered 2xx: an error keeps the thumbnail, retried in the background\n // stable per content: a rotated content token does not reload the open board\n const htmlUrl = useCheckedContentUrl(useStableContentUrl(designContentUrl(apiBaseUrl, board?.htmlUrl), true));\n const thumbnailUrl = useStableContentUrl(designContentUrl(apiBaseUrl, board?.thumbnailUrl), true);\n const pinnedThreads = threads.filter(thread => thread.pinNumber !== null && (showResolved || !thread.root.isResolved));\n\n const copyReference = () => {\n onCopyReference({ region, note: referenceNote });\n if (region) {\n setIsRegionFlashing(true);\n window.setTimeout(() => setIsRegionFlashing(false), 1200);\n }\n };\n\n const boardPointOf = (event: PointerEvent<HTMLButtonElement>) => {\n const rect = event.currentTarget.getBoundingClientRect();\n return {\n x: Math.max(0, Math.min(width, event.clientX - rect.left)),\n y: Math.max(0, Math.min(height, event.clientY - rect.top)),\n };\n };\n const startRegion = (event: PointerEvent<HTMLButtonElement>) => {\n event.currentTarget.setPointerCapture(event.pointerId);\n const point = boardPointOf(event);\n setRegionDraft({ startX: point.x, startY: point.y, x: point.x, y: point.y });\n };\n const moveRegion = (event: PointerEvent<HTMLButtonElement>) => {\n if (!regionDraft) return;\n const point = boardPointOf(event);\n setRegionDraft({ ...regionDraft, x: point.x, y: point.y });\n };\n const endRegion = () => {\n if (!regionDraft) return;\n const marked = {\n x: Math.min(regionDraft.startX, regionDraft.x),\n y: Math.min(regionDraft.startY, regionDraft.y),\n width: Math.abs(regionDraft.x - regionDraft.startX),\n height: Math.abs(regionDraft.y - regionDraft.startY),\n };\n setRegionDraft(null);\n if (marked.width >= 4 && marked.height >= 4) {\n setRegion(marked);\n setIsMarkingRegion(false);\n }\n };\n const shownRegion: BoardRegion | null = regionDraft\n ? {\n x: Math.min(regionDraft.startX, regionDraft.x),\n y: Math.min(regionDraft.startY, regionDraft.y),\n width: Math.abs(regionDraft.x - regionDraft.startX),\n height: Math.abs(regionDraft.y - regionDraft.startY),\n }\n : region;\n\n const placePin = (event: MouseEvent<HTMLButtonElement>) => {\n const rect = event.currentTarget.getBoundingClientRect();\n setPendingPin({ x: Math.round(event.clientX - rect.left), y: Math.round(event.clientY - rect.top) });\n setIsPlacingPin(false);\n };\n\n return (\n <Dialog open={board !== null} onOpenChange={open => !open && onClose()}>\n <DialogContent\n showCloseButton={false}\n className=\"flex h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] max-w-none flex-col gap-0 overflow-hidden rounded-3xl p-0 sm:max-w-none\"\n >\n {board && (\n <>\n <header className=\"flex flex-wrap items-center gap-3 border-b border-border px-5 py-3\">\n <div className=\"min-w-0 flex-1\">\n <DialogTitle className=\"truncate text-lg font-semibold\">{board.title}</DialogTitle>\n <DialogDescription className=\"truncate text-xs\">\n {presentLabel ? 'Present · ' : ''}\n {sectionTitle ? `${sectionTitle} · ` : ''}\n {board.boardKey} · {shortContentHash(board.contentHash)} · {position.index} / {position.count}\n </DialogDescription>\n </div>\n <BoardStatusChips\n projectKey={projectKey}\n canvasKey={canvasKey}\n board={board}\n statuses={statuses}\n writesAllowed={writesAllowed}\n onStatusChanged={onStatusChanged}\n />\n <div className=\"flex items-center gap-1\">\n <Button variant=\"outline\" size=\"icon\" aria-label=\"Previous board (←)\" onClick={onPrevious}>\n <ChevronLeft />\n </Button>\n <Button variant=\"outline\" size=\"icon\" aria-label=\"Next board (→)\" onClick={onNext}>\n <ChevronRight />\n </Button>\n <Button variant=\"ghost\" size=\"icon\" aria-label=\"Close focus view\" onClick={onClose}>\n <X />\n </Button>\n </div>\n </header>\n <div className=\"flex min-h-0 flex-1 flex-col lg:flex-row\">\n <div className=\"flex min-h-0 flex-1 items-start justify-center overflow-auto bg-tint p-6\">\n <div className=\"rounded-[56px] bg-foreground p-3 shadow-surface-raised\">\n <div\n className=\"relative overflow-y-auto overflow-x-hidden rounded-[44px] bg-card\"\n style={{ width, height: Math.min(height, DEVICE_SCREEN_HEIGHT) }}\n >\n <div className=\"relative\" style={{ width, height }}>\n {thumbnailUrl && (\n // biome-ignore lint/performance/noImgElement: API thumbnail under the live board while it loads\n <img\n src={thumbnailUrl}\n alt=\"\"\n width={width}\n height={height}\n className=\"pointer-events-none absolute inset-0 select-none\"\n />\n )}\n {htmlUrl && (\n <iframe\n key={htmlUrl}\n src={htmlUrl}\n title={board.title ?? board.boardKey ?? 'Board'}\n sandbox=\"\"\n referrerPolicy=\"no-referrer\"\n width={width}\n height={height}\n className=\"absolute inset-0 border-0 bg-transparent\"\n />\n )}\n {isPlacingPin && (\n <button\n type=\"button\"\n aria-label=\"Place the pin here\"\n className=\"absolute inset-0 z-10 cursor-crosshair bg-brand/10\"\n onClick={placePin}\n />\n )}\n {isMarkingRegion && (\n <button\n type=\"button\"\n aria-label=\"Drag a rectangle to mark a region of the board\"\n className=\"absolute inset-0 z-10 cursor-crosshair touch-none bg-brand/5\"\n onPointerDown={startRegion}\n onPointerMove={moveRegion}\n onPointerUp={endRegion}\n />\n )}\n {shownRegion && (\n <span\n aria-hidden\n className={cx(\n 'pointer-events-none absolute z-20 rounded-md border-2 border-dashed border-brand bg-brand/10 transition-shadow motion-reduce:transition-none',\n isRegionFlashing && 'shadow-[0_0_0_6px_var(--brand)]'\n )}\n style={{\n left: shownRegion.x,\n top: shownRegion.y,\n width: shownRegion.width,\n height: shownRegion.height,\n }}\n />\n )}\n {pinnedThreads.map(thread => (\n <button\n key={String(thread.root.id)}\n type=\"button\"\n aria-label={`Comment ${thread.pinNumber}`}\n onMouseEnter={() => setHighlightedCommentId(Number(thread.root.id))}\n onClick={() => setHighlightedCommentId(Number(thread.root.id))}\n className={cx(\n 'absolute z-20 flex size-7 -translate-x-1/2 -translate-y-full items-center justify-center rounded-full rounded-bl-none text-xs font-bold shadow-surface-raised ring-2 ring-card',\n thread.root.isResolved ? 'bg-muted text-muted-foreground' : 'bg-primary text-primary-foreground',\n highlightedCommentId === Number(thread.root.id) && 'ring-brand scale-110'\n )}\n style={{ left: thread.root.x ?? 0, top: thread.root.y ?? 0 }}\n >\n {thread.pinNumber}\n </button>\n ))}\n {pendingPin && (\n <span\n className=\"absolute z-20 flex size-7 -translate-x-1/2 -translate-y-full items-center justify-center rounded-full rounded-bl-none bg-brand text-card shadow-surface-raised ring-2 ring-card\"\n style={{ left: pendingPin.x, top: pendingPin.y }}\n aria-hidden\n >\n <MapPin className=\"size-4\" />\n </span>\n )}\n </div>\n </div>\n </div>\n </div>\n <aside className=\"flex min-h-0 w-full flex-col border-t border-border lg:w-[400px] lg:border-t-0 lg:border-l\">\n <div className=\"space-y-2 border-b border-border px-5 py-4\">\n <p className=\"text-sm font-semibold\">Reference for an agent</p>\n <div className=\"flex flex-wrap items-center gap-2\">\n <Button\n variant={isMarkingRegion ? 'default' : 'outline'}\n size=\"sm\"\n aria-pressed={isMarkingRegion}\n onClick={() => setIsMarkingRegion(marking => !marking)}\n >\n <SquareDashedMousePointer /> {isMarkingRegion ? 'Drag on the board…' : 'Mark region'}\n </Button>\n {region && (\n <Button variant=\"ghost\" size=\"sm\" onClick={() => setRegion(null)}>\n Clear region\n </Button>\n )}\n <Button variant=\"outline\" size=\"sm\" className=\"ml-auto\" onClick={copyReference}>\n <ClipboardCopy /> Copy reference\n </Button>\n </div>\n {region && (\n <p className=\"text-xs text-muted-foreground tabular-nums\">\n Region {Math.round(region.x)},{Math.round(region.y)} · {Math.round(region.width)} ×{' '}\n {Math.round(region.height)} px\n </p>\n )}\n <Textarea\n value={referenceNote}\n onChange={event => setReferenceNote(event.target.value)}\n placeholder={texts.referenceNotePlaceholder}\n rows={2}\n aria-label=\"Note for the reference\"\n />\n </div>\n <div className=\"flex items-center gap-2 px-5 pt-4\">\n <Button\n variant={isPlacingPin ? 'default' : 'outline'}\n size=\"sm\"\n disabled={!writesAllowed}\n aria-pressed={isPlacingPin}\n onClick={() => setIsPlacingPin(placing => !placing)}\n >\n <MapPinPlus /> {isPlacingPin ? 'Click on the board…' : 'Add pin'}\n </Button>\n <span className=\"text-xs text-muted-foreground\">\n {threads.filter(thread => !thread.root.isResolved).length} open\n </span>\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto px-5 py-4\">\n <BoardComments\n projectKey={projectKey}\n canvasKey={canvasKey}\n board={board}\n threads={threads}\n pendingPin={pendingPin}\n onClearPendingPin={() => setPendingPin(null)}\n highlightedCommentId={highlightedCommentId}\n onHighlightComment={setHighlightedCommentId}\n writesAllowed={writesAllowed}\n showResolved={showResolved}\n onShowResolvedChange={setShowResolved}\n pinHint=\"“Add pin” marks a spot on the board\"\n onCopyThreadReference={onCopyThreadReference}\n />\n </div>\n </aside>\n </div>\n </>\n )}\n </DialogContent>\n </Dialog>\n );\n};\n","'use client';\n\nimport { type Node, type NodeProps, useStore } from '@xyflow/react';\nimport { ClipboardCopy, Download, Maximize2, MessageSquare } from 'lucide-react';\nimport { memo, useEffect, useRef, useState } from 'react';\n\nimport type { DesignStudioBoardView } from '../api/types';\nimport { useDesignStudio, useDesignStudioTexts } from '../provider/DesignStudioProvider';\nimport { cx } from '../utils/cx';\nimport { boardStatusDefinition } from './boardStatus';\nimport { thumbnailVariantForZoom } from './boardDetail';\nimport { boardCodeOf } from './boardKey';\nimport { BOARD_HEADER_HEIGHT, MAX_BOARD_CANVAS_HEIGHT } from './canvasLayout';\nimport { withoutContentToken } from './canvasLiveUpdate';\nimport { useCanvasView } from './canvasView';\nimport { useCheckedContentUrl, useImageRetry, wasContentUrlLoaded } from './useCheckedContentUrl';\nimport { useDeferredMount } from './useDeferredMount';\nimport { useStableContentUrl } from './stableContentUrl';\n\nexport type BoardNodeData = { board: DesignStudioBoardView };\nexport type BoardFlowNode = Node<BoardNodeData, 'board'>;\n\n/** Whether two delivery URLs show the same content (they differ at most in the content token). */\nconst isSameContent = (first: string | null | undefined, second: string | null | undefined): boolean =>\n Boolean(first && second) && withoutContentToken(first) === withoutContentToken(second);\n\n/**\n * Absolute URL of a delivery path (`/api/...`; `apiBaseUrl` is `environment.apiBaseUrl`, empty = same origin). The path\n * comes complete from the canvas view: content token, content hash and theme are already in it.\n */\nexport const designContentUrl = (apiBaseUrl: string, path: string | null | undefined): string | undefined =>\n path ? `${apiBaseUrl}${path}` : undefined;\n\n/** File name of a board download (`welcome-2.png`). */\nconst downloadName = (board: DesignStudioBoardView, extension: string) =>\n `${boardCodeOf(board.boardKey ?? 'board')}.${extension}`;\n\n/** A press that moved further than this (px) was a pan, not a click. */\nconst CLICK_MAX_MOVE = 5;\n\n/** Header icon button (canvas px: scales with the zoom like the title). */\nconst HEADER_ICON_BUTTON_CLASS =\n 'nodrag nopan flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-tint-strong hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none motion-reduce:transition-none';\n\n/**\n * One board on the canvas: a header line (title with ellipsis — the full title on hover —,\n * status, open comments, \"expand\" = focus view, \"download\" PNG / HTML) above the board. Far out the board shows the\n * ~120 px thumbnail, closer the board-width thumbnail; when the canvas marks it live (large on screen, inside the\n * viewport, one of the nearest six) the sandboxed board HTML is mounted on top — `sandbox=\"\"`: no scripts, no same\n * origin, no forms, no navigation. A board without a thumbnail in the shown look (not rendered yet) is a neutral\n * card until it is live. Only nodes in the viewport are mounted (`onlyRenderVisibleElements`).\n */\nconst BoardNodeComponent = ({ id, data }: NodeProps<BoardFlowNode>) => {\n const { board } = data;\n const { apiBaseUrl, components, statuses } = useDesignStudio();\n const texts = useDesignStudioTexts();\n const { StatusBadge } = components;\n const statusDefinition = board.status ? boardStatusDefinition(statuses, board.status) : undefined;\n const width = board.width ?? 390;\n const height = board.height ?? 844;\n // the canvas shows at most MAX_BOARD_CANVAS_HEIGHT of a board; the focus view shows it whole\n const visibleHeight = Math.min(height, MAX_BOARD_CANVAS_HEIGHT);\n const isCut = height > visibleHeight;\n const thumbnailVariant = useStore(state => thumbnailVariantForZoom(state.transform[2], width));\n const {\n liveBoardIds,\n selectedBoardIds,\n matchingBoardIds,\n openThreadCounts,\n defaultStatus,\n onSelectBoard,\n onCopyReference,\n onOpenBoard,\n } = useCanvasView();\n const isLive = liveBoardIds.has(id);\n const isSelected = selectedBoardIds.has(id);\n const isDimmed = matchingBoardIds !== null && !matchingBoardIds.has(id);\n const openThreads = openThreadCounts.get(id) ?? 0;\n // mass mounts (a zoom across a level) are spread over frames: a plain placeholder until this node's turn\n const isReady = useDeferredMount();\n // no thumbnail in the shown look (yet): nothing to draw until the board is live\n const isThumbnailMissing = !board.thumbnailUrl;\n const latestThumbnailUrl = designContentUrl(\n apiBaseUrl,\n thumbnailVariant === 'small' ? (board.thumbnailSmallUrl ?? board.thumbnailUrl) : board.thumbnailUrl\n );\n const latestHtmlUrl = designContentUrl(apiBaseUrl, board.htmlUrl);\n // Same content → same URL for the page's lifetime (a rotated content token never reloads an image / iframe, a\n // remount gets the URL the browser cache holds); only a new version or another theme changes the src.\n const [loadedImageUrl, setLoadedImageUrl] = useState<string | null>(null);\n const [loadedFrameUrl, setLoadedFrameUrl] = useState<string | null>(null);\n const thumbnailUrl = useStableContentUrl(latestThumbnailUrl, isSameContent(loadedImageUrl, latestThumbnailUrl));\n const htmlUrl = useStableContentUrl(latestHtmlUrl, isSameContent(loadedFrameUrl, latestHtmlUrl));\n // A board already seen live in this look never falls back to the empty card while it has no thumbnail: it remounts\n // its HTML at once (browser cache, bounded LRU) instead of waiting for the live set.\n const isRememberedLive =\n isThumbnailMissing && thumbnailVariant === 'default' && isReady && wasContentUrlLoaded(htmlUrl);\n const showsLiveHtml = isLive || isRememberedLive;\n // the iframe mounts only after its HTML answered 2xx (never an error body over the thumbnail); retried while live\n const liveHtmlUrl = useCheckedContentUrl(showsLiveHtml && isReady ? htmlUrl : undefined);\n const thumbnailRetry = useImageRetry(thumbnailUrl);\n useEffect(() => {\n if (!liveHtmlUrl) setLoadedFrameUrl(null);\n }, [liveHtmlUrl]);\n const title = board.title ?? board.boardKey ?? '';\n // the board's code under the title (`APP ONB-W2`; without one, the file name without extension), so a screen can be\n // named unambiguously and opened by its code\n const boardCode = board.code ?? boardCodeOf(board.boardKey ?? '');\n const [isDownloadOpen, setIsDownloadOpen] = useState(false);\n const pressPointRef = useRef<{ x: number; y: number } | null>(null);\n // far out (small thumbnails) the header is only the title: no buttons, no badges to mount per board\n const isCompact = thumbnailVariant === 'small';\n\n if (!isReady) {\n return (\n <div className={cx('h-full w-full', isDimmed && 'opacity-15')} style={{ paddingTop: BOARD_HEADER_HEIGHT }}>\n <div className=\"rounded-[20px] bg-card/70\" style={{ width, height: visibleHeight }} />\n </div>\n );\n }\n\n return (\n <div className={cx('relative h-full w-full', isDimmed && 'opacity-15')}>\n {/* two rows: the full title (up to two lines, never squeezed by the buttons), then the code + the buttons */}\n <div className=\"flex flex-col justify-end gap-0.5 pb-1\" style={{ height: BOARD_HEADER_HEIGHT }}>\n <span className=\"line-clamp-2 text-[19px] leading-6 font-medium text-muted-foreground\" title={title}>\n {title}\n </span>\n <div className=\"flex items-center gap-1\">\n <span className=\"min-w-0 flex-1 truncate text-[15px] leading-5 font-semibold text-foreground/70 tabular-nums\" title={boardCode}>\n {isCompact ? '' : boardCode}\n </span>\n {!isCompact && openThreads > 0 && (\n <span className=\"inline-flex shrink-0 items-center gap-1 rounded-full bg-primary px-2 py-0.5 text-sm font-semibold text-primary-foreground\">\n <MessageSquare className=\"size-3.5\" aria-hidden />\n {openThreads}\n </span>\n )}\n {!isCompact && board.status && board.status !== defaultStatus && (\n <StatusBadge\n tone={statusDefinition?.tone ?? 'neutral'}\n label={statusDefinition?.label ?? board.status}\n icon={statusDefinition?.icon}\n title={statusDefinition?.description}\n className=\"shrink-0\"\n />\n )}\n {!isCompact && (\n <button\n type=\"button\"\n className={HEADER_ICON_BUTTON_CLASS}\n aria-label={`Copy reference of ${title} for an agent`}\n title=\"Copy reference (C)\"\n onClick={() => onCopyReference(id)}\n >\n <ClipboardCopy className=\"size-5\" />\n </button>\n )}\n {!isCompact && (\n <button\n type=\"button\"\n className={HEADER_ICON_BUTTON_CLASS}\n aria-label={`Open ${title} large`}\n title=\"Expand\"\n onClick={() => onOpenBoard(id)}\n >\n <Maximize2 className=\"size-5\" />\n </button>\n )}\n {!isCompact && (\n <div className=\"relative\">\n <button\n type=\"button\"\n className={HEADER_ICON_BUTTON_CLASS}\n aria-label={`Download ${title}`}\n aria-expanded={isDownloadOpen}\n title=\"Download\"\n onClick={() => setIsDownloadOpen(isOpen => !isOpen)}\n >\n <Download className=\"size-5\" />\n </button>\n {isDownloadOpen && (\n // a plain menu instead of a Radix one: mounted only while open, nothing per node at rest\n <div\n className=\"nodrag nopan absolute top-full right-0 z-20 mt-1 flex w-56 flex-col rounded-2xl bg-popover p-1.5 text-[18px] shadow-surface-raised ring-1 ring-foreground/5\"\n >\n {board.thumbnailUrl && (\n <a\n href={designContentUrl(apiBaseUrl, board.thumbnailUrl)}\n download={downloadName(board, 'png')}\n className=\"rounded-[10px] px-3 py-2 hover:bg-tint\"\n onClick={() => setIsDownloadOpen(false)}\n >\n PNG (thumbnail)\n </a>\n )}\n {board.htmlUrl && (\n <a\n href={htmlUrl}\n download={downloadName(board, 'html')}\n className=\"rounded-[10px] px-3 py-2 hover:bg-tint\"\n onClick={() => setIsDownloadOpen(false)}\n >\n HTML\n </a>\n )}\n </div>\n )}\n </div>\n )}\n </div>\n </div>\n <div\n className={cx(\n 'relative overflow-hidden rounded-[20px] bg-card shadow-surface-raised ring-1 ring-foreground/10',\n isSelected && 'ring-4 ring-brand'\n )}\n style={{ width, height: visibleHeight }}\n >\n {thumbnailUrl && (\n // biome-ignore lint/performance/noImgElement: canvas thumbnails are API images at canvas scale, next/image cannot optimise them\n <img\n key={thumbnailRetry.imageKey}\n src={thumbnailUrl}\n alt=\"\"\n width={width}\n height={height}\n loading=\"lazy\"\n decoding=\"async\"\n draggable={false}\n onError={thumbnailRetry.onError}\n onLoad={() => setLoadedImageUrl(thumbnailUrl)}\n className={cx(\n 'pointer-events-none absolute inset-0 h-full w-full object-cover object-top select-none',\n thumbnailRetry.isFailed && 'invisible'\n )}\n />\n )}\n {isThumbnailMissing && !isCompact && !(showsLiveHtml && liveHtmlUrl) && (\n <span className=\"pointer-events-none absolute inset-0 flex items-center justify-center px-6 text-center text-[17px] font-semibold text-muted-foreground\">\n {texts.thumbnailMissing}\n </span>\n )}\n {showsLiveHtml && liveHtmlUrl && (\n <iframe\n src={liveHtmlUrl}\n onLoad={() => setLoadedFrameUrl(liveHtmlUrl)}\n title={title || 'Board'}\n sandbox=\"\"\n referrerPolicy=\"no-referrer\"\n loading=\"lazy\"\n width={width}\n height={height}\n className=\"pointer-events-none absolute inset-0 border-0 bg-transparent\"\n />\n )}\n {isCut && (\n <span className=\"pointer-events-none absolute inset-x-0 bottom-0 flex h-40 items-end justify-center bg-gradient-to-t from-card to-transparent pb-4 text-[16px] font-semibold text-muted-foreground\">\n ↓ {Math.round(height)} px — full length in the focus view\n </span>\n )}\n <button\n type=\"button\"\n className=\"absolute inset-0 z-10 cursor-pointer rounded-[20px] bg-transparent focus-visible:ring-4 focus-visible:ring-ring focus-visible:outline-none\"\n onPointerDown={event => {\n pressPointRef.current = { x: event.clientX, y: event.clientY };\n }}\n onClick={event => {\n // a drag that started on the board panned the canvas: no selection on its release\n const pressPoint = pressPointRef.current;\n if (pressPoint && Math.hypot(event.clientX - pressPoint.x, event.clientY - pressPoint.y) > CLICK_MAX_MOVE) return;\n onSelectBoard(id, event.shiftKey || event.metaKey || event.ctrlKey);\n }}\n onDoubleClick={() => onOpenBoard(id)}\n onKeyDown={event => {\n if (event.key === 'Enter' && event.shiftKey) onOpenBoard(id);\n }}\n aria-label={`${title}: select (double-click or Shift+Enter opens it)`}\n />\n </div>\n </div>\n );\n};\n\nexport const BoardNode = memo(BoardNodeComponent);\n","import type { DesignStudioStatusDefinition, DesignStudioStatuses } from '../provider/types';\n\n/**\n * The review statuses are configured in the backend (`DesignStudioCanvasView.statuses`, the first one is the default),\n * so a board's status is a plain string here; the application's status definitions (`environment.statuses`) know the\n * usual ones, any other key shows as it is.\n */\nexport const boardStatusDefinition = (\n statuses: DesignStudioStatuses,\n status: string\n): DesignStudioStatusDefinition | undefined => statuses[status];\n\nexport const boardStatusLabel = (statuses: DesignStudioStatuses, status: string): string =>\n boardStatusDefinition(statuses, status)?.label ?? status;\n","/**\n * Level of detail of the design canvas (render only what is visible). Pure functions, no React: which image a board shows at a zoom, and which boards may mount their live\n * (sandboxed iframe) HTML.\n */\n\n/** A board's place on the canvas, in canvas pixels. */\nexport interface BoardRect {\n id: string;\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** React Flow's viewport: screen = canvas × zoom + (x, y). */\nexport interface CanvasViewport {\n x: number;\n y: number;\n zoom: number;\n}\n\nexport interface ScreenSize {\n width: number;\n height: number;\n}\n\n/** Image a board shows: the ~120 px thumbnail at far zoom, the board-width thumbnail otherwise. */\nexport type BoardThumbnailVariant = 'small' | 'default';\n\n/** Rendered width (screen px) up to which the small thumbnail is enough (it is 120 px wide). */\nexport const SMALL_THUMBNAIL_MAX_RENDERED_WIDTH = 130;\n\n/** A board shows live HTML only when it is rendered at least this share of its native width. */\nexport const LIVE_MIN_RENDERED_WIDTH_RATIO = 0.6;\n\n/**\n * While boards have no thumbnail in the shown look yet (the renderer is still working, or it is off), they switch to\n * the live HTML earlier.\n */\nexport const LIVE_MIN_RENDERED_WIDTH_RATIO_WITHOUT_THUMBNAILS = 0.35;\n\n/** At most this many live iframes at once (the ones nearest the viewport centre). */\nexport const MAX_LIVE_BOARDS = 6;\n\nexport const thumbnailVariantForZoom = (zoom: number, boardWidth: number): BoardThumbnailVariant =>\n boardWidth * zoom <= SMALL_THUMBNAIL_MAX_RENDERED_WIDTH ? 'small' : 'default';\n\nexport const isZoomLiveCapable = (zoom: number, minRatio: number = LIVE_MIN_RENDERED_WIDTH_RATIO): boolean =>\n zoom >= minRatio;\n\n/**\n * The boards that may show live HTML: inside the viewport, rendered at ≥ `minRatio` of their width,\n * nearest the viewport centre first, at most `maxLiveBoards`.\n */\nexport const selectLiveBoardIds = (\n boards: readonly BoardRect[],\n viewport: CanvasViewport,\n screen: ScreenSize,\n maxLiveBoards: number = MAX_LIVE_BOARDS,\n minRatio: number = LIVE_MIN_RENDERED_WIDTH_RATIO\n): Set<string> => {\n if (!isZoomLiveCapable(viewport.zoom, minRatio) || screen.width <= 0 || screen.height <= 0) {\n return new Set();\n }\n const left = -viewport.x / viewport.zoom;\n const top = -viewport.y / viewport.zoom;\n const right = left + screen.width / viewport.zoom;\n const bottom = top + screen.height / viewport.zoom;\n const centreX = (left + right) / 2;\n const centreY = (top + bottom) / 2;\n const visible: { id: string; distance: number }[] = [];\n for (const board of boards) {\n const isInside =\n board.x < right && board.x + board.width > left && board.y < bottom && board.y + board.height > top;\n if (!isInside) continue;\n const distance = Math.hypot(board.x + board.width / 2 - centreX, board.y + Math.min(board.height, 844) / 2 - centreY);\n visible.push({ id: board.id, distance });\n }\n visible.sort((first, second) => first.distance - second.distance);\n return new Set(visible.slice(0, maxLiveBoards).map(entry => entry.id));\n};\n\n/** The boards inside the viewport, nearest the viewport centre first (render priority of missing thumbnails). */\nexport const selectVisibleBoardIds = (\n boards: readonly BoardRect[],\n viewport: CanvasViewport,\n screen: ScreenSize\n): string[] => {\n if (screen.width <= 0 || screen.height <= 0 || viewport.zoom <= 0) return [];\n const left = -viewport.x / viewport.zoom;\n const top = -viewport.y / viewport.zoom;\n const right = left + screen.width / viewport.zoom;\n const bottom = top + screen.height / viewport.zoom;\n const centreX = (left + right) / 2;\n const centreY = (top + bottom) / 2;\n return boards\n .filter(board => board.x < right && board.x + board.width > left && board.y < bottom && board.y + board.height > top)\n .map(board => ({ id: board.id, distance: Math.hypot(board.x + board.width / 2 - centreX, board.y + board.height / 2 - centreY) }))\n .sort((first, second) => first.distance - second.distance)\n .map(entry => entry.id);\n};\n","/**\n * Auto layout of a design canvas: each section a bold title line above a grid of its\n * boards (rows aligned on their top edge, tall boards allowed), every board with a header line (title + actions) above\n * it. All sections share one row count, so a section's width follows its board count (≤ MAX_COLUMNS per row); the\n * sections are shelf-packed left → right in their order, and the row count and shelf width are chosen so a viewport\n * of TARGET_ASPECT_RATIO shows the whole canvas as large as possible (\"Fit all\" stays readable). Sections without boards are not drawn. The stored x / y of a board\n * (its place in the source canvas.json) only decide its order inside the section. Pure functions, no React.\n */\n\nexport interface LayoutSectionInput {\n id: string;\n title: string;\n displayOrder: number;\n}\n\nexport interface LayoutBoardInput {\n id: string;\n /** Section id, null = no section (\"Weitere Boards\" at the end). */\n sectionId: string | null;\n width: number;\n height: number;\n /** Order inside the section (publish order). */\n displayOrder: number;\n}\n\nexport interface LayoutRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface LayoutSection extends LayoutRect {\n id: string;\n title: string;\n boardCount: number;\n /** Board ids in layout order. */\n boardIds: string[];\n}\n\nexport interface CanvasLayout {\n sections: LayoutSection[];\n /** Board node rect: the header line plus the board (node id = board id). */\n boards: Map<string, LayoutRect>;\n bounds: LayoutRect;\n}\n\n/** Most boards in one row of a section (12–14 per row). */\nexport const MAX_COLUMNS = 14;\n/** Horizontal gap between boards. */\nexport const BOARD_GAP_X = 44;\n/** Vertical gap between board rows (below a board, above the next row's header). */\nexport const BOARD_GAP_Y = 64;\n/** Tallest board height drawn on the canvas; longer boards are cut there (the focus view shows the full length). */\nexport const MAX_BOARD_CANVAS_HEIGHT = 1400;\n/** Height of the header line above each board (title + expand / download). */\nexport const BOARD_HEADER_HEIGHT = 92;\n/** Height of a section's title line plus its gap to the first row. */\nexport const SECTION_TITLE_HEIGHT = 104;\n/** Padding of a section's background around its title and boards. */\nexport const SECTION_PADDING = 48;\n/** Gap between two sections' backgrounds (both directions). */\nexport const SECTION_GAP = 140;\n/** Aspect ratio (width / height) of the canvas area the packing optimises \"Fit all\" for (a laptop canvas area). */\nexport const TARGET_ASPECT_RATIO = 1.4;\n/** Section key of boards without a section. */\nexport const UNSECTIONED_ID = 'unsectioned';\n\ninterface SectionGrid {\n section: LayoutSectionInput;\n boards: LayoutBoardInput[];\n /** Board rects relative to the section's top-left corner. */\n relativeRects: Map<string, LayoutRect>;\n width: number;\n height: number;\n}\n\n/** Rows the layout tries for its sections (all sections share one row count, so shelves stay even). */\nconst ROW_COUNT_CANDIDATES = [1, 2, 3, 4, 5, 6, 7, 8, 10];\n\n/** Fewest columns of a section with enough boards (no single tall column of boards). */\nexport const MIN_COLUMNS = 4;\n\n/**\n * Columns of a section's grid for a shared row count: ⌈n / rows⌉, at least MIN_COLUMNS (fewer only with fewer\n * boards), at most MAX_COLUMNS (then it gets more rows).\n */\nexport const columnsForSection = (boardCount: number, rows: number): number =>\n Math.max(\n Math.min(boardCount, MIN_COLUMNS),\n Math.min(boardCount, MAX_COLUMNS, Math.ceil(boardCount / Math.max(1, rows)))\n );\n\nconst buildSectionGrid = (section: LayoutSectionInput, boards: LayoutBoardInput[], rows: number): SectionGrid => {\n const columns = columnsForSection(boards.length, rows);\n const relativeRects = new Map<string, LayoutRect>();\n let rowTop = SECTION_PADDING + SECTION_TITLE_HEIGHT;\n let right = 0;\n for (let rowStart = 0; rowStart < boards.length; rowStart += columns) {\n const row = boards.slice(rowStart, rowStart + columns);\n let left = SECTION_PADDING;\n let rowHeight = 0;\n for (const board of row) {\n const height = BOARD_HEADER_HEIGHT + Math.min(board.height, MAX_BOARD_CANVAS_HEIGHT);\n relativeRects.set(board.id, { x: left, y: rowTop, width: board.width, height });\n left += board.width + BOARD_GAP_X;\n rowHeight = Math.max(rowHeight, height);\n }\n right = Math.max(right, left - BOARD_GAP_X);\n rowTop += rowHeight + BOARD_GAP_Y;\n }\n return {\n section,\n boards,\n relativeRects,\n width: right + SECTION_PADDING,\n height: rowTop - BOARD_GAP_Y + SECTION_PADDING,\n };\n};\n\n/** Shelf packing in order: sections left → right, a new shelf when the next one passes `maxShelfWidth`. */\nconst packShelves = (grids: SectionGrid[], maxShelfWidth: number): { positions: LayoutRect[]; bounds: LayoutRect } => {\n const positions: LayoutRect[] = [];\n let shelfTop = 0;\n let shelfHeight = 0;\n let x = 0;\n let maxRight = 0;\n for (const grid of grids) {\n if (x > 0 && x + grid.width > maxShelfWidth) {\n shelfTop += shelfHeight + SECTION_GAP;\n shelfHeight = 0;\n x = 0;\n }\n positions.push({ x, y: shelfTop, width: grid.width, height: grid.height });\n maxRight = Math.max(maxRight, x + grid.width);\n shelfHeight = Math.max(shelfHeight, grid.height);\n x += grid.width + SECTION_GAP;\n }\n return { positions, bounds: { x: 0, y: 0, width: maxRight, height: shelfTop + shelfHeight } };\n};\n\nexport const computeCanvasLayout = (\n sections: readonly LayoutSectionInput[],\n boards: readonly LayoutBoardInput[],\n targetAspectRatio: number = TARGET_ASPECT_RATIO\n): CanvasLayout => {\n const boardsBySectionId = new Map<string, LayoutBoardInput[]>();\n for (const board of boards) {\n const sectionId = board.sectionId ?? UNSECTIONED_ID;\n const sectionBoards = boardsBySectionId.get(sectionId) ?? [];\n sectionBoards.push(board);\n boardsBySectionId.set(sectionId, sectionBoards);\n }\n const orderedSections: LayoutSectionInput[] = [...sections].sort(\n (first, second) => first.displayOrder - second.displayOrder\n );\n if (boardsBySectionId.has(UNSECTIONED_ID)) {\n orderedSections.push({ id: UNSECTIONED_ID, title: 'Weitere Boards', displayOrder: Number.MAX_SAFE_INTEGER });\n }\n const sectionsWithBoards = orderedSections\n .map(section => ({\n section,\n boards: [...(boardsBySectionId.get(section.id) ?? [])].sort(\n (first, second) => first.displayOrder - second.displayOrder\n ),\n }))\n .filter(entry => entry.boards.length > 0);\n if (sectionsWithBoards.length === 0) {\n return { sections: [], boards: new Map(), bounds: { x: 0, y: 0, width: 0, height: 0 } };\n }\n\n // Every shared row count × shelf width; keep the packing a viewport of the target aspect ratio shows largest.\n let bestGrids: SectionGrid[] = [];\n let best = { positions: [] as LayoutRect[], bounds: { x: 0, y: 0, width: 1, height: 1 } };\n let bestFitScale = 0;\n for (const rows of ROW_COUNT_CANDIDATES) {\n const grids = sectionsWithBoards.map(entry => buildSectionGrid(entry.section, entry.boards, rows));\n const widestSection = Math.max(...grids.map(grid => grid.width));\n const totalWidth = grids.reduce((sum, grid) => sum + grid.width + SECTION_GAP, -SECTION_GAP);\n for (let step = 0; step <= 32; step++) {\n const packed = packShelves(grids, widestSection + ((totalWidth - widestSection) * step) / 32);\n const fitScale = Math.min(targetAspectRatio / packed.bounds.width, 1 / packed.bounds.height);\n if (fitScale > bestFitScale) {\n bestFitScale = fitScale;\n best = packed;\n bestGrids = grids;\n }\n }\n }\n const grids = bestGrids;\n\n const layoutSections: LayoutSection[] = [];\n const boardRects = new Map<string, LayoutRect>();\n grids.forEach((grid, index) => {\n const position = best.positions[index];\n for (const [boardId, rect] of grid.relativeRects) {\n boardRects.set(boardId, { ...rect, x: position.x + rect.x, y: position.y + rect.y });\n }\n layoutSections.push({\n id: grid.section.id,\n title: grid.section.title,\n ...position,\n boardCount: grid.boards.length,\n boardIds: grid.boards.map(board => board.id),\n });\n });\n return { sections: layoutSections, boards: boardRects, bounds: best.bounds };\n};\n\n/** The section that holds a canvas point, else the one whose centre is nearest. */\nexport const findSectionAt = (\n sections: readonly LayoutSection[],\n x: number,\n y: number\n): LayoutSection | undefined => {\n let nearest: LayoutSection | undefined;\n let nearestDistance = Number.POSITIVE_INFINITY;\n for (const section of sections) {\n if (x >= section.x && x <= section.x + section.width && y >= section.y && y <= section.y + section.height) {\n return section;\n }\n const distance = Math.hypot(x - section.x - section.width / 2, y - section.y - section.height / 2);\n if (distance < nearestDistance) {\n nearest = section;\n nearestDistance = distance;\n }\n }\n return nearest;\n};\n","/**\n * Canvas viewport in the URL (`vp=<x>,<y>,<zoom>`) and the in-place board update of a refetched canvas (reload button,\n * live update). Pure functions, no React (tested in canvasLiveUpdate.test.ts).\n */\n\n/** A React Flow viewport: pan in screen px, zoom factor. */\nexport interface CanvasViewport {\n x: number;\n y: number;\n zoom: number;\n}\n\n/** The smallest / largest zoom a `vp` parameter may carry (the canvas' own limits are 0.005 … 2.5). */\nconst VIEWPORT_MIN_ZOOM = 0.001;\nconst VIEWPORT_MAX_ZOOM = 10;\n\n/** `vp` value: pan rounded to whole px, zoom to 4 decimals without trailing zeros (`-1234,560,0.0762`). */\nexport const formatViewportParam = ({ x, y, zoom }: CanvasViewport): string =>\n `${Math.round(x)},${Math.round(y)},${Number(zoom.toFixed(4))}`;\n\n/** Parses a `vp` value; null when missing or malformed (the canvas then fits its first view). */\nexport const parseViewportParam = (value: string | null | undefined): CanvasViewport | null => {\n if (!value) return null;\n const parts = value.split(',');\n if (parts.length !== 3 || parts.some(part => part.trim() === '')) return null;\n const [x, y, zoom] = parts.map(Number);\n if (![x, y, zoom].every(Number.isFinite) || zoom < VIEWPORT_MIN_ZOOM || zoom > VIEWPORT_MAX_ZOOM) return null;\n return { x, y, zoom };\n};\n\n/** The board fields the in-place update compares (a subset of DesignStudioBoardView). */\nexport interface LiveBoard {\n boardKey?: string | null;\n /** Version of the board file (git blob hash). */\n contentHash?: string | null;\n htmlUrl?: string | null;\n thumbnailUrl?: string | null;\n thumbnailSmallUrl?: string | null;\n}\n\n/** A delivery URL without its content token (the token rotates every 30 min, the content behind it does not). */\nexport const withoutContentToken = (url: string | null | undefined): string => {\n if (!url) return '';\n const [path, query = ''] = url.split('?');\n const params = new URLSearchParams(query);\n params.delete('token');\n const rest = params.toString();\n return rest ? `${path}?${rest}` : path;\n};\n\n/** The first characters of a content hash, as shown for a board's version (`3f9c2ab`). */\nexport const shortContentHash = (contentHash: string | null | undefined): string => (contentHash ?? '').slice(0, 7);\n\n/**\n * The delivery URL to show: the previous one while it shows the same content (same URL without the token) and\n * `keepPreviousUrls`, else the new one (another version, a thumbnail that arrived, a stale token).\n */\nconst pickDeliveryUrl = (\n previous: string | null | undefined,\n next: string | null | undefined,\n keepPreviousUrls: boolean\n): string | null | undefined =>\n keepPreviousUrls && previous && withoutContentToken(previous) === withoutContentToken(next) ? previous : next;\n\n/** Shallow equality of two board objects (every own key, values by identity). */\nconst isSameBoard = (previous: object, next: object): boolean => {\n const previousEntries = Object.entries(previous);\n if (previousEntries.length !== Object.keys(next).length) return false;\n const nextRecord = next as Record<string, unknown>;\n return previousEntries.every(([key, value]) => key in nextRecord && Object.is(nextRecord[key], value));\n};\n\nexport interface BoardMergeResult<T extends LiveBoard> {\n /** The boards to render: unchanged boards keep their previous object (no re-render, no iframe / image reload). */\n boards: T[];\n /** Keys of the boards whose file changed (another content hash) or that are new, in the order of `nextBoards`. */\n changedBoardKeys: string[];\n /** Whether anything differs from `previousBoards` (false → `boards` is `previousBoards` itself). */\n isChanged: boolean;\n}\n\n/**\n * Merges a refetched board list into the shown one, board by board (`boardKey`). A delivery URL that shows the same\n * content keeps its previous value while `keepPreviousUrls` (the previous content token is still valid), so a\n * thumbnail or live iframe is not reloaded just because the token rotated; a board keeps its previous object when\n * nothing else changed either. A URL with other content (a thumbnail that was rendered meanwhile, a new version) is\n * taken over in place. Only a new board or another `contentHash` counts as changed — a thumbnail arriving for the\n * same version does not.\n */\nexport const mergeRefetchedBoards = <T extends LiveBoard>(\n previousBoards: readonly T[] | null,\n nextBoards: readonly T[],\n keepPreviousUrls: boolean\n): BoardMergeResult<T> => {\n if (previousBoards === null) return { boards: [...nextBoards], changedBoardKeys: [], isChanged: true };\n const previousByKey = new Map(previousBoards.map(board => [String(board.boardKey), board]));\n const changedBoardKeys: string[] = [];\n const boards = nextBoards.map(next => {\n const previous = previousByKey.get(String(next.boardKey));\n if (!previous || (previous.contentHash ?? null) !== (next.contentHash ?? null)) {\n changedBoardKeys.push(String(next.boardKey));\n return next;\n }\n const candidate: T = {\n ...next,\n htmlUrl: pickDeliveryUrl(previous.htmlUrl, next.htmlUrl, keepPreviousUrls),\n thumbnailUrl: pickDeliveryUrl(previous.thumbnailUrl, next.thumbnailUrl, keepPreviousUrls),\n thumbnailSmallUrl: pickDeliveryUrl(previous.thumbnailSmallUrl, next.thumbnailSmallUrl, keepPreviousUrls),\n };\n return isSameBoard(previous, candidate) ? previous : candidate;\n });\n const isChanged =\n boards.length !== previousBoards.length || boards.some((board, index) => board !== previousBoards[index]);\n return { boards: isChanged ? boards : (previousBoards as T[]), changedBoardKeys, isChanged };\n};\n","'use client';\n\nimport { createContext, useContext } from 'react';\n\n/**\n * Canvas state the board nodes read without being rebuilt: which boards may show live HTML, the selection, the search\n * / filter matches and the actions. The node array itself only changes when the canvas data changes.\n */\nexport interface CanvasViewState {\n liveBoardIds: ReadonlySet<string>;\n /** The board shown in the side panel (the last one clicked). */\n selectedBoardId: string | null;\n /** Every selected board (shift / cmd click, marquee): \"Copy reference\" copies one block per board. */\n selectedBoardIds: ReadonlySet<string>;\n /** Boards matching search and filters; null = no filter active (everything matches). */\n matchingBoardIds: ReadonlySet<string> | null;\n /** Open threads per board node id. */\n openThreadCounts: ReadonlyMap<string, number>;\n /** The status a board has without a stored one (the first configured status): shown without a badge. */\n defaultStatus: string | null;\n /** Hand tool (the default): every drag pans, a click on a board still selects it. */\n isHandTool: boolean;\n /** `isAdditive`: shift / cmd / ctrl click toggles the board in the selection instead of replacing it. */\n onSelectBoard: (boardId: string, isAdditive: boolean) => void;\n /** Copies the design reference of one board (header button). */\n onCopyReference: (boardId: string) => void;\n onOpenBoard: (boardId: string) => void;\n /** Overview card click: fit the view to that section. */\n onZoomToSection: (sectionId: string) => void;\n}\n\nexport const CanvasViewContext = createContext<CanvasViewState | null>(null);\n\nexport const useCanvasView = (): CanvasViewState => {\n const canvasView = useContext(CanvasViewContext);\n if (!canvasView) {\n throw new Error('useCanvasView needs a CanvasViewContext provider');\n }\n return canvasView;\n};\n\n/** The node id of a board (its `boardKey`, the file name in the canvas folder). */\nexport const boardNodeId = (boardKey: string): string => `board-${boardKey}`;\n\n/** The node id of a section (its `sectionKey`). */\nexport const sectionNodeId = (sectionKey: string): string => `section-${sectionKey}`;\n","'use client';\n\nimport { useEffect, useState } from 'react';\n\n/**\n * Loads a board's delivery URL (HTML) before an iframe shows it. An `<iframe src>` renders whatever the server answers —\n * on a storage error that was the raw error JSON on top of the thumbnail. The URL is fetched first (at most\n * MAX_CONCURRENT_LOADS at once across the canvas, so a zoom does not fire every board at the object storage); only a 2xx\n * answer is handed to the iframe, which then reads it from the browser cache (the endpoint answers `private,\n * immutable`). A failed load leaves the thumbnail in place and is retried with growing delays while the board stays\n * live.\n */\nconst MAX_CONCURRENT_LOADS = 2;\n\n/** Delays (ms) before the next attempt after a failure; the last one repeats. */\nconst RETRY_DELAYS_MS = [2000, 5000, 15000, 30000];\n\n/**\n * URLs already loaded successfully in this page, least recently used first (a remount shows them at once; the browser\n * cache holds the bytes). Bounded: it also decides which boards remount their live HTML outside the live set.\n */\nconst MAX_REMEMBERED_URLS = 24;\nconst loadedUrls = new Set<string>();\n\nconst rememberLoadedUrl = (url: string) => {\n loadedUrls.delete(url);\n loadedUrls.add(url);\n while (loadedUrls.size > MAX_REMEMBERED_URLS) {\n const oldestUrl = loadedUrls.values().next().value;\n if (oldestUrl === undefined) break;\n loadedUrls.delete(oldestUrl);\n }\n};\n\n/** Whether this board HTML URL (content hash + theme in its query) was shown live before in this page. */\nexport const wasContentUrlLoaded = (url: string | undefined): boolean => Boolean(url && loadedUrls.has(url));\n\nlet activeLoads = 0;\nconst waitingLoads: Array<() => void> = [];\n\nconst acquireLoadSlot = (): Promise<void> =>\n new Promise(resolve => {\n if (activeLoads < MAX_CONCURRENT_LOADS) {\n activeLoads += 1;\n resolve();\n return;\n }\n waitingLoads.push(() => {\n activeLoads += 1;\n resolve();\n });\n });\n\nconst releaseLoadSlot = () => {\n activeLoads -= 1;\n waitingLoads.shift()?.();\n};\n\nconst loadUrl = async (url: string, signal: AbortSignal): Promise<boolean> => {\n await acquireLoadSlot();\n try {\n if (signal.aborted) return false;\n const response = await fetch(url, { signal, credentials: 'omit', referrerPolicy: 'no-referrer' });\n if (!response.ok) return false;\n // read the whole body so the browser cache holds the complete answer for the iframe\n await response.blob();\n return true;\n } catch {\n // network error or abort: the caller retries while the board is still live\n return false;\n } finally {\n releaseLoadSlot();\n }\n};\n\n/**\n * @param url the delivery URL, undefined when nothing should load (board not live)\n * @returns the URL once it answered 2xx, else undefined (show the thumbnail)\n */\nexport const useCheckedContentUrl = (url: string | undefined): string | undefined => {\n const [checkedUrl, setCheckedUrl] = useState<string | undefined>(() =>\n url && loadedUrls.has(url) ? url : undefined\n );\n\n useEffect(() => {\n if (!url) {\n setCheckedUrl(undefined);\n return;\n }\n if (loadedUrls.has(url)) {\n rememberLoadedUrl(url);\n setCheckedUrl(url);\n return;\n }\n setCheckedUrl(undefined);\n const abortController = new AbortController();\n let retryTimer: ReturnType<typeof setTimeout> | undefined;\n let attempt = 0;\n const tryLoad = async () => {\n const isLoaded = await loadUrl(url, abortController.signal);\n if (abortController.signal.aborted) return;\n if (isLoaded) {\n rememberLoadedUrl(url);\n setCheckedUrl(url);\n return;\n }\n const delay = RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)];\n attempt += 1;\n retryTimer = setTimeout(tryLoad, delay);\n };\n void tryLoad();\n return () => {\n abortController.abort();\n if (retryTimer) clearTimeout(retryTimer);\n };\n }, [url]);\n\n return checkedUrl;\n};\n\n/**\n * Retries a failed `<img>` (a thumbnail answered with an error): the image is hidden, and after a growing delay it is\n * mounted again under a new key, which requests the URL once more (error answers are not cached).\n * @returns the key for the `<img>`, whether it failed (hide it until the retry) and its `onError` handler\n */\nexport const useImageRetry = (url: string | undefined) => {\n const [attempt, setAttempt] = useState(0);\n const [isFailed, setIsFailed] = useState(false);\n const [previousUrl, setPreviousUrl] = useState(url);\n // a new URL (another theme, a new token window) starts over (state reset during render, no effect needed)\n if (url !== previousUrl) {\n setPreviousUrl(url);\n setAttempt(0);\n setIsFailed(false);\n }\n\n useEffect(() => {\n if (!isFailed) return;\n const retryTimer = setTimeout(\n () => {\n setIsFailed(false);\n setAttempt(previousAttempt => previousAttempt + 1);\n },\n RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)]\n );\n return () => clearTimeout(retryTimer);\n }, [isFailed, attempt]);\n\n return { imageKey: `${url ?? ''}#${attempt}`, isFailed, onError: () => setIsFailed(true) };\n};\n","'use client';\n\nimport { useEffect, useState } from 'react';\n\n/**\n * Spreads mass mounts over frames: a component that uses this hook renders its cheap placeholder first and its full\n * content once its turn comes — at most MOUNTS_PER_FRAME per animation frame, in the order they asked. When a zoom\n * crosses a level and React Flow mounts a hundred board nodes at once, the work lands in many short frames instead of\n * one long task.\n */\nconst MOUNTS_PER_FRAME = 12;\n\nconst queue: Array<() => void> = [];\nlet isScheduled = false;\n\nconst flush = () => {\n isScheduled = false;\n for (const mount of queue.splice(0, MOUNTS_PER_FRAME)) mount();\n if (queue.length > 0) schedule();\n};\n\nconst schedule = () => {\n if (isScheduled) return;\n isScheduled = true;\n requestAnimationFrame(flush);\n};\n\n/** @returns false until this component's turn, then true (stays true for its lifetime). */\nexport const useDeferredMount = (): boolean => {\n const [isMounted, setIsMounted] = useState(false);\n useEffect(() => {\n let isActive = true;\n const mount = () => {\n if (isActive) setIsMounted(true);\n };\n queue.push(mount);\n schedule();\n return () => {\n isActive = false;\n const index = queue.indexOf(mount);\n if (index >= 0) queue.splice(index, 1);\n };\n }, []);\n return isMounted;\n};\n","'use client';\n\nimport { useState } from 'react';\n\nimport { withoutContentToken } from './canvasLiveUpdate.ts';\n\n/**\n * Delivery URLs that stay the same for the page's lifetime. The content behind a board URL is fixed by its path and\n * query (board, content hash, theme, size); only the content token in it rotates (a new token every 30 min).\n * A new token must never reload an image or iframe that already shows that content, and a board that remounts (pan,\n * zoom level) should get the URL the browser cache already holds. So:\n * - one URL per content (the URL without its token) is kept for the page — the first one seen — and handed to every\n * element that shows that content, until its token is about to expire (EXPIRY_MARGIN_SECONDS), then the newest one;\n * - an element that already displays its content keeps its URL even past the expiry (it never requests it again).\n * Pure helpers tested in stableContentUrl.test.ts.\n */\n\n/** A token closer than this to its expiry is not handed to elements that still have to load (seconds). */\nconst EXPIRY_MARGIN_SECONDS = 120;\n\n/** content key (URL without token) → the URL shown for it */\nconst urlByContentKey = new Map<string, string>();\n/** token → its expiry (epoch seconds; 0 = unreadable, treated as expired) */\nconst expiryByToken = new Map<string, number>();\n\n/** The `expiresAt` claim of the URL's content token (epoch seconds), null when the URL has no token. */\nexport const contentTokenExpiry = (url: string): number | null => {\n const query = url.split('?')[1];\n if (!query) return null;\n const token = new URLSearchParams(query).get('token');\n if (!token) return null;\n const known = expiryByToken.get(token);\n if (known !== undefined) return known;\n let expiry = 0;\n try {\n const payload = token.split('.')[1] ?? '';\n const json = JSON.parse(atob(payload.replace(/-/g, '+').replace(/_/g, '/')));\n expiry = Number(json.expiresAt ?? json.exp ?? 0) || 0;\n } catch {\n // not a readable JWT: treated as expired, the newest URL wins\n expiry = 0;\n }\n expiryByToken.set(token, expiry);\n return expiry;\n};\n\n/** Whether the URL's token expires within the margin (URLs without a token never expire). */\nexport const isContentUrlExpiring = (url: string, nowSeconds = Date.now() / 1000): boolean => {\n const expiry = contentTokenExpiry(url);\n return expiry !== null && expiry - EXPIRY_MARGIN_SECONDS <= nowSeconds;\n};\n\n/** The page's URL for this content: the one kept so far while its token is still good, else `url` (kept from now). */\nexport const resolveStableContentUrl = (url: string): string => {\n const contentKey = withoutContentToken(url);\n const kept = urlByContentKey.get(contentKey);\n if (kept !== undefined && (kept === url || !isContentUrlExpiring(kept))) return kept;\n urlByContentKey.set(contentKey, url);\n return url;\n};\n\n/**\n * @param url the current delivery URL (from the latest API answer), undefined = nothing to show\n * @param isDisplayed whether the element already shows this content (then its URL is kept even past the expiry)\n * @returns the URL for the element: unchanged as long as the content is the same\n */\nexport const useStableContentUrl = (url: string | undefined, isDisplayed = false): string | undefined => {\n const [shownUrl, setShownUrl] = useState<string | undefined>(() => (url ? resolveStableContentUrl(url) : undefined));\n if (!url) {\n if (shownUrl !== undefined) setShownUrl(undefined);\n return undefined;\n }\n if (\n shownUrl !== undefined &&\n withoutContentToken(shownUrl) === withoutContentToken(url) &&\n (isDisplayed || !isContentUrlExpiring(shownUrl))\n ) {\n return shownUrl;\n }\n const nextUrl = resolveStableContentUrl(url);\n if (nextUrl !== shownUrl) setShownUrl(nextUrl);\n return nextUrl;\n};\n","'use client';\n\nimport { normalizeDddError } from '@mgamadeus/ddd-web/api';\n\nimport type { DesignStudioBoardView } from '../api/types';\nimport { useDesignStudio } from '../provider/DesignStudioProvider';\nimport { cx } from '../utils/cx';\nimport { boardStatusDefinition, boardStatusLabel } from './boardStatus';\n\nexport interface BoardStatusChipsProps {\n projectKey: string;\n canvasKey: string;\n board: DesignStudioBoardView;\n /** The configured status keys in display order (`DesignStudioCanvasView.statuses`). */\n statuses: readonly string[];\n writesAllowed: boolean;\n /** Called with the saved status (the canvas updates its copy). */\n onStatusChanged: (status: string) => void;\n}\n\n/** The review status of a board as chips (one per configured status); a click saves it. */\nexport const BoardStatusChips = ({\n projectKey,\n canvasKey,\n board,\n statuses,\n writesAllowed,\n onStatusChanged,\n}: BoardStatusChipsProps) => {\n const { api, notify, statuses: statusDefinitions } = useDesignStudio();\n const [patchStatus, { isLoading }] = api.useSetBoardStatusMutation();\n return (\n <fieldset className=\"m-0 flex flex-wrap items-center gap-1.5 border-0 p-0\" aria-label=\"Board status\">\n {statuses.map(status => {\n const Icon = boardStatusDefinition(statusDefinitions, status)?.icon;\n const isActive = board.status === status;\n return (\n <button\n key={status}\n type=\"button\"\n aria-pressed={isActive}\n disabled={!writesAllowed || isLoading || isActive || !board.boardKey}\n onClick={async () => {\n try {\n await patchStatus({\n projectKey,\n canvasKey,\n boardKey: board.boardKey ?? '',\n body: { status },\n }).unwrap();\n onStatusChanged(status);\n } catch (error) {\n notify.error(normalizeDddError(error, 'Request failed').message);\n }\n }}\n className={cx(\n 'inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-xs font-semibold transition-colors motion-reduce:transition-none',\n 'disabled:cursor-default',\n isActive\n ? 'bg-primary text-primary-foreground'\n : 'bg-tint text-muted-foreground hover:bg-tint-strong hover:text-foreground disabled:opacity-60'\n )}\n >\n {Icon && <Icon className=\"size-3.5\" aria-hidden />}\n {boardStatusLabel(statusDefinitions, status)}\n </button>\n );\n })}\n {board.hasChangedSinceStatus && (\n <span className=\"text-xs text-muted-foreground\" title=\"The board file changed after this status was set\">\n changed since\n </span>\n )}\n </fieldset>\n );\n};\n","'use client';\n\nimport '@xyflow/react/dist/style.css';\n\nimport {\n Background,\n BackgroundVariant,\n MiniMap,\n type Node,\n Panel,\n ReactFlow,\n ReactFlowProvider,\n useReactFlow,\n useStore,\n type Viewport,\n} from '@xyflow/react';\nimport { ChevronDown, Hand, MousePointer2, Play } from 'lucide-react';\nimport { type PointerEvent, type ReactNode, type RefObject, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport type { DesignStudioBoardView } from '../api/types';\nimport { useDesignStudio, useDesignStudioComponents } from '../provider/DesignStudioProvider';\nimport { cx } from '../utils/cx';\nimport { type BoardFlowNode, BoardNode } from './BoardNode';\nimport { type BoardRect, selectLiveBoardIds, selectVisibleBoardIds } from './boardDetail';\nimport { type CanvasLayout, findSectionAt, type LayoutRect } from './canvasLayout';\nimport { type CanvasViewport, formatViewportParam, withoutContentToken } from './canvasLiveUpdate';\nimport { sectionNodeId } from './canvasView';\nimport { type SectionFlowNode, SectionNode } from './SectionNode';\nimport { resolveStableContentUrl } from './stableContentUrl';\n\nconst NODE_TYPES = { board: BoardNode, section: SectionNode };\n\nconst ZOOM_PRESETS = [0.25, 0.5, 1];\nconst MIN_ZOOM = 0.005;\nconst MAX_ZOOM = 2.5;\n/** Wheel zoom: ~12 % per mouse notch (100 px); trackpad / Magic Mouse pixel deltas zoom proportionally. */\nconst WHEEL_ZOOM_PER_PIXEL = Math.log(1.12) / 100;\n/** Pinch (the browser sends ctrl + wheel with small deltas) zooms faster per pixel. */\nconst PINCH_ZOOM_PER_PIXEL = 0.012;\n/** deltaMode 1 (lines, e.g. Firefox: 3 lines per notch) and 2 (pages) in pixels. */\nconst WHEEL_LINE_PIXELS = 100 / 3;\nconst WHEEL_PAGE_PIXELS = 800;\n/** One wheel event never zooms by more than this many pixels (fast-spinning wheels, coalesced events). */\nconst WHEEL_MAX_PIXELS = 300;\n/** Per animation frame the zoom closes this share of the gap to its target (log scale): smooth, never springy. */\nconst ZOOM_EASE = 0.35;\n/** The viewport goes into the URL after this rest (a smooth zoom ends a move every frame). */\nconst VIEWPORT_COMMIT_MS = 300;\n/** Fit margins (px): sides / bottom, and the top below the canvas toolbar. */\nconst FIT_PADDING = 24;\nconst FIT_TOP = 72;\n/** Below this zoom the canvas is drawn at the overview level: one card per section, no boards. */\nexport const OVERVIEW_ZOOM = 0.06;\n/** Rest after a pan / zoom before the live boards are recomputed. */\nconst LIVE_BOARDS_SETTLE_MS = 300;\n\n/** Cover thumbnails per overview card. */\nconst OVERVIEW_COVER_COUNT = 4;\n/** Minimap width (px); its height follows the canvas' aspect ratio. */\nconst MINIMAP_WIDTH = 200;\n\n/** Canvas tools (select / hand). */\nexport type CanvasTool = 'select' | 'hand';\n\n/** A request to fit the view to some nodes; `key` changes for every request. */\nexport interface CanvasFitRequest {\n nodeIds: string[];\n key: number;\n}\n\nexport interface DesignCanvasFlowProps {\n layout: CanvasLayout;\n boardsByNodeId: ReadonlyMap<string, DesignStudioBoardView>;\n fitRequest: CanvasFitRequest | null;\n /** Nodes the first view fits (the first section: a whole tall canvas would start unreadably small). */\n initialFitNodeIds: string[];\n /** The first view as saved (`?vp=`): wins over `initialFitNodeIds`. */\n initialViewport?: CanvasViewport | null;\n /** A pan / zoom / fit ended on a new viewport (not called for the first view). */\n onViewportCommit?: (viewport: CanvasViewport) => void;\n tool: CanvasTool;\n onToolChange: (tool: CanvasTool) => void;\n /** Rendered width share from which a board shows live HTML (lower when the thumbnails show another theme). */\n liveMinRatio: number;\n onLiveBoardIdsChange: (liveBoardIds: Set<string>) => void;\n /** The boards in the viewport after a pan / zoom settled, nearest the centre first (node ids). */\n onVisibleBoardIdsChange?: (visibleBoardIds: string[]) => void;\n onPaneClick: () => void;\n /** \"Present\" for the section in the middle of the view. */\n onPresentSection: (sectionId: string) => void;\n /** Left toolbar content after the tools (canvas name, search, filters). */\n toolbarStart: ReactNode;\n /** Controls of the right toolbar group before the zoom (theme, theme mode, comments, fullscreen). */\n toolbarEnd: ReactNode;\n /** The selected board (Shift+2 fits it). */\n selectedNodeId: string | null;\n /** Marquee with the select tool: the boards inside the rectangle (`isAdditive` with shift / cmd / ctrl). */\n onMarqueeSelect: (nodeIds: string[], isAdditive: boolean) => void;\n}\n\n/** A marquee in progress, in container pixels. */\ninterface Marquee {\n startX: number;\n startY: number;\n x: number;\n y: number;\n}\n\n/** A press that moved less than this (px) is a click (selects), a longer one a pan (same as BoardNode). */\nconst CLICK_MAX_MOVE = 5;\n\n/** Below this drag distance (px) a press on the pane is a click, not a marquee. */\nconst MARQUEE_MIN_DRAG = 4;\n\nconst TOOLBAR_GROUP_CLASS = 'surface-glass-strong flex items-center gap-1 rounded-2xl p-1 ring-1 ring-foreground/5';\nconst TOOL_BUTTON_CLASS =\n 'flex size-8 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-tint hover:text-foreground motion-reduce:transition-none';\n\nconst ZoomMenu = ({ onFitAll }: { onFitAll: () => void }) => {\n const { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } =\n useDesignStudioComponents();\n const reactFlow = useReactFlow();\n const zoomPercent = useStore(state => Math.round(state.transform[2] * 100));\n return (\n <DropdownMenu modal={false}>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n className=\"flex h-8 min-w-16 items-center justify-center gap-1 rounded-xl px-2 text-sm font-semibold tabular-nums transition-colors hover:bg-tint\"\n aria-label={`Zoom ${zoomPercent} %`}\n >\n {zoomPercent}%\n <ChevronDown className=\"size-3.5 text-muted-foreground\" aria-hidden />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {ZOOM_PRESETS.map(zoom => (\n <DropdownMenuItem key={zoom} onSelect={() => void reactFlow.zoomTo(zoom, { duration: 250 })}>\n {Math.round(zoom * 100)} %\n </DropdownMenuItem>\n ))}\n <DropdownMenuSeparator />\n <DropdownMenuItem onSelect={() => void reactFlow.zoomIn({ duration: 200 })}>Zoom in</DropdownMenuItem>\n <DropdownMenuItem onSelect={() => void reactFlow.zoomOut({ duration: 200 })}>Zoom out</DropdownMenuItem>\n <DropdownMenuItem onSelect={onFitAll}>Fit all</DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n};\n\nconst buildNodes = (\n layout: CanvasLayout,\n boardsByNodeId: ReadonlyMap<string, DesignStudioBoardView>,\n isOverview: boolean,\n apiBaseUrl: string\n): Node[] => {\n const sectionNodes: SectionFlowNode[] = layout.sections.map(section => ({\n id: sectionNodeId(section.id),\n type: 'section',\n position: { x: section.x, y: section.y },\n width: section.width,\n height: section.height,\n data: {\n sectionId: section.id,\n title: section.title,\n boardCount: section.boardCount,\n isOverview,\n width: section.width,\n coverUrls: isOverview\n ? section.boardIds\n .slice(0, OVERVIEW_COVER_COUNT)\n .map(boardId => boardsByNodeId.get(boardId)?.thumbnailSmallUrl)\n .filter((url): url is string => Boolean(url))\n .map(url => resolveStableContentUrl(`${apiBaseUrl}${url}`))\n : [],\n },\n draggable: false,\n selectable: false,\n focusable: false,\n // overview cards are buttons (click = zoom to the section); React Flow would set pointer-events: none otherwise\n style: isOverview ? { pointerEvents: 'all' } : undefined,\n zIndex: 0,\n }));\n if (isOverview) return sectionNodes;\n const boardNodes: BoardFlowNode[] = [];\n for (const [nodeId, rect] of layout.boards) {\n const board = boardsByNodeId.get(nodeId);\n if (!board) continue;\n boardNodes.push({\n id: nodeId,\n type: 'board',\n position: { x: rect.x, y: rect.y },\n width: rect.width,\n height: rect.height,\n data: { board },\n draggable: false,\n selectable: false,\n // the node's own buttons select / open it; React Flow would set pointer-events: none on a non-selectable node\n style: { pointerEvents: 'all' },\n zIndex: 1,\n });\n }\n return [...sectionNodes, ...boardNodes];\n};\n\n/** Values equal for a node update: same identity, or arrays of URLs showing the same content (token aside). */\nconst isSameNodeValue = (previous: unknown, next: unknown): boolean => {\n if (Object.is(previous, next)) return true;\n if (Array.isArray(previous) && Array.isArray(next)) {\n return (\n previous.length === next.length &&\n previous.every((value, index) =>\n typeof value === 'string' && typeof next[index] === 'string'\n ? withoutContentToken(value) === withoutContentToken(next[index])\n : Object.is(value, next[index])\n )\n );\n }\n return false;\n};\n\n/** Shallow comparison of two flat records with isSameNodeValue (`style` and `position` are compared by content). */\nconst isSameRecord = (previous: object | undefined, next: object | undefined): boolean => {\n if (previous === next) return true;\n if (!previous || !next) return false;\n const previousEntries = Object.entries(previous);\n const nextRecord = next as Record<string, unknown>;\n return (\n previousEntries.length === Object.keys(next).length &&\n previousEntries.every(([key, value]) => key in nextRecord && isSameNodeValue(value, nextRecord[key]))\n );\n};\n\n/** The next node list with every node that equals its shown counterpart replaced by the shown object. */\nexport const reuseUnchangedNodes = (previousNodes: readonly Node[], nextNodes: Node[]): Node[] => {\n if (previousNodes.length === 0) return nextNodes;\n const previousById = new Map(previousNodes.map(node => [node.id, node]));\n let isAnyChanged = previousNodes.length !== nextNodes.length;\n const nodes = nextNodes.map((next, index) => {\n const previous = previousById.get(next.id);\n const isSame =\n previous !== undefined &&\n previous.type === next.type &&\n previous.width === next.width &&\n previous.height === next.height &&\n previous.zIndex === next.zIndex &&\n isSameRecord(previous.position, next.position) &&\n isSameRecord(previous.style, next.style) &&\n isSameRecord(previous.data, next.data);\n if (!isSame || previousNodes[index] !== previous) isAnyChanged = true;\n return isSame ? previous : next;\n });\n return isAnyChanged ? nodes : (previousNodes as Node[]);\n};\n\n/**\n * Wheel zoom towards the cursor for every input: mouse wheel (pixel or line deltas), Magic Mouse and trackpad scroll,\n * pinch (ctrl + wheel; Safari gesture events). The zoom eases to its target over a few frames (calm, no overshoot),\n * so a notch of a mouse wheel and a stream of small trackpad deltas both feel continuous; min / max zoom respected.\n * `nowheel` elements keep their own scrolling.\n */\nconst useWheelZoom = (containerRef: RefObject<HTMLDivElement | null>) => {\n const reactFlow = useReactFlow();\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n const minLogZoom = Math.log(MIN_ZOOM);\n const maxLogZoom = Math.log(MAX_ZOOM);\n let targetLogZoom = 0;\n let anchorX = 0;\n let anchorY = 0;\n let frame: number | null = null;\n let frameCount = 0;\n const step = () => {\n const { x, y, zoom } = reactFlow.getViewport();\n const currentLogZoom = Math.log(zoom);\n const difference = targetLogZoom - currentLogZoom;\n frameCount += 1;\n const isLast = Math.abs(difference) < 0.002 || frameCount > 90;\n const nextZoom = Math.exp(isLast ? targetLogZoom : currentLogZoom + difference * ZOOM_EASE);\n // the canvas point under the cursor stays under the cursor\n void reactFlow.setViewport({\n x: anchorX - ((anchorX - x) / zoom) * nextZoom,\n y: anchorY - ((anchorY - y) / zoom) * nextZoom,\n zoom: nextZoom,\n });\n frame = isLast ? null : requestAnimationFrame(step);\n };\n const zoomBy = (logDelta: number, clientX: number, clientY: number) => {\n const bounds = container.getBoundingClientRect();\n anchorX = clientX - bounds.left;\n anchorY = clientY - bounds.top;\n // a new gesture starts from the current zoom (a pan or fit may have changed it)\n if (frame === null) targetLogZoom = Math.log(reactFlow.getZoom());\n targetLogZoom = Math.min(maxLogZoom, Math.max(minLogZoom, targetLogZoom + logDelta));\n frameCount = 0;\n if (frame === null) frame = requestAnimationFrame(step);\n };\n const onWheel = (event: WheelEvent) => {\n if (event.target instanceof Element && event.target.closest('.nowheel')) return;\n event.preventDefault();\n if (isGesturing && event.ctrlKey) return;\n const unit = event.deltaMode === 1 ? WHEEL_LINE_PIXELS : event.deltaMode === 2 ? WHEEL_PAGE_PIXELS : 1;\n const pixels = Math.max(-WHEEL_MAX_PIXELS, Math.min(WHEEL_MAX_PIXELS, event.deltaY * unit));\n zoomBy(-pixels * (event.ctrlKey ? PINCH_ZOOM_PER_PIXEL : WHEEL_ZOOM_PER_PIXEL), event.clientX, event.clientY);\n };\n // Safari reports a trackpad pinch as gesture events (scale relative to the gesture start)\n let gestureScale = 1;\n let isGesturing = false;\n const onGestureStart = (event: Event) => {\n event.preventDefault();\n gestureScale = 1;\n isGesturing = true;\n };\n const onGestureEnd = () => {\n isGesturing = false;\n };\n const onGestureChange = (event: Event) => {\n event.preventDefault();\n const gesture = event as Event & { scale?: number; clientX?: number; clientY?: number };\n const scale = gesture.scale ?? 1;\n if (scale <= 0) return;\n zoomBy(Math.log(scale / gestureScale), gesture.clientX ?? 0, gesture.clientY ?? 0);\n gestureScale = scale;\n };\n container.addEventListener('wheel', onWheel, { passive: false });\n container.addEventListener('gesturestart', onGestureStart);\n container.addEventListener('gesturechange', onGestureChange);\n container.addEventListener('gestureend', onGestureEnd);\n return () => {\n container.removeEventListener('gestureend', onGestureEnd);\n container.removeEventListener('wheel', onWheel);\n container.removeEventListener('gesturestart', onGestureStart);\n container.removeEventListener('gesturechange', onGestureChange);\n if (frame !== null) cancelAnimationFrame(frame);\n };\n }, [containerRef, reactFlow]);\n};\n\nconst FlowCanvas = ({\n layout,\n boardsByNodeId,\n fitRequest,\n initialFitNodeIds,\n initialViewport = null,\n onViewportCommit,\n tool,\n onToolChange,\n liveMinRatio,\n onLiveBoardIdsChange,\n onVisibleBoardIdsChange,\n onPaneClick,\n onPresentSection,\n toolbarStart,\n toolbarEnd,\n selectedNodeId,\n onMarqueeSelect,\n}: DesignCanvasFlowProps) => {\n const { apiBaseUrl, components, statusColors } = useDesignStudio();\n const { Tooltip, TooltipContent, TooltipTrigger } = components;\n const containerRef = useRef<HTMLDivElement>(null);\n const reactFlow = useReactFlow();\n useWheelZoom(containerRef);\n const isOverview = useStore(state => state.transform[2] < OVERVIEW_ZOOM);\n // Structural update: a rebuilt node equal to the shown one keeps the shown object, so React Flow re-renders only\n // boards / sections whose data really changed (a poll or one changed board never redraws the whole canvas).\n const previousNodesRef = useRef<Node[]>([]);\n const nodes = useMemo(() => {\n const reused = reuseUnchangedNodes(\n previousNodesRef.current,\n buildNodes(layout, boardsByNodeId, isOverview, apiBaseUrl)\n );\n previousNodesRef.current = reused;\n return reused;\n }, [layout, boardsByNodeId, isOverview, apiBaseUrl]);\n // The minimap only helps while part of the canvas is outside the view.\n const isEverythingVisible = useStore(state => {\n const [x, y, zoom] = state.transform;\n return (\n x >= -1 &&\n y >= -1 &&\n x + layout.bounds.width * zoom <= state.width + 1 &&\n y + layout.bounds.height * zoom <= state.height + 1\n );\n });\n const boardRects = useMemo<BoardRect[]>(\n () => [...layout.boards].map(([id, rect]) => ({ id, ...rect })),\n [layout]\n );\n\n // Live boards are recomputed when a pan / zoom ends, never during it: panning stays thumbnail-only. A trackpad pan\n // ends many times (each wheel burst), so the update waits LIVE_BOARDS_SETTLE_MS of rest: passing over boards does\n // not start loads that are thrown away a moment later.\n const liveBoardsTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const cancelLiveBoardsUpdate = useCallback(() => {\n if (liveBoardsTimerRef.current) clearTimeout(liveBoardsTimerRef.current);\n liveBoardsTimerRef.current = null;\n }, []);\n useEffect(() => cancelLiveBoardsUpdate, [cancelLiveBoardsUpdate]);\n const updateLiveBoards = useCallback(\n (viewport: Viewport) => {\n const container = containerRef.current;\n if (!container) return;\n const screen = { width: container.clientWidth, height: container.clientHeight };\n onLiveBoardIdsChange(selectLiveBoardIds(boardRects, viewport, screen, undefined, liveMinRatio));\n onVisibleBoardIdsChange?.(selectVisibleBoardIds(boardRects, viewport, screen));\n },\n [boardRects, onLiveBoardIdsChange, onVisibleBoardIdsChange, liveMinRatio]\n );\n\n // Fit: the content top-aligned under the toolbar, centred horizontally, never above 100 %.\n const hasInitialFitRef = useRef(false);\n const fitRect = useCallback(\n (rect: LayoutRect, duration: number, fitWidthOnly = false): Viewport | null => {\n const container = containerRef.current;\n if (!container || container.clientWidth === 0 || rect.width <= 0 || rect.height <= 0) return null;\n const width = container.clientWidth;\n const height = container.clientHeight;\n // a section is fitted by its width (a tall section then scrolls), everything else whole\n const widthZoom = (width - 2 * FIT_PADDING) / rect.width;\n const heightZoom = fitWidthOnly ? widthZoom : (height - FIT_TOP - FIT_PADDING) / rect.height;\n const zoom = Math.max(MIN_ZOOM, Math.min(widthZoom, heightZoom, 1));\n const viewport = { x: (width - rect.width * zoom) / 2 - rect.x * zoom, y: FIT_TOP - rect.y * zoom, zoom };\n void reactFlow.setViewport(viewport, { duration }).then(() => {\n updateLiveBoards(viewport);\n });\n return viewport;\n },\n [reactFlow, updateLiveBoards]\n );\n const rectOfNodes = useCallback(\n (nodeIds: string[]): LayoutRect | null => {\n const sectionRects = new Map(layout.sections.map(section => [sectionNodeId(section.id), section as LayoutRect]));\n const rects = nodeIds\n .map(nodeId => sectionRects.get(nodeId) ?? layout.boards.get(nodeId))\n .filter((rect): rect is LayoutRect => rect !== undefined);\n if (rects.length === 0) return null;\n const left = Math.min(...rects.map(rect => rect.x));\n const top = Math.min(...rects.map(rect => rect.y));\n const right = Math.max(...rects.map(rect => rect.x + rect.width));\n const bottom = Math.max(...rects.map(rect => rect.y + rect.height));\n return { x: left, y: top, width: right - left, height: bottom - top };\n },\n [layout]\n );\n const fitNodes = useCallback(\n (nodeIds: string[], duration = 400): Viewport | null => {\n const rect = rectOfNodes(nodeIds);\n const isSingleSection = nodeIds.length === 1 && nodeIds[0].startsWith(sectionNodeId(''));\n return rect ? fitRect(rect, duration, isSingleSection) : null;\n },\n [rectOfNodes, fitRect]\n );\n const fitAll = useCallback(() => {\n fitRect(layout.bounds, 400);\n }, [fitRect, layout]);\n\n // Each fit request once (the callbacks change with the live threshold, the request does not).\n const handledFitKeyRef = useRef<number | null>(null);\n useEffect(() => {\n if (!fitRequest || handledFitKeyRef.current === fitRequest.key) return;\n handledFitKeyRef.current = fitRequest.key;\n fitNodes(fitRequest.nodeIds);\n }, [fitRequest, fitNodes]);\n\n // The last viewport reported through onViewportCommit (the first view counts as reported: a fresh page writes no\n // `vp` until the user moves).\n const committedViewportRef = useRef<string | null>(null);\n\n // First view once the layout and the container exist: the saved viewport (`?vp=`, a reload keeps the place), else\n // the first section (a whole tall canvas would start unreadably small). Retried from the resize observer while the\n // container has no size yet.\n const isFlowReadyRef = useRef(false);\n const initialViewportRef = useRef(initialViewport);\n const fitInitialView = useCallback(() => {\n if (!isFlowReadyRef.current || hasInitialFitRef.current || layout.sections.length === 0) return;\n const container = containerRef.current;\n if (!container || container.clientWidth === 0) return;\n const savedViewport = initialViewportRef.current;\n if (savedViewport) {\n hasInitialFitRef.current = true;\n committedViewportRef.current = formatViewportParam(savedViewport);\n void reactFlow.setViewport(savedViewport, { duration: 0 }).then(() => updateLiveBoards(savedViewport));\n return;\n }\n const viewport = initialFitNodeIds.length > 0 ? fitNodes(initialFitNodeIds, 0) : fitRect(layout.bounds, 0);\n if (viewport) {\n hasInitialFitRef.current = true;\n committedViewportRef.current = formatViewportParam(viewport);\n }\n }, [layout, initialFitNodeIds, fitNodes, fitRect, reactFlow, updateLiveBoards]);\n // the URL gets the viewport once the view rests (a smooth zoom ends a move every frame)\n const viewportCommitTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(\n () => () => {\n if (viewportCommitTimerRef.current) clearTimeout(viewportCommitTimerRef.current);\n },\n []\n );\n const commitViewport = (viewport: Viewport) => {\n if (!hasInitialFitRef.current) return;\n if (viewportCommitTimerRef.current) clearTimeout(viewportCommitTimerRef.current);\n viewportCommitTimerRef.current = setTimeout(() => {\n viewportCommitTimerRef.current = null;\n const value = formatViewportParam(viewport);\n if (value === committedViewportRef.current) return;\n committedViewportRef.current = value;\n onViewportCommit?.(viewport);\n }, VIEWPORT_COMMIT_MS);\n };\n useEffect(() => {\n fitInitialView();\n }, [fitInitialView]);\n\n // A different live threshold (thumbnails missing / complete) re-evaluates the live boards of the current view.\n useEffect(() => {\n if (hasInitialFitRef.current) updateLiveBoards(reactFlow.getViewport());\n }, [reactFlow, updateLiveBoards]);\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n const resizeObserver = new ResizeObserver(() => {\n if (hasInitialFitRef.current) updateLiveBoards(reactFlow.getViewport());\n else fitInitialView();\n });\n resizeObserver.observe(container);\n return () => resizeObserver.disconnect();\n }, [reactFlow, updateLiveBoards, fitInitialView]);\n\n // Keys as in common design tools: V select, H hand, + / − zoom, 0 = 100 %, Shift+1 fit all (not while typing).\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement | null;\n if (target && (target.tagName === 'TEXTAREA' || target.tagName === 'INPUT' || target.isContentEditable)) return;\n if (document.querySelector('[role=dialog]')) return;\n if (event.metaKey || event.ctrlKey || event.altKey) return;\n if (event.key === 'v' || event.key === 'V') onToolChange('select');\n else if (event.key === 'h' || event.key === 'H' || event.key === 'Escape') onToolChange('hand');\n else if (event.shiftKey && event.code === 'Digit1') fitAll();\n else if (event.shiftKey && event.code === 'Digit2') fitSelectionOrSection();\n else if (event.key === '+' || event.key === '=') void reactFlow.zoomIn({ duration: 200 });\n else if (event.key === '-' || event.key === '_') void reactFlow.zoomOut({ duration: 200 });\n else if (event.key === '0' && !event.shiftKey) void reactFlow.zoomTo(1, { duration: 250 });\n };\n window.addEventListener('keydown', onKeyDown);\n return () => window.removeEventListener('keydown', onKeyDown);\n });\n\n const sectionInView = () => {\n const container = containerRef.current;\n if (!container || layout.sections.length === 0) return undefined;\n const viewport = reactFlow.getViewport();\n const centreX = (-viewport.x + container.clientWidth / 2) / viewport.zoom;\n const centreY = (-viewport.y + container.clientHeight / 2) / viewport.zoom;\n return findSectionAt(layout.sections, centreX, centreY) ?? layout.sections[0];\n };\n const fitSelectionOrSection = () => {\n if (selectedNodeId && layout.boards.has(selectedNodeId)) {\n fitNodes([selectedNodeId]);\n return;\n }\n const section = sectionInView();\n if (section) fitNodes([sectionNodeId(section.id)]);\n };\n const presentCurrentSection = () => {\n const section = sectionInView();\n if (section) onPresentSection(section.id);\n };\n // Marquee selection with the select tool (Space or the middle button pans meanwhile, React Flow's defaults).\n const [marquee, setMarquee] = useState<Marquee | null>(null);\n const isMarqueeJustEndedRef = useRef(false);\n const startMarquee = (event: PointerEvent<HTMLDivElement>) => {\n const target = event.target as HTMLElement;\n if (tool !== 'select' || event.button !== 0 || !target.classList.contains('react-flow__pane')) return;\n const container = containerRef.current;\n if (!container) return;\n const bounds = container.getBoundingClientRect();\n const startX = event.clientX - bounds.left;\n const startY = event.clientY - bounds.top;\n const isAdditive = event.shiftKey || event.metaKey || event.ctrlKey;\n let current: Marquee = { startX, startY, x: startX, y: startY };\n setMarquee(current);\n const onMove = (moveEvent: globalThis.PointerEvent) => {\n current = { startX, startY, x: moveEvent.clientX - bounds.left, y: moveEvent.clientY - bounds.top };\n setMarquee(current);\n };\n const onUp = () => {\n window.removeEventListener('pointermove', onMove);\n window.removeEventListener('pointerup', onUp);\n setMarquee(null);\n if (Math.abs(current.x - startX) < MARQUEE_MIN_DRAG && Math.abs(current.y - startY) < MARQUEE_MIN_DRAG) return;\n isMarqueeJustEndedRef.current = true;\n const topLeft = reactFlow.screenToFlowPosition({\n x: bounds.left + Math.min(startX, current.x),\n y: bounds.top + Math.min(startY, current.y),\n });\n const bottomRight = reactFlow.screenToFlowPosition({\n x: bounds.left + Math.max(startX, current.x),\n y: bounds.top + Math.max(startY, current.y),\n });\n const nodeIds = [...layout.boards]\n .filter(\n ([, rect]) =>\n rect.x < bottomRight.x &&\n rect.x + rect.width > topLeft.x &&\n rect.y < bottomRight.y &&\n rect.y + rect.height > topLeft.y\n )\n .map(([nodeId]) => nodeId);\n onMarqueeSelect(nodeIds, isAdditive);\n };\n window.addEventListener('pointermove', onMove);\n window.addEventListener('pointerup', onUp);\n };\n const onPaneClickUnlessMarquee = () => {\n if (isMarqueeJustEndedRef.current) {\n isMarqueeJustEndedRef.current = false;\n return;\n }\n onPaneClick();\n };\n\n const minimapHeight = Math.round(\n Math.min(180, Math.max(60, (MINIMAP_WIDTH * layout.bounds.height) / Math.max(1, layout.bounds.width)))\n );\n\n return (\n <div\n ref={containerRef}\n className={cx('relative h-full w-full', tool === 'hand' && 'cursor-grab active:cursor-grabbing')}\n onPointerDownCapture={startMarquee}\n >\n {marquee && (\n <div\n aria-hidden\n className=\"pointer-events-none absolute z-10 rounded-sm border border-brand bg-brand/10\"\n style={{\n left: Math.min(marquee.startX, marquee.x),\n top: Math.min(marquee.startY, marquee.y),\n width: Math.abs(marquee.x - marquee.startX),\n height: Math.abs(marquee.y - marquee.startY),\n }}\n />\n )}\n <ReactFlow\n nodes={nodes}\n edges={[]}\n nodeTypes={NODE_TYPES}\n onlyRenderVisibleElements\n nodesDraggable={false}\n nodesConnectable={false}\n elementsSelectable={false}\n zoomOnDoubleClick={false}\n // every wheel (mouse, Magic Mouse, trackpad scroll and pinch) zooms towards the cursor: our own handler\n // (useWheelZoom), React Flow handles no wheel at all; drag pans (also over boards, they are not draggable)\n panOnScroll={false}\n zoomOnScroll={false}\n zoomOnPinch={false}\n minZoom={MIN_ZOOM}\n maxZoom={MAX_ZOOM}\n defaultViewport={{ x: 0, y: 0, zoom: 0.1 }}\n onInit={() => {\n isFlowReadyRef.current = true;\n fitInitialView();\n }}\n onMoveStart={cancelLiveBoardsUpdate}\n onMoveEnd={(_event, viewport) => {\n cancelLiveBoardsUpdate();\n liveBoardsTimerRef.current = setTimeout(() => updateLiveBoards(viewport), LIVE_BOARDS_SETTLE_MS);\n commitViewport(viewport);\n }}\n onPaneClick={onPaneClickUnlessMarquee}\n panOnDrag={tool === 'hand' ? true : [1, 2]}\n // a press that moved less than this is still a click (d3-zoom otherwise swallows the click after any move)\n paneClickDistance={CLICK_MAX_MOVE}\n selectionOnDrag={false}\n proOptions={{ hideAttribution: true }}\n >\n <Background variant={BackgroundVariant.Dots} gap={32} size={1.5} color=\"var(--tint-strong)\" />\n <Panel position=\"top-left\" className=\"flex max-w-[calc(100%-32rem)] flex-wrap items-center gap-2\">\n <div className={TOOLBAR_GROUP_CLASS} role=\"toolbar\" aria-label=\"Canvas tools\">\n {(\n [\n ['hand', Hand, 'Pan (H / Esc) — drag moves the canvas, click selects a board'],\n ['select', MousePointer2, 'Select area (V) — drag a rectangle to select boards, Space + drag pans'],\n ] as const\n ).map(([toolName, Icon, label]) => (\n <Tooltip key={toolName}>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n aria-label={label}\n aria-pressed={tool === toolName}\n onClick={() => onToolChange(toolName)}\n className={cx(TOOL_BUTTON_CLASS, tool === toolName && 'bg-brand-light text-brand-emphasis')}\n >\n <Icon className=\"size-4\" />\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{label}</TooltipContent>\n </Tooltip>\n ))}\n </div>\n {toolbarStart}\n </Panel>\n <Panel position=\"top-right\">\n <div className={TOOLBAR_GROUP_CLASS}>\n {toolbarEnd}\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n aria-label=\"Present the section in view\"\n onClick={presentCurrentSection}\n className={TOOL_BUTTON_CLASS}\n >\n <Play className=\"size-4\" />\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">Present this section (← / →)</TooltipContent>\n </Tooltip>\n <ZoomMenu onFitAll={fitAll} />\n </div>\n </Panel>\n <Panel position=\"bottom-left\" className=\"pointer-events-none\">\n <p className=\"surface-glass-strong rounded-xl px-3 py-1.5 text-xs text-muted-foreground ring-1 ring-foreground/5\">\n Drag to pan · Scroll or pinch to zoom · Click selects · Double-click opens · + / − / 0 · Shift+1 fits all\n </p>\n </Panel>\n {!isEverythingVisible && (\n <MiniMap\n pannable\n zoomable\n ariaLabel=\"Canvas overview: click or drag to move\"\n style={{ width: MINIMAP_WIDTH, height: minimapHeight }}\n nodeColor={node =>\n node.type === 'section'\n ? 'var(--brand-light)'\n : (statusColors?.[(node as BoardFlowNode).data.board.status ?? ''] ?? 'var(--muted-foreground)')\n }\n nodeStrokeWidth={0}\n nodeBorderRadius={24}\n maskColor=\"rgb(8 9 72 / 0.12)\"\n maskStrokeColor=\"var(--brand)\"\n maskStrokeWidth={3}\n onClick={(_event, position) =>\n void reactFlow.setCenter(position.x, position.y, { zoom: reactFlow.getZoom(), duration: 300 })\n }\n className=\"surface-glass-strong !rounded-xl\"\n />\n )}\n </ReactFlow>\n </div>\n );\n};\n\n/** The infinite canvas (React Flow / xyflow, MIT): auto-laid-out sections and boards, tools, zoom, minimap. */\nexport const DesignCanvasFlow = (props: DesignCanvasFlowProps) => (\n <ReactFlowProvider>\n <FlowCanvas {...props} />\n </ReactFlowProvider>\n);\n","'use client';\n\nimport { type Node, type NodeProps, useStore } from '@xyflow/react';\nimport { memo } from 'react';\n\nimport { SECTION_PADDING } from './canvasLayout';\nimport { useCanvasView } from './canvasView';\n\nexport type SectionNodeData = {\n sectionId: string;\n title: string;\n boardCount: number;\n /** Overview level (far zoom): the section is drawn as a card with cover thumbnails instead of its boards. */\n isOverview: boolean;\n /** Small thumbnails of the first boards (overview card). */\n coverUrls: string[];\n /** Section width in canvas px (overview title size). */\n width: number;\n};\nexport type SectionFlowNode = Node<SectionNodeData, 'section'>;\n\n/** Title size in screen px on an overview card (the card scales with the canvas, the title keeps readable). */\nconst OVERVIEW_TITLE_SCREEN_PX = 15;\n\n/**\n * A section of the canvas. Normally a quiet background exactly around its title and boards (computed by\n * `computeCanvasLayout`) with the title as one bold line above the boards — scaled with the canvas like the boards,\n * never behind them. At the overview level (far zoom) the boards are not drawn; the section becomes a card with its\n * title, board count and a few cover thumbnails, and a click zooms to it.\n */\nconst SectionNodeComponent = ({ data }: NodeProps<SectionFlowNode>) => {\n const { onZoomToSection } = useCanvasView();\n // follows the zoom only at the overview level (a handful of section cards), a constant 1 otherwise\n const zoom = useStore(state => (data.isOverview ? Math.round(state.transform[2] * 1000) / 1000 : 1));\n\n if (!data.isOverview) {\n return (\n <div className=\"pointer-events-none h-full w-full rounded-[64px] bg-card/50 ring-2 ring-foreground/5 backdrop-blur-xl\">\n <div\n className=\"flex items-baseline gap-4 overflow-hidden text-ellipsis whitespace-nowrap\"\n style={{ padding: `${SECTION_PADDING}px ${SECTION_PADDING}px 0` }}\n title={data.title}\n >\n <span className=\"text-[56px] leading-none font-bold tracking-tight text-foreground\">{data.title}</span>\n <span className=\"text-[28px] leading-none text-muted-foreground\">{data.boardCount} boards</span>\n </div>\n </div>\n );\n }\n\n // readable on screen, but never wider than the card allows\n const titleFontSize = Math.min(OVERVIEW_TITLE_SCREEN_PX / zoom, data.width / 7);\n return (\n <button\n type=\"button\"\n onClick={() => onZoomToSection(data.sectionId)}\n aria-label={`${data.title}: ${data.boardCount} boards — zoom in`}\n className=\"flex h-full w-full cursor-zoom-in flex-col overflow-hidden rounded-[64px] bg-card text-left shadow-surface-raised ring-1 ring-foreground/10 transition-shadow hover:ring-[24px] hover:ring-brand/40\"\n style={{ padding: titleFontSize }}\n >\n <span className=\"block w-full\" style={{ fontSize: titleFontSize, lineHeight: 1.2 }}>\n <span className=\"line-clamp-2 font-bold text-foreground\">{data.title}</span>\n <span className=\"block text-muted-foreground\" style={{ fontSize: titleFontSize * 0.8 }}>\n {data.boardCount} boards\n </span>\n </span>\n <span\n className=\"mt-auto grid min-h-0 flex-1 grid-cols-2 content-end\"\n style={{ gap: titleFontSize * 0.6, paddingTop: titleFontSize * 0.6 }}\n >\n {data.coverUrls.map(coverUrl => (\n // biome-ignore lint/performance/noImgElement: small cover thumbnails from the API at canvas scale\n <img\n key={coverUrl}\n src={coverUrl}\n alt=\"\"\n loading=\"lazy\"\n decoding=\"async\"\n draggable={false}\n className=\"pointer-events-none w-full rounded-[24px] object-cover object-top shadow-surface-raised select-none\"\n />\n ))}\n </span>\n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ACzB;AAAA,YACA,SAAS,UAAU,cAAc;AAAA,YACjC;AAAA,YACA,cAAc;AAAA,YACd,SAAS;AAAA,YACT,YAAY,MAAM,UAAU,EAAE;AAAA,YAC9B,QAAQ,MAAM,UAAU,CAAC;AAAA,YACzB,iBAAiB,YAAU,kBAAkB,eAAe,gBAAgB,MAAM;AAAA,YAClF,iBAAiB,CAAC,EAAE,QAAQ,KAAK,MAC/B,kBAAkB,KAAK,eAAe,CAAC,kBAAkB,gBAAgB,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC;AAAA,YAE7F,uBAAuB;AAAA;AAAA,QACzB;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["normalizeDddError","ClipboardCopy","Maximize2","MessageSquare","useCallback","useEffect","useMemo","useRef","useState","ClipboardCopy","MapPin","useEffect","useState","ClipboardCopy","useEffect","useState","grids","useState","useEffect","useState","useState","useState","jsx","jsxs","useState","useEffect","ClipboardCopy","normalizeDddError","jsx","jsxs","normalizeDddError","Fragment","jsx","jsxs","useState","useEffect","MapPin","ClipboardCopy","useStore","useEffect","useRef","useState","useStore","memo","jsx","jsxs","useStore","memo","jsx","jsxs","CLICK_MAX_MOVE","useStore","useEffect","useRef","useState","Fragment","jsx","jsxs","useState","useEffect","TOOL_BUTTON_CLASS","TOOLBAR_GROUP_CLASS","useRef","Maximize2","useCallback","useMemo","ClipboardCopy","normalizeDddError","MessageSquare"]}