{"version":3,"file":"useTimelineMarkers.mjs","names":[],"sources":["../../../src/hooks/markers/useTimelineMarkers.ts"],"sourcesContent":["import type {\n  TimelineCommandResult,\n  Marker,\n  TimelineReadonly,\n} from '@techsquidtv/canvas-timeline-core';\nimport type { RationalTime } from '@techsquidtv/canvas-timeline-utils';\nimport { useTimelineEngine } from '#react/hooks/core/useTimelineEngine';\nimport { useTimelineSelector } from '#react/hooks/core/useTimelineSelector';\nimport {\n  createTimelineMarkersCommands,\n  sortTimelineMarkers,\n} from '#react/hooks/markers/createTimelineMarkersCommands';\nimport { useMemo } from 'react';\n/** Editable marker fields accepted by `useTimelineMarkers().updateMarker`. */\nexport type TimelineMarkerUpdate = Partial<\n  Pick<Marker, 'time' | 'label' | 'color' | 'description'>\n>;\n\n/** Result returned by `useTimelineMarkers`. */\nexport interface UseTimelineMarkersResult {\n  /** Current timeline markers sorted by time. */\n  markers: readonly TimelineReadonly<Marker>[];\n  /** Adds a marker at a timeline time. */\n  addMarker: (\n    time: RationalTime,\n    label?: string,\n    color?: string,\n    description?: string\n  ) => TimelineCommandResult<TimelineReadonly<Marker>>;\n  /** Adds a marker at the current playhead. */\n  addMarkerAtPlayhead: (\n    label?: string,\n    color?: string,\n    description?: string\n  ) => TimelineCommandResult<TimelineReadonly<Marker>>;\n  /** Removes a marker by id. */\n  removeMarker: (id: string) => TimelineCommandResult;\n  /** Updates marker metadata by id. */\n  updateMarker: (\n    id: string,\n    updates: TimelineMarkerUpdate\n  ) => TimelineCommandResult<TimelineReadonly<Marker>>;\n  /** Moves the playhead to a marker by id. */\n  seekToMarker: (id: string) => TimelineCommandResult<TimelineReadonly<Marker>>;\n  /** Moves the playhead to the next marker after the current playhead. */\n  seekToNextMarker: () => TimelineCommandResult<TimelineReadonly<Marker>>;\n  /** Moves the playhead to the previous marker before the current playhead. */\n  seekToPreviousMarker: () => TimelineCommandResult<TimelineReadonly<Marker>>;\n}\n\n/**\n * Accesses and manages bookmark/annotation pins (markers).\n *\n * This canonical marker hook does not subscribe to live playhead ticks. Compose\n * it with `useActiveMarkers` when UI needs marker proximity at the current\n * playhead.\n *\n * @returns Sorted marker state and commands for adding, removing, updating, and seeking markers.\n */\nexport function useTimelineMarkers(): UseTimelineMarkersResult {\n  const engine = useTimelineEngine();\n  const state = useTimelineSelector((state) => state.markers, Object.is);\n  const markers = useMemo(() => sortTimelineMarkers(state), [state]);\n  const commands = useMemo(() => createTimelineMarkersCommands(engine), [engine]);\n  return useMemo(() => ({ markers, ...commands }), [markers, commands]);\n}\n"],"mappings":";;;;;;;;;;;;;;AA2DA,SAAgB,qBAA+C;CAC7D,MAAM,SAAS,kBAAkB;CACjC,MAAM,QAAQ,qBAAqB,UAAU,MAAM,SAAS,OAAO,EAAE;CACrE,MAAM,UAAU,cAAc,oBAAoB,KAAK,GAAG,CAAC,KAAK,CAAC;CACjE,MAAM,WAAW,cAAc,8BAA8B,MAAM,GAAG,CAAC,MAAM,CAAC;CAC9E,OAAO,eAAe;EAAE;EAAS,GAAG;CAAS,IAAI,CAAC,SAAS,QAAQ,CAAC;AACtE"}