awesome-timeline-react 0.3.0 → 0.4.0
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.
- package/README.md +131 -1
- package/dist/_tsup-dts-rollup.d.mts +230 -10
- package/dist/_tsup-dts-rollup.d.ts +230 -10
- package/dist/index.css +9 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +705 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +707 -93
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/timeline.tsx","../src/canvas/animator.ts","../src/hooks/use-resize-observer.ts","../src/helpers/sort-events.ts","../src/components/rt-indicator.tsx","../src/components/event-prompt.tsx","../src/components/canvas-time-bar.tsx","../src/helpers/get-month-name.ts","../src/helpers/get-week-day-name.ts","../src/core/time-blocks.ts","../src/canvas/dpr.ts","../src/canvas/theme.ts","../src/canvas/draw-grid.ts","../src/components/canvas-board.tsx","../src/canvas/frame-scheduler.ts","../src/core/culling.ts","../src/core/coords.ts","../src/core/geometry.ts","../src/core/lanes.ts","../src/core/interactions.ts","../src/canvas/draw-events.ts","../src/canvas/renderer.ts","../src/hooks/use-canvas-interactions.ts","../src/core/types.ts","../src/core/hit-test.ts","../src/core/scene.ts"],"sourcesContent":["export * from \"./timeline\";\nexport type {\n RowType,\n EventType,\n EventPropsType,\n EventStyle,\n EventState,\n DrawEventFn,\n Theme,\n ResolvedTheme,\n Rect,\n OnDropProps,\n OnResizeProps,\n OnEventClickProps,\n OnEventHoverProps,\n PanZoomConfig,\n EventPatch,\n TimelineHandle,\n TimelineProps,\n TimelineType,\n} from \"./types\";\n","import React, {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n EventPromptActionsType,\n TimelineHandle,\n TimelineProps,\n} from \"./types\";\nimport {\n DEFAULT_FADE_DURATION_MS,\n DEFAULT_LAYOUT_DURATION_MS,\n} from \"./canvas/animator\";\nimport \"./style.css\";\nimport useResizeObserver from \"./hooks/use-resize-observer\";\nimport sortEvents from \"./helpers/sort-events\";\nimport RTIndicator from \"./components/rt-indicator\";\nimport EventPrompt from \"./components/event-prompt\";\nimport CanvasTimeBar from \"./components/canvas-time-bar\";\nimport CanvasBoard from \"./components/canvas-board\";\nimport { SceneStore } from \"./core/scene\";\nimport { TimelineRenderer } from \"./canvas/renderer\";\nimport { resolveTheme } from \"./canvas/theme\";\nimport { geometryFromTheme } from \"./core/geometry\";\n\nexport const Timeline = forwardRef<TimelineHandle, TimelineProps>(\n (\n {\n rows,\n events,\n staticEvents,\n onDrop,\n onResize,\n onEventClick,\n onEventHover,\n startDate,\n endDate,\n theme,\n drawEvent,\n additionalClassNames,\n showRTIndicator = true,\n eventsResize = true,\n eventPromptTemplate,\n showEventPrompt = true,\n panZoom,\n timeBar,\n animations = true,\n },\n handleRef\n ) => {\n const [windowTime, setWindowTime] = useState([\n new Date(\n startDate.getFullYear(),\n startDate.getMonth(),\n startDate.getDate(),\n startDate.getHours(),\n 0,\n 0\n ).getTime() / 1000,\n new Date(\n endDate.getFullYear(),\n endDate.getMonth(),\n endDate.getDate(),\n endDate.getHours(),\n 0,\n 0\n ).getTime() / 1000,\n ]);\n\n // cellWidth is in px\n const [cellWidth, setCellWidth] = useState(0);\n\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const mainRef = useRef<HTMLDivElement | null>(null);\n\n const bodyRef = useRef<HTMLDivElement | null>(null);\n\n // tick is represent how many seconds is a one pixel\n const [tick, setTick] = useState<number | null>(null);\n\n const [scrollWidth, setScrollWidth] = useState(0);\n\n const eventPromptRef = useRef<EventPromptActionsType | null>(null);\n\n const rendererRef = useRef<TimelineRenderer | null>(null);\n\n // The SceneStore is the single source of truth for event data. The\n // `events` prop is authoritative on every reference change (full reset);\n // interactions and the imperative handle mutate the store directly.\n const sceneRef = useRef<SceneStore | null>(null);\n if (sceneRef.current === null) {\n sceneRef.current = new SceneStore();\n }\n const scene = sceneRef.current;\n\n useEffect(() => {\n scene.setRows(rows);\n }, [scene, rows]);\n useEffect(() => {\n scene.setEvents([...events].sort(sortEvents));\n }, [scene, events]);\n useEffect(() => {\n scene.setStaticEvents(staticEvents ? [...staticEvents] : []);\n }, [scene, staticEvents]);\n\n const windowTimeRef = useRef(windowTime);\n windowTimeRef.current = windowTime;\n\n useImperativeHandle(\n handleRef,\n (): TimelineHandle => ({\n setEvents: (next) => scene.setEvents([...next].sort(sortEvents)),\n updateEvents: (patches) => scene.applyPatches(patches),\n getEvent: (id) => scene.getEvent(id),\n scrollToRow: (rowId) => {\n const [windowStart, windowEnd] = windowTimeRef.current;\n const offset = scene\n .getRowOffsets(windowStart, windowEnd)\n .offsetOf.get(rowId);\n if (offset !== undefined && bodyRef.current) {\n bodyRef.current.scrollTop = offset;\n }\n },\n scrollToTime: (time) => {\n setWindowTime((prev) => [time, time + (prev[1] - prev[0])]);\n },\n setWindow: (startTime, endTime) => setWindowTime([startTime, endTime]),\n getVisibleRange: () => ({\n startTime: windowTimeRef.current[0],\n endTime: windowTimeRef.current[1],\n }),\n redraw: () => rendererRef.current?.invalidate(\"all\"),\n }),\n [scene]\n );\n\n useEffect(() => {\n if (contentRef.current) {\n const windowDuration = windowTime[1] - windowTime[0];\n const numberOfHourBlocks = windowDuration / 3600;\n setTick(\n windowDuration / contentRef.current.getBoundingClientRect().width\n );\n setCellWidth(\n contentRef.current.getBoundingClientRect().width / numberOfHourBlocks\n );\n }\n }, []);\n\n useEffect(() => {\n if (bodyRef.current) {\n setScrollWidth(\n bodyRef.current.getBoundingClientRect().width -\n bodyRef.current.scrollWidth\n );\n }\n }, []);\n\n useResizeObserver({ contentRef, setCellWidth, setTick, windowTime });\n\n const resolvedTheme = useMemo(() => resolveTheme(theme), [theme]);\n\n // Push themeable bar geometry into the scene (single source of truth for\n // row heights / lane offsets, read by the renderer and hit-testing).\n const geometry = useMemo(\n () => geometryFromTheme(resolvedTheme),\n [resolvedTheme]\n );\n useEffect(() => {\n scene.setGeometry(geometry);\n }, [scene, geometry]);\n\n const resolvedAnimations = useMemo(() => {\n if (animations === false) return { layoutMs: 0, fadeMs: 0 };\n if (animations === true) {\n return {\n layoutMs: DEFAULT_LAYOUT_DURATION_MS,\n fadeMs: DEFAULT_FADE_DURATION_MS,\n };\n }\n return {\n layoutMs: animations.layoutMs ?? DEFAULT_LAYOUT_DURATION_MS,\n fadeMs: animations.fadeMs ?? DEFAULT_FADE_DURATION_MS,\n };\n }, [animations]);\n\n const eventPrompt = useMemo(\n () => (\n <EventPrompt\n ref={eventPromptRef}\n template={eventPromptTemplate}\n ></EventPrompt>\n ),\n [eventPromptTemplate]\n );\n\n return (\n <div className=\"main-wrapper\" ref={mainRef}>\n {showRTIndicator && (\n <RTIndicator tick={tick} windowTime={windowTime}></RTIndicator>\n )}\n <CanvasTimeBar\n windowTime={windowTime}\n tick={tick}\n contentWidth={\n contentRef.current\n ? contentRef.current.getBoundingClientRect().width\n : null\n }\n scrollWidth={scrollWidth}\n theme={resolvedTheme}\n timeBar={timeBar}\n />\n\n <div className=\"body-wrapper\" ref={bodyRef}>\n <CanvasBoard\n scene={scene}\n rows={rows}\n windowTime={windowTime}\n tick={tick}\n cellWidth={cellWidth}\n theme={resolvedTheme}\n drawEvent={drawEvent}\n bodyRef={bodyRef}\n rendererRef={rendererRef}\n eventPromptRef={eventPromptRef}\n rowsHeaderClassName={additionalClassNames?.rowsHeader}\n setWindowTime={setWindowTime}\n setCellWidth={setCellWidth}\n setTick={setTick}\n onDrop={onDrop}\n onResize={onResize}\n onEventClick={onEventClick}\n onEventHover={onEventHover}\n eventsResize={eventsResize}\n panZoom={panZoom}\n animations={resolvedAnimations}\n ref={contentRef}\n />\n {showEventPrompt && eventPrompt}\n </div>\n </div>\n );\n }\n);\n","// defaults — snappier than the legacy CSS (0.5s / 0.3s) by user request\nexport const DEFAULT_LAYOUT_DURATION_MS = 200;\nexport const DEFAULT_FADE_DURATION_MS = 120;\n\ntype Tween = {\n from: number;\n to: number;\n start: number;\n duration: number;\n};\n\n// smoothstep — visually equivalent to CSS ease-in-out\nconst ease = (t: number) => t * t * (3 - 2 * t);\n\n/**\n * Replaces the CSS transitions the DOM renderer got for free:\n * row heights and event tops tween when stacking changes, and resize\n * handles fade in/out. Values are queried per frame; while any tween is\n * live the renderer keeps scheduling frames.\n *\n * Durations are configurable via the Timeline `animations` prop; a duration\n * of 0 disables that animation (values jump straight to target).\n *\n * Coordinate rules: row heights are content-space; event tops are\n * ROW-LOCAL lane offsets. Tweens must never target a value that is itself\n * animated (e.g. an absolute top including the animated row position) —\n * a moving target retargets every frame and the tween lags behind it\n * perpetually, desyncing the layers.\n */\nexport class LayoutAnimator {\n private rowHeights = new Map<string, Tween>();\n private eventTops = new Map<string, Tween>();\n private handleAlphas = new Map<string, Tween>();\n private now = 0;\n private activeUntil = 0;\n private layoutDuration = DEFAULT_LAYOUT_DURATION_MS;\n private fadeDuration = DEFAULT_FADE_DURATION_MS;\n\n setDurations(layoutMs: number, fadeMs: number) {\n this.layoutDuration = layoutMs;\n this.fadeDuration = fadeMs;\n }\n\n beginFrame(now: number) {\n this.now = now;\n }\n\n rowHeight(rowId: string, target: number): number {\n return this.value(this.rowHeights, rowId, target, this.layoutDuration);\n }\n\n eventTop(eventId: string, target: number): number {\n return this.value(this.eventTops, eventId, target, this.layoutDuration);\n }\n\n /** 0..1 opacity of an event's resize handles; target 1 = hovered. */\n handleAlpha(eventId: string, target: number): number {\n return this.value(this.handleAlphas, eventId, target, this.fadeDuration);\n }\n\n isAnimating(): boolean {\n return this.now < this.activeUntil;\n }\n\n /**\n * Drop an event's top tween so its next draw renders at the target\n * instantly — used on drag-drop commit, where the ghost already previewed\n * the final position and a tween would feel like a rubber-band.\n */\n snapEventTop(eventId: string) {\n this.eventTops.delete(eventId);\n }\n\n /** Drop all state, e.g. when the scene is reset wholesale. */\n reset() {\n this.rowHeights.clear();\n this.eventTops.clear();\n this.handleAlphas.clear();\n this.activeUntil = 0;\n }\n\n private value(\n map: Map<string, Tween>,\n key: string,\n target: number,\n duration: number\n ): number {\n let tween = map.get(key);\n if (!tween) {\n // first sighting renders at the target instantly (legacy: a newly\n // mounted element has no previous value to transition from)\n tween = { from: target, to: target, start: 0, duration };\n map.set(key, tween);\n return target;\n }\n if (tween.to !== target) {\n if (duration <= 0) {\n tween.from = target;\n tween.to = target;\n return target;\n }\n const current = this.current(tween);\n tween.from = current;\n tween.to = target;\n tween.start = this.now;\n tween.duration = duration;\n this.activeUntil = Math.max(this.activeUntil, this.now + duration);\n }\n return this.current(tween);\n }\n\n private current(tween: Tween): number {\n if (tween.from === tween.to || tween.duration <= 0) return tween.to;\n const t = Math.min(1, (this.now - tween.start) / tween.duration);\n return tween.from + (tween.to - tween.from) * ease(t);\n }\n}\n","import { useEffect, useMemo, useRef } from \"react\";\n\nconst useResizeObserver = ({\n windowTime,\n setTick,\n setCellWidth,\n contentRef,\n}: {\n windowTime: number[];\n setTick: React.Dispatch<React.SetStateAction<number | null>>;\n setCellWidth: React.Dispatch<React.SetStateAction<number>>;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n}) => {\n const prevWidthRef = useRef(0);\n\n const resizeObserver = useMemo(() => {\n return new ResizeObserver((entries) => {\n for (const entry of entries) {\n const width = entry.borderBoxSize?.[0].inlineSize;\n if (typeof width === \"number\" && width !== prevWidthRef.current) {\n prevWidthRef.current = width;\n const windowDuration = windowTime[1] - windowTime[0];\n const numberOfHourBlocks = windowDuration / 3600;\n setTick(windowDuration / entry.contentRect.width);\n setCellWidth(entry.contentRect.width / numberOfHourBlocks);\n }\n }\n });\n }, [windowTime]);\n\n useEffect(() => {\n if (contentRef.current) {\n resizeObserver.observe(contentRef.current, { box: \"border-box\" });\n }\n return () => resizeObserver.disconnect();\n }, [resizeObserver]);\n};\n\nexport default useResizeObserver;\n","import { EventType } from \"../types\";\n\nconst sortEvents = (eventA: EventType, eventB: EventType) => {\n if (eventA.startTime - eventB.startTime < 0) return -1;\n if (eventA.startTime === eventB.startTime) {\n if (eventA.endTime < eventB.endTime) {\n return -1;\n } else {\n return 1;\n }\n } else {\n return 1;\n }\n};\nexport default sortEvents;\n","import React, { useEffect, useRef, useState } from \"react\";\n\nconst RTIndicator = ({\n tick,\n windowTime,\n}: {\n tick: number | null;\n windowTime: number[];\n}) => {\n const [currentTime, setCurrentTime] = useState(new Date().getTime() / 1000);\n const [leftOffset, setLeftOffset] = useState(0);\n const intervalIdRef = useRef<NodeJS.Timeout | null>(null);\n\n useEffect(() => {\n if (tick) {\n const leftOffsetTime = currentTime - windowTime[0];\n setLeftOffset(Math.round(leftOffsetTime / tick));\n if (intervalIdRef.current !== null) {\n clearInterval(intervalIdRef.current);\n }\n const intervalId = setInterval(() => {\n setCurrentTime(new Date().getTime() / 1000);\n }, tick * 1000);\n intervalIdRef.current = intervalId;\n }\n }, [tick, windowTime, currentTime]);\n\n return (\n <>\n {windowTime[0] <= currentTime && currentTime <= windowTime[1] && (\n <>\n <div className=\"rt-arrow\" style={{ left: 86 + leftOffset }}></div>\n <div className=\"rt-line\" style={{ left: 100 + leftOffset }}></div>\n </>\n )}\n </>\n );\n};\n\nexport default RTIndicator;\n","import React, {\n forwardRef,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport { computePosition, flip, offset, shift } from \"@floating-ui/dom\";\nimport { EventPromptActionsType, EventType } from \"../types\";\nimport type { Rect } from \"../core/types\";\n\ntype EventPromptType = {\n template?: (event: EventType) => JSX.Element;\n};\n\n/**\n * Hover tooltip for events. Positioned with @floating-ui/dom against the\n * hovered event's rect (viewport coordinates): preferred above the event,\n * flips below when there is no room, and shifts horizontally to stay\n * on-screen.\n */\nconst EventPrompt = forwardRef<EventPromptActionsType, EventPromptType>(\n ({ template }, ref) => {\n const promptRef = useRef<HTMLDivElement | null>(null);\n const [hoveredEvent, setHoveredEvent] = useState<EventType>();\n // guards against an async position landing after hide()\n const showSeqRef = useRef(0);\n\n useImperativeHandle(ref, () => {\n return {\n show(event: EventType, anchorRect: Rect) {\n const prompt = promptRef.current;\n if (!prompt) return;\n setHoveredEvent(event);\n const seq = ++showSeqRef.current;\n\n const virtualAnchor = {\n getBoundingClientRect: () => ({\n x: anchorRect.x,\n y: anchorRect.y,\n width: anchorRect.width,\n height: anchorRect.height,\n top: anchorRect.y,\n left: anchorRect.x,\n right: anchorRect.x + anchorRect.width,\n bottom: anchorRect.y + anchorRect.height,\n }),\n };\n\n // render invisibly first so floating-ui can measure the template\n prompt.style.display = \"block\";\n prompt.style.visibility = \"hidden\";\n computePosition(virtualAnchor, prompt, {\n placement: \"top\",\n middleware: [\n offset(8),\n flip({ padding: 8 }),\n shift({ padding: 8 }),\n ],\n }).then(({ x, y }) => {\n if (seq !== showSeqRef.current || !promptRef.current) return;\n promptRef.current.style.left = `${x}px`;\n promptRef.current.style.top = `${y}px`;\n promptRef.current.style.visibility = \"visible\";\n });\n },\n hide() {\n showSeqRef.current++;\n if (promptRef.current) {\n promptRef.current.style.display = \"none\";\n }\n },\n };\n });\n\n return (\n <div className=\"event-prompt\" ref={promptRef}>\n {template && hoveredEvent && template(hoveredEvent)}\n </div>\n );\n }\n);\n\nexport default EventPrompt;\n","import React, { useEffect, useRef } from \"react\";\nimport { generateUnitBlocks } from \"../core/time-blocks\";\nimport { sizeCanvas } from \"../canvas/dpr\";\nimport { drawTimeBar } from \"../canvas/draw-grid\";\nimport { ResolvedTheme, TimeBarConfig } from \"../types\";\n\n// .time-bar is 50px with a 1px border on each side\nconst TIME_BAR_INNER_HEIGHT = 48;\n\nconst CanvasTimeBar = ({\n windowTime,\n tick,\n contentWidth,\n scrollWidth,\n theme,\n timeBar,\n}: {\n windowTime: number[];\n tick: number | null;\n contentWidth: number | null;\n scrollWidth: number;\n theme?: ResolvedTheme;\n timeBar?: TimeBarConfig;\n}) => {\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n\n const topRow = timeBar?.topRow ?? { unit: \"day\" as const };\n const bottomRow = timeBar?.bottomRow ?? { unit: \"hour\" as const };\n\n useEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas || !contentWidth) return;\n const ctx = sizeCanvas(\n canvas,\n contentWidth,\n TIME_BAR_INNER_HEIGHT,\n window.devicePixelRatio\n );\n if (!ctx) return;\n const [windowStart, windowEnd] = windowTime;\n drawTimeBar(ctx, {\n width: contentWidth,\n height: TIME_BAR_INNER_HEIGHT,\n font: theme?.font ?? getComputedStyle(canvas).font,\n borderColor: theme?.timeBarBorder,\n textColor: theme?.timeBarTextColor,\n topBlocks: generateUnitBlocks({ ...topRow, windowStart, windowEnd, tick }),\n bottomBlocks: generateUnitBlocks({\n ...bottomRow,\n windowStart,\n windowEnd,\n tick,\n }),\n });\n // topRow/bottomRow are derived from `timeBar`; depend on it directly so a\n // new config object re-renders the bar.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [windowTime, tick, contentWidth, theme, timeBar]);\n\n return (\n <div className=\"time-bar\">\n <div className=\"empty-block\"></div>\n <canvas\n ref={canvasRef}\n className=\"canvas-time-bar\"\n style={{ minWidth: contentWidth ? contentWidth : 0 }}\n ></canvas>\n {scrollWidth ? (\n <div\n style={{\n width: scrollWidth,\n height: \"100%\",\n boxSizing: \"border-box\",\n borderLeft: \"1px solid yellow\",\n }}\n ></div>\n ) : null}\n </div>\n );\n};\n\nexport default CanvasTimeBar;\n","const getMonthName = (monthIndex: number) => {\n let monthName: string | null = null;\n switch (monthIndex) {\n case 0:\n monthName = \"Jan\";\n break;\n case 1:\n monthName = \"Feb\";\n break;\n case 2:\n monthName = \"Mar\";\n break;\n case 3:\n monthName = \"Apr\";\n break;\n case 4:\n monthName = \"May\";\n break;\n case 5:\n monthName = \"Jun\";\n break;\n case 6:\n monthName = \"Jul\";\n break;\n case 7:\n monthName = \"Aug\";\n break;\n case 8:\n monthName = \"Sep\";\n break;\n case 9:\n monthName = \"Oct\";\n break;\n case 10:\n monthName = \"Nov\";\n break;\n case 11:\n monthName = \"Dec\";\n break;\n default:\n monthName = \"Jan\";\n }\n\n return monthName;\n};\n\nexport default getMonthName;\n","// Maps a JS Date.getDay() index (0 = Sunday … 6 = Saturday) to a short name.\nconst WEEKDAY_NAMES = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\nconst getWeekDayName = (dayIndex: number) =>\n WEEKDAY_NAMES[dayIndex] ?? \"Sun\";\n\nexport default getWeekDayName;\n","import getMonthName from \"../helpers/get-month-name\";\nimport getWeekDayName from \"../helpers/get-week-day-name\";\nimport { TimeBarRowConfig, TimeBarUnit } from \"../types\";\n\nexport type TimeBlock = {\n label: string;\n x: number; // CSS px from the content's left edge\n width: number;\n};\n\nexport type TimeBlocks = {\n dayBlocks: TimeBlock[];\n hourBlocks: TimeBlock[];\n};\n\nconst pad2 = (n: number) => (n < 10 ? `0${n}` : `${n}`);\nconst hourLabel = (hour: number) => `${pad2(hour)}:00`;\n\nconst dayLabel = (date: Date) =>\n `${getWeekDayName(date.getDay())} ${date.getDate()} ${getMonthName(\n date.getMonth()\n )}`;\n\n/** Default label per unit — mirrors the pre-config day (\"Mon 1 Jan\") and\n * hour (\"HH:00\") labels; week labels its starting day, month its name/year. */\nconst defaultFormat = (\n unit: TimeBarUnit | { stepSeconds: number }\n): ((blockStart: Date) => string) => {\n if (typeof unit === \"object\") {\n return (d) => `${pad2(d.getHours())}:${pad2(d.getMinutes())}`;\n }\n switch (unit) {\n case \"hour\":\n return (d) => hourLabel(d.getHours());\n case \"month\":\n return (d) => `${getMonthName(d.getMonth())} ${d.getFullYear()}`;\n case \"day\":\n case \"week\":\n default:\n return (d) => dayLabel(d);\n }\n};\n\n/** Start of the calendar/step block containing `date`. */\nconst floorToUnit = (\n date: Date,\n unit: TimeBarUnit | { stepSeconds: number },\n anchorSec: number\n): Date => {\n if (typeof unit === \"object\") {\n const t = date.getTime() / 1000;\n const step = unit.stepSeconds;\n return new Date((anchorSec + Math.floor((t - anchorSec) / step) * step) * 1000);\n }\n const y = date.getFullYear();\n const mo = date.getMonth();\n const d = date.getDate();\n switch (unit) {\n case \"hour\":\n return new Date(y, mo, d, date.getHours());\n case \"day\":\n return new Date(y, mo, d);\n case \"week\": {\n const dow = (date.getDay() + 6) % 7; // Monday = 0\n return new Date(y, mo, d - dow);\n }\n case \"month\":\n return new Date(y, mo, 1);\n }\n};\n\n/** Start of the next block after `blockStart` (calendar-correct, DST-safe). */\nconst nextBoundary = (\n blockStart: Date,\n unit: TimeBarUnit | { stepSeconds: number }\n): Date => {\n if (typeof unit === \"object\") {\n return new Date(blockStart.getTime() + unit.stepSeconds * 1000);\n }\n const y = blockStart.getFullYear();\n const mo = blockStart.getMonth();\n const d = blockStart.getDate();\n switch (unit) {\n case \"hour\":\n return new Date(y, mo, d, blockStart.getHours() + 1);\n case \"day\":\n return new Date(y, mo, d + 1);\n case \"week\":\n return new Date(y, mo, d + 7);\n case \"month\":\n return new Date(y, mo + 1, 1);\n }\n};\n\n/**\n * Positioned blocks for one time-bar row. Walks real calendar/step boundaries\n * from `windowStart` to `windowEnd` and derives each block's pixel x/width\n * from `tick` (seconds per pixel), so blocks stay aligned to the wall clock as\n * the window pans. The first/last blocks are clipped to the window edges, so\n * the row tiles contiguously from x=0 to the content width.\n */\nexport const generateUnitBlocks = ({\n unit,\n format,\n windowStart,\n windowEnd,\n tick,\n}: TimeBarRowConfig & {\n windowStart: number;\n windowEnd: number;\n tick: number | null;\n}): TimeBlock[] => {\n const blocks: TimeBlock[] = [];\n const resolvedUnit = unit ?? \"hour\";\n if (tick === null || tick <= 0 || windowEnd <= windowStart) return blocks;\n\n const label = format ?? defaultFormat(resolvedUnit);\n // custom fixed steps are anchored to the start of windowStart's local day,\n // so e.g. 8h shifts fall on 00:00 / 08:00 / 16:00.\n const anchorSec =\n new Date(\n new Date(windowStart * 1000).getFullYear(),\n new Date(windowStart * 1000).getMonth(),\n new Date(windowStart * 1000).getDate()\n ).getTime() / 1000;\n\n let cursorSec = windowStart;\n let guard = 0;\n while (cursorSec < windowEnd && guard++ < 100000) {\n const blockStart = floorToUnit(new Date(cursorSec * 1000), resolvedUnit, anchorSec);\n const blockEnd = nextBoundary(blockStart, resolvedUnit);\n const startSec = blockStart.getTime() / 1000;\n const endSec = blockEnd.getTime() / 1000;\n if (endSec <= startSec) break; // safety against a non-advancing step\n\n const visibleStart = Math.max(startSec, windowStart);\n const visibleEnd = Math.min(endSec, windowEnd);\n blocks.push({\n label: label(blockStart, blockEnd),\n x: (visibleStart - windowStart) / tick,\n width: (visibleEnd - visibleStart) / tick,\n });\n cursorSec = endSec;\n }\n return blocks;\n};\n\n/**\n * The default two-row time bar: a day row over an hour row. Thin wrapper over\n * `generateUnitBlocks` kept for the golden tests and as the documented\n * default; the canvas time bar resolves `TimeBarConfig` and calls\n * `generateUnitBlocks` per row directly.\n */\nexport const generateTimeBlocks = ({\n windowStart,\n tick,\n contentWidth,\n}: {\n windowStart: number;\n tick: number | null;\n contentWidth: number | null;\n /** @deprecated unused — block widths now derive from `tick` */\n blockWidth?: number;\n}): TimeBlocks => {\n if (tick === null || contentWidth === null) {\n return { dayBlocks: [], hourBlocks: [] };\n }\n const windowEnd = windowStart + contentWidth * tick;\n return {\n dayBlocks: generateUnitBlocks({ unit: \"day\", windowStart, windowEnd, tick }),\n hourBlocks: generateUnitBlocks({ unit: \"hour\", windowStart, windowEnd, tick }),\n };\n};\n","/**\n * Sizes a canvas backing store for the given devicePixelRatio and resets the\n * context transform so ALL drawing code works in CSS pixels.\n */\nexport const sizeCanvas = (\n canvas: HTMLCanvasElement,\n cssWidth: number,\n cssHeight: number,\n dpr: number\n) => {\n canvas.width = Math.max(1, Math.round(cssWidth * dpr));\n canvas.height = Math.max(1, Math.round(cssHeight * dpr));\n canvas.style.width = `${cssWidth}px`;\n canvas.style.height = `${cssHeight}px`;\n const ctx = canvas.getContext(\"2d\");\n if (ctx) {\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n }\n return ctx;\n};\n\n/** Notifies when devicePixelRatio changes (browser zoom, monitor switch). */\nexport const watchDpr = (onChange: (dpr: number) => void): (() => void) => {\n let disposed = false;\n let cleanup = () => {};\n\n const listen = () => {\n if (disposed) return;\n const media = window.matchMedia(\n `(resolution: ${window.devicePixelRatio}dppx)`\n );\n const handler = () => {\n onChange(window.devicePixelRatio);\n media.removeEventListener(\"change\", handler);\n listen(); // re-arm for the new ratio\n };\n media.addEventListener(\"change\", handler);\n cleanup = () => media.removeEventListener(\"change\", handler);\n };\n\n listen();\n return () => {\n disposed = true;\n cleanup();\n };\n};\n","import { ResolvedTheme, Theme } from \"../types\";\n\n/** Defaults mirror the pre-0.2.0 stylesheet values. */\nexport const DEFAULT_THEME: ResolvedTheme = {\n eventFill: \"#ffffff\",\n eventStroke: \"#000000\",\n eventTextColor: \"#000000\",\n staticEventFill: \"#e0e0e0\",\n gridColor: \"#e4dcdc\",\n timeBarBorder: \"yellow\",\n timeBarTextColor: \"white\",\n font: undefined,\n barHeight: 20,\n laneGap: 2,\n rowPaddingY: 10,\n barRadius: 5,\n};\n\nexport const resolveTheme = (theme?: Theme): ResolvedTheme => ({\n ...DEFAULT_THEME,\n ...theme,\n});\n","import { TimeBlock } from \"../core/time-blocks\";\nimport { DEFAULT_THEME } from \"./theme\";\n\n/**\n * Vertical grid lines, one per grid cell (`cellWidth` px == `cellWidth * tick`\n * seconds). Lines are anchored to absolute time — placed at cell boundaries\n * (multiples of the cell duration), not at fixed screen offsets — so they pan\n * with the content and stay aligned with the time-bar blocks. Keeps the legacy\n * \"hide-last-line\" behavior: no line within 1px of either edge.\n */\nexport const drawGridLines = (\n ctx: CanvasRenderingContext2D,\n {\n width,\n height,\n cellWidth,\n windowStart,\n tick,\n color = DEFAULT_THEME.gridColor,\n }: {\n width: number;\n height: number;\n cellWidth: number;\n windowStart: number;\n tick: number;\n color?: string;\n }\n) => {\n if (cellWidth <= 0 || tick <= 0) return;\n const cellTime = cellWidth * tick; // seconds per grid cell\n ctx.strokeStyle = color;\n ctx.lineWidth = 1;\n ctx.beginPath();\n // first absolute cell boundary strictly after the left edge\n for (\n let t = Math.floor(windowStart / cellTime) * cellTime + cellTime;\n ;\n t += cellTime\n ) {\n const x = (t - windowStart) / tick;\n if (x >= width || width - x < 1) break; // hide line at/!near the right edge\n if (x < 1) continue; // and at the left edge\n const crisp = Math.round(x) - 0.5;\n ctx.moveTo(crisp, 0);\n ctx.lineTo(crisp, height);\n }\n ctx.stroke();\n};\n\n/**\n * Two-row time bar (top row over bottom row) — canvas replacement for the\n * day/hour block divs of time-bar.tsx. The two rows are unit-agnostic\n * (day/hour by default, configurable via TimeBarConfig). Background is left\n * transparent so the .time-bar container color shows through.\n */\nexport const drawTimeBar = (\n ctx: CanvasRenderingContext2D,\n {\n width,\n height,\n topBlocks,\n bottomBlocks,\n font,\n borderColor = DEFAULT_THEME.timeBarBorder,\n textColor = DEFAULT_THEME.timeBarTextColor,\n }: {\n width: number;\n height: number;\n font: string;\n borderColor?: string;\n textColor?: string;\n topBlocks: TimeBlock[];\n bottomBlocks: TimeBlock[];\n }\n) => {\n const mid = height / 2;\n\n ctx.strokeStyle = borderColor;\n ctx.lineWidth = 1;\n\n // day-row border-bottom\n ctx.beginPath();\n ctx.moveTo(0, Math.round(mid) - 0.5);\n ctx.lineTo(width, Math.round(mid) - 0.5);\n ctx.stroke();\n\n // block separators (right border on every block except the last)\n ctx.beginPath();\n for (let i = 0; i < topBlocks.length - 1; i++) {\n const edge = Math.round(topBlocks[i].x + topBlocks[i].width) - 0.5;\n ctx.moveTo(edge, 0);\n ctx.lineTo(edge, mid);\n }\n for (let i = 0; i < bottomBlocks.length - 1; i++) {\n const edge = Math.round(bottomBlocks[i].x + bottomBlocks[i].width) - 0.5;\n ctx.moveTo(edge, mid);\n ctx.lineTo(edge, height);\n }\n ctx.stroke();\n\n // labels, centered in their blocks like the DOM time bar\n ctx.fillStyle = textColor;\n ctx.font = font;\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"center\";\n const inset = 4;\n for (const block of topBlocks) {\n ctx.fillText(\n block.label,\n block.x + block.width / 2,\n mid / 2,\n block.width - inset\n );\n }\n for (const block of bottomBlocks) {\n ctx.fillText(\n block.label,\n block.x + block.width / 2,\n mid + mid / 2,\n block.width - inset\n );\n }\n};\n","import React, {\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport {\n DrawEventFn,\n EventPromptActionsType,\n OnDropProps,\n OnEventClickProps,\n OnEventHoverProps,\n OnResizeProps,\n PanZoomConfig,\n ResolvedTheme,\n RowType,\n} from \"../types\";\nimport { SceneStore } from \"../core/scene\";\nimport { TimelineRenderer } from \"../canvas/renderer\";\nimport useCanvasInteractions from \"../hooks/use-canvas-interactions\";\nimport \"./style.css\";\n\ntype CanvasBoardProps = {\n scene: SceneStore;\n rows: RowType[];\n windowTime: number[];\n tick: number | null;\n cellWidth: number;\n theme: ResolvedTheme;\n drawEvent?: DrawEventFn;\n bodyRef: React.MutableRefObject<HTMLDivElement | null>;\n rendererRef: React.MutableRefObject<TimelineRenderer | null>;\n eventPromptRef: React.MutableRefObject<EventPromptActionsType | null>;\n rowsHeaderClassName?: string;\n setWindowTime: React.Dispatch<React.SetStateAction<number[]>>;\n setCellWidth: React.Dispatch<React.SetStateAction<number>>;\n setTick: React.Dispatch<React.SetStateAction<number | null>>;\n onDrop?: (props: OnDropProps) => void;\n onResize?: (props: OnResizeProps) => void;\n onEventClick?: (props: OnEventClickProps) => void;\n onEventHover?: (props: OnEventHoverProps) => void;\n eventsResize: boolean;\n panZoom?: PanZoomConfig;\n animations: { layoutMs: number; fadeMs: number };\n};\n\n/**\n * Canvas board: two viewport-sized canvases (grid + events) kept fixed\n * inside the scrolling body via position:sticky, with a tall spacer div\n * providing the native scrollbar. Drawing is translated by scrollTop, so the\n * canvas never exceeds browser size limits regardless of row count.\n *\n * The forwarded ref targets the content column — the element timeline.tsx\n * measures for tick/cellWidth.\n */\nconst CanvasBoard = forwardRef<HTMLDivElement, CanvasBoardProps>(\n (\n {\n scene,\n rows,\n windowTime,\n tick,\n cellWidth,\n theme,\n drawEvent,\n bodyRef,\n rendererRef,\n eventPromptRef,\n rowsHeaderClassName,\n setWindowTime,\n setCellWidth,\n setTick,\n onDrop,\n onResize,\n onEventClick,\n onEventHover,\n eventsResize,\n panZoom,\n animations,\n },\n contentRef\n ) => {\n const staticCanvasRef = useRef<HTMLCanvasElement | null>(null);\n const dynamicCanvasRef = useRef<HTMLCanvasElement | null>(null);\n const ghostRef = useRef<HTMLDivElement | null>(null);\n\n const [scrollTop, setScrollTop] = useState(0);\n const [viewportHeight, setViewportHeight] = useState(0);\n\n // renderer lifecycle\n useEffect(() => {\n if (!staticCanvasRef.current || !dynamicCanvasRef.current) return;\n const renderer = new TimelineRenderer(\n staticCanvasRef.current,\n dynamicCanvasRef.current,\n scene\n );\n rendererRef.current = renderer;\n return () => {\n renderer.dispose();\n rendererRef.current = null;\n };\n }, [scene, rendererRef]);\n\n // view-state -> renderer\n useEffect(() => {\n rendererRef.current?.animator.setDurations(\n animations.layoutMs,\n animations.fadeMs\n );\n rendererRef.current?.setView({\n windowTime: [windowTime[0], windowTime[1]],\n tick,\n cellWidth,\n theme,\n drawEvent,\n eventsResize,\n });\n }, [\n windowTime,\n tick,\n cellWidth,\n theme,\n drawEvent,\n eventsResize,\n animations,\n rendererRef,\n ]);\n\n // viewport size (content column width x body height)\n useEffect(() => {\n const column =\n contentRef && \"current\" in contentRef ? contentRef.current : null;\n const body = bodyRef.current;\n if (!column || !body) return;\n const measure = () => {\n // Clamp to the window: if the consumer didn't bound the timeline's\n // height the body grows to its content, and a content-sized canvas\n // would blow past browser canvas limits on large boards.\n const height = Math.min(body.clientHeight, window.innerHeight);\n setViewportHeight(height);\n rendererRef.current?.setView({\n width: column.getBoundingClientRect().width,\n height,\n });\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(column);\n observer.observe(body);\n return () => observer.disconnect();\n }, [bodyRef, contentRef, rendererRef]);\n\n // scroll: renderer gets it imperatively, React only re-renders the\n // virtualized header list\n useEffect(() => {\n const body = bodyRef.current;\n if (!body) return;\n const handleScroll = () => {\n rendererRef.current?.setView({ scrollTop: body.scrollTop });\n setScrollTop(body.scrollTop);\n };\n body.addEventListener(\"scroll\", handleScroll, { passive: true });\n return () => body.removeEventListener(\"scroll\", handleScroll);\n }, [bodyRef, rendererRef]);\n\n // re-render header/spacer when scene data changes row heights\n useSyncExternalStore(\n useCallback((listener) => scene.subscribe(listener), [scene]),\n () => scene.version\n );\n\n const {\n handlePointerDown,\n handlePointerMove,\n handlePointerUp,\n handlePointerLeave,\n handlePointerCancel,\n handleAuxClick,\n } = useCanvasInteractions({\n scene,\n rendererRef,\n dynamicCanvasRef,\n bodyRef,\n ghostRef,\n eventPromptRef,\n setWindowTime,\n setCellWidth,\n setTick,\n onDrop,\n onResize,\n onEventClick,\n onEventHover,\n eventsResize,\n panZoom,\n });\n\n const { offsetOf, totalHeight } = scene.getRowOffsets(\n windowTime[0],\n windowTime[1]\n );\n\n // virtualized rows header: only headers intersecting the viewport\n const visibleHeaders: JSX.Element[] = [];\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const top = offsetOf.get(row.id) as number;\n const height = scene.getRowHeight(row.id, windowTime[0], windowTime[1]);\n if (top + height < scrollTop) continue;\n if (top > scrollTop + viewportHeight) break;\n visibleHeaders.push(\n <div\n key={`row_header_${row.id}`}\n className=\"row-header canvas-row-header\"\n style={{\n top,\n height,\n borderBottom:\n i === rows.length - 1 ? \"none\" : \"1px solid yellow\",\n // keeps the DOM header in step with the canvas layout tween\n transition:\n animations.layoutMs > 0\n ? `top ${animations.layoutMs}ms ease-in-out, height ${animations.layoutMs}ms ease-in-out`\n : \"none\",\n }}\n >\n {row.name}\n </div>\n );\n }\n\n const headerClassNames = rowsHeaderClassName\n ? `rows-header-wrapper canvas-rows-header ${rowsHeaderClassName}`\n : \"rows-header-wrapper canvas-rows-header\";\n\n return (\n <>\n <div className={headerClassNames} style={{ height: totalHeight }}>\n {visibleHeaders}\n </div>\n <div className=\"canvas-content-column\" ref={contentRef}>\n <div className=\"canvas-sticky\">\n <canvas ref={staticCanvasRef}></canvas>\n <canvas\n ref={dynamicCanvasRef}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={handlePointerUp}\n onPointerLeave={handlePointerLeave}\n onPointerCancel={handlePointerCancel}\n onAuxClick={handleAuxClick}\n ></canvas>\n <div\n ref={ghostRef}\n className=\"event canvas-drag-ghost\"\n style={{ height: scene.getGeometry().barHeight }}\n ></div>\n </div>\n <div\n className=\"canvas-scroll-spacer\"\n style={{ height: totalHeight }}\n ></div>\n </div>\n </>\n );\n }\n);\n\nexport default CanvasBoard;\n","export type Layer = \"static\" | \"dynamic\";\n\nexport type LayerDirty = { static: boolean; dynamic: boolean };\n\n/**\n * Coalesces invalidations into a single requestAnimationFrame callback.\n * Any number of invalidate() calls within one frame produce exactly one\n * onFrame() with the union of dirty layers — the backbone of 60fps under\n * streaming updates.\n */\nexport class FrameScheduler {\n private rafId: number | null = null;\n private dirty: LayerDirty = { static: false, dynamic: false };\n\n constructor(private onFrame: (dirty: LayerDirty) => void) {}\n\n invalidate(layer: Layer | \"all\") {\n if (layer === \"all\" || layer === \"static\") this.dirty.static = true;\n if (layer === \"all\" || layer === \"dynamic\") this.dirty.dynamic = true;\n this.schedule();\n }\n\n /** Runs a pending frame immediately (tests, synchronous reads). */\n flush() {\n if (this.rafId !== null) {\n cancelAnimationFrame(this.rafId);\n this.rafId = null;\n this.run();\n }\n }\n\n dispose() {\n if (this.rafId !== null) {\n cancelAnimationFrame(this.rafId);\n this.rafId = null;\n }\n this.dirty = { static: false, dynamic: false };\n }\n\n private schedule() {\n if (this.rafId !== null) return;\n this.rafId = requestAnimationFrame(() => {\n this.rafId = null;\n this.run();\n });\n }\n\n private run() {\n const dirty = this.dirty;\n this.dirty = { static: false, dynamic: false };\n if (dirty.static || dirty.dynamic) this.onFrame(dirty);\n }\n}\n","import { EventType } from \"../types\";\n\n/**\n * Returns the window-visible slice of a startTime-sorted event array.\n * Binary search cuts the tail (startTime > windowEnd) in O(log n); the head\n * is filtered linearly on endTime, which cannot be binary-searched on a\n * startTime ordering.\n */\nexport const cullToWindow = (\n events: EventType[],\n windowStart: number,\n windowEnd: number\n): EventType[] => {\n // first index with startTime > windowEnd\n let lo = 0;\n let hi = events.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (events[mid].startTime <= windowEnd) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n\n const visible: EventType[] = [];\n for (let i = 0; i < lo; i++) {\n if (events[i].endTime >= windowStart) visible.push(events[i]);\n }\n return visible;\n};\n","import { EventType } from \"../types\";\n\n// All times are unix timestamps in seconds.\n// tick = seconds per pixel; all x/width values are CSS pixels.\n\nexport const timeToX = (time: number, windowStart: number, tick: number) =>\n (time - windowStart) / tick;\n\nexport const timeToWidth = (startTime: number, endTime: number, tick: number) =>\n (endTime - startTime) / tick;\n\nexport const xToTime = (x: number, windowStart: number, tick: number) =>\n windowStart + x * tick;\n\nexport const intersectsWindow = (\n event: EventType,\n windowStart: number,\n windowEnd: number\n) => event.endTime >= windowStart && event.startTime <= windowEnd;\n","import { ResolvedTheme } from \"../types\";\n\n/**\n * Resolved vertical layout for event bars and rows (px). Derived once from the\n * theme (see `geometryFromTheme`) and owned by the SceneStore, which both the\n * renderer (`draw-events`) and hit-testing read so positioning stays in sync.\n *\n * Only `barHeight`, `laneGap`, `rowPaddingY`, and `barRadius` are themeable;\n * the rest are derived from them.\n */\nexport type Geometry = {\n /** event bar height */\n barHeight: number;\n /** vertical stride between stacked lanes (barHeight + laneGap) */\n laneHeight: number;\n /** top padding before the first lane (== rowPaddingY) */\n laneTopOffset: number;\n /** minimum row height with no stacking (barHeight + 2*rowPaddingY) */\n rowBaseHeight: number;\n /** static-event height with no stacking (== barHeight) */\n staticEventBaseHeight: number;\n /** event bar corner radius */\n barRadius: number;\n};\n\n/** Defaults mirror the pre-0.2.x constants (20px bars, 22px lanes, 10px pad). */\nexport const DEFAULT_GEOMETRY: Geometry = {\n barHeight: 20,\n laneHeight: 22,\n laneTopOffset: 10,\n rowBaseHeight: 40,\n staticEventBaseHeight: 20,\n barRadius: 5,\n};\n\n/** Derive the full Geometry from the resolved theme's geometry tokens. */\nexport const geometryFromTheme = (theme: ResolvedTheme): Geometry => {\n const barHeight = theme.barHeight;\n const rowPaddingY = theme.rowPaddingY;\n return {\n barHeight,\n laneHeight: barHeight + theme.laneGap,\n laneTopOffset: rowPaddingY,\n rowBaseHeight: barHeight + 2 * rowPaddingY,\n staticEventBaseHeight: barHeight,\n barRadius: theme.barRadius,\n };\n};\n","import { EventType } from \"../types\";\nimport { intersectsWindow } from \"./coords\";\nimport { Geometry, DEFAULT_GEOMETRY } from \"./geometry\";\n\n// Vertical layout is a function of the (themeable) Geometry. The geometry\n// argument defaults to DEFAULT_GEOMETRY so callers using the legacy constants\n// — and the golden tests — keep their exact pre-0.2.x numbers.\n\nexport const laneTop = (lane: number, g: Geometry = DEFAULT_GEOMETRY) =>\n g.laneTopOffset + g.laneHeight * lane;\n\nexport const rowMinHeight = (highestLane: number, g: Geometry = DEFAULT_GEOMETRY) =>\n g.rowBaseHeight + highestLane * g.laneHeight;\n\nexport const staticEventHeight = (\n highestLane: number,\n g: Geometry = DEFAULT_GEOMETRY\n) => g.staticEventBaseHeight + highestLane * g.laneHeight;\n\nexport type LaneResult = {\n // eventId -> lane index, only for events intersecting the window\n laneOf: Map<string, number>;\n highestLane: number;\n};\n\n/**\n * Assigns a vertical lane (stacking order) to each window-visible event of a\n * single row. Faithful extraction of the algorithm previously inlined in\n * use-produce-content.tsx — including its quirks:\n *\n * - Events outside [windowStart, windowEnd] are skipped and do not influence\n * lane assignment at all.\n * - The occupancy scan for an event only covers lanes 0..eventOrder (the lane\n * of the previously placed event), not every tracked lane.\n * - Touching events (prev.endTime === next.startTime) do not overlap.\n *\n * `rowEvents` must already be filtered to one row and sorted with\n * helpers/sort-events (startTime asc, endTime asc).\n */\nexport const assignLanes = (\n rowEvents: EventType[],\n windowStart: number,\n windowEnd: number\n): LaneResult => {\n let eventOrder = 0;\n const prevEvent: EventType[] = [];\n let highestEventOrder = 0;\n const laneOf = new Map<string, number>();\n\n for (const event of rowEvents) {\n if (!intersectsWindow(event, windowStart, windowEnd)) continue;\n\n let tempEventOrder = 0;\n let assignEventOrder = true;\n for (let i = 0; i <= eventOrder; i++) {\n if (prevEvent[i] && prevEvent[i].endTime > event.startTime) {\n tempEventOrder += 1;\n } else {\n if (eventOrder > highestEventOrder) {\n highestEventOrder = eventOrder;\n }\n eventOrder = 0;\n assignEventOrder = false;\n break;\n }\n }\n\n if (assignEventOrder) {\n eventOrder = tempEventOrder;\n }\n\n prevEvent[tempEventOrder] = event;\n laneOf.set(event.id, tempEventOrder);\n }\n\n if (eventOrder > highestEventOrder) {\n highestEventOrder = eventOrder;\n }\n\n return { laneOf, highestLane: highestEventOrder };\n};\n","import { EventType } from \"../types\";\n\n/**\n * Pure commit math for canvas pointer interactions. Each function mirrors the\n * corresponding legacy DOM handler byte-for-byte so the canvas engine keeps\n * identical snap/guard semantics.\n */\n\n/**\n * Drop: snap the dropped start to the nearest grid cell boundary. Cells are\n * anchored to absolute time (multiples of the cell duration), matching the\n * vertical grid lines (`drawGridLines`) — so a dropped event lands on a line\n * regardless of how the window has been panned.\n */\nexport const computeDropTimes = ({\n pointerX,\n cellWidth,\n tick,\n windowStart,\n duration,\n}: {\n pointerX: number; // px from the content's left edge\n cellWidth: number;\n tick: number;\n windowStart: number;\n duration: number; // event duration in seconds\n}): { startTime: number; endTime: number } => {\n const cellTime = cellWidth * tick; // seconds per grid cell\n const pointerTime = windowStart + pointerX * tick;\n const startTime = Math.round(pointerTime / cellTime) * cellTime;\n return { startTime, endTime: startTime + duration };\n};\n\n/**\n * Resize: same rounding and duration-must-stay-positive guard as\n * event.tsx handleDocumentOnMouseUp. Returns null when the resize would\n * collapse or invert the event (legacy keeps the old value silently).\n */\nexport const computeResizeTimes = (\n event: Pick<EventType, \"startTime\" | \"endTime\">,\n deltaPx: number, // raw pointer delta (clientX - initial), sign preserved\n tick: number,\n direction: \"left\" | \"right\"\n): { startTime: number; endTime: number } | null => {\n if (direction === \"left\") {\n const startTime = Math.round(event.startTime + deltaPx * tick);\n if (event.endTime - startTime > 0) {\n return { startTime, endTime: event.endTime };\n }\n return null;\n }\n const endTime = Math.round(event.endTime + deltaPx * tick);\n if (endTime - event.startTime > 0) {\n return { startTime: event.startTime, endTime };\n }\n return null;\n};\n\n/** Eligibility: same expression as the legacy Event component's render guard. */\nexport const canResizeEvent = (\n event: EventType,\n eventsResize: boolean\n): boolean =>\n !event.props?.isLocked &&\n ((eventsResize &&\n (event.props?.isResizable === true ||\n event.props?.isResizable === undefined)) ||\n (!eventsResize && event.props?.isResizable === true));\n\n/** Grid granularity step: same clamp as content.tsx handleOnWheel. */\nexport const stepCellWidth = (\n cellWidth: number,\n deltaY: number,\n tick: number\n): number => {\n const pixelsToCalculate = 900 / tick;\n const next =\n deltaY > 0 ? cellWidth + pixelsToCalculate : cellWidth - pixelsToCalculate;\n if (next < pixelsToCalculate || next > pixelsToCalculate * 12) {\n return cellWidth;\n }\n return next;\n};\n\nexport type ZoomLimits = { minWindowSeconds: number; maxWindowSeconds: number };\n\n/**\n * Time-frame zoom: returns a new visible window (+ derived tick and cellWidth)\n * for scaling the visible duration by `factor` (newDuration = oldDuration *\n * factor; <1 zooms in, >1 zooms out), anchored so the timestamp under\n * `anchorX` (px from the content's left edge) stays under that pixel.\n *\n * `tick` is recomputed from the new (integer-rounded) window; `cellWidth` is\n * then derived from the *actual* new tick so time-per-cell (`cellWidth * tick`)\n * — i.e. the grid cell duration the grid lines snap to — is preserved exactly.\n * Rescaling cellWidth by the unrounded factor instead would let rounding drift\n * the cell duration off the hour over many zooms, so the grid lines would creep\n * out of step with the time-bar blocks. The new duration is clamped to the\n * limits; the anchor still holds after clamping.\n */\nexport const computeZoom = (\n windowTime: [number, number],\n tick: number,\n cellWidth: number,\n anchorX: number,\n factor: number,\n contentWidth: number,\n { minWindowSeconds, maxWindowSeconds }: ZoomLimits\n): { windowTime: [number, number]; tick: number; cellWidth: number } => {\n const [start, end] = windowTime;\n const oldDuration = end - start;\n const newDuration = Math.min(\n Math.max(oldDuration * factor, minWindowSeconds),\n maxWindowSeconds\n );\n const cellTime = cellWidth * tick; // seconds per grid cell — kept invariant\n const tAnchor = start + anchorX * tick;\n const newStart = Math.round(tAnchor - (anchorX / contentWidth) * newDuration);\n const newEnd = newStart + Math.round(newDuration);\n const newTick = (newEnd - newStart) / contentWidth;\n return {\n windowTime: [newStart, newEnd],\n tick: newTick,\n cellWidth: cellTime / newTick,\n };\n};\n","import { SceneStore } from \"../core/scene\";\nimport { cullToWindow } from \"../core/culling\";\nimport { timeToWidth, timeToX } from \"../core/coords\";\nimport { laneTop, staticEventHeight } from \"../core/lanes\";\nimport { EventState, EventType } from \"../types\";\nimport type { Rect } from \"../core/types\";\nimport type { RendererView } from \"./renderer\";\nimport { canResizeEvent } from \"../core/interactions\";\nimport { LayoutAnimator } from \"./animator\";\n\nconst EVENT_TEXT_INSET = 13; // legacy .event-content margin-inline\n// legacy .event-resize / .resize-bar geometry\nconst HANDLE_INSET = 4;\nconst HANDLE_BAR_WIDTH = 3;\nconst HANDLE_BAR_GAP = 1;\nconst HANDLE_BAR_HEIGHT = 10;\n\nconst roundedRect = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n width: number,\n height: number,\n radius: number\n) => {\n const r = Math.min(radius, width / 2, height / 2);\n ctx.beginPath();\n if (typeof ctx.roundRect === \"function\") {\n ctx.roundRect(x, y, width, height, r);\n } else {\n ctx.moveTo(x + r, y);\n ctx.arcTo(x + width, y, x + width, y + height, r);\n ctx.arcTo(x + width, y + height, x, y + height, r);\n ctx.arcTo(x, y + height, x, y, r);\n ctx.arcTo(x, y, x + width, y, r);\n ctx.closePath();\n }\n};\n\n/** Horizontal row dividers — replaces .row-content border-bottom. */\nexport const drawRowDividers = (\n ctx: CanvasRenderingContext2D,\n view: RendererView,\n scene: SceneStore,\n animator: LayoutAnimator\n) => {\n const [windowStart, windowEnd] = view.windowTime;\n const rowIds = scene.getRowIds();\n ctx.strokeStyle = view.theme.gridColor;\n ctx.lineWidth = 1;\n ctx.beginPath();\n let y = 0;\n for (let i = 0; i < rowIds.length; i++) {\n y += animator.rowHeight(\n rowIds[i],\n scene.getRowHeight(rowIds[i], windowStart, windowEnd)\n );\n if (i === rowIds.length - 1) break; // :not(:last-child)\n const screenY = y - view.scrollTop;\n if (screenY < 0) continue;\n if (screenY > view.height) break;\n const crisp = Math.round(screenY) - 0.5;\n ctx.moveTo(0, crisp);\n ctx.lineTo(view.width, crisp);\n }\n ctx.stroke();\n};\n\n/** Legacy ResizeIcon: two small rounded bars at each end, shown on hover. */\nconst drawResizeHandles = (\n ctx: CanvasRenderingContext2D,\n rect: Rect,\n alpha: number,\n strokeColor: string\n) => {\n ctx.save();\n ctx.globalAlpha *= alpha;\n ctx.strokeStyle = strokeColor;\n ctx.lineWidth = 1;\n const barY = rect.y + (rect.height - HANDLE_BAR_HEIGHT) / 2;\n const xs = [\n rect.x + HANDLE_INSET,\n rect.x + HANDLE_INSET + HANDLE_BAR_WIDTH + HANDLE_BAR_GAP,\n rect.x + rect.width - HANDLE_INSET - HANDLE_BAR_WIDTH,\n rect.x +\n rect.width -\n HANDLE_INSET -\n HANDLE_BAR_WIDTH * 2 -\n HANDLE_BAR_GAP,\n ];\n for (const barX of xs) {\n ctx.beginPath();\n if (typeof ctx.roundRect === \"function\") {\n ctx.roundRect(\n barX + 0.5,\n barY + 0.5,\n HANDLE_BAR_WIDTH - 1,\n HANDLE_BAR_HEIGHT - 1,\n 1.5\n );\n } else {\n ctx.rect(barX + 0.5, barY + 0.5, HANDLE_BAR_WIDTH - 1, HANDLE_BAR_HEIGHT - 1);\n }\n ctx.stroke();\n }\n ctx.restore();\n};\n\nconst defaultDrawEvent = (\n ctx: CanvasRenderingContext2D,\n event: EventType,\n rect: Rect,\n view: RendererView,\n font: string,\n barRadius: number\n) => {\n const theme = view.theme;\n const style = event.props?.style;\n\n if (style?.opacity !== undefined) ctx.globalAlpha *= style.opacity;\n ctx.fillStyle = style?.fill ?? theme.eventFill;\n ctx.strokeStyle = style?.stroke ?? theme.eventStroke;\n ctx.lineWidth = style?.strokeWidth ?? 1;\n roundedRect(\n ctx,\n rect.x + 0.5,\n rect.y + 0.5,\n rect.width - 1,\n rect.height - 1,\n style?.borderRadius ?? barRadius\n );\n ctx.fill();\n ctx.stroke();\n\n const label = event.props?.label;\n if (label && rect.width > EVENT_TEXT_INSET * 2) {\n ctx.fillStyle = style?.textColor ?? theme.eventTextColor;\n ctx.font = style?.font ?? theme.font ?? font;\n ctx.save();\n ctx.beginPath();\n ctx.rect(\n rect.x + EVENT_TEXT_INSET,\n rect.y,\n rect.width - EVENT_TEXT_INSET * 2,\n rect.height\n );\n ctx.clip();\n ctx.fillText(label, rect.x + EVENT_TEXT_INSET, rect.y + rect.height / 2);\n ctx.restore();\n }\n};\n\n/**\n * All window- and viewport-visible events in one pass. Rows fully outside\n * the vertical viewport are skipped without touching their events. Custom\n * renderers resolve per-event drawEvent -> Timeline drawEvent -> default.\n */\nexport const drawEvents = (\n ctx: CanvasRenderingContext2D,\n view: RendererView,\n scene: SceneStore,\n font: string,\n animator: LayoutAnimator\n) => {\n if (view.tick === null) return;\n const [windowStart, windowEnd] = view.windowTime;\n const tick = view.tick;\n const geometry = scene.getGeometry();\n\n ctx.font = view.theme.font ?? font;\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n\n let rowTop = 0;\n for (const rowId of scene.getRowIds()) {\n const rowHeight = animator.rowHeight(\n rowId,\n scene.getRowHeight(rowId, windowStart, windowEnd)\n );\n const rowY = rowTop - view.scrollTop;\n rowTop += rowHeight;\n if (rowY + rowHeight < 0) continue;\n if (rowY > view.height) break;\n\n const lanes = scene.getLanes(rowId, windowStart, windowEnd);\n\n // static events sit below interactive ones (legacy z-index 0 vs 1)\n for (const event of cullToWindow(\n scene.getRowStaticEvents(rowId),\n windowStart,\n windowEnd\n )) {\n const x = timeToX(event.startTime, windowStart, tick);\n const width = timeToWidth(event.startTime, event.endTime, tick);\n ctx.fillStyle = view.theme.staticEventFill;\n roundedRect(\n ctx,\n x,\n rowY + geometry.laneTopOffset,\n width,\n staticEventHeight(lanes.highestLane, geometry),\n geometry.barRadius\n );\n ctx.fill();\n }\n\n for (const event of cullToWindow(\n scene.getRowEvents(rowId),\n windowStart,\n windowEnd\n )) {\n let x = timeToX(event.startTime, windowStart, tick);\n let width = timeToWidth(event.startTime, event.endTime, tick);\n // The lane offset tweens in ROW-LOCAL coordinates (legacy .event\n // transition on `top`), while the row's animated position applies\n // instantly. Tweening the absolute top instead would chase the\n // moving row with a perpetual lag, desyncing events from their\n // row dividers/headers under rapid updates.\n const y =\n rowY +\n animator.eventTop(\n event.id,\n laneTop(lanes.laneOf.get(event.id) as number, geometry)\n );\n\n const resize = view.resizePreview;\n const resizing = resize !== null && resize.eventId === event.id;\n if (resizing) {\n // live edge preview, same arithmetic as the legacy inline style\n if (resize.direction === \"left\") {\n x += resize.deltaPx;\n width -= resize.deltaPx;\n } else {\n width += resize.deltaPx;\n }\n }\n\n const rect: Rect = { x, y, width, height: geometry.barHeight };\n const state: EventState = {\n hovered: view.hoveredEventId === event.id,\n dragging: view.draggedEventId === event.id,\n resizing,\n selected: false,\n };\n\n ctx.save();\n if (state.dragging) ctx.globalAlpha = 0.5; // legacy drag opacity\n\n const custom = event.props?.drawEvent ?? view.drawEvent;\n const drawn =\n custom !== undefined &&\n custom(ctx, event, rect, state, view.theme) !== false;\n if (!drawn) {\n defaultDrawEvent(ctx, event, rect, view, font, geometry.barRadius);\n }\n\n if (canResizeEvent(event, view.eventsResize)) {\n const alpha = animator.handleAlpha(\n event.id,\n state.hovered || state.resizing ? 1 : 0\n );\n if (alpha > 0.01) {\n drawResizeHandles(\n ctx,\n rect,\n alpha,\n event.props?.style?.stroke ?? view.theme.eventStroke\n );\n }\n }\n ctx.restore();\n }\n }\n};\n","import { SceneStore } from \"../core/scene\";\nimport { DrawEventFn, ResolvedTheme } from \"../types\";\nimport { FrameScheduler, Layer, LayerDirty } from \"./frame-scheduler\";\nimport { sizeCanvas, watchDpr } from \"./dpr\";\nimport { drawGridLines } from \"./draw-grid\";\nimport { drawEvents, drawRowDividers } from \"./draw-events\";\nimport { DEFAULT_THEME } from \"./theme\";\nimport { LayoutAnimator } from \"./animator\";\n\nexport type ResizePreview = {\n eventId: string;\n deltaPx: number; // raw pointer delta, sign preserved\n direction: \"left\" | \"right\";\n};\n\nexport type RendererView = {\n windowTime: [number, number];\n tick: number | null; // seconds per pixel; null until the container is measured\n cellWidth: number;\n scrollTop: number;\n width: number; // viewport CSS px\n height: number;\n theme: ResolvedTheme;\n drawEvent?: DrawEventFn;\n eventsResize: boolean;\n // interaction state\n hoveredEventId: string | null;\n draggedEventId: string | null;\n resizePreview: ResizePreview | null;\n};\n\n/**\n * Owns the two viewport-sized canvases and the frame loop.\n *\n * - static layer: grid lines, day/hour bands, time bar (Phase 2)\n * - dynamic layer: events (Phase 3)\n *\n * React pushes view-state via setView(); the SceneStore pushes data changes\n * via its subscription. Both only flip dirty flags — actual drawing happens\n * once per animation frame.\n */\nexport class TimelineRenderer {\n private view: RendererView = {\n windowTime: [0, 0],\n tick: null,\n cellWidth: 0,\n scrollTop: 0,\n width: 0,\n height: 0,\n theme: DEFAULT_THEME,\n drawEvent: undefined,\n eventsResize: true,\n hoveredEventId: null,\n draggedEventId: null,\n resizePreview: null,\n };\n readonly animator = new LayoutAnimator();\n private scheduler: FrameScheduler;\n private unsubscribeScene: () => void;\n private unwatchDpr: () => void;\n private dpr = typeof window !== \"undefined\" ? window.devicePixelRatio : 1;\n private font = \"16px sans-serif\";\n\n constructor(\n private staticCanvas: HTMLCanvasElement,\n private dynamicCanvas: HTMLCanvasElement,\n private scene: SceneStore\n ) {\n this.scheduler = new FrameScheduler((dirty) => this.drawFrame(dirty));\n // data changes can move row heights, which both layers draw from\n this.unsubscribeScene = scene.subscribe(() => this.invalidate(\"all\"));\n this.unwatchDpr = watchDpr((dpr) => {\n this.dpr = dpr;\n this.resizeCanvases();\n this.invalidate(\"all\");\n });\n }\n\n getView(): RendererView {\n return this.view;\n }\n\n setView(partial: Partial<RendererView>) {\n const sizeChanged =\n (partial.width !== undefined && partial.width !== this.view.width) ||\n (partial.height !== undefined && partial.height !== this.view.height);\n this.view = { ...this.view, ...partial };\n if (sizeChanged) {\n this.resizeCanvases();\n this.invalidate(\"all\");\n return;\n }\n // scroll/pan/zoom move both layers; scrollTop alone still shifts the grid\n this.invalidate(\"all\");\n }\n\n invalidate(layer: Layer | \"all\") {\n this.scheduler.invalidate(layer);\n }\n\n /** Force a synchronous draw of anything pending (tests, screenshots). */\n flush() {\n this.scheduler.flush();\n }\n\n dispose() {\n this.scheduler.dispose();\n this.unsubscribeScene();\n this.unwatchDpr();\n }\n\n private resizeCanvases() {\n sizeCanvas(this.staticCanvas, this.view.width, this.view.height, this.dpr);\n sizeCanvas(this.dynamicCanvas, this.view.width, this.view.height, this.dpr);\n if (typeof getComputedStyle === \"function\") {\n this.font = getComputedStyle(this.dynamicCanvas).font || this.font;\n }\n }\n\n private drawFrame(dirty: LayerDirty) {\n if (this.view.tick === null) return;\n this.animator.beginFrame(performance.now());\n if (dirty.static) {\n const ctx = this.staticCanvas.getContext(\"2d\");\n if (ctx) {\n ctx.clearRect(0, 0, this.view.width, this.view.height);\n drawGridLines(ctx, {\n width: this.view.width,\n height: this.view.height,\n cellWidth: this.view.cellWidth,\n windowStart: this.view.windowTime[0],\n tick: this.view.tick,\n color: this.view.theme.gridColor,\n });\n drawRowDividers(ctx, this.view, this.scene, this.animator);\n }\n }\n if (dirty.dynamic) {\n const ctx = this.dynamicCanvas.getContext(\"2d\");\n if (ctx) {\n ctx.clearRect(0, 0, this.view.width, this.view.height);\n drawEvents(ctx, this.view, this.scene, this.font, this.animator);\n }\n }\n // layout tweens in progress -> keep the frame loop running\n if (this.animator.isAnimating()) {\n this.scheduler.invalidate(\"all\");\n }\n }\n}\n","import React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport {\n EventPromptActionsType,\n EventType,\n OnDropProps,\n OnEventClickProps,\n OnEventHoverProps,\n OnResizeProps,\n PanZoomConfig,\n} from \"../types\";\nimport { SceneStore } from \"../core/scene\";\nimport { TimelineRenderer } from \"../canvas/renderer\";\nimport { hitTest, HitTarget } from \"../core/hit-test\";\nimport {\n canResizeEvent,\n computeDropTimes,\n computeResizeTimes,\n computeZoom,\n stepCellWidth,\n ZoomLimits,\n} from \"../core/interactions\";\n\nconst DRAG_THRESHOLD_PX = 3;\nconst RESIZE_HOT_ZONE_PX = 8; // matches the legacy .event-resize handle width\nconst DRAG_ZOOM_PX_PER_DOUBLING = 300; // drag this many px to halve/double the span\n\n/** Window/tick/cellWidth captured at the start of a continuous zoom gesture,\n * so pinch/drag scale relative to the start rather than compounding. */\ntype ZoomBase = {\n windowTime: [number, number];\n tick: number;\n cellWidth: number;\n};\n\ntype InteractionState =\n | { mode: \"idle\" }\n | { mode: \"pan\"; lastClientX: number; lastClientY: number; touch: boolean }\n | {\n mode: \"drag\";\n hit: HitTarget;\n startClientX: number;\n startClientY: number;\n active: boolean; // becomes true past DRAG_THRESHOLD_PX\n }\n | {\n mode: \"resize\";\n event: EventType;\n direction: \"left\" | \"right\";\n startClientX: number;\n deltaPx: number;\n }\n | {\n mode: \"zoom\"; // ctrl/cmd + background drag\n startClientX: number;\n anchorX: number;\n contentWidth: number;\n snapshot: ZoomBase;\n }\n | {\n mode: \"pinch\"; // two-finger touch\n startDist: number;\n anchorX: number;\n contentWidth: number;\n snapshot: ZoomBase;\n };\n\ntype UseCanvasInteractionsArgs = {\n scene: SceneStore;\n rendererRef: React.MutableRefObject<TimelineRenderer | null>;\n dynamicCanvasRef: React.MutableRefObject<HTMLCanvasElement | null>;\n bodyRef: React.MutableRefObject<HTMLDivElement | null>;\n ghostRef: React.MutableRefObject<HTMLDivElement | null>;\n eventPromptRef: React.MutableRefObject<EventPromptActionsType | null>;\n setWindowTime: React.Dispatch<React.SetStateAction<number[]>>;\n setCellWidth: React.Dispatch<React.SetStateAction<number>>;\n setTick: React.Dispatch<React.SetStateAction<number | null>>;\n onDrop?: (props: OnDropProps) => void;\n onResize?: (props: OnResizeProps) => void;\n onEventClick?: (props: OnEventClickProps) => void;\n onEventHover?: (props: OnEventHoverProps) => void;\n eventsResize: boolean;\n panZoom?: PanZoomConfig;\n};\n\nconst lockCursor = (cursor: string) => {\n const style = document.createElement(\"style\");\n style.id = \"lock-cursor\";\n style.innerHTML = `* { cursor: ${cursor} !important; }`;\n document.head.appendChild(style);\n};\n\nconst unlockCursor = () => {\n document.getElementById(\"lock-cursor\")?.remove();\n};\n\n/**\n * Pointer-event state machine for the canvas board: pan the time window,\n * drag events between rows/times (DOM ghost preview), resize event edges,\n * change grid granularity (middle-click mode or ctrl+wheel). Event mutations\n * are applied straight to the SceneStore — no React state on the hot path.\n */\nconst useCanvasInteractions = ({\n scene,\n rendererRef,\n dynamicCanvasRef,\n bodyRef,\n ghostRef,\n eventPromptRef,\n setWindowTime,\n setCellWidth,\n setTick,\n onDrop,\n onResize,\n onEventClick,\n onEventHover,\n eventsResize,\n panZoom,\n}: UseCanvasInteractionsArgs) => {\n const stateRef = useRef<InteractionState>({ mode: \"idle\" });\n const changeGridRef = useRef(false);\n const panFrameRef = useRef<number | null>(null);\n const panPendingDxRef = useRef(0);\n const hoveredRef = useRef<HitTarget | null>(null);\n // active pointers, for two-finger pinch detection\n const pointersRef = useRef(new Map<number, { x: number; y: number; touch: boolean }>());\n const zoomFrameRef = useRef<number | null>(null);\n const zoomPendingRef = useRef<{ anchorX: number; factor: number } | null>(null);\n\n const config = useMemo(\n () => ({\n panOnDragBackground: panZoom?.panOnDragBackground ?? true,\n ctrlWheelZoom: panZoom?.ctrlWheelZoom ?? true,\n pinchZoom: panZoom?.pinchZoom ?? true,\n dragZoom: panZoom?.dragZoom ?? true,\n zoomWheelFactor: panZoom?.zoomWheelFactor ?? 1.15,\n middleClickGranularity: panZoom?.middleClickGranularity ?? true,\n zoomStepSeconds: panZoom?.zoomStepSeconds ?? 900,\n }),\n [panZoom]\n );\n\n const limits: ZoomLimits = useMemo(\n () => ({\n minWindowSeconds: panZoom?.minWindowSeconds ?? 900,\n maxWindowSeconds: panZoom?.maxWindowSeconds ?? 30 * 24 * 3600,\n }),\n [panZoom]\n );\n\n // Apply a zoom by `factor` around `anchorX` (px from canvas left), scaling\n // from `base`. Pushes the result both to the renderer (immediate, so a\n // following wheel notch reads the new window) and to React state (time bar /\n // RT indicator / header virtualization).\n const applyZoom = useCallback(\n (base: ZoomBase, anchorX: number, factor: number, contentWidth: number) => {\n if (contentWidth <= 0) return;\n const next = computeZoom(\n base.windowTime,\n base.tick,\n base.cellWidth,\n anchorX,\n factor,\n contentWidth,\n limits\n );\n rendererRef.current?.setView({\n windowTime: next.windowTime,\n tick: next.tick,\n cellWidth: next.cellWidth,\n });\n setWindowTime(next.windowTime);\n setTick(next.tick);\n setCellWidth(next.cellWidth);\n },\n [rendererRef, setWindowTime, setTick, setCellWidth, limits]\n );\n\n // Continuous gestures (pinch/drag) coalesce to one apply per frame, scaling\n // from the gesture-start snapshot so they never compound.\n const scheduleContinuousZoom = useCallback(() => {\n if (zoomFrameRef.current !== null) return;\n zoomFrameRef.current = requestAnimationFrame(() => {\n zoomFrameRef.current = null;\n const pending = zoomPendingRef.current;\n const state = stateRef.current;\n if (!pending || (state.mode !== \"pinch\" && state.mode !== \"zoom\")) return;\n applyZoom(state.snapshot, pending.anchorX, pending.factor, state.contentWidth);\n });\n }, [applyZoom]);\n\n const snapshotView = useCallback((): { base: ZoomBase; contentWidth: number } | null => {\n const renderer = rendererRef.current;\n const canvas = dynamicCanvasRef.current;\n if (!renderer || !canvas) return null;\n const view = renderer.getView();\n if (view.tick === null) return null;\n return {\n base: {\n windowTime: [view.windowTime[0], view.windowTime[1]],\n tick: view.tick,\n cellWidth: view.cellWidth,\n },\n contentWidth: canvas.getBoundingClientRect().width,\n };\n }, [rendererRef, dynamicCanvasRef]);\n\n const hidePrompt = useCallback(() => {\n eventPromptRef.current?.hide();\n }, [eventPromptRef]);\n\n const currentHit = useCallback(\n (clientX: number, clientY: number): HitTarget | null => {\n const canvas = dynamicCanvasRef.current;\n const renderer = rendererRef.current;\n if (!canvas || !renderer) return null;\n const view = renderer.getView();\n if (view.tick === null) return null;\n const rect = canvas.getBoundingClientRect();\n return hitTest(\n scene,\n {\n windowStart: view.windowTime[0],\n windowEnd: view.windowTime[1],\n tick: view.tick,\n scrollTop: view.scrollTop,\n },\n clientX - rect.left,\n clientY - rect.top\n );\n },\n [scene, dynamicCanvasRef, rendererRef]\n );\n\n const resizeDirectionAt = useCallback(\n (hit: HitTarget, clientX: number): \"left\" | \"right\" | null => {\n if (hit.kind !== \"event\" || !canResizeEvent(hit.event, eventsResize)) {\n return null;\n }\n const canvas = dynamicCanvasRef.current;\n if (!canvas) return null;\n const x = clientX - canvas.getBoundingClientRect().left;\n const zone = Math.min(RESIZE_HOT_ZONE_PX, hit.rect.width / 3);\n if (x <= hit.rect.x + zone) return \"left\";\n if (x >= hit.rect.x + hit.rect.width - zone) return \"right\";\n return null;\n },\n [dynamicCanvasRef, eventsResize]\n );\n\n // pan applies at most once per frame regardless of pointermove rate\n const schedulePan = useCallback(() => {\n if (panFrameRef.current !== null) return;\n panFrameRef.current = requestAnimationFrame(() => {\n panFrameRef.current = null;\n const renderer = rendererRef.current;\n const dx = panPendingDxRef.current;\n panPendingDxRef.current = 0;\n const tick = renderer?.getView().tick;\n if (!tick || dx === 0) return;\n const dt = Math.round(dx * tick);\n if (dt === 0) {\n panPendingDxRef.current = dx; // accumulate sub-second moves\n return;\n }\n setWindowTime((prev) => [prev[0] - dt, prev[1] - dt]);\n });\n }, [rendererRef, setWindowTime]);\n\n const updateGhost = useCallback(\n (\n state: Extract<InteractionState, { mode: \"drag\" }>,\n clientX: number,\n clientY: number\n ) => {\n const ghost = ghostRef.current;\n if (!ghost) return;\n ghost.style.display = \"flex\";\n ghost.style.left = `${state.hit.rect.x + (clientX - state.startClientX)}px`;\n ghost.style.top = `${state.hit.rect.y + (clientY - state.startClientY)}px`;\n ghost.style.width = `${state.hit.rect.width}px`;\n },\n [ghostRef]\n );\n\n // The ghost is a DOM pill, so it can't run a custom canvas drawEvent — but it\n // should at least inherit the picked event's resolved style + label so a\n // themed event doesn't drag as the default white pill.\n const styleGhost = useCallback(\n (event: EventType) => {\n const ghost = ghostRef.current;\n const theme = rendererRef.current?.getView().theme;\n if (!ghost || !theme) return;\n const style = event.props?.style;\n ghost.style.backgroundColor = style?.fill ?? theme.eventFill;\n ghost.style.border = `${style?.strokeWidth ?? 1}px solid ${\n style?.stroke ?? theme.eventStroke\n }`;\n ghost.style.borderRadius = `${style?.borderRadius ?? theme.barRadius}px`;\n ghost.style.color = style?.textColor ?? theme.eventTextColor;\n ghost.style.font = style?.font ?? theme.font ?? \"\";\n ghost.style.justifyContent = \"flex-start\";\n ghost.style.alignItems = \"center\";\n ghost.style.paddingInline = \"13px\"; // matches the canvas EVENT_TEXT_INSET\n ghost.style.overflow = \"hidden\";\n ghost.style.whiteSpace = \"nowrap\";\n ghost.textContent = event.props?.label ?? \"\";\n },\n [ghostRef, rendererRef]\n );\n\n const handlePointerDown = useCallback(\n (pointerEvent: React.PointerEvent<HTMLCanvasElement>) => {\n const canvas = dynamicCanvasRef.current;\n if (!canvas) return;\n const isTouch = pointerEvent.pointerType === \"touch\";\n pointersRef.current.set(pointerEvent.pointerId, {\n x: pointerEvent.clientX,\n y: pointerEvent.clientY,\n touch: isTouch,\n });\n\n // second touch finger -> pinch zoom (cancels any single-finger gesture)\n if (config.pinchZoom && isTouch && pointersRef.current.size === 2) {\n const snap = snapshotView();\n if (snap) {\n if (ghostRef.current) ghostRef.current.style.display = \"none\";\n rendererRef.current?.setView({ draggedEventId: null });\n const pts = [...pointersRef.current.values()];\n const startDist =\n Math.hypot(pts[0].x - pts[1].x, pts[0].y - pts[1].y) || 1;\n const rect = canvas.getBoundingClientRect();\n stateRef.current = {\n mode: \"pinch\",\n startDist,\n anchorX: (pts[0].x + pts[1].x) / 2 - rect.left,\n contentWidth: snap.contentWidth,\n snapshot: snap.base,\n };\n canvas.setPointerCapture(pointerEvent.pointerId);\n hidePrompt();\n }\n return;\n }\n\n if (pointerEvent.button !== 0) return;\n const hit = currentHit(pointerEvent.clientX, pointerEvent.clientY);\n\n if (hit?.kind === \"event\" && !hit.event.props?.isLocked) {\n const direction = resizeDirectionAt(hit, pointerEvent.clientX);\n if (direction) {\n stateRef.current = {\n mode: \"resize\",\n event: hit.event,\n direction,\n startClientX: pointerEvent.clientX,\n deltaPx: 0,\n };\n lockCursor(\"e-resize\");\n } else {\n stateRef.current = {\n mode: \"drag\",\n hit,\n startClientX: pointerEvent.clientX,\n startClientY: pointerEvent.clientY,\n active: false,\n };\n styleGhost(hit.event);\n }\n } else if (\n config.dragZoom &&\n (pointerEvent.ctrlKey || pointerEvent.metaKey) &&\n !isTouch\n ) {\n // ctrl/cmd + background drag -> time-frame zoom (anchored at press)\n const snap = snapshotView();\n if (!snap) return;\n const rect = canvas.getBoundingClientRect();\n stateRef.current = {\n mode: \"zoom\",\n startClientX: pointerEvent.clientX,\n anchorX: pointerEvent.clientX - rect.left,\n contentWidth: snap.contentWidth,\n snapshot: snap.base,\n };\n } else if (config.panOnDragBackground) {\n stateRef.current = {\n mode: \"pan\",\n lastClientX: pointerEvent.clientX,\n lastClientY: pointerEvent.clientY,\n touch: isTouch,\n };\n canvas.style.cursor = \"grabbing\";\n } else {\n return;\n }\n hidePrompt();\n canvas.setPointerCapture(pointerEvent.pointerId);\n },\n [\n currentHit,\n resizeDirectionAt,\n dynamicCanvasRef,\n hidePrompt,\n config,\n snapshotView,\n ghostRef,\n rendererRef,\n styleGhost,\n ]\n );\n\n const handleHover = useCallback(\n (pointerEvent: React.PointerEvent<HTMLCanvasElement>) => {\n const canvas = dynamicCanvasRef.current;\n if (!canvas) return;\n const hit = currentHit(pointerEvent.clientX, pointerEvent.clientY);\n const prevHovered = hoveredRef.current;\n hoveredRef.current = hit;\n\n if (hit?.kind === \"event\") {\n if (hit.event.props?.isLocked) {\n canvas.style.cursor = \"not-allowed\";\n } else if (resizeDirectionAt(hit, pointerEvent.clientX)) {\n canvas.style.cursor = \"e-resize\";\n } else {\n canvas.style.cursor = \"pointer\";\n }\n } else {\n canvas.style.cursor = \"grab\";\n }\n\n const hoveredId = hit?.kind === \"event\" ? hit.event.id : null;\n const prevId = prevHovered?.kind === \"event\" ? prevHovered.event.id : null;\n if (hoveredId !== prevId) {\n rendererRef.current?.setView({ hoveredEventId: hoveredId });\n if (onEventHover) {\n onEventHover({\n eventId: hoveredId,\n rowId: hoveredId !== null && hit ? hit.rowId : null,\n });\n }\n }\n\n const prompt = eventPromptRef.current;\n if (!prompt) return;\n if (\n hit?.kind === \"event\" &&\n (hit.event.props?.showPrompt ||\n hit.event.props?.showPrompt === undefined)\n ) {\n if (prevId !== hit.event.id) {\n const canvasRect = canvas.getBoundingClientRect();\n // anchor in viewport coordinates; floating-ui handles flip/shift\n prompt.show(hit.event, {\n x: canvasRect.left + hit.rect.x,\n y: canvasRect.top + hit.rect.y,\n width: hit.rect.width,\n height: hit.rect.height,\n });\n }\n } else {\n prompt.hide();\n }\n },\n [\n currentHit,\n resizeDirectionAt,\n dynamicCanvasRef,\n eventPromptRef,\n rendererRef,\n onEventHover,\n ]\n );\n\n const handlePointerMove = useCallback(\n (pointerEvent: React.PointerEvent<HTMLCanvasElement>) => {\n const tracked = pointersRef.current.get(pointerEvent.pointerId);\n if (tracked) {\n tracked.x = pointerEvent.clientX;\n tracked.y = pointerEvent.clientY;\n }\n\n const state = stateRef.current;\n if (state.mode === \"idle\") {\n handleHover(pointerEvent);\n return;\n }\n if (state.mode === \"pinch\") {\n const pts = [...pointersRef.current.values()];\n if (pts.length < 2) return;\n const dist =\n Math.hypot(pts[0].x - pts[1].x, pts[0].y - pts[1].y) || 1;\n zoomPendingRef.current = {\n anchorX: state.anchorX,\n factor: state.startDist / dist, // fingers apart -> factor<1 -> zoom in\n };\n scheduleContinuousZoom();\n return;\n }\n if (state.mode === \"zoom\") {\n const dx = pointerEvent.clientX - state.startClientX;\n zoomPendingRef.current = {\n anchorX: state.anchorX,\n factor: Math.pow(2, -dx / DRAG_ZOOM_PX_PER_DOUBLING), // right -> zoom in\n };\n scheduleContinuousZoom();\n return;\n }\n if (state.mode === \"pan\") {\n panPendingDxRef.current += pointerEvent.clientX - state.lastClientX;\n // touch has no wheel for vertical scroll, so single-finger drag also\n // scrolls rows (canvas touch-action is none, so we drive it manually)\n if (state.touch && bodyRef.current) {\n bodyRef.current.scrollTop -= pointerEvent.clientY - state.lastClientY;\n }\n state.lastClientX = pointerEvent.clientX;\n state.lastClientY = pointerEvent.clientY;\n schedulePan();\n return;\n }\n if (state.mode === \"drag\") {\n if (\n !state.active &&\n Math.abs(pointerEvent.clientX - state.startClientX) +\n Math.abs(pointerEvent.clientY - state.startClientY) >\n DRAG_THRESHOLD_PX\n ) {\n state.active = true;\n rendererRef.current?.setView({ draggedEventId: state.hit.event.id });\n }\n if (state.active) {\n updateGhost(state, pointerEvent.clientX, pointerEvent.clientY);\n }\n return;\n }\n // resize\n state.deltaPx = pointerEvent.clientX - state.startClientX;\n rendererRef.current?.setView({\n resizePreview: {\n eventId: state.event.id,\n deltaPx: state.deltaPx,\n direction: state.direction,\n },\n });\n },\n [\n handleHover,\n schedulePan,\n updateGhost,\n rendererRef,\n scheduleContinuousZoom,\n bodyRef,\n ]\n );\n\n const commitDrop = useCallback(\n (\n state: Extract<InteractionState, { mode: \"drag\" }>,\n clientX: number,\n clientY: number\n ) => {\n const canvas = dynamicCanvasRef.current;\n const renderer = rendererRef.current;\n if (!canvas || !renderer) return;\n const view = renderer.getView();\n if (view.tick === null || view.cellWidth <= 0) return;\n const canvasRect = canvas.getBoundingClientRect();\n const yContent = clientY - canvasRect.top + view.scrollTop;\n\n // target row by accumulated heights (same walk the drawing uses)\n let rowTop = 0;\n let targetRowId: string | null = null;\n for (const id of scene.getRowIds()) {\n const height = scene.getRowHeight(\n id,\n view.windowTime[0],\n view.windowTime[1]\n );\n if (yContent >= rowTop && yContent < rowTop + height) {\n targetRowId = id;\n break;\n }\n rowTop += height;\n }\n if (targetRowId === null) return; // dropped outside all rows -> cancel\n\n const liveEvent = scene.getEvent(state.hit.event.id);\n if (!liveEvent) return;\n\n const { startTime, endTime } = computeDropTimes({\n pointerX: clientX - canvasRect.left,\n cellWidth: view.cellWidth,\n tick: view.tick,\n windowStart: view.windowTime[0],\n duration: liveEvent.endTime - liveEvent.startTime,\n });\n\n if (onDrop) {\n onDrop({\n eventId: liveEvent.id,\n oldRowId: liveEvent.rowId,\n newRowId: targetRowId,\n startTime,\n endTime,\n });\n }\n // the ghost already previewed the destination — the dropped event must\n // land instantly; only the events re-stacking around it animate\n renderer.animator.snapEventTop(liveEvent.id);\n scene.applyPatches([\n {\n op: \"update\",\n id: liveEvent.id,\n changes: { startTime, endTime, rowId: targetRowId },\n },\n ]);\n },\n [scene, dynamicCanvasRef, rendererRef, onDrop]\n );\n\n const commitResize = useCallback(\n (state: Extract<InteractionState, { mode: \"resize\" }>) => {\n const renderer = rendererRef.current;\n const tick = renderer?.getView().tick;\n renderer?.setView({ resizePreview: null });\n unlockCursor();\n if (!tick) return;\n const liveEvent = scene.getEvent(state.event.id);\n if (!liveEvent) return;\n const next = computeResizeTimes(\n liveEvent,\n state.deltaPx,\n tick,\n state.direction\n );\n if (next) {\n scene.applyPatches([\n { op: \"update\", id: liveEvent.id, changes: next },\n ]);\n }\n if (onResize) {\n // legacy reported the (possibly unchanged) committed values\n const committed = next ?? {\n startTime: liveEvent.startTime,\n endTime: liveEvent.endTime,\n };\n onResize({ eventId: liveEvent.id, ...committed });\n }\n },\n [scene, rendererRef, onResize]\n );\n\n const handlePointerUp = useCallback(\n (pointerEvent: React.PointerEvent<HTMLCanvasElement>) => {\n const canvas = dynamicCanvasRef.current;\n const state = stateRef.current;\n pointersRef.current.delete(pointerEvent.pointerId);\n stateRef.current = { mode: \"idle\" };\n if (canvas?.hasPointerCapture(pointerEvent.pointerId)) {\n canvas.releasePointerCapture(pointerEvent.pointerId);\n }\n if (canvas) canvas.style.cursor = \"grab\";\n\n if (state.mode === \"drag\" && state.active) {\n if (ghostRef.current) ghostRef.current.style.display = \"none\";\n rendererRef.current?.setView({ draggedEventId: null });\n commitDrop(state, pointerEvent.clientX, pointerEvent.clientY);\n } else if (state.mode === \"drag\" && !state.active) {\n // press + release without movement = click\n if (onEventClick) {\n onEventClick({\n eventId: state.hit.event.id,\n rowId: state.hit.rowId,\n nativeEvent: pointerEvent.nativeEvent,\n modifiers: {\n shift: pointerEvent.shiftKey,\n ctrl: pointerEvent.ctrlKey,\n meta: pointerEvent.metaKey,\n alt: pointerEvent.altKey,\n },\n });\n }\n } else if (state.mode === \"resize\") {\n commitResize(state);\n }\n },\n [\n dynamicCanvasRef,\n ghostRef,\n rendererRef,\n commitDrop,\n commitResize,\n onEventClick,\n ]\n );\n\n const handlePointerCancel = useCallback(\n (pointerEvent: React.PointerEvent<HTMLCanvasElement>) => {\n pointersRef.current.delete(pointerEvent.pointerId);\n stateRef.current = { mode: \"idle\" };\n const canvas = dynamicCanvasRef.current;\n if (canvas?.hasPointerCapture(pointerEvent.pointerId)) {\n canvas.releasePointerCapture(pointerEvent.pointerId);\n }\n if (ghostRef.current) ghostRef.current.style.display = \"none\";\n rendererRef.current?.setView({ draggedEventId: null });\n },\n [dynamicCanvasRef, ghostRef, rendererRef]\n );\n\n const handlePointerLeave = useCallback(() => {\n if (stateRef.current.mode !== \"idle\") return; // captured pointer still active\n if (hoveredRef.current?.kind === \"event\") {\n rendererRef.current?.setView({ hoveredEventId: null });\n if (onEventHover) onEventHover({ eventId: null, rowId: null });\n }\n hoveredRef.current = null;\n if (dynamicCanvasRef.current) {\n dynamicCanvasRef.current.style.cursor = \"\";\n }\n hidePrompt();\n }, [dynamicCanvasRef, rendererRef, hidePrompt, onEventHover]);\n\n // middle-click toggles grid-granularity mode (legacy \"awesome feature\")\n const handleAuxClick = useCallback(\n (pointerEvent: React.MouseEvent<HTMLCanvasElement>) => {\n pointerEvent.preventDefault();\n if (pointerEvent.button === 1 && config.middleClickGranularity) {\n changeGridRef.current = !changeGridRef.current;\n if (bodyRef.current) {\n bodyRef.current.style.overflowY = changeGridRef.current\n ? \"hidden\"\n : \"auto\";\n }\n }\n },\n [bodyRef, config]\n );\n\n // wheel must be non-passive to preventDefault (browser zoom / scroll)\n useEffect(() => {\n const canvas = dynamicCanvasRef.current;\n if (!canvas) return;\n const handleWheel = (wheelEvent: WheelEvent) => {\n const view = rendererRef.current?.getView();\n if (!view || view.tick === null) return;\n const tick = view.tick;\n\n // middle-click granularity mode: wheel adjusts the grid cell width\n if (changeGridRef.current) {\n wheelEvent.preventDefault();\n setCellWidth((cellWidth) =>\n stepCellWidth(\n cellWidth,\n wheelEvent.deltaY,\n (tick * 900) / config.zoomStepSeconds\n )\n );\n return;\n }\n\n // ctrl/cmd + wheel (and Mac trackpad pinch) zooms the time frame\n if ((wheelEvent.ctrlKey || wheelEvent.metaKey) && config.ctrlWheelZoom) {\n wheelEvent.preventDefault();\n const rect = canvas.getBoundingClientRect();\n const factor =\n wheelEvent.deltaY > 0\n ? config.zoomWheelFactor\n : 1 / config.zoomWheelFactor;\n applyZoom(\n {\n windowTime: [view.windowTime[0], view.windowTime[1]],\n tick,\n cellWidth: view.cellWidth,\n },\n wheelEvent.clientX - rect.left,\n factor,\n rect.width\n );\n return;\n }\n // otherwise: let the body scroll the rows natively\n };\n canvas.addEventListener(\"wheel\", handleWheel, { passive: false });\n return () => canvas.removeEventListener(\"wheel\", handleWheel);\n }, [dynamicCanvasRef, rendererRef, setCellWidth, applyZoom, config]);\n\n useEffect(() => unlockCursor, []); // safety on unmount\n\n return {\n handlePointerDown,\n handlePointerMove,\n handlePointerUp,\n handlePointerLeave,\n handlePointerCancel,\n handleAuxClick,\n };\n};\n\nexport default useCanvasInteractions;\n","export type Rect = {\n x: number;\n y: number;\n width: number;\n height: number;\n};\n\nexport const rectContains = (rect: Rect, x: number, y: number) =>\n x >= rect.x &&\n x <= rect.x + rect.width &&\n y >= rect.y &&\n y <= rect.y + rect.height;\n","import { EventType } from \"../types\";\nimport { SceneStore } from \"./scene\";\nimport { Rect, rectContains } from \"./types\";\nimport { cullToWindow } from \"./culling\";\nimport { timeToWidth, timeToX } from \"./coords\";\nimport { laneTop, staticEventHeight } from \"./lanes\";\n\nexport type HitTarget = {\n kind: \"event\" | \"static\";\n event: EventType;\n rowId: string;\n /** rect in viewport (canvas CSS px) coordinates, scroll already applied */\n rect: Rect;\n};\n\nexport type HitTestView = {\n windowStart: number;\n windowEnd: number;\n tick: number;\n scrollTop: number;\n};\n\n/**\n * Point query against the scene at viewport coordinates (x, y).\n * Finds the row by accumulated heights, then scans that row's window-visible\n * events back-to-front (interactive events sit above static ones, later\n * events draw above earlier ones). Per-row event counts are small, so the\n * scan after the row/window cut is cheap — no spatial index needed.\n */\nexport const hitTest = (\n scene: SceneStore,\n view: HitTestView,\n x: number,\n y: number\n): HitTarget | null => {\n const { windowStart, windowEnd, tick, scrollTop } = view;\n const geometry = scene.getGeometry();\n const yContent = y + scrollTop;\n\n let rowTop = 0;\n let rowId: string | null = null;\n for (const id of scene.getRowIds()) {\n const height = scene.getRowHeight(id, windowStart, windowEnd);\n if (yContent >= rowTop && yContent < rowTop + height) {\n rowId = id;\n break;\n }\n rowTop += height;\n }\n if (rowId === null) return null;\n\n const lanes = scene.getLanes(rowId, windowStart, windowEnd);\n const rowY = rowTop - scrollTop;\n\n const events = cullToWindow(\n scene.getRowEvents(rowId),\n windowStart,\n windowEnd\n );\n for (let i = events.length - 1; i >= 0; i--) {\n const event = events[i];\n const rect: Rect = {\n x: timeToX(event.startTime, windowStart, tick),\n y: rowY + laneTop(lanes.laneOf.get(event.id) as number, geometry),\n width: timeToWidth(event.startTime, event.endTime, tick),\n height: geometry.barHeight,\n };\n if (rectContains(rect, x, y)) {\n return { kind: \"event\", event, rowId, rect };\n }\n }\n\n const statics = cullToWindow(\n scene.getRowStaticEvents(rowId),\n windowStart,\n windowEnd\n );\n for (let i = statics.length - 1; i >= 0; i--) {\n const event = statics[i];\n const rect: Rect = {\n x: timeToX(event.startTime, windowStart, tick),\n y: rowY + geometry.laneTopOffset,\n width: timeToWidth(event.startTime, event.endTime, tick),\n height: staticEventHeight(lanes.highestLane, geometry),\n };\n if (rectContains(rect, x, y)) {\n return { kind: \"static\", event, rowId, rect };\n }\n }\n\n return null;\n};\n","import { EventPatch, EventType, RowType } from \"../types\";\nimport sortEvents from \"../helpers/sort-events\";\nimport { assignLanes, LaneResult, rowMinHeight } from \"./lanes\";\nimport { Geometry, DEFAULT_GEOMETRY } from \"./geometry\";\n\nexport type { EventPatch };\n\ntype RowIndex = {\n row: RowType;\n // both arrays kept sorted with helpers/sort-events\n events: EventType[];\n staticEvents: EventType[];\n lanesDirty: boolean;\n lanes: LaneResult | null;\n // window the cached lanes were computed for (lanes depend on visibility)\n laneWindowStart: number;\n laneWindowEnd: number;\n};\n\nconst binaryInsertIndex = (events: EventType[], event: EventType) => {\n let lo = 0;\n let hi = events.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (sortEvents(events[mid], event) < 0) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n return lo;\n};\n\n/**\n * Imperative event store for the canvas renderer. Lives outside React state:\n * streaming patches mutate it directly and the renderer reads from it per\n * frame — React never reconciles individual event motion.\n *\n * Lane assignment (and therefore row height) is computed lazily per row, only\n * when that row is queried for the current window. Bursts of patches against\n * off-screen rows cost nothing beyond an index update.\n */\nexport class SceneStore {\n private rowIndexes = new Map<string, RowIndex>();\n private rowOrder: string[] = [];\n private eventRow = new Map<string, string>();\n private listeners = new Set<() => void>();\n // Themeable vertical layout. Lanes are geometry-free (pure time logic), so a\n // geometry change only affects heights/offsets — the cached lanes stay valid\n // and we just bump to trigger a redraw.\n private geometry: Geometry = DEFAULT_GEOMETRY;\n version = 0;\n\n setGeometry(geometry: Geometry) {\n this.geometry = geometry;\n this.bump();\n }\n\n getGeometry(): Geometry {\n return this.geometry;\n }\n\n setRows(rows: RowType[]) {\n const next = new Map<string, RowIndex>();\n for (const row of rows) {\n const existing = this.rowIndexes.get(row.id);\n next.set(\n row.id,\n existing\n ? { ...existing, row }\n : {\n row,\n events: [],\n staticEvents: [],\n lanesDirty: true,\n lanes: null,\n laneWindowStart: NaN,\n laneWindowEnd: NaN,\n }\n );\n }\n // events of removed rows drop with their index\n for (const [id, rowId] of this.eventRow) {\n if (!next.has(rowId)) this.eventRow.delete(id);\n }\n this.rowIndexes = next;\n this.rowOrder = rows.map((row) => row.id);\n this.bump();\n }\n\n setEvents(events: EventType[]) {\n for (const index of this.rowIndexes.values()) {\n index.events = [];\n index.lanesDirty = true;\n }\n this.eventRow.clear();\n for (const event of events) {\n const index = this.rowIndexes.get(event.rowId);\n if (!index) continue;\n index.events.push(event);\n this.eventRow.set(event.id, event.rowId);\n }\n for (const index of this.rowIndexes.values()) {\n index.events.sort(sortEvents);\n }\n this.bump();\n }\n\n setStaticEvents(events: EventType[]) {\n for (const index of this.rowIndexes.values()) {\n index.staticEvents = [];\n }\n for (const event of events) {\n const index = this.rowIndexes.get(event.rowId);\n if (!index) continue;\n index.staticEvents.push(event);\n }\n for (const index of this.rowIndexes.values()) {\n index.staticEvents.sort(sortEvents);\n }\n this.bump();\n }\n\n applyPatches(patches: EventPatch[]) {\n for (const patch of patches) {\n if (patch.op === \"upsert\") {\n this.remove(patch.event.id);\n this.insert(patch.event);\n } else if (patch.op === \"update\") {\n const existing = this.getEvent(patch.id);\n if (!existing) continue;\n this.remove(patch.id);\n this.insert({ ...existing, ...patch.changes, id: patch.id });\n } else {\n this.remove(patch.id);\n }\n }\n this.bump();\n }\n\n getEvent(id: string): EventType | undefined {\n const rowId = this.eventRow.get(id);\n if (rowId === undefined) return undefined;\n return this.rowIndexes\n .get(rowId)\n ?.events.find((event) => event.id === id);\n }\n\n getRowIds(): string[] {\n return this.rowOrder;\n }\n\n getRow(rowId: string): RowType | undefined {\n return this.rowIndexes.get(rowId)?.row;\n }\n\n getRowEvents(rowId: string): EventType[] {\n return this.rowIndexes.get(rowId)?.events ?? [];\n }\n\n getRowStaticEvents(rowId: string): EventType[] {\n return this.rowIndexes.get(rowId)?.staticEvents ?? [];\n }\n\n getLanes(rowId: string, windowStart: number, windowEnd: number): LaneResult {\n const index = this.rowIndexes.get(rowId);\n if (!index) return { laneOf: new Map(), highestLane: 0 };\n if (\n index.lanesDirty ||\n index.lanes === null ||\n index.laneWindowStart !== windowStart ||\n index.laneWindowEnd !== windowEnd\n ) {\n index.lanes = assignLanes(index.events, windowStart, windowEnd);\n index.laneWindowStart = windowStart;\n index.laneWindowEnd = windowEnd;\n index.lanesDirty = false;\n }\n return index.lanes;\n }\n\n getRowHeight(rowId: string, windowStart: number, windowEnd: number): number {\n return rowMinHeight(\n this.getLanes(rowId, windowStart, windowEnd).highestLane,\n this.geometry\n );\n }\n\n /**\n * y offset of each row's top edge (content coordinates, before scroll) plus\n * the total content height — drives both drawing and the scroll spacer.\n */\n getRowOffsets(\n windowStart: number,\n windowEnd: number\n ): { offsetOf: Map<string, number>; totalHeight: number } {\n const offsetOf = new Map<string, number>();\n let y = 0;\n for (const rowId of this.rowOrder) {\n offsetOf.set(rowId, y);\n y += this.getRowHeight(rowId, windowStart, windowEnd);\n }\n return { offsetOf, totalHeight: y };\n }\n\n subscribe(listener: () => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n private insert(event: EventType) {\n const index = this.rowIndexes.get(event.rowId);\n if (!index) return;\n index.events.splice(binaryInsertIndex(index.events, event), 0, event);\n index.lanesDirty = true;\n this.eventRow.set(event.id, event.rowId);\n }\n\n private remove(id: string) {\n const rowId = this.eventRow.get(id);\n if (rowId === undefined) return;\n const index = this.rowIndexes.get(rowId);\n if (index) {\n const at = index.events.findIndex((event) => event.id === id);\n if (at !== -1) index.events.splice(at, 1);\n index.lanesDirty = true;\n }\n this.eventRow.delete(id);\n }\n\n private bump() {\n this.version++;\n for (const listener of this.listeners) listener();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAOO;;;ACNA,IAAM,6BAA6B;AACnC,IAAM,2BAA2B;AAUxC,IAAM,OAAO,CAAC,MAAc,IAAI,KAAK,IAAI,IAAI;AAiBtC,IAAM,iBAAN,MAAqB;AAAA,EAArB;AACL,SAAQ,aAAa,oBAAI,IAAmB;AAC5C,SAAQ,YAAY,oBAAI,IAAmB;AAC3C,SAAQ,eAAe,oBAAI,IAAmB;AAC9C,SAAQ,MAAM;AACd,SAAQ,cAAc;AACtB,SAAQ,iBAAiB;AACzB,SAAQ,eAAe;AAAA;AAAA,EAEvB,aAAa,UAAkB,QAAgB;AAC7C,SAAK,iBAAiB;AACtB,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,WAAW,KAAa;AACtB,SAAK,MAAM;AAAA,EACb;AAAA,EAEA,UAAU,OAAe,QAAwB;AAC/C,WAAO,KAAK,MAAM,KAAK,YAAY,OAAO,QAAQ,KAAK,cAAc;AAAA,EACvE;AAAA,EAEA,SAAS,SAAiB,QAAwB;AAChD,WAAO,KAAK,MAAM,KAAK,WAAW,SAAS,QAAQ,KAAK,cAAc;AAAA,EACxE;AAAA;AAAA,EAGA,YAAY,SAAiB,QAAwB;AACnD,WAAO,KAAK,MAAM,KAAK,cAAc,SAAS,QAAQ,KAAK,YAAY;AAAA,EACzE;AAAA,EAEA,cAAuB;AACrB,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;A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eAAe,MAAO,QAAO,EAAE,UAAU,GAAG,QAAQ,EAAE;AAC1D,UAAI,eAAe,MAAM;AACvB,eAAO;AAAA,UACL,UAAU;AAAA,UACV,QAAQ;AAAA,QACV;AAAA,MACF;AACA,aAAO;AAAA,QACL,WAAU,gBAAW,aAAX,YAAuB;AAAA,QACjC,SAAQ,gBAAW,WAAX,YAAqB;AAAA,MAC/B;AAAA,IACF,GAAG,CAAC,UAAU,CAAC;AAEf,UAAM,kBAAc;AAAA,MAClB,MACE,8BAAAC,QAAA;AAAA,QAAC;AAAA;AAAA,UACC,KAAK;AAAA,UACL,UAAU;AAAA;AAAA,MACX;AAAA,MAEH,CAAC,mBAAmB;AAAA,IACtB;AAEA,WACE,8BAAAA,QAAA,cAAC,SAAI,WAAU,gBAAe,KAAK,WAChC,mBACC,8BAAAA,QAAA,cAAC,wBAAY,MAAY,YAAwB,GAEnD,8BAAAA,QAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,cACE,WAAW,UACP,WAAW,QAAQ,sBAAsB,EAAE,QAC3C;AAAA,QAEN;AAAA,QACA,OAAO;AAAA,QACP;AAAA;AAAA,IACF,GAEA,8BAAAA,QAAA,cAAC,SAAI,WAAU,gBAAe,KAAK,WACjC,8BAAAA,QAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,qBAAqB,6DAAsB;AAAA,QAC3C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,YAAY;AAAA,QACZ,KAAK;AAAA;AAAA,IACP,GACC,mBAAmB,WACtB,CACF;AAAA,EAEJ;AACF;","names":["import_react","import_react","React","import_react","React","import_react","_a","React","import_react","import_react","React","offset","React"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/timeline.tsx","../src/canvas/animator.ts","../src/hooks/use-resize-observer.ts","../src/helpers/sort-events.ts","../src/components/rt-indicator.tsx","../src/components/event-prompt.tsx","../src/components/canvas-time-bar.tsx","../src/helpers/get-month-name.ts","../src/helpers/get-week-day-name.ts","../src/core/time-blocks.ts","../src/canvas/dpr.ts","../src/canvas/theme.ts","../src/canvas/draw-grid.ts","../src/components/canvas-board.tsx","../src/canvas/frame-scheduler.ts","../src/core/culling.ts","../src/core/coords.ts","../src/core/geometry.ts","../src/core/lanes.ts","../src/core/interactions.ts","../src/canvas/draw-events.ts","../src/canvas/renderer.ts","../src/hooks/use-canvas-interactions.ts","../src/core/types.ts","../src/core/hit-test.ts","../src/core/scene.ts"],"sourcesContent":["export * from \"./timeline\";\nexport type {\n RowType,\n EventType,\n EventPropsType,\n EventStyle,\n EventState,\n DrawEventFn,\n Theme,\n ResolvedTheme,\n Rect,\n OnDropProps,\n OnResizeProps,\n OnEventClickProps,\n OnEventHoverProps,\n DroppableError,\n PanZoomConfig,\n EventPatch,\n TimelineHandle,\n TimelineProps,\n TimelineType,\n} from \"./types\";\n","import React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n EventPromptActionsType,\n TimelineHandle,\n TimelineProps,\n} from \"./types\";\nimport {\n DEFAULT_FADE_DURATION_MS,\n DEFAULT_LAYOUT_DURATION_MS,\n} from \"./canvas/animator\";\nimport \"./style.css\";\nimport useResizeObserver from \"./hooks/use-resize-observer\";\nimport sortEvents from \"./helpers/sort-events\";\nimport RTIndicator from \"./components/rt-indicator\";\nimport EventPrompt from \"./components/event-prompt\";\nimport CanvasTimeBar from \"./components/canvas-time-bar\";\nimport CanvasBoard from \"./components/canvas-board\";\nimport { SceneStore } from \"./core/scene\";\nimport { TimelineRenderer } from \"./canvas/renderer\";\nimport { resolveTheme } from \"./canvas/theme\";\nimport { geometryFromTheme } from \"./core/geometry\";\n\nexport const Timeline = forwardRef<TimelineHandle, TimelineProps>(\n (\n {\n rows,\n events,\n staticEvents,\n onDrop,\n onResize,\n onEventClick,\n onEventHover,\n selectable = false,\n defaultSelectedEventIds,\n onSelectionChange,\n defaultCollapsedRowIds,\n startDate,\n endDate,\n theme,\n drawEvent,\n additionalClassNames,\n showRTIndicator = true,\n eventsResize = true,\n eventPromptTemplate,\n showEventPrompt = true,\n panZoom,\n timeBar,\n animations = true,\n },\n handleRef\n ) => {\n const [windowTime, setWindowTime] = useState([\n new Date(\n startDate.getFullYear(),\n startDate.getMonth(),\n startDate.getDate(),\n startDate.getHours(),\n 0,\n 0\n ).getTime() / 1000,\n new Date(\n endDate.getFullYear(),\n endDate.getMonth(),\n endDate.getDate(),\n endDate.getHours(),\n 0,\n 0\n ).getTime() / 1000,\n ]);\n\n // cellWidth is in px\n const [cellWidth, setCellWidth] = useState(0);\n\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const mainRef = useRef<HTMLDivElement | null>(null);\n\n const bodyRef = useRef<HTMLDivElement | null>(null);\n\n // tick is represent how many seconds is a one pixel\n const [tick, setTick] = useState<number | null>(null);\n\n const [scrollWidth, setScrollWidth] = useState(0);\n\n const eventPromptRef = useRef<EventPromptActionsType | null>(null);\n\n const rendererRef = useRef<TimelineRenderer | null>(null);\n\n // The SceneStore is the single source of truth for event data. The\n // `events` prop is authoritative on every reference change (full reset);\n // interactions and the imperative handle mutate the store directly.\n const sceneRef = useRef<SceneStore | null>(null);\n if (sceneRef.current === null) {\n sceneRef.current = new SceneStore();\n }\n const scene = sceneRef.current;\n\n // Uncontrolled selection state. Lives in a ref (off the React render path,\n // like the SceneStore) and is mirrored into the renderer view for drawing.\n // `applySelection` is the single write path used by both the click handler\n // and the imperative handle.\n const selectionRef = useRef<Set<string>>(\n new Set(defaultSelectedEventIds ?? [])\n );\n const onSelectionChangeRef = useRef(onSelectionChange);\n onSelectionChangeRef.current = onSelectionChange;\n const applySelection = useCallback(\n (ids: string[]) => {\n // group expansion (parent → children): selecting a group-parent event\n // also selects all of its child events. Done here so click, group-click,\n // and the imperative setSelection all inherit it. Direction is\n // parent → children only — selecting a child alone selects just it.\n const expanded: string[] = [];\n for (const id of ids) {\n expanded.push(id);\n for (const childId of scene.getChildEventIds(id)) {\n expanded.push(childId);\n }\n }\n // single enforcement point: events opted out via props.isSelectable\n // never enter the selection — covers click, group-click and the\n // imperative setSelection alike.\n selectionRef.current = new Set(\n expanded.filter((id) => scene.isEventSelectable(id))\n );\n rendererRef.current?.setView({\n selectedEventIds: selectionRef.current,\n });\n onSelectionChangeRef.current?.([...selectionRef.current]);\n },\n [scene]\n );\n const getSelection = useCallback(() => [...selectionRef.current], []);\n\n // A `rows`/`events` reference change is a full scene reset. The animator's\n // per-row tweens are keyed by rowId and would otherwise survive the swap,\n // leaving the canvas drawing a row at the previous dataset's (stale) height\n // while the DOM header already shows the new one — most visibly on rows\n // whose height differs between datasets. Drop the tweens so every row is a\n // \"first sighting\" and renders at its true height instantly.\n useEffect(() => {\n scene.setRows(rows);\n rendererRef.current?.animator.reset();\n }, [scene, rows]);\n useEffect(() => {\n scene.setEvents([...events].sort(sortEvents));\n rendererRef.current?.animator.reset();\n }, [scene, events]);\n useEffect(() => {\n scene.setStaticEvents(staticEvents ? [...staticEvents] : []);\n }, [scene, staticEvents]);\n\n // Seed the uncontrolled collapse state once. After this the scene owns it and\n // it survives every data update — we never re-apply the prop.\n const seededCollapseRef = useRef(false);\n useEffect(() => {\n if (seededCollapseRef.current) return;\n seededCollapseRef.current = true;\n for (const id of defaultCollapsedRowIds ?? []) {\n scene.setCollapsed(id, true);\n }\n }, [scene, defaultCollapsedRowIds]);\n\n const windowTimeRef = useRef(windowTime);\n windowTimeRef.current = windowTime;\n\n useImperativeHandle(\n handleRef,\n (): TimelineHandle => ({\n setEvents: (next) => scene.setEvents([...next].sort(sortEvents)),\n updateEvents: (patches) => scene.applyPatches(patches),\n getEvent: (id) => scene.getEvent(id),\n scrollToRow: (rowId) => {\n const [windowStart, windowEnd] = windowTimeRef.current;\n const offset = scene\n .getRowOffsets(windowStart, windowEnd)\n .offsetOf.get(rowId);\n if (offset !== undefined && bodyRef.current) {\n bodyRef.current.scrollTop = offset;\n }\n },\n scrollToTime: (time) => {\n setWindowTime((prev) => [time, time + (prev[1] - prev[0])]);\n },\n setWindow: (startTime, endTime) => setWindowTime([startTime, endTime]),\n getVisibleRange: () => ({\n startTime: windowTimeRef.current[0],\n endTime: windowTimeRef.current[1],\n }),\n setSelection: (ids) => applySelection(ids),\n getSelection,\n toggleRow: (rowId) => scene.toggleCollapsed(rowId),\n setCollapsed: (rowId, collapsed) => scene.setCollapsed(rowId, collapsed),\n redraw: () => rendererRef.current?.invalidate(\"all\"),\n }),\n [scene, applySelection, getSelection]\n );\n\n useEffect(() => {\n if (contentRef.current) {\n const windowDuration = windowTime[1] - windowTime[0];\n const numberOfHourBlocks = windowDuration / 3600;\n setTick(\n windowDuration / contentRef.current.getBoundingClientRect().width\n );\n setCellWidth(\n contentRef.current.getBoundingClientRect().width / numberOfHourBlocks\n );\n }\n }, []);\n\n useEffect(() => {\n if (bodyRef.current) {\n setScrollWidth(\n bodyRef.current.getBoundingClientRect().width -\n bodyRef.current.scrollWidth\n );\n }\n }, []);\n\n useResizeObserver({ contentRef, setCellWidth, setTick, windowTime });\n\n const resolvedTheme = useMemo(() => resolveTheme(theme), [theme]);\n\n // Push themeable bar geometry into the scene (single source of truth for\n // row heights / lane offsets, read by the renderer and hit-testing).\n const geometry = useMemo(\n () => geometryFromTheme(resolvedTheme),\n [resolvedTheme]\n );\n useEffect(() => {\n scene.setGeometry(geometry);\n }, [scene, geometry]);\n\n const resolvedAnimations = useMemo(() => {\n if (animations === false) return { layoutMs: 0, fadeMs: 0 };\n if (animations === true) {\n return {\n layoutMs: DEFAULT_LAYOUT_DURATION_MS,\n fadeMs: DEFAULT_FADE_DURATION_MS,\n };\n }\n return {\n layoutMs: animations.layoutMs ?? DEFAULT_LAYOUT_DURATION_MS,\n fadeMs: animations.fadeMs ?? DEFAULT_FADE_DURATION_MS,\n };\n }, [animations]);\n\n const eventPrompt = useMemo(\n () => (\n <EventPrompt\n ref={eventPromptRef}\n template={eventPromptTemplate}\n ></EventPrompt>\n ),\n [eventPromptTemplate]\n );\n\n return (\n <div className=\"main-wrapper\" ref={mainRef}>\n {showRTIndicator && (\n <RTIndicator tick={tick} windowTime={windowTime}></RTIndicator>\n )}\n <CanvasTimeBar\n windowTime={windowTime}\n tick={tick}\n contentWidth={\n contentRef.current\n ? contentRef.current.getBoundingClientRect().width\n : null\n }\n scrollWidth={scrollWidth}\n theme={resolvedTheme}\n timeBar={timeBar}\n />\n\n <div className=\"body-wrapper\" ref={bodyRef}>\n <CanvasBoard\n scene={scene}\n rows={rows}\n windowTime={windowTime}\n tick={tick}\n cellWidth={cellWidth}\n theme={resolvedTheme}\n drawEvent={drawEvent}\n bodyRef={bodyRef}\n rendererRef={rendererRef}\n eventPromptRef={eventPromptRef}\n rowsHeaderClassName={additionalClassNames?.rowsHeader}\n setWindowTime={setWindowTime}\n setCellWidth={setCellWidth}\n setTick={setTick}\n onDrop={onDrop}\n onResize={onResize}\n onEventClick={onEventClick}\n onEventHover={onEventHover}\n eventsResize={eventsResize}\n panZoom={panZoom}\n animations={resolvedAnimations}\n selectable={selectable}\n applySelection={applySelection}\n getSelection={getSelection}\n ref={contentRef}\n />\n {showEventPrompt && eventPrompt}\n </div>\n </div>\n );\n }\n);\n","// defaults — snappier than the legacy CSS (0.5s / 0.3s) by user request\nexport const DEFAULT_LAYOUT_DURATION_MS = 200;\nexport const DEFAULT_FADE_DURATION_MS = 120;\n\ntype Tween = {\n from: number;\n to: number;\n start: number;\n duration: number;\n};\n\n// smoothstep — visually equivalent to CSS ease-in-out\nconst ease = (t: number) => t * t * (3 - 2 * t);\n\n/**\n * Replaces the CSS transitions the DOM renderer got for free: event tops\n * tween when stacking changes, and resize handles fade in/out. (Row heights\n * apply instantly so the canvas rows stay locked to the DOM headers, which\n * also snap.) Values are queried per frame; while any tween is live the\n * renderer keeps scheduling frames.\n *\n * Durations are configurable via the Timeline `animations` prop; a duration\n * of 0 disables that animation (values jump straight to target).\n *\n * Coordinate rules: row heights are content-space; event tops are\n * ROW-LOCAL lane offsets. Tweens must never target a value that is itself\n * animated (e.g. an absolute top including the animated row position) —\n * a moving target retargets every frame and the tween lags behind it\n * perpetually, desyncing the layers.\n */\nexport class LayoutAnimator {\n private eventTops = new Map<string, Tween>();\n private handleAlphas = new Map<string, Tween>();\n private now = 0;\n private activeUntil = 0;\n private layoutDuration = DEFAULT_LAYOUT_DURATION_MS;\n private fadeDuration = DEFAULT_FADE_DURATION_MS;\n\n setDurations(layoutMs: number, fadeMs: number) {\n this.layoutDuration = layoutMs;\n this.fadeDuration = fadeMs;\n }\n\n beginFrame(now: number) {\n this.now = now;\n }\n\n eventTop(eventId: string, target: number): number {\n return this.value(this.eventTops, eventId, target, this.layoutDuration);\n }\n\n /** 0..1 opacity of an event's resize handles; target 1 = hovered. */\n handleAlpha(eventId: string, target: number): number {\n return this.value(this.handleAlphas, eventId, target, this.fadeDuration);\n }\n\n isAnimating(): boolean {\n return this.now < this.activeUntil;\n }\n\n /**\n * Drop an event's top tween so its next draw renders at the target\n * instantly — used on drag-drop commit, where the ghost already previewed\n * the final position and a tween would feel like a rubber-band.\n */\n snapEventTop(eventId: string) {\n this.eventTops.delete(eventId);\n }\n\n /** Drop all state, e.g. when the scene is reset wholesale. */\n reset() {\n this.eventTops.clear();\n this.handleAlphas.clear();\n this.activeUntil = 0;\n }\n\n private value(\n map: Map<string, Tween>,\n key: string,\n target: number,\n duration: number\n ): number {\n let tween = map.get(key);\n if (!tween) {\n // first sighting renders at the target instantly (legacy: a newly\n // mounted element has no previous value to transition from)\n tween = { from: target, to: target, start: 0, duration };\n map.set(key, tween);\n return target;\n }\n if (tween.to !== target) {\n if (duration <= 0) {\n tween.from = target;\n tween.to = target;\n return target;\n }\n const current = this.current(tween);\n tween.from = current;\n tween.to = target;\n tween.start = this.now;\n tween.duration = duration;\n this.activeUntil = Math.max(this.activeUntil, this.now + duration);\n }\n return this.current(tween);\n }\n\n private current(tween: Tween): number {\n if (tween.from === tween.to || tween.duration <= 0) return tween.to;\n const t = Math.min(1, (this.now - tween.start) / tween.duration);\n return tween.from + (tween.to - tween.from) * ease(t);\n }\n}\n","import { useEffect, useMemo, useRef } from \"react\";\n\nconst useResizeObserver = ({\n windowTime,\n setTick,\n setCellWidth,\n contentRef,\n}: {\n windowTime: number[];\n setTick: React.Dispatch<React.SetStateAction<number | null>>;\n setCellWidth: React.Dispatch<React.SetStateAction<number>>;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n}) => {\n const prevWidthRef = useRef(0);\n\n const resizeObserver = useMemo(() => {\n return new ResizeObserver((entries) => {\n for (const entry of entries) {\n const width = entry.borderBoxSize?.[0].inlineSize;\n if (typeof width === \"number\" && width !== prevWidthRef.current) {\n prevWidthRef.current = width;\n const windowDuration = windowTime[1] - windowTime[0];\n const numberOfHourBlocks = windowDuration / 3600;\n setTick(windowDuration / entry.contentRect.width);\n setCellWidth(entry.contentRect.width / numberOfHourBlocks);\n }\n }\n });\n }, [windowTime]);\n\n useEffect(() => {\n if (contentRef.current) {\n resizeObserver.observe(contentRef.current, { box: \"border-box\" });\n }\n return () => resizeObserver.disconnect();\n }, [resizeObserver]);\n};\n\nexport default useResizeObserver;\n","import { EventType } from \"../types\";\n\nconst sortEvents = (eventA: EventType, eventB: EventType) => {\n if (eventA.startTime - eventB.startTime < 0) return -1;\n if (eventA.startTime === eventB.startTime) {\n if (eventA.endTime < eventB.endTime) {\n return -1;\n } else {\n return 1;\n }\n } else {\n return 1;\n }\n};\nexport default sortEvents;\n","import React, { useEffect, useRef, useState } from \"react\";\n\nconst RTIndicator = ({\n tick,\n windowTime,\n}: {\n tick: number | null;\n windowTime: number[];\n}) => {\n const [currentTime, setCurrentTime] = useState(new Date().getTime() / 1000);\n const [leftOffset, setLeftOffset] = useState(0);\n const intervalIdRef = useRef<NodeJS.Timeout | null>(null);\n\n useEffect(() => {\n if (tick) {\n const leftOffsetTime = currentTime - windowTime[0];\n setLeftOffset(Math.round(leftOffsetTime / tick));\n if (intervalIdRef.current !== null) {\n clearInterval(intervalIdRef.current);\n }\n const intervalId = setInterval(() => {\n setCurrentTime(new Date().getTime() / 1000);\n }, tick * 1000);\n intervalIdRef.current = intervalId;\n }\n }, [tick, windowTime, currentTime]);\n\n return (\n <>\n {windowTime[0] <= currentTime && currentTime <= windowTime[1] && (\n <>\n <div className=\"rt-arrow\" style={{ left: 86 + leftOffset }}></div>\n <div className=\"rt-line\" style={{ left: 100 + leftOffset }}></div>\n </>\n )}\n </>\n );\n};\n\nexport default RTIndicator;\n","import React, {\n forwardRef,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport { computePosition, flip, offset, shift } from \"@floating-ui/dom\";\nimport { EventPromptActionsType, EventType } from \"../types\";\nimport type { Rect } from \"../core/types\";\n\ntype EventPromptType = {\n template?: (event: EventType) => JSX.Element;\n};\n\n/**\n * Hover tooltip for events. Positioned with @floating-ui/dom against the\n * hovered event's rect (viewport coordinates): preferred above the event,\n * flips below when there is no room, and shifts horizontally to stay\n * on-screen.\n */\nconst EventPrompt = forwardRef<EventPromptActionsType, EventPromptType>(\n ({ template }, ref) => {\n const promptRef = useRef<HTMLDivElement | null>(null);\n const [hoveredEvent, setHoveredEvent] = useState<EventType>();\n // guards against an async position landing after hide()\n const showSeqRef = useRef(0);\n\n useImperativeHandle(ref, () => {\n return {\n show(event: EventType, anchorRect: Rect) {\n const prompt = promptRef.current;\n if (!prompt) return;\n setHoveredEvent(event);\n const seq = ++showSeqRef.current;\n\n const virtualAnchor = {\n getBoundingClientRect: () => ({\n x: anchorRect.x,\n y: anchorRect.y,\n width: anchorRect.width,\n height: anchorRect.height,\n top: anchorRect.y,\n left: anchorRect.x,\n right: anchorRect.x + anchorRect.width,\n bottom: anchorRect.y + anchorRect.height,\n }),\n };\n\n // render invisibly first so floating-ui can measure the template\n prompt.style.display = \"block\";\n prompt.style.visibility = \"hidden\";\n computePosition(virtualAnchor, prompt, {\n placement: \"top\",\n middleware: [\n offset(8),\n flip({ padding: 8 }),\n shift({ padding: 8 }),\n ],\n }).then(({ x, y }) => {\n if (seq !== showSeqRef.current || !promptRef.current) return;\n promptRef.current.style.left = `${x}px`;\n promptRef.current.style.top = `${y}px`;\n promptRef.current.style.visibility = \"visible\";\n });\n },\n hide() {\n showSeqRef.current++;\n if (promptRef.current) {\n promptRef.current.style.display = \"none\";\n }\n },\n };\n });\n\n return (\n <div className=\"event-prompt\" ref={promptRef}>\n {template && hoveredEvent && template(hoveredEvent)}\n </div>\n );\n }\n);\n\nexport default EventPrompt;\n","import React, { useEffect, useRef } from \"react\";\nimport { generateUnitBlocks } from \"../core/time-blocks\";\nimport { sizeCanvas } from \"../canvas/dpr\";\nimport { drawTimeBar } from \"../canvas/draw-grid\";\nimport { ResolvedTheme, TimeBarConfig } from \"../types\";\n\n// .time-bar is 50px with a 1px border on each side\nconst TIME_BAR_INNER_HEIGHT = 48;\n\nconst CanvasTimeBar = ({\n windowTime,\n tick,\n contentWidth,\n scrollWidth,\n theme,\n timeBar,\n}: {\n windowTime: number[];\n tick: number | null;\n contentWidth: number | null;\n scrollWidth: number;\n theme?: ResolvedTheme;\n timeBar?: TimeBarConfig;\n}) => {\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n\n const topRow = timeBar?.topRow ?? { unit: \"day\" as const };\n const bottomRow = timeBar?.bottomRow ?? { unit: \"hour\" as const };\n\n useEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas || !contentWidth) return;\n const ctx = sizeCanvas(\n canvas,\n contentWidth,\n TIME_BAR_INNER_HEIGHT,\n window.devicePixelRatio\n );\n if (!ctx) return;\n const [windowStart, windowEnd] = windowTime;\n drawTimeBar(ctx, {\n width: contentWidth,\n height: TIME_BAR_INNER_HEIGHT,\n font: theme?.font ?? getComputedStyle(canvas).font,\n borderColor: theme?.timeBarBorder,\n textColor: theme?.timeBarTextColor,\n topBlocks: generateUnitBlocks({ ...topRow, windowStart, windowEnd, tick }),\n bottomBlocks: generateUnitBlocks({\n ...bottomRow,\n windowStart,\n windowEnd,\n tick,\n }),\n });\n // topRow/bottomRow are derived from `timeBar`; depend on it directly so a\n // new config object re-renders the bar.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [windowTime, tick, contentWidth, theme, timeBar]);\n\n return (\n <div className=\"time-bar\">\n <div className=\"empty-block\"></div>\n <canvas\n ref={canvasRef}\n className=\"canvas-time-bar\"\n style={{ minWidth: contentWidth ? contentWidth : 0 }}\n ></canvas>\n {scrollWidth ? (\n <div\n style={{\n width: scrollWidth,\n height: \"100%\",\n boxSizing: \"border-box\",\n borderLeft: \"1px solid yellow\",\n }}\n ></div>\n ) : null}\n </div>\n );\n};\n\nexport default CanvasTimeBar;\n","const getMonthName = (monthIndex: number) => {\n let monthName: string | null = null;\n switch (monthIndex) {\n case 0:\n monthName = \"Jan\";\n break;\n case 1:\n monthName = \"Feb\";\n break;\n case 2:\n monthName = \"Mar\";\n break;\n case 3:\n monthName = \"Apr\";\n break;\n case 4:\n monthName = \"May\";\n break;\n case 5:\n monthName = \"Jun\";\n break;\n case 6:\n monthName = \"Jul\";\n break;\n case 7:\n monthName = \"Aug\";\n break;\n case 8:\n monthName = \"Sep\";\n break;\n case 9:\n monthName = \"Oct\";\n break;\n case 10:\n monthName = \"Nov\";\n break;\n case 11:\n monthName = \"Dec\";\n break;\n default:\n monthName = \"Jan\";\n }\n\n return monthName;\n};\n\nexport default getMonthName;\n","// Maps a JS Date.getDay() index (0 = Sunday … 6 = Saturday) to a short name.\nconst WEEKDAY_NAMES = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\nconst getWeekDayName = (dayIndex: number) =>\n WEEKDAY_NAMES[dayIndex] ?? \"Sun\";\n\nexport default getWeekDayName;\n","import getMonthName from \"../helpers/get-month-name\";\nimport getWeekDayName from \"../helpers/get-week-day-name\";\nimport { TimeBarRowConfig, TimeBarUnit } from \"../types\";\n\nexport type TimeBlock = {\n label: string;\n x: number; // CSS px from the content's left edge\n width: number;\n};\n\nexport type TimeBlocks = {\n dayBlocks: TimeBlock[];\n hourBlocks: TimeBlock[];\n};\n\nconst pad2 = (n: number) => (n < 10 ? `0${n}` : `${n}`);\nconst hourLabel = (hour: number) => `${pad2(hour)}:00`;\n\nconst dayLabel = (date: Date) =>\n `${getWeekDayName(date.getDay())} ${date.getDate()} ${getMonthName(\n date.getMonth()\n )}`;\n\n/** Default label per unit — mirrors the pre-config day (\"Mon 1 Jan\") and\n * hour (\"HH:00\") labels; week labels its starting day, month its name/year. */\nconst defaultFormat = (\n unit: TimeBarUnit | { stepSeconds: number }\n): ((blockStart: Date) => string) => {\n if (typeof unit === \"object\") {\n return (d) => `${pad2(d.getHours())}:${pad2(d.getMinutes())}`;\n }\n switch (unit) {\n case \"hour\":\n return (d) => hourLabel(d.getHours());\n case \"month\":\n return (d) => `${getMonthName(d.getMonth())} ${d.getFullYear()}`;\n case \"day\":\n case \"week\":\n default:\n return (d) => dayLabel(d);\n }\n};\n\n/** Start of the calendar/step block containing `date`. */\nconst floorToUnit = (\n date: Date,\n unit: TimeBarUnit | { stepSeconds: number },\n anchorSec: number\n): Date => {\n if (typeof unit === \"object\") {\n const t = date.getTime() / 1000;\n const step = unit.stepSeconds;\n return new Date((anchorSec + Math.floor((t - anchorSec) / step) * step) * 1000);\n }\n const y = date.getFullYear();\n const mo = date.getMonth();\n const d = date.getDate();\n switch (unit) {\n case \"hour\":\n return new Date(y, mo, d, date.getHours());\n case \"day\":\n return new Date(y, mo, d);\n case \"week\": {\n const dow = (date.getDay() + 6) % 7; // Monday = 0\n return new Date(y, mo, d - dow);\n }\n case \"month\":\n return new Date(y, mo, 1);\n }\n};\n\n/** Start of the next block after `blockStart` (calendar-correct, DST-safe). */\nconst nextBoundary = (\n blockStart: Date,\n unit: TimeBarUnit | { stepSeconds: number }\n): Date => {\n if (typeof unit === \"object\") {\n return new Date(blockStart.getTime() + unit.stepSeconds * 1000);\n }\n const y = blockStart.getFullYear();\n const mo = blockStart.getMonth();\n const d = blockStart.getDate();\n switch (unit) {\n case \"hour\":\n return new Date(y, mo, d, blockStart.getHours() + 1);\n case \"day\":\n return new Date(y, mo, d + 1);\n case \"week\":\n return new Date(y, mo, d + 7);\n case \"month\":\n return new Date(y, mo + 1, 1);\n }\n};\n\n/**\n * Positioned blocks for one time-bar row. Walks real calendar/step boundaries\n * from `windowStart` to `windowEnd` and derives each block's pixel x/width\n * from `tick` (seconds per pixel), so blocks stay aligned to the wall clock as\n * the window pans. The first/last blocks are clipped to the window edges, so\n * the row tiles contiguously from x=0 to the content width.\n */\nexport const generateUnitBlocks = ({\n unit,\n format,\n windowStart,\n windowEnd,\n tick,\n}: TimeBarRowConfig & {\n windowStart: number;\n windowEnd: number;\n tick: number | null;\n}): TimeBlock[] => {\n const blocks: TimeBlock[] = [];\n const resolvedUnit = unit ?? \"hour\";\n if (tick === null || tick <= 0 || windowEnd <= windowStart) return blocks;\n\n const label = format ?? defaultFormat(resolvedUnit);\n // custom fixed steps are anchored to the start of windowStart's local day,\n // so e.g. 8h shifts fall on 00:00 / 08:00 / 16:00.\n const anchorSec =\n new Date(\n new Date(windowStart * 1000).getFullYear(),\n new Date(windowStart * 1000).getMonth(),\n new Date(windowStart * 1000).getDate()\n ).getTime() / 1000;\n\n let cursorSec = windowStart;\n let guard = 0;\n while (cursorSec < windowEnd && guard++ < 100000) {\n const blockStart = floorToUnit(new Date(cursorSec * 1000), resolvedUnit, anchorSec);\n const blockEnd = nextBoundary(blockStart, resolvedUnit);\n const startSec = blockStart.getTime() / 1000;\n const endSec = blockEnd.getTime() / 1000;\n if (endSec <= startSec) break; // safety against a non-advancing step\n\n const visibleStart = Math.max(startSec, windowStart);\n const visibleEnd = Math.min(endSec, windowEnd);\n blocks.push({\n label: label(blockStart, blockEnd),\n x: (visibleStart - windowStart) / tick,\n width: (visibleEnd - visibleStart) / tick,\n });\n cursorSec = endSec;\n }\n return blocks;\n};\n\n/**\n * The default two-row time bar: a day row over an hour row. Thin wrapper over\n * `generateUnitBlocks` kept for the golden tests and as the documented\n * default; the canvas time bar resolves `TimeBarConfig` and calls\n * `generateUnitBlocks` per row directly.\n */\nexport const generateTimeBlocks = ({\n windowStart,\n tick,\n contentWidth,\n}: {\n windowStart: number;\n tick: number | null;\n contentWidth: number | null;\n /** @deprecated unused — block widths now derive from `tick` */\n blockWidth?: number;\n}): TimeBlocks => {\n if (tick === null || contentWidth === null) {\n return { dayBlocks: [], hourBlocks: [] };\n }\n const windowEnd = windowStart + contentWidth * tick;\n return {\n dayBlocks: generateUnitBlocks({ unit: \"day\", windowStart, windowEnd, tick }),\n hourBlocks: generateUnitBlocks({ unit: \"hour\", windowStart, windowEnd, tick }),\n };\n};\n","/**\n * Sizes a canvas backing store for the given devicePixelRatio and resets the\n * context transform so ALL drawing code works in CSS pixels.\n */\nexport const sizeCanvas = (\n canvas: HTMLCanvasElement,\n cssWidth: number,\n cssHeight: number,\n dpr: number\n) => {\n canvas.width = Math.max(1, Math.round(cssWidth * dpr));\n canvas.height = Math.max(1, Math.round(cssHeight * dpr));\n canvas.style.width = `${cssWidth}px`;\n canvas.style.height = `${cssHeight}px`;\n const ctx = canvas.getContext(\"2d\");\n if (ctx) {\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n }\n return ctx;\n};\n\n/** Notifies when devicePixelRatio changes (browser zoom, monitor switch). */\nexport const watchDpr = (onChange: (dpr: number) => void): (() => void) => {\n let disposed = false;\n let cleanup = () => {};\n\n const listen = () => {\n if (disposed) return;\n const media = window.matchMedia(\n `(resolution: ${window.devicePixelRatio}dppx)`\n );\n const handler = () => {\n onChange(window.devicePixelRatio);\n media.removeEventListener(\"change\", handler);\n listen(); // re-arm for the new ratio\n };\n media.addEventListener(\"change\", handler);\n cleanup = () => media.removeEventListener(\"change\", handler);\n };\n\n listen();\n return () => {\n disposed = true;\n cleanup();\n };\n};\n","import { ResolvedTheme, Theme } from \"../types\";\n\n/** Defaults mirror the pre-0.2.0 stylesheet values. */\nexport const DEFAULT_THEME: ResolvedTheme = {\n eventFill: \"#ffffff\",\n eventStroke: \"#000000\",\n eventTextColor: \"#000000\",\n staticEventFill: \"#e0e0e0\",\n gridColor: \"#e4dcdc\",\n timeBarBorder: \"yellow\",\n timeBarTextColor: \"white\",\n dimmedOpacity: 0.35,\n selectionShadowColor: \"rgba(0,0,0,0.35)\",\n selectionShadowBlur: 8,\n selectionElevation: 2,\n font: undefined,\n barHeight: 20,\n laneGap: 2,\n rowPaddingY: 10,\n barRadius: 5,\n groupChildBackground: \"rgba(0,0,0,0.05)\",\n groupShadowColor: \"rgba(0,0,0,0.22)\",\n};\n\nexport const resolveTheme = (theme?: Theme): ResolvedTheme => ({\n ...DEFAULT_THEME,\n ...theme,\n});\n","import { TimeBlock } from \"../core/time-blocks\";\nimport { DEFAULT_THEME } from \"./theme\";\n\n/**\n * Vertical grid lines, one per grid cell (`cellWidth` px == `cellWidth * tick`\n * seconds). Lines are anchored to absolute time — placed at cell boundaries\n * (multiples of the cell duration), not at fixed screen offsets — so they pan\n * with the content and stay aligned with the time-bar blocks. Keeps the legacy\n * \"hide-last-line\" behavior: no line within 1px of either edge.\n */\nexport const drawGridLines = (\n ctx: CanvasRenderingContext2D,\n {\n width,\n height,\n cellWidth,\n windowStart,\n tick,\n color = DEFAULT_THEME.gridColor,\n }: {\n width: number;\n height: number;\n cellWidth: number;\n windowStart: number;\n tick: number;\n color?: string;\n }\n) => {\n if (cellWidth <= 0 || tick <= 0) return;\n const cellTime = cellWidth * tick; // seconds per grid cell\n ctx.strokeStyle = color;\n ctx.lineWidth = 1;\n ctx.beginPath();\n // first absolute cell boundary strictly after the left edge\n for (\n let t = Math.floor(windowStart / cellTime) * cellTime + cellTime;\n ;\n t += cellTime\n ) {\n const x = (t - windowStart) / tick;\n if (x >= width || width - x < 1) break; // hide line at/!near the right edge\n if (x < 1) continue; // and at the left edge\n const crisp = Math.round(x) - 0.5;\n ctx.moveTo(crisp, 0);\n ctx.lineTo(crisp, height);\n }\n ctx.stroke();\n};\n\n/**\n * Two-row time bar (top row over bottom row) — canvas replacement for the\n * day/hour block divs of time-bar.tsx. The two rows are unit-agnostic\n * (day/hour by default, configurable via TimeBarConfig). Background is left\n * transparent so the .time-bar container color shows through.\n */\nexport const drawTimeBar = (\n ctx: CanvasRenderingContext2D,\n {\n width,\n height,\n topBlocks,\n bottomBlocks,\n font,\n borderColor = DEFAULT_THEME.timeBarBorder,\n textColor = DEFAULT_THEME.timeBarTextColor,\n }: {\n width: number;\n height: number;\n font: string;\n borderColor?: string;\n textColor?: string;\n topBlocks: TimeBlock[];\n bottomBlocks: TimeBlock[];\n }\n) => {\n const mid = height / 2;\n\n ctx.strokeStyle = borderColor;\n ctx.lineWidth = 1;\n\n // day-row border-bottom\n ctx.beginPath();\n ctx.moveTo(0, Math.round(mid) - 0.5);\n ctx.lineTo(width, Math.round(mid) - 0.5);\n ctx.stroke();\n\n // block separators (right border on every block except the last)\n ctx.beginPath();\n for (let i = 0; i < topBlocks.length - 1; i++) {\n const edge = Math.round(topBlocks[i].x + topBlocks[i].width) - 0.5;\n ctx.moveTo(edge, 0);\n ctx.lineTo(edge, mid);\n }\n for (let i = 0; i < bottomBlocks.length - 1; i++) {\n const edge = Math.round(bottomBlocks[i].x + bottomBlocks[i].width) - 0.5;\n ctx.moveTo(edge, mid);\n ctx.lineTo(edge, height);\n }\n ctx.stroke();\n\n // labels, centered in their blocks like the DOM time bar\n ctx.fillStyle = textColor;\n ctx.font = font;\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"center\";\n const inset = 4;\n for (const block of topBlocks) {\n ctx.fillText(\n block.label,\n block.x + block.width / 2,\n mid / 2,\n block.width - inset\n );\n }\n for (const block of bottomBlocks) {\n ctx.fillText(\n block.label,\n block.x + block.width / 2,\n mid + mid / 2,\n block.width - inset\n );\n }\n};\n","import React, {\n forwardRef,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport {\n DrawEventFn,\n EventPromptActionsType,\n OnDropProps,\n OnEventClickProps,\n OnEventHoverProps,\n OnResizeProps,\n PanZoomConfig,\n ResolvedTheme,\n RowType,\n} from \"../types\";\nimport { SceneStore } from \"../core/scene\";\nimport { TimelineRenderer } from \"../canvas/renderer\";\nimport useCanvasInteractions from \"../hooks/use-canvas-interactions\";\nimport \"./style.css\";\n\ntype CanvasBoardProps = {\n scene: SceneStore;\n rows: RowType[];\n windowTime: number[];\n tick: number | null;\n cellWidth: number;\n theme: ResolvedTheme;\n drawEvent?: DrawEventFn;\n bodyRef: React.MutableRefObject<HTMLDivElement | null>;\n rendererRef: React.MutableRefObject<TimelineRenderer | null>;\n eventPromptRef: React.MutableRefObject<EventPromptActionsType | null>;\n rowsHeaderClassName?: string;\n setWindowTime: React.Dispatch<React.SetStateAction<number[]>>;\n setCellWidth: React.Dispatch<React.SetStateAction<number>>;\n setTick: React.Dispatch<React.SetStateAction<number | null>>;\n onDrop?: (props: OnDropProps) => void;\n onResize?: (props: OnResizeProps) => void;\n onEventClick?: (props: OnEventClickProps) => void;\n onEventHover?: (props: OnEventHoverProps) => void;\n eventsResize: boolean;\n panZoom?: PanZoomConfig;\n animations: { layoutMs: number; fadeMs: number };\n selectable: boolean;\n applySelection: (eventIds: string[]) => void;\n getSelection: () => string[];\n};\n\n/**\n * Canvas board: two viewport-sized canvases (grid + events) kept fixed\n * inside the scrolling body via position:sticky, with a tall spacer div\n * providing the native scrollbar. Drawing is translated by scrollTop, so the\n * canvas never exceeds browser size limits regardless of row count.\n *\n * The forwarded ref targets the content column — the element timeline.tsx\n * measures for tick/cellWidth.\n */\nconst CanvasBoard = forwardRef<HTMLDivElement, CanvasBoardProps>(\n (\n {\n scene,\n rows,\n windowTime,\n tick,\n cellWidth,\n theme,\n drawEvent,\n bodyRef,\n rendererRef,\n eventPromptRef,\n rowsHeaderClassName,\n setWindowTime,\n setCellWidth,\n setTick,\n onDrop,\n onResize,\n onEventClick,\n onEventHover,\n eventsResize,\n panZoom,\n animations,\n selectable,\n applySelection,\n getSelection,\n },\n contentRef\n ) => {\n const staticCanvasRef = useRef<HTMLCanvasElement | null>(null);\n const dynamicCanvasRef = useRef<HTMLCanvasElement | null>(null);\n const ghostRef = useRef<HTMLDivElement | null>(null);\n const headerWrapperRef = useRef<HTMLDivElement | null>(null);\n // Latest content height, read by measureViewport (which is defined before\n // totalHeight is computed). Assigned during render below.\n const totalHeightRef = useRef(0);\n\n const [scrollTop, setScrollTop] = useState(0);\n const [viewportHeight, setViewportHeight] = useState(0);\n\n // renderer lifecycle\n useEffect(() => {\n if (!staticCanvasRef.current || !dynamicCanvasRef.current) return;\n const renderer = new TimelineRenderer(\n staticCanvasRef.current,\n dynamicCanvasRef.current,\n scene\n );\n rendererRef.current = renderer;\n return () => {\n renderer.dispose();\n rendererRef.current = null;\n };\n }, [scene, rendererRef]);\n\n // view-state -> renderer\n useEffect(() => {\n rendererRef.current?.animator.setDurations(\n animations.layoutMs,\n animations.fadeMs\n );\n rendererRef.current?.setView({\n windowTime: [windowTime[0], windowTime[1]],\n tick,\n cellWidth,\n theme,\n drawEvent,\n eventsResize,\n });\n }, [\n windowTime,\n tick,\n cellWidth,\n theme,\n drawEvent,\n eventsResize,\n animations,\n rendererRef,\n ]);\n\n // viewport size (content column width x body height)\n const measureViewport = useCallback(() => {\n const column =\n contentRef && \"current\" in contentRef ? contentRef.current : null;\n const body = bodyRef.current;\n if (!column || !body) return;\n // Clamp the viewport-sized canvas to:\n // - window.innerHeight: a content-sized board (unbounded host) would\n // otherwise blow past browser canvas limits on large boards;\n // - totalHeight (content): body.clientHeight is inflated by the\n // absolutely-positioned canvas itself, so deriving the canvas height\n // purely from it feeds back on itself and sticks at a stale value\n // after the content shrinks (canvas taller than the column). The\n // content height is the clean upper bound.\n const cap = totalHeightRef.current > 0 ? totalHeightRef.current : Infinity;\n const height = Math.min(body.clientHeight, cap, window.innerHeight);\n setViewportHeight(height);\n rendererRef.current?.setView({\n width: column.getBoundingClientRect().width,\n height,\n });\n }, [bodyRef, contentRef, rendererRef]);\n\n useEffect(() => {\n const column =\n contentRef && \"current\" in contentRef ? contentRef.current : null;\n const body = bodyRef.current;\n if (!column || !body) return;\n measureViewport();\n const observer = new ResizeObserver(measureViewport);\n observer.observe(column);\n observer.observe(body);\n return () => observer.disconnect();\n }, [bodyRef, contentRef, measureViewport]);\n\n // scroll: renderer gets it imperatively, React only re-renders the\n // virtualized header list\n useEffect(() => {\n const body = bodyRef.current;\n if (!body) return;\n const handleScroll = () => {\n rendererRef.current?.setView({ scrollTop: body.scrollTop });\n setScrollTop(body.scrollTop);\n };\n body.addEventListener(\"scroll\", handleScroll, { passive: true });\n return () => body.removeEventListener(\"scroll\", handleScroll);\n }, [bodyRef, rendererRef]);\n\n // re-render header/spacer when scene data changes row heights\n useSyncExternalStore(\n useCallback((listener) => scene.subscribe(listener), [scene]),\n () => scene.version\n );\n\n // Measure how tall each row's label is when wrapped at the header width and\n // feed it into the scene as a per-row minimum height. A long label thus\n // grows its row (and the matching canvas dividers) instead of overflowing.\n // All rows are measured — not just the visible ones — so scrolling doesn't\n // jump as off-screen labels are discovered. Measurement uses one reused\n // off-screen node styled like the real label so fonts/wrapping match.\n useLayoutEffect(() => {\n const wrapper = headerWrapperRef.current;\n if (!wrapper) return;\n\n const measurer = document.createElement(\"div\");\n measurer.className = \"row-header-label\";\n measurer.setAttribute(\"aria-hidden\", \"true\");\n measurer.style.position = \"absolute\";\n measurer.style.left = \"-9999px\";\n measurer.style.top = \"0\";\n measurer.style.visibility = \"hidden\";\n measurer.style.height = \"auto\";\n wrapper.appendChild(measurer);\n\n let lastWidth = -1;\n const measure = () => {\n const width = wrapper.clientWidth;\n // ResizeObserver also fires when the wrapper grows in height (our own\n // height changes feed back here); only re-measure when the wrapping\n // width actually changed, otherwise the result is identical.\n if (width === 0 || width === lastWidth) return;\n lastWidth = width;\n measurer.style.width = `${width}px`;\n const heights = new Map<string, number>();\n for (const row of rows) {\n measurer.textContent = row.name ?? \"\";\n heights.set(\n row.id,\n Math.ceil(measurer.offsetHeight) + 2 * theme.rowPaddingY\n );\n }\n scene.setLabelMinHeights(heights);\n };\n measure();\n\n const observer = new ResizeObserver(measure);\n observer.observe(wrapper);\n return () => {\n observer.disconnect();\n wrapper.removeChild(measurer);\n };\n }, [rows, scene, theme.rowPaddingY, rowsHeaderClassName]);\n\n const {\n handlePointerDown,\n handlePointerMove,\n handlePointerUp,\n handlePointerLeave,\n handlePointerCancel,\n handleAuxClick,\n } = useCanvasInteractions({\n scene,\n rendererRef,\n dynamicCanvasRef,\n bodyRef,\n ghostRef,\n eventPromptRef,\n setWindowTime,\n setCellWidth,\n setTick,\n onDrop,\n onResize,\n onEventClick,\n onEventHover,\n eventsResize,\n panZoom,\n selectable,\n applySelection,\n getSelection,\n });\n\n // Seed the renderer with the current selection (e.g. defaultSelectedEventIds)\n // once it exists. Later changes flow through applySelection directly.\n useEffect(() => {\n rendererRef.current?.setView({\n selectedEventIds: new Set(getSelection()),\n });\n }, [getSelection, rendererRef]);\n\n const { offsetOf, totalHeight } = scene.getRowOffsets(\n windowTime[0],\n windowTime[1]\n );\n totalHeightRef.current = totalHeight;\n\n // Keep the canvas height locked to the content in the SAME commit the DOM\n // (header panel + scroll spacer) resizes in. The ResizeObserver above is\n // async, so on its own the canvas lags a frame behind a row re-stack — the\n // canvas/timeline momentarily taller than the header panel, leaving empty\n // space and a transient scrollbar. Re-measure synchronously, before paint.\n useLayoutEffect(() => {\n measureViewport();\n }, [totalHeight, measureViewport]);\n\n // last child row id per parent (in `rows` order) — drives the └─ vs ├─\n // connector shape so the tree spine stops at the final child.\n const lastChildOf = new Map<string, string>();\n for (const row of rows) {\n if (row.parentId !== undefined) lastChildOf.set(row.parentId, row.id);\n }\n // the rows header has a dark background, so the connector uses the (light)\n // grid/divider color rather than the dark group-shadow color\n const connectorColor = theme.gridColor;\n const SPINE_X = 11; // px from the left edge of the header\n\n // virtualized rows header: only headers intersecting the viewport. Rows\n // hidden inside a collapsed parent are skipped entirely (and aren't in\n // offsetOf, which now walks the visible rows). Parent rows get a collapse\n // caret; child rows show a tree connector linking them to their parent.\n const visibleHeaders: JSX.Element[] = [];\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n if (scene.isRowHidden(row.id)) continue;\n const top = offsetOf.get(row.id);\n if (top === undefined) continue;\n const height = scene.getRowHeight(row.id, windowTime[0], windowTime[1]);\n if (top + height < scrollTop) continue;\n if (top > scrollTop + viewportHeight) break;\n const isParent = scene.isRowParent(row.id);\n const parentId = row.parentId;\n const isChild = parentId !== undefined;\n const isLastChild =\n parentId !== undefined && lastChildOf.get(parentId) === row.id;\n const collapsed = scene.isRowCollapsed(row.id);\n const grouped = isParent || isChild;\n visibleHeaders.push(\n <div\n key={`row_header_${row.id}`}\n className=\"row-header canvas-row-header\"\n style={{\n top,\n height,\n borderBottom:\n i === rows.length - 1 ? \"none\" : \"1px solid yellow\",\n // Row heights/positions apply instantly (no layout tween) so the\n // header snaps in lockstep with its canvas row — see draw-events.\n // Grouped rows left-align so the caret + tree spine line up; plain\n // rows keep the centered default.\n justifyContent: grouped ? \"flex-start\" : undefined,\n paddingLeft: isChild ? 24 : isParent ? 6 : undefined,\n }}\n >\n {isChild && (\n // tree connector: a vertical spine + a horizontal tick at the row's\n // vertical center. The spine runs the full height for a mid child\n // (├─) and stops at the center for the last child (└─), so stacked\n // children form one continuous spine descending from the parent.\n <>\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: SPINE_X,\n top: 0,\n width: 1,\n height: isLastChild ? \"50%\" : \"100%\",\n backgroundColor: connectorColor,\n pointerEvents: \"none\",\n }}\n />\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: SPINE_X,\n top: \"50%\",\n width: 9,\n height: 1,\n backgroundColor: connectorColor,\n pointerEvents: \"none\",\n }}\n />\n </>\n )}\n {isParent && (\n <span\n className=\"row-header-caret\"\n role=\"button\"\n aria-label={collapsed ? \"Expand group\" : \"Collapse group\"}\n onClick={() => scene.toggleCollapsed(row.id)}\n style={{ cursor: \"pointer\", marginRight: 4, userSelect: \"none\" }}\n >\n {collapsed ? \"▸\" : \"▾\"}\n </span>\n )}\n <span\n className=\"row-header-label\"\n style={grouped ? { textAlign: \"left\" } : undefined}\n >\n {row.name}\n </span>\n </div>\n );\n }\n\n const headerClassNames = rowsHeaderClassName\n ? `rows-header-wrapper canvas-rows-header ${rowsHeaderClassName}`\n : \"rows-header-wrapper canvas-rows-header\";\n\n return (\n <>\n <div\n ref={headerWrapperRef}\n className={headerClassNames}\n style={{ height: totalHeight }}\n >\n {visibleHeaders}\n </div>\n <div className=\"canvas-content-column\" ref={contentRef}>\n <div className=\"canvas-sticky\">\n <canvas ref={staticCanvasRef}></canvas>\n <canvas\n ref={dynamicCanvasRef}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={handlePointerUp}\n onPointerLeave={handlePointerLeave}\n onPointerCancel={handlePointerCancel}\n onAuxClick={handleAuxClick}\n ></canvas>\n <div\n ref={ghostRef}\n className=\"event canvas-drag-ghost\"\n style={{ height: scene.getGeometry().barHeight }}\n ></div>\n </div>\n <div\n className=\"canvas-scroll-spacer\"\n style={{ height: totalHeight }}\n ></div>\n </div>\n </>\n );\n }\n);\n\nexport default CanvasBoard;\n","export type Layer = \"static\" | \"dynamic\";\n\nexport type LayerDirty = { static: boolean; dynamic: boolean };\n\n/**\n * Coalesces invalidations into a single requestAnimationFrame callback.\n * Any number of invalidate() calls within one frame produce exactly one\n * onFrame() with the union of dirty layers — the backbone of 60fps under\n * streaming updates.\n */\nexport class FrameScheduler {\n private rafId: number | null = null;\n private dirty: LayerDirty = { static: false, dynamic: false };\n\n constructor(private onFrame: (dirty: LayerDirty) => void) {}\n\n invalidate(layer: Layer | \"all\") {\n if (layer === \"all\" || layer === \"static\") this.dirty.static = true;\n if (layer === \"all\" || layer === \"dynamic\") this.dirty.dynamic = true;\n this.schedule();\n }\n\n /** Runs a pending frame immediately (tests, synchronous reads). */\n flush() {\n if (this.rafId !== null) {\n cancelAnimationFrame(this.rafId);\n this.rafId = null;\n this.run();\n }\n }\n\n dispose() {\n if (this.rafId !== null) {\n cancelAnimationFrame(this.rafId);\n this.rafId = null;\n }\n this.dirty = { static: false, dynamic: false };\n }\n\n private schedule() {\n if (this.rafId !== null) return;\n this.rafId = requestAnimationFrame(() => {\n this.rafId = null;\n this.run();\n });\n }\n\n private run() {\n const dirty = this.dirty;\n this.dirty = { static: false, dynamic: false };\n if (dirty.static || dirty.dynamic) this.onFrame(dirty);\n }\n}\n","import { EventType } from \"../types\";\n\n/**\n * Returns the window-visible slice of a startTime-sorted event array.\n * Binary search cuts the tail (startTime > windowEnd) in O(log n); the head\n * is filtered linearly on endTime, which cannot be binary-searched on a\n * startTime ordering.\n */\nexport const cullToWindow = (\n events: EventType[],\n windowStart: number,\n windowEnd: number\n): EventType[] => {\n // first index with startTime > windowEnd\n let lo = 0;\n let hi = events.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (events[mid].startTime <= windowEnd) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n\n const visible: EventType[] = [];\n for (let i = 0; i < lo; i++) {\n if (events[i].endTime >= windowStart) visible.push(events[i]);\n }\n return visible;\n};\n","import { EventType } from \"../types\";\n\n// All times are unix timestamps in seconds.\n// tick = seconds per pixel; all x/width values are CSS pixels.\n\nexport const timeToX = (time: number, windowStart: number, tick: number) =>\n (time - windowStart) / tick;\n\nexport const timeToWidth = (startTime: number, endTime: number, tick: number) =>\n (endTime - startTime) / tick;\n\nexport const xToTime = (x: number, windowStart: number, tick: number) =>\n windowStart + x * tick;\n\nexport const intersectsWindow = (\n event: EventType,\n windowStart: number,\n windowEnd: number\n) => event.endTime >= windowStart && event.startTime <= windowEnd;\n","import { ResolvedTheme } from \"../types\";\n\n/**\n * Resolved vertical layout for event bars and rows (px). Derived once from the\n * theme (see `geometryFromTheme`) and owned by the SceneStore, which both the\n * renderer (`draw-events`) and hit-testing read so positioning stays in sync.\n *\n * Only `barHeight`, `laneGap`, `rowPaddingY`, and `barRadius` are themeable;\n * the rest are derived from them.\n */\nexport type Geometry = {\n /** event bar height */\n barHeight: number;\n /** vertical stride between stacked lanes (barHeight + laneGap) */\n laneHeight: number;\n /** top padding before the first lane (== rowPaddingY) */\n laneTopOffset: number;\n /** minimum row height with no stacking (barHeight + 2*rowPaddingY) */\n rowBaseHeight: number;\n /** static-event height with no stacking (== barHeight) */\n staticEventBaseHeight: number;\n /** event bar corner radius */\n barRadius: number;\n};\n\n/** Defaults mirror the pre-0.2.x constants (20px bars, 22px lanes, 10px pad). */\nexport const DEFAULT_GEOMETRY: Geometry = {\n barHeight: 20,\n laneHeight: 22,\n laneTopOffset: 10,\n rowBaseHeight: 40,\n staticEventBaseHeight: 20,\n barRadius: 5,\n};\n\n/** Derive the full Geometry from the resolved theme's geometry tokens. */\nexport const geometryFromTheme = (theme: ResolvedTheme): Geometry => {\n const barHeight = theme.barHeight;\n const rowPaddingY = theme.rowPaddingY;\n return {\n barHeight,\n laneHeight: barHeight + theme.laneGap,\n laneTopOffset: rowPaddingY,\n rowBaseHeight: barHeight + 2 * rowPaddingY,\n staticEventBaseHeight: barHeight,\n barRadius: theme.barRadius,\n };\n};\n","import { EventType } from \"../types\";\nimport { intersectsWindow } from \"./coords\";\nimport { Geometry, DEFAULT_GEOMETRY } from \"./geometry\";\n\n// Vertical layout is a function of the (themeable) Geometry. The geometry\n// argument defaults to DEFAULT_GEOMETRY so callers using the legacy constants\n// — and the golden tests — keep their exact pre-0.2.x numbers.\n\nexport const laneTop = (lane: number, g: Geometry = DEFAULT_GEOMETRY) =>\n g.laneTopOffset + g.laneHeight * lane;\n\nexport const rowMinHeight = (highestLane: number, g: Geometry = DEFAULT_GEOMETRY) =>\n g.rowBaseHeight + highestLane * g.laneHeight;\n\nexport const staticEventHeight = (\n highestLane: number,\n g: Geometry = DEFAULT_GEOMETRY\n) => g.staticEventBaseHeight + highestLane * g.laneHeight;\n\nexport type LaneResult = {\n // eventId -> lane index, only for events intersecting the window\n laneOf: Map<string, number>;\n highestLane: number;\n};\n\n/**\n * Assigns a vertical lane (stacking order) to each window-visible event of a\n * single row. Faithful extraction of the algorithm previously inlined in\n * use-produce-content.tsx — including its quirks:\n *\n * - Events outside [windowStart, windowEnd] are skipped and do not influence\n * lane assignment at all.\n * - The occupancy scan for an event only covers lanes 0..eventOrder (the lane\n * of the previously placed event), not every tracked lane.\n * - Touching events (prev.endTime === next.startTime) do not overlap.\n *\n * `rowEvents` must already be filtered to one row and sorted with\n * helpers/sort-events (startTime asc, endTime asc).\n */\nexport const assignLanes = (\n rowEvents: EventType[],\n windowStart: number,\n windowEnd: number\n): LaneResult => {\n let eventOrder = 0;\n const prevEvent: EventType[] = [];\n let highestEventOrder = 0;\n const laneOf = new Map<string, number>();\n\n for (const event of rowEvents) {\n if (!intersectsWindow(event, windowStart, windowEnd)) continue;\n\n let tempEventOrder = 0;\n let assignEventOrder = true;\n for (let i = 0; i <= eventOrder; i++) {\n if (prevEvent[i] && prevEvent[i].endTime > event.startTime) {\n tempEventOrder += 1;\n } else {\n if (eventOrder > highestEventOrder) {\n highestEventOrder = eventOrder;\n }\n eventOrder = 0;\n assignEventOrder = false;\n break;\n }\n }\n\n if (assignEventOrder) {\n eventOrder = tempEventOrder;\n }\n\n prevEvent[tempEventOrder] = event;\n laneOf.set(event.id, tempEventOrder);\n }\n\n if (eventOrder > highestEventOrder) {\n highestEventOrder = eventOrder;\n }\n\n return { laneOf, highestLane: highestEventOrder };\n};\n","import { EventType } from \"../types\";\n\n/**\n * Pure commit math for canvas pointer interactions. Each function mirrors the\n * corresponding legacy DOM handler byte-for-byte so the canvas engine keeps\n * identical snap/guard semantics.\n */\n\n/**\n * Drop: snap the dropped start to the nearest grid cell boundary. Cells are\n * anchored to absolute time (multiples of the cell duration), matching the\n * vertical grid lines (`drawGridLines`) — so a dropped event lands on a line\n * regardless of how the window has been panned.\n */\nexport const computeDropTimes = ({\n pointerX,\n cellWidth,\n tick,\n windowStart,\n duration,\n}: {\n pointerX: number; // px from the content's left edge\n cellWidth: number;\n tick: number;\n windowStart: number;\n duration: number; // event duration in seconds\n}): { startTime: number; endTime: number } => {\n const cellTime = cellWidth * tick; // seconds per grid cell\n const pointerTime = windowStart + pointerX * tick;\n const startTime = Math.round(pointerTime / cellTime) * cellTime;\n return { startTime, endTime: startTime + duration };\n};\n\n/**\n * Resize: same rounding and duration-must-stay-positive guard as\n * event.tsx handleDocumentOnMouseUp. Returns null when the resize would\n * collapse or invert the event (legacy keeps the old value silently).\n */\nexport const computeResizeTimes = (\n event: Pick<EventType, \"startTime\" | \"endTime\">,\n deltaPx: number, // raw pointer delta (clientX - initial), sign preserved\n tick: number,\n direction: \"left\" | \"right\"\n): { startTime: number; endTime: number } | null => {\n if (direction === \"left\") {\n const startTime = Math.round(event.startTime + deltaPx * tick);\n if (event.endTime - startTime > 0) {\n return { startTime, endTime: event.endTime };\n }\n return null;\n }\n const endTime = Math.round(event.endTime + deltaPx * tick);\n if (endTime - event.startTime > 0) {\n return { startTime: event.startTime, endTime };\n }\n return null;\n};\n\n/** Eligibility: same expression as the legacy Event component's render guard.\n * A group-parent (summary) event is never resizable — its span is derived from\n * its children. */\nexport const canResizeEvent = (\n event: EventType,\n eventsResize: boolean\n): boolean =>\n !event.props?.isLocked &&\n !event.props?.isGroupParent &&\n ((eventsResize &&\n (event.props?.isResizable === true ||\n event.props?.isResizable === undefined)) ||\n (!eventsResize && event.props?.isResizable === true));\n\n/**\n * Whether an event may be dropped onto a row, given its `droppableRowIds`.\n * `undefined` = unrestricted (any row); otherwise the target must be listed.\n */\nexport const isRowDroppable = (\n droppableRowIds: string[] | undefined,\n targetRowId: string\n): boolean =>\n droppableRowIds === undefined || droppableRowIds.includes(targetRowId);\n\n/** Grid granularity step: same clamp as content.tsx handleOnWheel. */\nexport const stepCellWidth = (\n cellWidth: number,\n deltaY: number,\n tick: number\n): number => {\n const pixelsToCalculate = 900 / tick;\n const next =\n deltaY > 0 ? cellWidth + pixelsToCalculate : cellWidth - pixelsToCalculate;\n if (next < pixelsToCalculate || next > pixelsToCalculate * 12) {\n return cellWidth;\n }\n return next;\n};\n\nexport type ZoomLimits = { minWindowSeconds: number; maxWindowSeconds: number };\n\n/**\n * Time-frame zoom: returns a new visible window (+ derived tick and cellWidth)\n * for scaling the visible duration by `factor` (newDuration = oldDuration *\n * factor; <1 zooms in, >1 zooms out), anchored so the timestamp under\n * `anchorX` (px from the content's left edge) stays under that pixel.\n *\n * `tick` is recomputed from the new (integer-rounded) window; `cellWidth` is\n * then derived from the *actual* new tick so time-per-cell (`cellWidth * tick`)\n * — i.e. the grid cell duration the grid lines snap to — is preserved exactly.\n * Rescaling cellWidth by the unrounded factor instead would let rounding drift\n * the cell duration off the hour over many zooms, so the grid lines would creep\n * out of step with the time-bar blocks. The new duration is clamped to the\n * limits; the anchor still holds after clamping.\n */\nexport const computeZoom = (\n windowTime: [number, number],\n tick: number,\n cellWidth: number,\n anchorX: number,\n factor: number,\n contentWidth: number,\n { minWindowSeconds, maxWindowSeconds }: ZoomLimits\n): { windowTime: [number, number]; tick: number; cellWidth: number } => {\n const [start, end] = windowTime;\n const oldDuration = end - start;\n const newDuration = Math.min(\n Math.max(oldDuration * factor, minWindowSeconds),\n maxWindowSeconds\n );\n const cellTime = cellWidth * tick; // seconds per grid cell — kept invariant\n const tAnchor = start + anchorX * tick;\n const newStart = Math.round(tAnchor - (anchorX / contentWidth) * newDuration);\n const newEnd = newStart + Math.round(newDuration);\n const newTick = (newEnd - newStart) / contentWidth;\n return {\n windowTime: [newStart, newEnd],\n tick: newTick,\n cellWidth: cellTime / newTick,\n };\n};\n","import { SceneStore } from \"../core/scene\";\nimport { cullToWindow } from \"../core/culling\";\nimport { timeToWidth, timeToX } from \"../core/coords\";\nimport { laneTop, staticEventHeight } from \"../core/lanes\";\nimport { EventState, EventType } from \"../types\";\nimport type { Rect } from \"../core/types\";\nimport type { RendererView } from \"./renderer\";\nimport { canResizeEvent } from \"../core/interactions\";\nimport { LayoutAnimator } from \"./animator\";\n\nconst EVENT_TEXT_INSET = 13; // legacy .event-content margin-inline\n// legacy .event-resize / .resize-bar geometry\nconst HANDLE_INSET = 4;\nconst HANDLE_BAR_WIDTH = 3;\nconst HANDLE_BAR_GAP = 1;\nconst HANDLE_BAR_HEIGHT = 10;\n\nconst roundedRect = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n width: number,\n height: number,\n radius: number\n) => {\n const r = Math.min(radius, width / 2, height / 2);\n ctx.beginPath();\n if (typeof ctx.roundRect === \"function\") {\n ctx.roundRect(x, y, width, height, r);\n } else {\n ctx.moveTo(x + r, y);\n ctx.arcTo(x + width, y, x + width, y + height, r);\n ctx.arcTo(x + width, y + height, x, y + height, r);\n ctx.arcTo(x, y + height, x, y, r);\n ctx.arcTo(x, y, x + width, y, r);\n ctx.closePath();\n }\n};\n\n/**\n * Recessed-group depth cue. For each expanded group, the contiguous block of\n * its visible child rows is filled with a faint tint and given an inset shadow\n * along its top (and left) edge, so the child rows read as sitting *beneath*\n * their parent row. Drawn on the static layer beneath the grid lines/dividers.\n */\nexport const drawGroupShading = (\n ctx: CanvasRenderingContext2D,\n view: RendererView,\n scene: SceneStore\n) => {\n const [windowStart, windowEnd] = view.windowTime;\n const visible = scene.getVisibleRowIds();\n // collect the content-space y-range of each contiguous run of child rows\n const regions: Array<{ top: number; bottom: number }> = [];\n let y = 0;\n let runParent: string | null = null;\n let runTop = 0;\n let runBottom = 0;\n const flush = () => {\n if (runParent !== null) regions.push({ top: runTop, bottom: runBottom });\n runParent = null;\n };\n for (const rowId of visible) {\n const height = scene.getRowHeight(rowId, windowStart, windowEnd);\n const parentId = scene.getRow(rowId)?.parentId;\n if (parentId !== undefined) {\n if (runParent === parentId) {\n runBottom = y + height;\n } else {\n flush();\n runParent = parentId;\n runTop = y;\n runBottom = y + height;\n }\n } else {\n flush();\n }\n y += height;\n }\n flush();\n if (regions.length === 0) return;\n\n ctx.save();\n for (const { top, bottom } of regions) {\n const sTop = top - view.scrollTop;\n const sBottom = bottom - view.scrollTop;\n if (sBottom < 0 || sTop > view.height) continue;\n const regionHeight = sBottom - sTop;\n // 1. faint recess tint over the whole child block\n ctx.fillStyle = view.theme.groupChildBackground;\n ctx.fillRect(0, sTop, view.width, regionHeight);\n const depth = Math.min(12, regionHeight / 2);\n // 2. inset top shadow — the \"beneath the parent\" depth cue\n const topGrad = ctx.createLinearGradient(0, sTop, 0, sTop + depth);\n topGrad.addColorStop(0, view.theme.groupShadowColor);\n topGrad.addColorStop(1, \"rgba(0,0,0,0)\");\n ctx.fillStyle = topGrad;\n ctx.fillRect(0, sTop, view.width, depth);\n // 3. inset bottom shadow — closes the recessed shelf at its lower edge\n const botGrad = ctx.createLinearGradient(0, sBottom - depth, 0, sBottom);\n botGrad.addColorStop(0, \"rgba(0,0,0,0)\");\n botGrad.addColorStop(1, view.theme.groupShadowColor);\n ctx.fillStyle = botGrad;\n ctx.fillRect(0, sBottom - depth, view.width, depth);\n // 4. matching inset left shadow so the recess reads on the leading edge too\n const leftShadow = 10;\n const hGrad = ctx.createLinearGradient(0, 0, leftShadow, 0);\n hGrad.addColorStop(0, view.theme.groupShadowColor);\n hGrad.addColorStop(1, \"rgba(0,0,0,0)\");\n ctx.fillStyle = hGrad;\n ctx.fillRect(0, sTop, leftShadow, regionHeight);\n }\n ctx.restore();\n};\n\n/** Horizontal row dividers — replaces .row-content border-bottom. */\nexport const drawRowDividers = (\n ctx: CanvasRenderingContext2D,\n view: RendererView,\n scene: SceneStore\n) => {\n const [windowStart, windowEnd] = view.windowTime;\n const rowIds = scene.getVisibleRowIds();\n ctx.strokeStyle = view.theme.gridColor;\n ctx.lineWidth = 1;\n ctx.beginPath();\n let y = 0;\n for (let i = 0; i < rowIds.length; i++) {\n // Row heights apply instantly (no layout tween) so the canvas rows stay\n // locked to the DOM headers, which also snap. Only event tops animate.\n y += scene.getRowHeight(rowIds[i], windowStart, windowEnd);\n if (i === rowIds.length - 1) break; // :not(:last-child)\n const screenY = y - view.scrollTop;\n if (screenY < 0) continue;\n if (screenY > view.height) break;\n const crisp = Math.round(screenY) - 0.5;\n ctx.moveTo(0, crisp);\n ctx.lineTo(view.width, crisp);\n }\n ctx.stroke();\n};\n\n/** Legacy ResizeIcon: two small rounded bars at each end, shown on hover. */\nconst drawResizeHandles = (\n ctx: CanvasRenderingContext2D,\n rect: Rect,\n alpha: number,\n strokeColor: string\n) => {\n ctx.save();\n ctx.globalAlpha *= alpha;\n ctx.strokeStyle = strokeColor;\n ctx.lineWidth = 1;\n const barY = rect.y + (rect.height - HANDLE_BAR_HEIGHT) / 2;\n const xs = [\n rect.x + HANDLE_INSET,\n rect.x + HANDLE_INSET + HANDLE_BAR_WIDTH + HANDLE_BAR_GAP,\n rect.x + rect.width - HANDLE_INSET - HANDLE_BAR_WIDTH,\n rect.x +\n rect.width -\n HANDLE_INSET -\n HANDLE_BAR_WIDTH * 2 -\n HANDLE_BAR_GAP,\n ];\n for (const barX of xs) {\n ctx.beginPath();\n if (typeof ctx.roundRect === \"function\") {\n ctx.roundRect(\n barX + 0.5,\n barY + 0.5,\n HANDLE_BAR_WIDTH - 1,\n HANDLE_BAR_HEIGHT - 1,\n 1.5\n );\n } else {\n ctx.rect(barX + 0.5, barY + 0.5, HANDLE_BAR_WIDTH - 1, HANDLE_BAR_HEIGHT - 1);\n }\n ctx.stroke();\n }\n ctx.restore();\n};\n\nconst defaultDrawEvent = (\n ctx: CanvasRenderingContext2D,\n event: EventType,\n rect: Rect,\n view: RendererView,\n font: string,\n barRadius: number\n) => {\n const theme = view.theme;\n const style = event.props?.style;\n\n if (style?.opacity !== undefined) ctx.globalAlpha *= style.opacity;\n ctx.fillStyle = style?.fill ?? theme.eventFill;\n ctx.strokeStyle = style?.stroke ?? theme.eventStroke;\n ctx.lineWidth = style?.strokeWidth ?? 1;\n roundedRect(\n ctx,\n rect.x + 0.5,\n rect.y + 0.5,\n rect.width - 1,\n rect.height - 1,\n style?.borderRadius ?? barRadius\n );\n ctx.fill();\n ctx.stroke();\n\n const label = event.props?.label;\n if (label && rect.width > EVENT_TEXT_INSET * 2) {\n ctx.fillStyle = style?.textColor ?? theme.eventTextColor;\n ctx.font = style?.font ?? theme.font ?? font;\n ctx.save();\n ctx.beginPath();\n ctx.rect(\n rect.x + EVENT_TEXT_INSET,\n rect.y,\n rect.width - EVENT_TEXT_INSET * 2,\n rect.height\n );\n ctx.clip();\n ctx.fillText(label, rect.x + EVENT_TEXT_INSET, rect.y + rect.height / 2);\n ctx.restore();\n }\n};\n\n/**\n * All window- and viewport-visible events in one pass. Rows fully outside\n * the vertical viewport are skipped without touching their events. Custom\n * renderers resolve per-event drawEvent -> Timeline drawEvent -> default.\n */\nexport const drawEvents = (\n ctx: CanvasRenderingContext2D,\n view: RendererView,\n scene: SceneStore,\n font: string,\n animator: LayoutAnimator\n) => {\n if (view.tick === null) return;\n const [windowStart, windowEnd] = view.windowTime;\n const tick = view.tick;\n const geometry = scene.getGeometry();\n\n ctx.font = view.theme.font ?? font;\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n\n const selectedIds = view.selectedEventIds;\n const hasSelection = selectedIds.size > 0;\n // Selected events are drawn last (after every row) so they sit above their\n // neighbours, with a shadow + upward offset to read as \"lifted\". Non-selected\n // events draw dimmed in the main loop while a selection is active.\n const deferred: Array<() => void> = [];\n\n const paintEvent = (\n event: EventType,\n rect: Rect,\n state: EventState,\n opts: { dim: boolean; elevate: boolean }\n ) => {\n ctx.save();\n if (opts.elevate) {\n ctx.translate(0, -view.theme.selectionElevation);\n ctx.shadowColor = view.theme.selectionShadowColor;\n ctx.shadowBlur = view.theme.selectionShadowBlur;\n ctx.shadowOffsetY = view.theme.selectionElevation;\n }\n if (state.dragging) ctx.globalAlpha = 0.5; // legacy drag opacity\n else if (opts.dim) ctx.globalAlpha *= view.theme.dimmedOpacity;\n\n const custom = event.props?.drawEvent ?? view.drawEvent;\n const drawn =\n custom !== undefined &&\n custom(ctx, event, rect, state, view.theme) !== false;\n if (!drawn) {\n defaultDrawEvent(ctx, event, rect, view, font, geometry.barRadius);\n }\n\n if (canResizeEvent(event, view.eventsResize)) {\n const alpha = animator.handleAlpha(\n event.id,\n state.hovered || state.resizing ? 1 : 0\n );\n if (alpha > 0.01) {\n // the lift shadow shouldn't smear the thin handle bars\n ctx.shadowColor = \"transparent\";\n drawResizeHandles(\n ctx,\n rect,\n alpha,\n event.props?.style?.stroke ?? view.theme.eventStroke\n );\n }\n }\n ctx.restore();\n };\n\n let rowTop = 0;\n for (const rowId of scene.getVisibleRowIds()) {\n // Row heights are instant (see drawRowDividers); only event tops animate.\n const rowHeight = scene.getRowHeight(rowId, windowStart, windowEnd);\n const rowY = rowTop - view.scrollTop;\n rowTop += rowHeight;\n if (rowY + rowHeight < 0) continue;\n if (rowY > view.height) break;\n\n const lanes = scene.getLanes(rowId, windowStart, windowEnd);\n\n // static events sit below interactive ones (legacy z-index 0 vs 1)\n for (const event of cullToWindow(\n scene.getRowStaticEvents(rowId),\n windowStart,\n windowEnd\n )) {\n const x = timeToX(event.startTime, windowStart, tick);\n const width = timeToWidth(event.startTime, event.endTime, tick);\n ctx.fillStyle = view.theme.staticEventFill;\n roundedRect(\n ctx,\n x,\n rowY + geometry.laneTopOffset,\n width,\n staticEventHeight(lanes.highestLane, geometry),\n geometry.barRadius\n );\n ctx.fill();\n }\n\n for (const event of cullToWindow(\n scene.getRowEvents(rowId),\n windowStart,\n windowEnd\n )) {\n let x = timeToX(event.startTime, windowStart, tick);\n let width = timeToWidth(event.startTime, event.endTime, tick);\n // The lane offset tweens in ROW-LOCAL coordinates (legacy .event\n // transition on `top`), while the row's animated position applies\n // instantly. Tweening the absolute top instead would chase the\n // moving row with a perpetual lag, desyncing events from their\n // row dividers/headers under rapid updates.\n const y =\n rowY +\n animator.eventTop(\n event.id,\n laneTop(lanes.laneOf.get(event.id) as number, geometry)\n );\n\n const resize = view.resizePreview;\n const resizing = resize !== null && resize.eventId === event.id;\n if (resizing) {\n // live edge preview, same arithmetic as the legacy inline style\n if (resize.direction === \"left\") {\n x += resize.deltaPx;\n width -= resize.deltaPx;\n } else {\n width += resize.deltaPx;\n }\n }\n\n const rect: Rect = { x, y, width, height: geometry.barHeight };\n const selected = selectedIds.has(event.id);\n const state: EventState = {\n hovered: view.hoveredEventId === event.id,\n dragging: view.draggedEventId === event.id,\n resizing,\n selected,\n };\n\n if (selected) {\n deferred.push(() =>\n paintEvent(event, rect, state, { dim: false, elevate: true })\n );\n } else {\n paintEvent(event, rect, state, { dim: hasSelection, elevate: false });\n }\n }\n }\n\n for (const paint of deferred) paint();\n};\n","import { SceneStore } from \"../core/scene\";\nimport { DrawEventFn, ResolvedTheme } from \"../types\";\nimport { FrameScheduler, Layer, LayerDirty } from \"./frame-scheduler\";\nimport { sizeCanvas, watchDpr } from \"./dpr\";\nimport { drawGridLines } from \"./draw-grid\";\nimport {\n drawEvents,\n drawGroupShading,\n drawRowDividers,\n} from \"./draw-events\";\nimport { DEFAULT_THEME } from \"./theme\";\nimport { LayoutAnimator } from \"./animator\";\n\nexport type ResizePreview = {\n eventId: string;\n deltaPx: number; // raw pointer delta, sign preserved\n direction: \"left\" | \"right\";\n};\n\nexport type RendererView = {\n windowTime: [number, number];\n tick: number | null; // seconds per pixel; null until the container is measured\n cellWidth: number;\n scrollTop: number;\n width: number; // viewport CSS px\n height: number;\n theme: ResolvedTheme;\n drawEvent?: DrawEventFn;\n eventsResize: boolean;\n // interaction state\n hoveredEventId: string | null;\n draggedEventId: string | null;\n resizePreview: ResizePreview | null;\n selectedEventIds: ReadonlySet<string>;\n};\n\n/**\n * Owns the two viewport-sized canvases and the frame loop.\n *\n * - static layer: grid lines, day/hour bands, time bar (Phase 2)\n * - dynamic layer: events (Phase 3)\n *\n * React pushes view-state via setView(); the SceneStore pushes data changes\n * via its subscription. Both only flip dirty flags — actual drawing happens\n * once per animation frame.\n */\nexport class TimelineRenderer {\n private view: RendererView = {\n windowTime: [0, 0],\n tick: null,\n cellWidth: 0,\n scrollTop: 0,\n width: 0,\n height: 0,\n theme: DEFAULT_THEME,\n drawEvent: undefined,\n eventsResize: true,\n hoveredEventId: null,\n draggedEventId: null,\n resizePreview: null,\n selectedEventIds: new Set<string>(),\n };\n readonly animator = new LayoutAnimator();\n private scheduler: FrameScheduler;\n private unsubscribeScene: () => void;\n private unwatchDpr: () => void;\n private dpr = typeof window !== \"undefined\" ? window.devicePixelRatio : 1;\n private font = \"16px sans-serif\";\n\n constructor(\n private staticCanvas: HTMLCanvasElement,\n private dynamicCanvas: HTMLCanvasElement,\n private scene: SceneStore\n ) {\n this.scheduler = new FrameScheduler((dirty) => this.drawFrame(dirty));\n // data changes can move row heights, which both layers draw from\n this.unsubscribeScene = scene.subscribe(() => this.invalidate(\"all\"));\n this.unwatchDpr = watchDpr((dpr) => {\n this.dpr = dpr;\n this.resizeCanvases();\n this.invalidate(\"all\");\n this.scheduler.flush(); // repaint in-frame; see setView's resize branch\n });\n }\n\n getView(): RendererView {\n return this.view;\n }\n\n setView(partial: Partial<RendererView>) {\n const sizeChanged =\n (partial.width !== undefined && partial.width !== this.view.width) ||\n (partial.height !== undefined && partial.height !== this.view.height);\n this.view = { ...this.view, ...partial };\n if (sizeChanged) {\n // Setting canvas.width/height clears both backing stores. setView is\n // usually called from a ResizeObserver/effect that fires AFTER this\n // frame's rAF redraw, so a deferred (scheduled) redraw would leave the\n // canvas blank until the next frame — a one-frame flash of every event\n // (seen e.g. when a row re-stacks and the viewport height changes).\n // Repaint synchronously so the clear and the redraw land in the same\n // frame.\n this.resizeCanvases();\n this.invalidate(\"all\");\n this.scheduler.flush();\n return;\n }\n // scroll/pan/zoom move both layers; scrollTop alone still shifts the grid\n this.invalidate(\"all\");\n }\n\n invalidate(layer: Layer | \"all\") {\n this.scheduler.invalidate(layer);\n }\n\n /** Force a synchronous draw of anything pending (tests, screenshots). */\n flush() {\n this.scheduler.flush();\n }\n\n dispose() {\n this.scheduler.dispose();\n this.unsubscribeScene();\n this.unwatchDpr();\n }\n\n private resizeCanvases() {\n sizeCanvas(this.staticCanvas, this.view.width, this.view.height, this.dpr);\n sizeCanvas(this.dynamicCanvas, this.view.width, this.view.height, this.dpr);\n if (typeof getComputedStyle === \"function\") {\n this.font = getComputedStyle(this.dynamicCanvas).font || this.font;\n }\n }\n\n private drawFrame(dirty: LayerDirty) {\n if (this.view.tick === null) return;\n this.animator.beginFrame(performance.now());\n if (dirty.static) {\n const ctx = this.staticCanvas.getContext(\"2d\");\n if (ctx) {\n ctx.clearRect(0, 0, this.view.width, this.view.height);\n // recessed-group tint/shadow first, so grid lines + dividers stay crisp\n // on top of it\n drawGroupShading(ctx, this.view, this.scene);\n drawGridLines(ctx, {\n width: this.view.width,\n height: this.view.height,\n cellWidth: this.view.cellWidth,\n windowStart: this.view.windowTime[0],\n tick: this.view.tick,\n color: this.view.theme.gridColor,\n });\n drawRowDividers(ctx, this.view, this.scene);\n }\n }\n if (dirty.dynamic) {\n const ctx = this.dynamicCanvas.getContext(\"2d\");\n if (ctx) {\n ctx.clearRect(0, 0, this.view.width, this.view.height);\n drawEvents(ctx, this.view, this.scene, this.font, this.animator);\n }\n }\n // layout tweens in progress -> keep the frame loop running\n if (this.animator.isAnimating()) {\n this.scheduler.invalidate(\"all\");\n }\n }\n}\n","import React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport {\n EventPromptActionsType,\n EventType,\n OnDropProps,\n OnEventClickProps,\n OnEventHoverProps,\n OnResizeProps,\n PanZoomConfig,\n} from \"../types\";\nimport { SceneStore } from \"../core/scene\";\nimport { TimelineRenderer } from \"../canvas/renderer\";\nimport { hitTest, HitTarget } from \"../core/hit-test\";\nimport {\n canResizeEvent,\n computeDropTimes,\n computeResizeTimes,\n computeZoom,\n isRowDroppable,\n stepCellWidth,\n ZoomLimits,\n} from \"../core/interactions\";\n\nconst DRAG_THRESHOLD_PX = 3;\nconst RESIZE_HOT_ZONE_PX = 8; // matches the legacy .event-resize handle width\nconst DRAG_ZOOM_PX_PER_DOUBLING = 300; // drag this many px to halve/double the span\n\n/** Window/tick/cellWidth captured at the start of a continuous zoom gesture,\n * so pinch/drag scale relative to the start rather than compounding. */\ntype ZoomBase = {\n windowTime: [number, number];\n tick: number;\n cellWidth: number;\n};\n\ntype InteractionState =\n | { mode: \"idle\" }\n | {\n mode: \"pan\";\n lastClientX: number;\n lastClientY: number;\n startClientX: number;\n startClientY: number;\n touch: boolean;\n }\n | {\n mode: \"drag\";\n hit: HitTarget;\n startClientX: number;\n startClientY: number;\n active: boolean; // becomes true past DRAG_THRESHOLD_PX\n }\n | {\n mode: \"resize\";\n event: EventType;\n direction: \"left\" | \"right\";\n startClientX: number;\n deltaPx: number;\n }\n | {\n mode: \"zoom\"; // ctrl/cmd + background drag\n startClientX: number;\n anchorX: number;\n contentWidth: number;\n snapshot: ZoomBase;\n }\n | {\n mode: \"pinch\"; // two-finger touch\n startDist: number;\n anchorX: number;\n contentWidth: number;\n snapshot: ZoomBase;\n };\n\ntype UseCanvasInteractionsArgs = {\n scene: SceneStore;\n rendererRef: React.MutableRefObject<TimelineRenderer | null>;\n dynamicCanvasRef: React.MutableRefObject<HTMLCanvasElement | null>;\n bodyRef: React.MutableRefObject<HTMLDivElement | null>;\n ghostRef: React.MutableRefObject<HTMLDivElement | null>;\n eventPromptRef: React.MutableRefObject<EventPromptActionsType | null>;\n setWindowTime: React.Dispatch<React.SetStateAction<number[]>>;\n setCellWidth: React.Dispatch<React.SetStateAction<number>>;\n setTick: React.Dispatch<React.SetStateAction<number | null>>;\n onDrop?: (props: OnDropProps) => void;\n onResize?: (props: OnResizeProps) => void;\n onEventClick?: (props: OnEventClickProps) => void;\n onEventHover?: (props: OnEventHoverProps) => void;\n eventsResize: boolean;\n panZoom?: PanZoomConfig;\n selectable: boolean;\n /** replace the selection with exactly these ids (single write path) */\n applySelection: (eventIds: string[]) => void;\n getSelection: () => string[];\n};\n\nconst lockCursor = (cursor: string) => {\n const style = document.createElement(\"style\");\n style.id = \"lock-cursor\";\n style.innerHTML = `* { cursor: ${cursor} !important; }`;\n document.head.appendChild(style);\n};\n\nconst unlockCursor = () => {\n document.getElementById(\"lock-cursor\")?.remove();\n};\n\n/**\n * Pointer-event state machine for the canvas board: pan the time window,\n * drag events between rows/times (DOM ghost preview), resize event edges,\n * change grid granularity (middle-click mode or ctrl+wheel). Event mutations\n * are applied straight to the SceneStore — no React state on the hot path.\n */\nconst useCanvasInteractions = ({\n scene,\n rendererRef,\n dynamicCanvasRef,\n bodyRef,\n ghostRef,\n eventPromptRef,\n setWindowTime,\n setCellWidth,\n setTick,\n onDrop,\n onResize,\n onEventClick,\n onEventHover,\n eventsResize,\n panZoom,\n selectable,\n applySelection,\n getSelection,\n}: UseCanvasInteractionsArgs) => {\n const stateRef = useRef<InteractionState>({ mode: \"idle\" });\n const changeGridRef = useRef(false);\n const panFrameRef = useRef<number | null>(null);\n const panPendingDxRef = useRef(0);\n const hoveredRef = useRef<HitTarget | null>(null);\n // active pointers, for two-finger pinch detection\n const pointersRef = useRef(new Map<number, { x: number; y: number; touch: boolean }>());\n const zoomFrameRef = useRef<number | null>(null);\n const zoomPendingRef = useRef<{ anchorX: number; factor: number } | null>(null);\n\n const config = useMemo(\n () => ({\n panOnDragBackground: panZoom?.panOnDragBackground ?? true,\n ctrlWheelZoom: panZoom?.ctrlWheelZoom ?? true,\n pinchZoom: panZoom?.pinchZoom ?? true,\n dragZoom: panZoom?.dragZoom ?? true,\n zoomWheelFactor: panZoom?.zoomWheelFactor ?? 1.15,\n middleClickGranularity: panZoom?.middleClickGranularity ?? true,\n zoomStepSeconds: panZoom?.zoomStepSeconds ?? 900,\n }),\n [panZoom]\n );\n\n const limits: ZoomLimits = useMemo(\n () => ({\n minWindowSeconds: panZoom?.minWindowSeconds ?? 900,\n maxWindowSeconds: panZoom?.maxWindowSeconds ?? 30 * 24 * 3600,\n }),\n [panZoom]\n );\n\n // Apply a zoom by `factor` around `anchorX` (px from canvas left), scaling\n // from `base`. Pushes the result both to the renderer (immediate, so a\n // following wheel notch reads the new window) and to React state (time bar /\n // RT indicator / header virtualization).\n const applyZoom = useCallback(\n (base: ZoomBase, anchorX: number, factor: number, contentWidth: number) => {\n if (contentWidth <= 0) return;\n const next = computeZoom(\n base.windowTime,\n base.tick,\n base.cellWidth,\n anchorX,\n factor,\n contentWidth,\n limits\n );\n rendererRef.current?.setView({\n windowTime: next.windowTime,\n tick: next.tick,\n cellWidth: next.cellWidth,\n });\n setWindowTime(next.windowTime);\n setTick(next.tick);\n setCellWidth(next.cellWidth);\n },\n [rendererRef, setWindowTime, setTick, setCellWidth, limits]\n );\n\n // Continuous gestures (pinch/drag) coalesce to one apply per frame, scaling\n // from the gesture-start snapshot so they never compound.\n const scheduleContinuousZoom = useCallback(() => {\n if (zoomFrameRef.current !== null) return;\n zoomFrameRef.current = requestAnimationFrame(() => {\n zoomFrameRef.current = null;\n const pending = zoomPendingRef.current;\n const state = stateRef.current;\n if (!pending || (state.mode !== \"pinch\" && state.mode !== \"zoom\")) return;\n applyZoom(state.snapshot, pending.anchorX, pending.factor, state.contentWidth);\n });\n }, [applyZoom]);\n\n const snapshotView = useCallback((): { base: ZoomBase; contentWidth: number } | null => {\n const renderer = rendererRef.current;\n const canvas = dynamicCanvasRef.current;\n if (!renderer || !canvas) return null;\n const view = renderer.getView();\n if (view.tick === null) return null;\n return {\n base: {\n windowTime: [view.windowTime[0], view.windowTime[1]],\n tick: view.tick,\n cellWidth: view.cellWidth,\n },\n contentWidth: canvas.getBoundingClientRect().width,\n };\n }, [rendererRef, dynamicCanvasRef]);\n\n const hidePrompt = useCallback(() => {\n eventPromptRef.current?.hide();\n }, [eventPromptRef]);\n\n const currentHit = useCallback(\n (clientX: number, clientY: number): HitTarget | null => {\n const canvas = dynamicCanvasRef.current;\n const renderer = rendererRef.current;\n if (!canvas || !renderer) return null;\n const view = renderer.getView();\n if (view.tick === null) return null;\n const rect = canvas.getBoundingClientRect();\n return hitTest(\n scene,\n {\n windowStart: view.windowTime[0],\n windowEnd: view.windowTime[1],\n tick: view.tick,\n scrollTop: view.scrollTop,\n },\n clientX - rect.left,\n clientY - rect.top\n );\n },\n [scene, dynamicCanvasRef, rendererRef]\n );\n\n const resizeDirectionAt = useCallback(\n (hit: HitTarget, clientX: number): \"left\" | \"right\" | null => {\n if (hit.kind !== \"event\" || !canResizeEvent(hit.event, eventsResize)) {\n return null;\n }\n const canvas = dynamicCanvasRef.current;\n if (!canvas) return null;\n const x = clientX - canvas.getBoundingClientRect().left;\n const zone = Math.min(RESIZE_HOT_ZONE_PX, hit.rect.width / 3);\n if (x <= hit.rect.x + zone) return \"left\";\n if (x >= hit.rect.x + hit.rect.width - zone) return \"right\";\n return null;\n },\n [dynamicCanvasRef, eventsResize]\n );\n\n // pan applies at most once per frame regardless of pointermove rate\n const schedulePan = useCallback(() => {\n if (panFrameRef.current !== null) return;\n panFrameRef.current = requestAnimationFrame(() => {\n panFrameRef.current = null;\n const renderer = rendererRef.current;\n const dx = panPendingDxRef.current;\n panPendingDxRef.current = 0;\n const tick = renderer?.getView().tick;\n if (!tick || dx === 0) return;\n const dt = Math.round(dx * tick);\n if (dt === 0) {\n panPendingDxRef.current = dx; // accumulate sub-second moves\n return;\n }\n setWindowTime((prev) => [prev[0] - dt, prev[1] - dt]);\n });\n }, [rendererRef, setWindowTime]);\n\n const updateGhost = useCallback(\n (\n state: Extract<InteractionState, { mode: \"drag\" }>,\n clientX: number,\n clientY: number\n ) => {\n const ghost = ghostRef.current;\n if (!ghost) return;\n const rawLeft = state.hit.rect.x + (clientX - state.startClientX);\n const rawTop = state.hit.rect.y + (clientY - state.startClientY);\n // Clamp the preview pill to the visible viewport. It's absolutely\n // positioned inside the scrolling body, so letting it run past the edge\n // (dragging left/up or below/right of the visible range) would inflate\n // the scroll area and flash scrollbars. The drop still uses the real\n // pointer position, so only the preview stops at the edge.\n const view = rendererRef.current?.getView();\n const ghostWidth = state.hit.rect.width;\n const ghostHeight = state.hit.rect.height;\n const left = view\n ? Math.max(0, Math.min(rawLeft, Math.max(0, view.width - ghostWidth)))\n : rawLeft;\n const top = view\n ? Math.max(0, Math.min(rawTop, Math.max(0, view.height - ghostHeight)))\n : rawTop;\n ghost.style.display = \"flex\";\n ghost.style.left = `${left}px`;\n ghost.style.top = `${top}px`;\n ghost.style.width = `${ghostWidth}px`;\n },\n [ghostRef, rendererRef]\n );\n\n // The ghost is a DOM pill, so it can't run a custom canvas drawEvent — but it\n // should at least inherit the picked event's resolved style + label so a\n // themed event doesn't drag as the default white pill.\n const styleGhost = useCallback(\n (event: EventType) => {\n const ghost = ghostRef.current;\n const theme = rendererRef.current?.getView().theme;\n if (!ghost || !theme) return;\n const style = event.props?.style;\n ghost.style.backgroundColor = style?.fill ?? theme.eventFill;\n ghost.style.border = `${style?.strokeWidth ?? 1}px solid ${\n style?.stroke ?? theme.eventStroke\n }`;\n ghost.style.borderRadius = `${style?.borderRadius ?? theme.barRadius}px`;\n ghost.style.color = style?.textColor ?? theme.eventTextColor;\n ghost.style.font = style?.font ?? theme.font ?? \"\";\n ghost.style.justifyContent = \"flex-start\";\n ghost.style.alignItems = \"center\";\n ghost.style.paddingInline = \"13px\"; // matches the canvas EVENT_TEXT_INSET\n ghost.style.overflow = \"hidden\";\n ghost.style.whiteSpace = \"nowrap\";\n ghost.textContent = event.props?.label ?? \"\";\n },\n [ghostRef, rendererRef]\n );\n\n const handlePointerDown = useCallback(\n (pointerEvent: React.PointerEvent<HTMLCanvasElement>) => {\n const canvas = dynamicCanvasRef.current;\n if (!canvas) return;\n const isTouch = pointerEvent.pointerType === \"touch\";\n pointersRef.current.set(pointerEvent.pointerId, {\n x: pointerEvent.clientX,\n y: pointerEvent.clientY,\n touch: isTouch,\n });\n\n // second touch finger -> pinch zoom (cancels any single-finger gesture)\n if (config.pinchZoom && isTouch && pointersRef.current.size === 2) {\n const snap = snapshotView();\n if (snap) {\n if (ghostRef.current) ghostRef.current.style.display = \"none\";\n rendererRef.current?.setView({ draggedEventId: null });\n const pts = [...pointersRef.current.values()];\n const startDist =\n Math.hypot(pts[0].x - pts[1].x, pts[0].y - pts[1].y) || 1;\n const rect = canvas.getBoundingClientRect();\n stateRef.current = {\n mode: \"pinch\",\n startDist,\n anchorX: (pts[0].x + pts[1].x) / 2 - rect.left,\n contentWidth: snap.contentWidth,\n snapshot: snap.base,\n };\n canvas.setPointerCapture(pointerEvent.pointerId);\n hidePrompt();\n }\n return;\n }\n\n if (pointerEvent.button !== 0) return;\n const hit = currentHit(pointerEvent.clientX, pointerEvent.clientY);\n\n if (hit?.kind === \"event\" && !hit.event.props?.isLocked) {\n const direction = resizeDirectionAt(hit, pointerEvent.clientX);\n if (direction) {\n stateRef.current = {\n mode: \"resize\",\n event: hit.event,\n direction,\n startClientX: pointerEvent.clientX,\n deltaPx: 0,\n };\n lockCursor(\"e-resize\");\n } else {\n stateRef.current = {\n mode: \"drag\",\n hit,\n startClientX: pointerEvent.clientX,\n startClientY: pointerEvent.clientY,\n active: false,\n };\n styleGhost(hit.event);\n }\n } else if (\n config.dragZoom &&\n (pointerEvent.ctrlKey || pointerEvent.metaKey) &&\n !isTouch\n ) {\n // ctrl/cmd + background drag -> time-frame zoom (anchored at press)\n const snap = snapshotView();\n if (!snap) return;\n const rect = canvas.getBoundingClientRect();\n stateRef.current = {\n mode: \"zoom\",\n startClientX: pointerEvent.clientX,\n anchorX: pointerEvent.clientX - rect.left,\n contentWidth: snap.contentWidth,\n snapshot: snap.base,\n };\n } else if (config.panOnDragBackground) {\n stateRef.current = {\n mode: \"pan\",\n lastClientX: pointerEvent.clientX,\n lastClientY: pointerEvent.clientY,\n startClientX: pointerEvent.clientX,\n startClientY: pointerEvent.clientY,\n touch: isTouch,\n };\n canvas.style.cursor = \"grabbing\";\n } else if (selectable && !hit) {\n // background press with panning disabled: still allow click-to-clear\n stateRef.current = {\n mode: \"pan\",\n lastClientX: pointerEvent.clientX,\n lastClientY: pointerEvent.clientY,\n startClientX: pointerEvent.clientX,\n startClientY: pointerEvent.clientY,\n touch: isTouch,\n };\n } else {\n return;\n }\n hidePrompt();\n canvas.setPointerCapture(pointerEvent.pointerId);\n },\n [\n currentHit,\n resizeDirectionAt,\n dynamicCanvasRef,\n hidePrompt,\n config,\n snapshotView,\n ghostRef,\n rendererRef,\n styleGhost,\n selectable,\n ]\n );\n\n const handleHover = useCallback(\n (pointerEvent: React.PointerEvent<HTMLCanvasElement>) => {\n const canvas = dynamicCanvasRef.current;\n if (!canvas) return;\n const hit = currentHit(pointerEvent.clientX, pointerEvent.clientY);\n const prevHovered = hoveredRef.current;\n hoveredRef.current = hit;\n\n if (hit?.kind === \"event\") {\n if (hit.event.props?.isLocked) {\n canvas.style.cursor = \"not-allowed\";\n } else if (resizeDirectionAt(hit, pointerEvent.clientX)) {\n canvas.style.cursor = \"e-resize\";\n } else {\n canvas.style.cursor = \"pointer\";\n }\n } else {\n canvas.style.cursor = \"grab\";\n }\n\n const hoveredId = hit?.kind === \"event\" ? hit.event.id : null;\n const prevId = prevHovered?.kind === \"event\" ? prevHovered.event.id : null;\n if (hoveredId !== prevId) {\n rendererRef.current?.setView({ hoveredEventId: hoveredId });\n if (onEventHover) {\n onEventHover({\n eventId: hoveredId,\n rowId: hoveredId !== null && hit ? hit.rowId : null,\n });\n }\n }\n\n const prompt = eventPromptRef.current;\n if (!prompt) return;\n if (\n hit?.kind === \"event\" &&\n (hit.event.props?.showPrompt ||\n hit.event.props?.showPrompt === undefined)\n ) {\n if (prevId !== hit.event.id) {\n const canvasRect = canvas.getBoundingClientRect();\n // anchor in viewport coordinates; floating-ui handles flip/shift\n prompt.show(hit.event, {\n x: canvasRect.left + hit.rect.x,\n y: canvasRect.top + hit.rect.y,\n width: hit.rect.width,\n height: hit.rect.height,\n });\n }\n } else {\n prompt.hide();\n }\n },\n [\n currentHit,\n resizeDirectionAt,\n dynamicCanvasRef,\n eventPromptRef,\n rendererRef,\n onEventHover,\n ]\n );\n\n // resolve which visible row a viewport y falls on (same accumulated-height\n // walk the drawing/hit-test use). Shared by the drop commit and the live\n // drop-target cursor feedback.\n const resolveRowAtClientY = useCallback(\n (clientY: number): string | null => {\n const canvas = dynamicCanvasRef.current;\n const renderer = rendererRef.current;\n if (!canvas || !renderer) return null;\n const view = renderer.getView();\n if (view.tick === null) return null;\n const yContent =\n clientY - canvas.getBoundingClientRect().top + view.scrollTop;\n let rowTop = 0;\n for (const id of scene.getVisibleRowIds()) {\n const height = scene.getRowHeight(\n id,\n view.windowTime[0],\n view.windowTime[1]\n );\n if (yContent >= rowTop && yContent < rowTop + height) return id;\n rowTop += height;\n }\n return null;\n },\n [dynamicCanvasRef, rendererRef, scene]\n );\n\n const handlePointerMove = useCallback(\n (pointerEvent: React.PointerEvent<HTMLCanvasElement>) => {\n const tracked = pointersRef.current.get(pointerEvent.pointerId);\n if (tracked) {\n tracked.x = pointerEvent.clientX;\n tracked.y = pointerEvent.clientY;\n }\n\n const state = stateRef.current;\n if (state.mode === \"idle\") {\n handleHover(pointerEvent);\n return;\n }\n if (state.mode === \"pinch\") {\n const pts = [...pointersRef.current.values()];\n if (pts.length < 2) return;\n const dist =\n Math.hypot(pts[0].x - pts[1].x, pts[0].y - pts[1].y) || 1;\n zoomPendingRef.current = {\n anchorX: state.anchorX,\n factor: state.startDist / dist, // fingers apart -> factor<1 -> zoom in\n };\n scheduleContinuousZoom();\n return;\n }\n if (state.mode === \"zoom\") {\n const dx = pointerEvent.clientX - state.startClientX;\n zoomPendingRef.current = {\n anchorX: state.anchorX,\n factor: Math.pow(2, -dx / DRAG_ZOOM_PX_PER_DOUBLING), // right -> zoom in\n };\n scheduleContinuousZoom();\n return;\n }\n if (state.mode === \"pan\") {\n panPendingDxRef.current += pointerEvent.clientX - state.lastClientX;\n // touch has no wheel for vertical scroll, so single-finger drag also\n // scrolls rows (canvas touch-action is none, so we drive it manually)\n if (state.touch && bodyRef.current) {\n bodyRef.current.scrollTop -= pointerEvent.clientY - state.lastClientY;\n }\n state.lastClientX = pointerEvent.clientX;\n state.lastClientY = pointerEvent.clientY;\n schedulePan();\n return;\n }\n if (state.mode === \"drag\") {\n // group-parent (summary) bars are read-only: their span is derived from\n // their children, so a parent is never dragged. The press still enters\n // drag mode (so a click-without-move selects it on pointerup) but never\n // activates — no ghost, no move.\n if (state.hit.event.props?.isGroupParent) return;\n if (\n !state.active &&\n Math.abs(pointerEvent.clientX - state.startClientX) +\n Math.abs(pointerEvent.clientY - state.startClientY) >\n DRAG_THRESHOLD_PX\n ) {\n state.active = true;\n rendererRef.current?.setView({ draggedEventId: state.hit.event.id });\n }\n if (state.active) {\n updateGhost(state, pointerEvent.clientX, pointerEvent.clientY);\n // live drop-target feedback: show not-allowed while hovering a row\n // outside the event's droppableRowIds (only when restricted)\n const allowed = state.hit.event.props?.droppableRowIds;\n if (allowed) {\n const row = resolveRowAtClientY(pointerEvent.clientY);\n const ok = row !== null && isRowDroppable(allowed, row);\n const canvas = dynamicCanvasRef.current;\n if (canvas) canvas.style.cursor = ok ? \"grabbing\" : \"not-allowed\";\n }\n }\n return;\n }\n // resize\n state.deltaPx = pointerEvent.clientX - state.startClientX;\n rendererRef.current?.setView({\n resizePreview: {\n eventId: state.event.id,\n deltaPx: state.deltaPx,\n direction: state.direction,\n },\n });\n },\n [\n handleHover,\n schedulePan,\n updateGhost,\n rendererRef,\n scheduleContinuousZoom,\n bodyRef,\n resolveRowAtClientY,\n dynamicCanvasRef,\n ]\n );\n\n const commitDrop = useCallback(\n (\n state: Extract<InteractionState, { mode: \"drag\" }>,\n clientX: number,\n clientY: number\n ) => {\n const canvas = dynamicCanvasRef.current;\n const renderer = rendererRef.current;\n if (!canvas || !renderer) return;\n const view = renderer.getView();\n if (view.tick === null || view.cellWidth <= 0) return;\n const canvasRect = canvas.getBoundingClientRect();\n\n const targetRowId = resolveRowAtClientY(clientY);\n if (targetRowId === null) return; // dropped outside all rows -> cancel\n\n const liveEvent = scene.getEvent(state.hit.event.id);\n if (!liveEvent) return;\n\n // drop-target restriction: a drop onto a row not in droppableRowIds is\n // cancelled — the event snaps back (no patch, no onDrop). Time-shifts that\n // stay on an allowed row are unaffected.\n if (!isRowDroppable(liveEvent.props?.droppableRowIds, targetRowId)) {\n renderer.animator.snapEventTop(liveEvent.id);\n return;\n }\n\n const { startTime, endTime } = computeDropTimes({\n pointerX: clientX - canvasRect.left,\n cellWidth: view.cellWidth,\n tick: view.tick,\n windowStart: view.windowTime[0],\n duration: liveEvent.endTime - liveEvent.startTime,\n });\n\n if (onDrop) {\n onDrop({\n eventId: liveEvent.id,\n oldRowId: liveEvent.rowId,\n newRowId: targetRowId,\n startTime,\n endTime,\n });\n }\n // the ghost already previewed the destination — the dropped event must\n // land instantly; only the events re-stacking around it animate\n renderer.animator.snapEventTop(liveEvent.id);\n scene.applyPatches([\n {\n op: \"update\",\n id: liveEvent.id,\n changes: { startTime, endTime, rowId: targetRowId },\n },\n ]);\n },\n [scene, dynamicCanvasRef, rendererRef, onDrop, resolveRowAtClientY]\n );\n\n const commitResize = useCallback(\n (state: Extract<InteractionState, { mode: \"resize\" }>) => {\n const renderer = rendererRef.current;\n const tick = renderer?.getView().tick;\n renderer?.setView({ resizePreview: null });\n unlockCursor();\n if (!tick) return;\n const liveEvent = scene.getEvent(state.event.id);\n if (!liveEvent) return;\n const next = computeResizeTimes(\n liveEvent,\n state.deltaPx,\n tick,\n state.direction\n );\n if (next) {\n scene.applyPatches([\n { op: \"update\", id: liveEvent.id, changes: next },\n ]);\n }\n if (onResize) {\n // legacy reported the (possibly unchanged) committed values\n const committed = next ?? {\n startTime: liveEvent.startTime,\n endTime: liveEvent.endTime,\n };\n onResize({ eventId: liveEvent.id, ...committed });\n }\n },\n [scene, rendererRef, onResize]\n );\n\n const handlePointerUp = useCallback(\n (pointerEvent: React.PointerEvent<HTMLCanvasElement>) => {\n const canvas = dynamicCanvasRef.current;\n const state = stateRef.current;\n pointersRef.current.delete(pointerEvent.pointerId);\n stateRef.current = { mode: \"idle\" };\n if (canvas?.hasPointerCapture(pointerEvent.pointerId)) {\n canvas.releasePointerCapture(pointerEvent.pointerId);\n }\n if (canvas) canvas.style.cursor = \"grab\";\n\n if (state.mode === \"drag\" && state.active) {\n if (ghostRef.current) ghostRef.current.style.display = \"none\";\n rendererRef.current?.setView({ draggedEventId: null });\n commitDrop(state, pointerEvent.clientX, pointerEvent.clientY);\n } else if (state.mode === \"drag\" && !state.active) {\n // press + release without movement = click\n if (onEventClick) {\n onEventClick({\n eventId: state.hit.event.id,\n rowId: state.hit.rowId,\n nativeEvent: pointerEvent.nativeEvent,\n modifiers: {\n shift: pointerEvent.shiftKey,\n ctrl: pointerEvent.ctrlKey,\n meta: pointerEvent.metaKey,\n alt: pointerEvent.altKey,\n },\n });\n }\n // selection is additive to onEventClick: plain click selects just the\n // event, Cmd/Ctrl+click selects its whole connected group. A\n // non-selectable event is transparent to selection — clicking it leaves\n // the current selection untouched (applySelection filters group members\n // too, so opted-out events never enter a group selection either).\n if (selectable) {\n const id = state.hit.event.id;\n if (scene.isEventSelectable(id)) {\n applySelection(\n pointerEvent.ctrlKey || pointerEvent.metaKey\n ? scene.getConnectedEventIds(id)\n : [id]\n );\n }\n }\n } else if (state.mode === \"pan\") {\n // a background press+release without movement clears the selection\n const moved =\n Math.abs(pointerEvent.clientX - state.startClientX) +\n Math.abs(pointerEvent.clientY - state.startClientY) >\n DRAG_THRESHOLD_PX;\n if (selectable && !moved && getSelection().length > 0) {\n applySelection([]);\n }\n } else if (state.mode === \"resize\") {\n commitResize(state);\n }\n },\n [\n dynamicCanvasRef,\n ghostRef,\n rendererRef,\n commitDrop,\n commitResize,\n onEventClick,\n selectable,\n applySelection,\n getSelection,\n scene,\n ]\n );\n\n const handlePointerCancel = useCallback(\n (pointerEvent: React.PointerEvent<HTMLCanvasElement>) => {\n pointersRef.current.delete(pointerEvent.pointerId);\n stateRef.current = { mode: \"idle\" };\n const canvas = dynamicCanvasRef.current;\n if (canvas?.hasPointerCapture(pointerEvent.pointerId)) {\n canvas.releasePointerCapture(pointerEvent.pointerId);\n }\n if (ghostRef.current) ghostRef.current.style.display = \"none\";\n rendererRef.current?.setView({ draggedEventId: null });\n },\n [dynamicCanvasRef, ghostRef, rendererRef]\n );\n\n const handlePointerLeave = useCallback(() => {\n if (stateRef.current.mode !== \"idle\") return; // captured pointer still active\n if (hoveredRef.current?.kind === \"event\") {\n rendererRef.current?.setView({ hoveredEventId: null });\n if (onEventHover) onEventHover({ eventId: null, rowId: null });\n }\n hoveredRef.current = null;\n if (dynamicCanvasRef.current) {\n dynamicCanvasRef.current.style.cursor = \"\";\n }\n hidePrompt();\n }, [dynamicCanvasRef, rendererRef, hidePrompt, onEventHover]);\n\n // middle-click toggles grid-granularity mode (legacy \"awesome feature\")\n const handleAuxClick = useCallback(\n (pointerEvent: React.MouseEvent<HTMLCanvasElement>) => {\n pointerEvent.preventDefault();\n if (pointerEvent.button === 1 && config.middleClickGranularity) {\n changeGridRef.current = !changeGridRef.current;\n if (bodyRef.current) {\n bodyRef.current.style.overflowY = changeGridRef.current\n ? \"hidden\"\n : \"auto\";\n }\n }\n },\n [bodyRef, config]\n );\n\n // wheel must be non-passive to preventDefault (browser zoom / scroll)\n useEffect(() => {\n const canvas = dynamicCanvasRef.current;\n if (!canvas) return;\n const handleWheel = (wheelEvent: WheelEvent) => {\n const view = rendererRef.current?.getView();\n if (!view || view.tick === null) return;\n const tick = view.tick;\n\n // middle-click granularity mode: wheel adjusts the grid cell width\n if (changeGridRef.current) {\n wheelEvent.preventDefault();\n setCellWidth((cellWidth) =>\n stepCellWidth(\n cellWidth,\n wheelEvent.deltaY,\n (tick * 900) / config.zoomStepSeconds\n )\n );\n return;\n }\n\n // ctrl/cmd + wheel (and Mac trackpad pinch) zooms the time frame\n if ((wheelEvent.ctrlKey || wheelEvent.metaKey) && config.ctrlWheelZoom) {\n wheelEvent.preventDefault();\n const rect = canvas.getBoundingClientRect();\n const factor =\n wheelEvent.deltaY > 0\n ? config.zoomWheelFactor\n : 1 / config.zoomWheelFactor;\n applyZoom(\n {\n windowTime: [view.windowTime[0], view.windowTime[1]],\n tick,\n cellWidth: view.cellWidth,\n },\n wheelEvent.clientX - rect.left,\n factor,\n rect.width\n );\n return;\n }\n // otherwise: let the body scroll the rows natively\n };\n canvas.addEventListener(\"wheel\", handleWheel, { passive: false });\n return () => canvas.removeEventListener(\"wheel\", handleWheel);\n }, [dynamicCanvasRef, rendererRef, setCellWidth, applyZoom, config]);\n\n useEffect(() => unlockCursor, []); // safety on unmount\n\n // Escape clears the selection while one is active.\n useEffect(() => {\n if (!selectable) return;\n const handleKeyDown = (keyEvent: KeyboardEvent) => {\n if (keyEvent.key === \"Escape\" && getSelection().length > 0) {\n applySelection([]);\n }\n };\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => window.removeEventListener(\"keydown\", handleKeyDown);\n }, [selectable, getSelection, applySelection]);\n\n return {\n handlePointerDown,\n handlePointerMove,\n handlePointerUp,\n handlePointerLeave,\n handlePointerCancel,\n handleAuxClick,\n };\n};\n\nexport default useCanvasInteractions;\n","export type Rect = {\n x: number;\n y: number;\n width: number;\n height: number;\n};\n\nexport const rectContains = (rect: Rect, x: number, y: number) =>\n x >= rect.x &&\n x <= rect.x + rect.width &&\n y >= rect.y &&\n y <= rect.y + rect.height;\n","import { EventType } from \"../types\";\nimport { SceneStore } from \"./scene\";\nimport { Rect, rectContains } from \"./types\";\nimport { cullToWindow } from \"./culling\";\nimport { timeToWidth, timeToX } from \"./coords\";\nimport { laneTop, staticEventHeight } from \"./lanes\";\n\nexport type HitTarget = {\n kind: \"event\" | \"static\";\n event: EventType;\n rowId: string;\n /** rect in viewport (canvas CSS px) coordinates, scroll already applied */\n rect: Rect;\n};\n\nexport type HitTestView = {\n windowStart: number;\n windowEnd: number;\n tick: number;\n scrollTop: number;\n};\n\n/**\n * Point query against the scene at viewport coordinates (x, y).\n * Finds the row by accumulated heights, then scans that row's window-visible\n * events back-to-front (interactive events sit above static ones, later\n * events draw above earlier ones). Per-row event counts are small, so the\n * scan after the row/window cut is cheap — no spatial index needed.\n */\nexport const hitTest = (\n scene: SceneStore,\n view: HitTestView,\n x: number,\n y: number\n): HitTarget | null => {\n const { windowStart, windowEnd, tick, scrollTop } = view;\n const geometry = scene.getGeometry();\n const yContent = y + scrollTop;\n\n let rowTop = 0;\n let rowId: string | null = null;\n for (const id of scene.getVisibleRowIds()) {\n const height = scene.getRowHeight(id, windowStart, windowEnd);\n if (yContent >= rowTop && yContent < rowTop + height) {\n rowId = id;\n break;\n }\n rowTop += height;\n }\n if (rowId === null) return null;\n\n const lanes = scene.getLanes(rowId, windowStart, windowEnd);\n const rowY = rowTop - scrollTop;\n\n const events = cullToWindow(\n scene.getRowEvents(rowId),\n windowStart,\n windowEnd\n );\n for (let i = events.length - 1; i >= 0; i--) {\n const event = events[i];\n const rect: Rect = {\n x: timeToX(event.startTime, windowStart, tick),\n y: rowY + laneTop(lanes.laneOf.get(event.id) as number, geometry),\n width: timeToWidth(event.startTime, event.endTime, tick),\n height: geometry.barHeight,\n };\n if (rectContains(rect, x, y)) {\n return { kind: \"event\", event, rowId, rect };\n }\n }\n\n const statics = cullToWindow(\n scene.getRowStaticEvents(rowId),\n windowStart,\n windowEnd\n );\n for (let i = statics.length - 1; i >= 0; i--) {\n const event = statics[i];\n const rect: Rect = {\n x: timeToX(event.startTime, windowStart, tick),\n y: rowY + geometry.laneTopOffset,\n width: timeToWidth(event.startTime, event.endTime, tick),\n height: staticEventHeight(lanes.highestLane, geometry),\n };\n if (rectContains(rect, x, y)) {\n return { kind: \"static\", event, rowId, rect };\n }\n }\n\n return null;\n};\n","import { EventPatch, EventType, RowType } from \"../types\";\nimport sortEvents from \"../helpers/sort-events\";\nimport { assignLanes, LaneResult, rowMinHeight } from \"./lanes\";\nimport { Geometry, DEFAULT_GEOMETRY } from \"./geometry\";\n\nexport type { EventPatch };\n\ntype RowIndex = {\n row: RowType;\n // both arrays kept sorted with helpers/sort-events\n events: EventType[];\n staticEvents: EventType[];\n lanesDirty: boolean;\n lanes: LaneResult | null;\n // window the cached lanes were computed for (lanes depend on visibility)\n laneWindowStart: number;\n laneWindowEnd: number;\n};\n\nconst binaryInsertIndex = (events: EventType[], event: EventType) => {\n let lo = 0;\n let hi = events.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (sortEvents(events[mid], event) < 0) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n return lo;\n};\n\n/**\n * Imperative event store for the canvas renderer. Lives outside React state:\n * streaming patches mutate it directly and the renderer reads from it per\n * frame — React never reconciles individual event motion.\n *\n * Lane assignment (and therefore row height) is computed lazily per row, only\n * when that row is queried for the current window. Bursts of patches against\n * off-screen rows cost nothing beyond an index update.\n */\nexport class SceneStore {\n private rowIndexes = new Map<string, RowIndex>();\n private rowOrder: string[] = [];\n private eventRow = new Map<string, string>();\n // Group index for tag-based \"connected\" selection. eventGroup: eventId ->\n // groupId; groupMembers: groupId -> set of eventIds. Maintained alongside\n // eventRow so Cmd/Ctrl+click resolves the whole group in O(group size)\n // without scanning all rows.\n private eventGroup = new Map<string, string>();\n private groupMembers = new Map<string, Set<string>>();\n // Row hierarchy for grouped (collapsible) rows. parentOf: childRowId ->\n // parentRowId; childRowsOf: parentRowId -> ordered child row ids. Rebuilt in\n // setRows from `row.parentId`. One level of nesting only in v1.\n private parentOf = new Map<string, string>();\n private childRowsOf = new Map<string, string[]>();\n // Rows the user has collapsed. Lives only here so it survives every data\n // update (setEvents / applyPatches / events-prop reset); setRows only prunes\n // entries for rows that no longer exist.\n private collapsedRows = new Set<string>();\n // Parent↔child EVENT index (distinct from the row hierarchy above).\n // childrenOf: parentEventId -> child event ids; parentEventOf: childEventId ->\n // parentEventId. Driven by props.parentEventId / props.isGroupParent. A parent\n // event's [startTime,endTime] is derived lazily from its children; any child\n // mutation marks the parent dirty and the span is recomputed on the next query\n // of the parent's row (flushParentSpans) — off-screen groups cost nothing.\n private childrenOf = new Map<string, Set<string>>();\n private parentEventOf = new Map<string, string>();\n private parentSpanDirty = new Set<string>();\n private listeners = new Set<() => void>();\n // Themeable vertical layout. Lanes are geometry-free (pure time logic), so a\n // geometry change only affects heights/offsets — the cached lanes stay valid\n // and we just bump to trigger a redraw.\n private geometry: Geometry = DEFAULT_GEOMETRY;\n // Per-row minimum height demanded by the (DOM-measured) row label when it\n // wraps to multiple lines. Measured in the shell and fed back here so the\n // canvas grid/dividers, hit-testing and the DOM header all agree on height.\n private labelMinHeights = new Map<string, number>();\n version = 0;\n\n setGeometry(geometry: Geometry) {\n this.geometry = geometry;\n this.bump();\n }\n\n getGeometry(): Geometry {\n return this.geometry;\n }\n\n setRows(rows: RowType[]) {\n const next = new Map<string, RowIndex>();\n for (const row of rows) {\n const existing = this.rowIndexes.get(row.id);\n next.set(\n row.id,\n existing\n ? { ...existing, row }\n : {\n row,\n events: [],\n staticEvents: [],\n lanesDirty: true,\n lanes: null,\n laneWindowStart: NaN,\n laneWindowEnd: NaN,\n }\n );\n }\n // events of removed rows drop with their index\n for (const [id, rowId] of this.eventRow) {\n if (!next.has(rowId)) {\n this.eventRow.delete(id);\n this.removeFromGroup(id);\n }\n }\n this.rowIndexes = next;\n this.rowOrder = rows.map((row) => row.id);\n // rebuild the row hierarchy\n this.parentOf = new Map();\n this.childRowsOf = new Map();\n for (const row of rows) {\n if (row.parentId === undefined) continue;\n this.parentOf.set(row.id, row.parentId);\n let children = this.childRowsOf.get(row.parentId);\n if (!children) {\n children = [];\n this.childRowsOf.set(row.parentId, children);\n }\n children.push(row.id);\n }\n // drop collapse entries for rows that no longer exist; keep the rest so an\n // open/collapsed group survives a `rows` change\n if (this.collapsedRows.size > 0) {\n const rowIds = new Set(this.rowOrder);\n for (const id of [...this.collapsedRows]) {\n if (!rowIds.has(id)) this.collapsedRows.delete(id);\n }\n }\n this.bump();\n }\n\n setEvents(events: EventType[]) {\n for (const index of this.rowIndexes.values()) {\n index.events = [];\n index.lanesDirty = true;\n }\n this.eventRow.clear();\n this.eventGroup.clear();\n this.groupMembers.clear();\n this.childrenOf.clear();\n this.parentEventOf.clear();\n this.parentSpanDirty.clear();\n for (const event of events) {\n const index = this.rowIndexes.get(event.rowId);\n if (!index) continue;\n index.events.push(event);\n this.eventRow.set(event.id, event.rowId);\n this.addToGroup(event.id, event.props?.groupId);\n this.addToParentIndex(event);\n this.validateDroppable(event);\n }\n for (const index of this.rowIndexes.values()) {\n index.events.sort(sortEvents);\n }\n this.bump();\n }\n\n setStaticEvents(events: EventType[]) {\n for (const index of this.rowIndexes.values()) {\n index.staticEvents = [];\n }\n for (const event of events) {\n const index = this.rowIndexes.get(event.rowId);\n if (!index) continue;\n index.staticEvents.push(event);\n }\n for (const index of this.rowIndexes.values()) {\n index.staticEvents.sort(sortEvents);\n }\n this.bump();\n }\n\n applyPatches(patches: EventPatch[]) {\n for (const patch of patches) {\n if (patch.op === \"upsert\") {\n this.remove(patch.event.id);\n this.insert(patch.event);\n } else if (patch.op === \"update\") {\n const existing = this.getEvent(patch.id);\n if (!existing) continue;\n this.remove(patch.id);\n this.insert({ ...existing, ...patch.changes, id: patch.id });\n } else {\n this.remove(patch.id);\n }\n }\n this.bump();\n }\n\n getEvent(id: string): EventType | undefined {\n const rowId = this.eventRow.get(id);\n if (rowId === undefined) return undefined;\n return this.rowIndexes\n .get(rowId)\n ?.events.find((event) => event.id === id);\n }\n\n /**\n * Event ids \"connected\" to the given event via a shared `props.groupId`.\n * Returns every member of the group (including the event itself), or just\n * `[eventId]` when the event has no group / no other members / is unknown.\n */\n getConnectedEventIds(eventId: string): string[] {\n const groupId = this.eventGroup.get(eventId);\n if (groupId === undefined) return [eventId];\n const members = this.groupMembers.get(groupId);\n if (!members || members.size === 0) return [eventId];\n return [...members];\n }\n\n /**\n * Whether an event may enter the selection. False only when the event is\n * present and explicitly opted out (`props.isSelectable === false`); unknown\n * ids are treated as selectable so a selection can be set before data loads\n * and survives streaming.\n */\n isEventSelectable(id: string): boolean {\n const event = this.getEvent(id);\n return event === undefined || event.props?.isSelectable !== false;\n }\n\n getRowIds(): string[] {\n return this.rowOrder;\n }\n\n /**\n * Row ids in display order, minus rows hidden inside a collapsed parent.\n * Drives offsets, drawing and hit-testing. The header still walks\n * `getRowIds()` so it can draw the carets and decide which rows to skip.\n */\n getVisibleRowIds(): string[] {\n if (this.collapsedRows.size === 0) return this.rowOrder;\n const visible: string[] = [];\n for (const rowId of this.rowOrder) {\n const parent = this.parentOf.get(rowId);\n if (parent !== undefined && this.collapsedRows.has(parent)) continue;\n visible.push(rowId);\n }\n return visible;\n }\n\n /** whether a row is a parent (owns at least one child row) */\n isRowParent(rowId: string): boolean {\n return (this.childRowsOf.get(rowId)?.length ?? 0) > 0;\n }\n\n /** whether a row is hidden because its parent row is collapsed */\n isRowHidden(rowId: string): boolean {\n const parent = this.parentOf.get(rowId);\n return parent !== undefined && this.collapsedRows.has(parent);\n }\n\n isRowCollapsed(rowId: string): boolean {\n return this.collapsedRows.has(rowId);\n }\n\n getCollapsedRowIds(): string[] {\n return [...this.collapsedRows];\n }\n\n setCollapsed(rowId: string, collapsed: boolean) {\n const has = this.collapsedRows.has(rowId);\n if (collapsed && !has) {\n this.collapsedRows.add(rowId);\n this.bump();\n } else if (!collapsed && has) {\n this.collapsedRows.delete(rowId);\n this.bump();\n }\n }\n\n toggleCollapsed(rowId: string) {\n this.setCollapsed(rowId, !this.collapsedRows.has(rowId));\n }\n\n /** child event ids of a parent (summary) event; empty if it has none */\n getChildEventIds(parentEventId: string): string[] {\n const children = this.childrenOf.get(parentEventId);\n return children ? [...children] : [];\n }\n\n getRow(rowId: string): RowType | undefined {\n return this.rowIndexes.get(rowId)?.row;\n }\n\n getRowEvents(rowId: string): EventType[] {\n this.flushParentSpans(rowId);\n return this.rowIndexes.get(rowId)?.events ?? [];\n }\n\n getRowStaticEvents(rowId: string): EventType[] {\n return this.rowIndexes.get(rowId)?.staticEvents ?? [];\n }\n\n getLanes(rowId: string, windowStart: number, windowEnd: number): LaneResult {\n this.flushParentSpans(rowId);\n const index = this.rowIndexes.get(rowId);\n if (!index) return { laneOf: new Map(), highestLane: 0 };\n if (\n index.lanesDirty ||\n index.lanes === null ||\n index.laneWindowStart !== windowStart ||\n index.laneWindowEnd !== windowEnd\n ) {\n index.lanes = assignLanes(index.events, windowStart, windowEnd);\n index.laneWindowStart = windowStart;\n index.laneWindowEnd = windowEnd;\n index.lanesDirty = false;\n }\n return index.lanes;\n }\n\n /**\n * Report the per-row label heights measured against the live DOM header\n * (key: rowId, value: the minimum row height the wrapped label needs,\n * already including vertical padding). Replaces the previous map wholesale\n * and only bumps when a value actually changed, so re-measuring identical\n * labels is a no-op and can't feed back into an infinite render loop.\n */\n setLabelMinHeights(heights: Map<string, number>) {\n let changed = heights.size !== this.labelMinHeights.size;\n if (!changed) {\n for (const [id, h] of heights) {\n if (this.labelMinHeights.get(id) !== h) {\n changed = true;\n break;\n }\n }\n }\n if (!changed) return;\n this.labelMinHeights = heights;\n this.bump();\n }\n\n getRowHeight(rowId: string, windowStart: number, windowEnd: number): number {\n const laneHeight = rowMinHeight(\n this.getLanes(rowId, windowStart, windowEnd).highestLane,\n this.geometry\n );\n const labelHeight = this.labelMinHeights.get(rowId) ?? 0;\n return Math.max(laneHeight, labelHeight);\n }\n\n /**\n * y offset of each row's top edge (content coordinates, before scroll) plus\n * the total content height — drives both drawing and the scroll spacer.\n */\n getRowOffsets(\n windowStart: number,\n windowEnd: number\n ): { offsetOf: Map<string, number>; totalHeight: number } {\n const offsetOf = new Map<string, number>();\n let y = 0;\n for (const rowId of this.getVisibleRowIds()) {\n offsetOf.set(rowId, y);\n y += this.getRowHeight(rowId, windowStart, windowEnd);\n }\n return { offsetOf, totalHeight: y };\n }\n\n subscribe(listener: () => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n private insert(event: EventType) {\n const index = this.rowIndexes.get(event.rowId);\n if (!index) return;\n index.events.splice(binaryInsertIndex(index.events, event), 0, event);\n index.lanesDirty = true;\n this.eventRow.set(event.id, event.rowId);\n this.addToGroup(event.id, event.props?.groupId);\n this.addToParentIndex(event);\n this.validateDroppable(event);\n }\n\n private remove(id: string) {\n const rowId = this.eventRow.get(id);\n if (rowId === undefined) return;\n const index = this.rowIndexes.get(rowId);\n if (index) {\n const at = index.events.findIndex((event) => event.id === id);\n if (at !== -1) index.events.splice(at, 1);\n index.lanesDirty = true;\n }\n this.eventRow.delete(id);\n this.removeFromGroup(id);\n this.removeFromParentIndex(id);\n }\n\n private addToGroup(eventId: string, groupId: string | undefined) {\n if (groupId === undefined) return;\n this.eventGroup.set(eventId, groupId);\n let members = this.groupMembers.get(groupId);\n if (!members) {\n members = new Set();\n this.groupMembers.set(groupId, members);\n }\n members.add(eventId);\n }\n\n private removeFromGroup(eventId: string) {\n const groupId = this.eventGroup.get(eventId);\n if (groupId === undefined) return;\n this.eventGroup.delete(eventId);\n const members = this.groupMembers.get(groupId);\n if (members) {\n members.delete(eventId);\n if (members.size === 0) this.groupMembers.delete(groupId);\n }\n }\n\n /**\n * Enforce the authoring contract for `props.droppableRowIds`: if the event's\n * current row is not among its allowed rows, record a `droppableError` on\n * `props.metadata` (merged non-destructively); otherwise clear any stale one.\n * Cheap no-op for events without `droppableRowIds` and no prior error.\n */\n private validateDroppable(event: EventType) {\n const allowed = event.props?.droppableRowIds;\n const meta = event.props?.metadata;\n const metaObj =\n typeof meta === \"object\" && meta !== null\n ? (meta as Record<string, unknown>)\n : undefined;\n const hadError = metaObj !== undefined && \"droppableError\" in metaObj;\n const needsError = allowed !== undefined && !allowed.includes(event.rowId);\n\n if (!needsError && !hadError) return; // common path: nothing to do\n if (!event.props) return; // droppableRowIds/metadata imply props exists\n\n if (needsError) {\n event.props.metadata = {\n ...(metaObj ?? {}),\n droppableError: {\n rowId: event.rowId,\n droppableRowIds: allowed,\n },\n };\n } else {\n // clear the stale error, preserving any other app-provided metadata\n const rest = { ...(metaObj as Record<string, unknown>) };\n delete rest.droppableError;\n event.props.metadata = Object.keys(rest).length > 0 ? rest : undefined;\n }\n }\n\n private addToParentIndex(event: EventType) {\n const parentId = event.props?.parentEventId;\n if (parentId === undefined) return;\n this.parentEventOf.set(event.id, parentId);\n let children = this.childrenOf.get(parentId);\n if (!children) {\n children = new Set();\n this.childrenOf.set(parentId, children);\n }\n children.add(event.id);\n // the parent's derived span now needs recomputing\n this.parentSpanDirty.add(parentId);\n }\n\n private removeFromParentIndex(eventId: string) {\n const parentId = this.parentEventOf.get(eventId);\n if (parentId === undefined) return;\n this.parentEventOf.delete(eventId);\n const children = this.childrenOf.get(parentId);\n if (children) {\n children.delete(eventId);\n if (children.size === 0) this.childrenOf.delete(parentId);\n }\n this.parentSpanDirty.add(parentId);\n }\n\n /**\n * Recompute the derived span of any dirty parent event living on `rowId`\n * (earliest child start → latest child end), write it back into the parent\n * event, and re-sort the row so the sorted-array invariant holds. Cheap no-op\n * when nothing is dirty (the common no-groups case never touches this).\n */\n private flushParentSpans(rowId: string) {\n if (this.parentSpanDirty.size === 0) return;\n const index = this.rowIndexes.get(rowId);\n if (!index) return;\n let changed = false;\n for (const event of index.events) {\n if (!event.props?.isGroupParent) continue;\n if (!this.parentSpanDirty.has(event.id)) continue;\n this.parentSpanDirty.delete(event.id);\n const children = this.childrenOf.get(event.id);\n if (!children || children.size === 0) continue; // childless: keep supplied times\n let minStart = Infinity;\n let maxEnd = -Infinity;\n for (const childId of children) {\n const child = this.getEvent(childId);\n if (!child) continue;\n if (child.startTime < minStart) minStart = child.startTime;\n if (child.endTime > maxEnd) maxEnd = child.endTime;\n }\n if (\n minStart !== Infinity &&\n (event.startTime !== minStart || event.endTime !== maxEnd)\n ) {\n event.startTime = minStart;\n event.endTime = maxEnd;\n changed = true;\n }\n }\n if (changed) {\n index.events.sort(sortEvents);\n index.lanesDirty = true;\n }\n }\n\n private bump() {\n this.version++;\n for (const listener of this.listeners) listener();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;A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A,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,qBAAqB,6DAAsB;AAAA,QAC3C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA;AAAA,QACA,KAAK;AAAA;AAAA,IACP,GACC,mBAAmB,WACtB,CACF;AAAA,EAEJ;AACF;","names":["import_react","import_react","React","import_react","React","import_react","_a","React","import_react","_a","import_react","React","offset","React"]}
|