strata-react 2.1.19 → 2.1.20

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 CHANGED
@@ -248,6 +248,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
248
248
  | Marking text | `MarkableText`, `Mark`, `MarkSummary`; `rangeBetween` | Select words by drag, Shift+click and Shift+arrows (ids in document order, so it holds across virtualised rows), apply the app's marks from a bar or single-key chords, marks drawn by role, pattern and text, summarised and announced |
249
249
  | Maps | `strata-react/map`: `RouteMap`; `geo`, `LatLng` (main entry) | Routes and a position that moves along them, on Leaflet (no react-leaflet), behind its own entry. Tiles are the app's (`tiles.light`, `tiles.dark`, each with its attribution); the dark scheme uses the dark set or a filter over the light one. Route colours are roles resolved at draw time; `values` with `colourScale` colour a route by value in runs of one step, with a key that names the steps; a single route gets direction chevrons and start/finish marks (a loop is one mark). The position is one marker moved with `setLatLng`: no route is redrawn for it (keep `routes` stable). As picture content (a route inset over footage): `zoom` sets any zoom (animate it per frame), `follow="centre"` holds the view exactly on a position with no animation (a frame is deterministic), and `positions` draws several, each tied to a route, in its colour and named in the text alternative; routes are not redrawn for any of it. Leaflet's keyboard pan and zoom stay; the map is named by `label` and described by a generated text alternative (routes, lengths, position along). Overlay slots `topEnd` and `bottomStart` avoid Leaflet's own controls and attribution. Leaflet's stylesheet is injected once, so an app imports nothing. `geo` (distance, bearing, bounds, `pointAlong`, `arrows`, `ends`) and `format.distance` need no map library |
250
250
  | Timeline | `Timeline`, `useTimelineZoom`, `TimelineZoomControls`, `noOverlap` | Items with a start and a length in lanes on a zoomable time axis, for media edits, bookings, rotas and plans. The timeline draws and the app decides: every move, trim, lane change, selection and current-time change is reported (`onItemChange`, `onSelect`, `onPositionChange`) and the app applies it; `validate` refuses a change with a reason shown in words while it is made. One tab stop for the items; arrows move between them, Ctrl+arrows nudge and change lane, Alt+arrows trim, the current time is its own slider, `+` `-` `0` zoom, and each change is announced ("run-02.mp4 moved to 0:13"). The ruler picks steps people write on a scale so labels never collide. Lanes take drops from outside (`dropTypes`, `onDrop` with the lane and snapped time, `validateDrop`, and React Aria's keyboard drag landing at the current time), `laneRows` makes them taller, `kindColours` fixes each kind's stripe, and the header column fits its content. Only items near the view are rendered |
251
+ | Speakers | `SpeakerTimeline`; `splitTurn`, `assignTurns`, `mergeWithNext`, `setEdge`, `renameVoice`, `removeTurns`, `copyTurns`, `turnsAt`, `voicesOf`, `newVoiceName`, `freshId`, `UNCLEAR` | Who spoke when, corrected by a person: `Timeline` with a lane per voice (moving a turn to a lane gives it to that voice), a lane for what nobody could make out, and other answers (models' diarizations, named blind if wanted) read-only beneath. Keys: `s` split at the playhead, the digits give the chosen turns to a voice, `n` a new voice, `u` unclear, `m` join with the voice's next turn, `[` `]` an edge to the playhead, `c` copy another answer's turns in, Delete; a voice is renamed from its lane (a name in use joins the two). Each edit is a pure function returning the new turns and its name ("Split Mum at 0:12"), reported through `onChange` for the app's `useHistory`; playing is the app's `MediaPlayer` through `position` |
251
252
  | Answering by tap | `ChoiceGrid`, `ChoiceGridSkeleton`, `ChoiceState`; the `type-picture` step | One question, large picture tiles, one right answer, for someone who may not read yet (a child's learning game). Each tile is `open`, `wrong` (greyed, never red), `right` or `answer` (shown after the tries ran out), always with its word; a choice with no answer key ("Which one next?", a rating) uses `picked` (primary border, neutral word, `marks={{ picked }}`), which closes the grid so a slow request cannot be tapped twice; the app owns the answer key. Answered tiles cannot be pressed again and the grid closes once the answer shows. React Aria's `GridList`: arrows across and down, Enter answers. Tiles at least 120px (`md`) or 160px (`lg`); `stretch` shares the row out so a few tiles fill a wide screen; `beckon` pulses the open tiles one at a time in a random order until the grid closes. For a learner who cannot read a tile's word: `renderCaption` (a fitted line under the picture, "12 December"), `onHover` (say a tile when a mouse or pen comes over it) and `reading` (the tile being read aloud, lit; `useReadAloud` reads the tiles once in turn after the prompt, and stops for good at the learner's first tap) |
252
253
  | Answering by placing | `PlaceBoard`, `PlaceState` | An answer that is an arrangement (give a number, put in order, match pairs, sort), for someone who may not read yet. Two taps: pick a piece up (`aria-pressed`, "Picked up", a blue info ring), put it in a place ("Put apple in the basket"; every place that takes it gets the same ring); tap it again to put it down, or tap its gap in the pile ("Put … back"). Or drag it there by pointer (from the press, no long press). With one place a tap moves at once, in or out (a big X on hover). `limit` caps a place: a piece put in a full one sends the one there back ("in place of 4"). The pile keeps a slot per piece and each place room for all it can hold (a lone place takes the row), so nothing moves during a round (the held word sits over its piece's foot; the Check keeps its room once locked). Same presses by touch, mouse, keyboard and screen reader; places are disabled until a piece is held, so Tab walks the pieces, then the places; focus follows a moved piece. The app owns `placement`, applies `onMove` and checks (`check` draws its big Check, `Button size="lg"` with a tick either side; `check.untilPlaced` greys it out until the pile is empty, for a round with a set number of answers); `placeState` marks a place `right` or `wrong` (neutral, never red) with its word, `locked` ends the round. Pieces 96px or more in the pile, 72px once placed; `beckon` pulses the pile's pieces one at a time while none is held; `stretch` shares the pile's and places' rows out; a picture never outgrows its tile. `renderCaption`, `onHover`, `onHoverPlace` and `reading` as on `ChoiceGrid` |
253
254
  | Telling the time | `Clock`, `ClockFace`, `DigitalClock`, `SetClock`, `clockWords`, `digitalTime` | One time on a clock people know. `Clock` picks the face: analogue (`teaching`, the default classroom clock with its hands told apart by length, width and colour; `railway`, the Swiss station clock with its red disc; `classic`, Roman numerals and Breguet hands; `bauhaus`; `aviator`; `modern`; `minimal`) or digital (`segments`, `flip`, `plain`; 12- or 24-hour, am and pm). Each analogue part can be set on its own (`numerals`, `numbers`, `marks`, `hands`, `minuteNumbers`), so a step can take one away. The hour hand moves between the numbers as the minutes pass. Each is an `img` named with the time in words or as written; pass `label` when the time is the answer. `SetClock` is the control: press or drag anywhere and the nearer hand goes there, snapping to `step` minutes; the hands are geared as a real clock's are; each hand is a slider for the arrow keys and Page Up and Down. |
package/dist/index.d.ts CHANGED
@@ -2454,6 +2454,81 @@ export declare function tickStep(pxPerUnit: number, minGapPx?: number): number;
2454
2454
  export declare function ticksBetween(from: number, to: number, step: number): number[];
2455
2455
  /** A tick's label: m:ss, h:mm:ss, with tenths or hundredths when the step is under a second. */
2456
2456
  export declare function tickLabel(time: number, step: number): string;
2457
+ /** One turn: `speaker` is a voice's name (a model's S1, or a person's "Mum"); `UNCLEAR` marks what nobody could make out. */
2458
+ type SpeakerTurn = {
2459
+ id: string;
2460
+ start: number;
2461
+ end: number;
2462
+ speaker: string;
2463
+ };
2464
+ /** The speaker of a stretch nobody could make out: kept, not scored (strata-python `speakers.UNCLEAR`). */
2465
+ export declare const UNCLEAR = "?";
2466
+ /** An edit's result: the new turns and the step's name. `null` when there was nothing to do (no turn under the time). */
2467
+ type TurnEdit = {
2468
+ turns: SpeakerTurn[];
2469
+ step: string;
2470
+ } | null;
2471
+ /** An id not yet in `turns`: `base`, else `base-2`, `base-3`… */
2472
+ export declare function freshId(turns: readonly SpeakerTurn[], base: string): string;
2473
+ /** The voices in order of first speech (the unclear stretches last), as a person reads down the lanes. */
2474
+ export declare function voicesOf(turns: readonly SpeakerTurn[]): string[];
2475
+ /** A name for a new voice that is not taken: "Voice 3" when two are named. */
2476
+ export declare function newVoiceName(turns: readonly SpeakerTurn[], word?: string): string;
2477
+ /** The turns that cover `time` (a turn holds its start, not its end), latest start first. */
2478
+ export declare function turnsAt(turns: readonly SpeakerTurn[], time: number): SpeakerTurn[];
2479
+ /** Cut the turn in two at `time`; the second half gets a fresh id. Nothing to do when `time` is not inside it. */
2480
+ export declare function splitTurn(turns: readonly SpeakerTurn[], id: string, time: number, format: (t: number) => string): TurnEdit;
2481
+ /** Give the turns to `speaker` (an existing voice, a new one, or `UNCLEAR`). */
2482
+ export declare function assignTurns(turns: readonly SpeakerTurn[], ids: readonly string[], speaker: string): TurnEdit;
2483
+ /** Join the turn with the next turn of the same voice: one turn from the first's start to the later end. */
2484
+ export declare function mergeWithNext(turns: readonly SpeakerTurn[], id: string): TurnEdit;
2485
+ /** Move the turn's start or end to `time`; refused (null) where it would leave the turn with no length. */
2486
+ export declare function setEdge(turns: readonly SpeakerTurn[], id: string, edge: "start" | "end", time: number, format: (t: number) => string): TurnEdit;
2487
+ /** Rename a voice in every turn; joining two voices is renaming one to the other's name. */
2488
+ export declare function renameVoice(turns: readonly SpeakerTurn[], from: string, to: string): TurnEdit;
2489
+ /** Take the turns out. */
2490
+ export declare function removeTurns(turns: readonly SpeakerTurn[], ids: readonly string[]): TurnEdit;
2491
+ /** Add copies of other turns (another answer's) under `speaker`, or under their own speaker's name when none is given. */
2492
+ export declare function copyTurns(turns: readonly SpeakerTurn[], from: readonly SpeakerTurn[], speaker?: string): TurnEdit;
2493
+ type SpeakerReference = {
2494
+ /** Stable id (a model's key). */
2495
+ id: string;
2496
+ /** The lane's name: the model's, or a blind letter. */
2497
+ label: string;
2498
+ turns: readonly SpeakerTurn[];
2499
+ };
2500
+ type SpeakerTimelineProps = {
2501
+ /** Names the timeline: "Who speaks, 10:50 to 20:50". */
2502
+ label: string;
2503
+ /** The person's turns. */
2504
+ turns: readonly SpeakerTurn[];
2505
+ /** An edit: the new turns and its name. Apply it (and push it to `useHistory`). */
2506
+ onChange: (edit: NonNullable<TurnEdit>) => void;
2507
+ /** Other answers, drawn read-only under the person's lanes. */
2508
+ references?: readonly SpeakerReference[];
2509
+ /** The axis, in seconds of the media. */
2510
+ from?: number;
2511
+ to: number;
2512
+ /** Pixels per second. */
2513
+ zoom: number;
2514
+ onZoomChange?: (zoom: number) => void;
2515
+ /** The playhead: the media's current time. Splits and edges are made here. */
2516
+ position: number;
2517
+ onPositionChange: (time: number) => void;
2518
+ /** Scroll to keep the playhead in view while it plays. */
2519
+ follow?: boolean;
2520
+ /** The turns chosen, controlled (an app that plays the chosen turn). Uncontrolled otherwise. */
2521
+ selectedIds?: ReadonlySet<string>;
2522
+ onSelect?: (ids: string[]) => void;
2523
+ /** The lane of what nobody could make out. Default "Unclear". */
2524
+ unclearLabel?: string;
2525
+ /** Show the legend of the keys. Default true. */
2526
+ legend?: boolean;
2527
+ formatTime?: (t: number) => string;
2528
+ className?: string;
2529
+ };
2530
+ /** Correct who spoke when: the person's turns as a lane per voice, other answers read-only beneath, and keys to split at the playhead, give turns to a voice, join, mark unclear and copy. Reports each edit with its name; the app holds the turns. */
2531
+ export declare function SpeakerTimeline({ label, turns, onChange, references, from, to, zoom, onZoomChange, position, onPositionChange, follow, selectedIds, onSelect, unclearLabel, legend, formatTime, className }: SpeakerTimelineProps): React.JSX.Element;
2457
2532
  /** Where a drop landed, relative to the item with `key`. */
2458
2533
  type DropTarget = {
2459
2534
  key: string;
@@ -6333,5 +6408,5 @@ type PartialDateFieldProps = {
6333
6408
  };
6334
6409
  /** Input for an uncertain or partial ISO date (`YYYY`, `YYYY-MM`, `YYYY-MM-DD`) with an optional approximate toggle. Wrap in `Field`. */
6335
6410
  export declare function PartialDateField({ value, onChange, placeholder, allowCirca, circaLabel, disabled, className }: PartialDateFieldProps): React.JSX.Element;
6336
- export { type ActiveItem, type AlertDialogProps, type AlertProps, type Api, type ApiOptions, type ApiPage, type AspectRatio, type AsyncAction, type AsyncActionOptions, AsyncButton, type AsyncLabels, type AudioMedia, type AutoRecorder, type AutoRecorderState, type AutoSave, type AutoSaveOptions, type AutoTake, type BalanceProps, type BalanceSide, type BinaryByteUnit, type BookPage, type BookUrl, type BookViewerProps, type BoxListProps, type BoxOverlayProps, type BoxSource, type BoxTone, type BoxedPictureProps, type BoxesState, type Brush, type BrushControl, type BrushKind, Button, type ButtonLinkProps, type ButtonProps, type ByteHighlight, type ByteRange, type ByteUnit, type ByteViewProps, type BytesOptions, COLOR_SCHEME_STORAGE_KEY, type Candidate, type CellValue, type ChartMark, type ChartSpan, type CheckboxGesture, type CheckboxProps, type Choice, type ChoiceCounts, type ChoiceGridProps, type ChoiceGroupProps, type ChoiceMarks, type ChoiceSize, type ChoiceState, type Choices, type ClientWork, type Clips, type ClipsContext, type ClipsProviderProps, type ClockFaceProps, type ClockFaceStyle, type ClockHands, type ClockMarks, type ClockNumbers, type ClockNumerals, type ClockParts, type ClockProps, type ClockStyle, type ClockTime, type ClockWordsOptions, type ColorFieldProps, type ColorScheme, ColorSchemeChoice, type ColorSchemeLabels, type ColorSchemePreference, type ColorSchemeState, type Column, type Command, type CommandMenuProps, type CommandsOptions, type CompareAudioProps, type CompareGridProps, type CompareMode, type CompareProps, type CompareTextProps, type CompareVideoGridProps, type CompareVideoProps, type ComposerProps, type CompositionBarProps, type CompositionPart, type ConcealedProps, type ConsoleLevel, type ConsoleLine, type ConsoleProps, type ContextMenuProps, type ControlSize, type ConversationImage, type ConversationProps, type ConversationTurn, type CountOptions, type CountdownOptions, type CurrencyOptions, type CursorMapping, type CursorOwner, CursorScope, type CursorScopeProps, type CutChange, type CutLimit, type CutRoom, DEFAULT_PALETTE, type DataTableProps, type DateFormatter, type DateInput, type DecodedAudio, type Delivery, Density, type DensityName, type DensityProps, type DescribeError, type DialogProps, type Difference, type DifferenceState, type DigitalClockProps, type DigitalClockStyle, type DigitalTimeOptions, type DisclosureOpenProps, type DisclosureProps, type DragData, type DragSourceProps, type DrawTool, type Drawing, type Box as DrawingBox, type DrawingLayerProps, type DrawingOp, type DrawingOptions, type DrawingState, type DrawingToolbarProps, type DropTarget, type Easing, type EditClip, type EditListOptions, type EditListPlayerProps, type EditListSlot, type EditListState, type EditTimes, type EditableRegion, type EntityMatch, type EntityMatcher, type ErrorBody, type EventLogEntry, type EventLogImage, type EventLogProps, type Expanded, type ExpandedOptions, type Facing, type FailedRemoval, type FetchJsonInit, type FetchJsonOptions, type FieldErrors, type FieldProps, type FileIntake, type FileIntakeOptions, type FileOutcome, type FillLevelProps, type FilmFrame, type FilmStripProps, type Folder, type FolderListing, type FolderPickerProps, type Format, type FormatOptions, type FractionCut, type FractionOutline, type FractionShapeProps, type FullscreenFrameProps, type GlimpseLook, type GlimpseProps, type GlimpseWhy, type Grid, type GroupMember, type GroupedChart, type Handle, type History, type HistoryOptions, type HistoryStateOptions, type HistoryStep, type HotkeysOptions, IconButton, type IconButtonProps, type IconComponent, type ImageMedia, type Implies, type InViewOptions, type InfiniteListProps, type InfiniteLoad, type InfiniteLoadOptions, type InitialSelection, type InkColours, type InkMatch, type InkMatchState, type InputLevelProps, type InspectorProps, type InspectorSectionProps, type Job, type JobAction, type JobActionOptions, type JobFailure, type JobOptions, type JobProgress, type JobRow, type JobStatusProps, type JobWords, type JobsTableProps, type JsonViewProps, type KeyCheck, KeysLegend, type LatLng, type LengthBarProps, type LengthLook, type LightboxItem, type LightboxProps, type LightboxUrl, LineChart, LineChartGroup, type LineChartGroupProps, type LineChartProps, type LinkCardProps, type ListeningLevelProps, type Load, type LoadFailure, type LoadMoreProps, type Loudness, type MarkKind, type MarkPattern, type MarkTone, type MarkableTextProps, type MediaContentsItem, type MediaContentsProps, type MediaElementOptions, type MediaElementState, type MediaHeading, type MediaMark, MediaPlayer, type MediaPlayerProps, type MediaProblem, type MediaProgress, type MediaSession, type MediaSource, type MediaSpanData, type MediaSpansState, MediaStage, type MediaStat, type MediaStats, type MediaWindow, type MenuEntry, type MenuProps, type MeterProps, type MeterThreshold, type MetricProps, type Microphone, MicrophoneContext, MicrophoneError, type MicrophoneStream, type MoneyProps, type MoneyValue, type More, type NativeSelectProps, type NavItem, type Nib, type NumberFieldProps, type NumberFormatter, type Outbox, type OutboxItem, type OutboxOptions, type OutboxRefusal, type OutboxRequest, type OutboxSnapshot, type OutboxStatusProps, PALETTE_STORAGE_KEY, type PageNames, type Pair, type PairAnswer, type PairJudgeProps, type PairVoteProps, type PairVoteSlot, type PairVoteWords, PaletteChoice, type PaletteOption, type PaletteState, type PaneProps, type PartialDateFieldProps, type PartialDateParseResult, type PartialDatePrecision, type PartialDateValue, type PeakPair, type PendingRemoval, type Phase, type PictureBox, type PictureRegion, type PixelImageProps, type Pixels, type PlaceBoardProps, type PlaceState, type Platform, type PlayWindowButtonProps, PlayerNotice, type PlayerWarning, type PlayerWarningEvent, type Point, type Poll, type PopoverProps, type Precision, type Property, type PropertyListProps, type PropertyRowProps, type RangeProps, type RangeSliderProps, RateChoice, type ReadAlongPart, type ReadAlongProps, type ReadAloud, type ReadAloudOptions, type ReadPixels, type Rebinding, type Recorder, type RecorderState, type Recording, type Rect, type RectLimits, type Region, type RegionEditorProps, type RegionTone, type Reserve, type ReserveOptions, type ResumeWords, type Revealed, type Block as RichBlock, type Inline as RichInline, type RichTextProps, RowAction, type RowActionProps, type RowExpansion, type RowSelection, SPEECH_RATES, type SaveState, type SayAgainProps, type SayOnShowOptions, type SayPictureProps, type Saying, type ScheduleRow, type ScheduleTableProps, type SearchParam, type SearchParamOptions, type SecretFieldProps, type SecretTestResult, SeekBar, type SeekBarProps, type SeekBarSpan, type Segment, type Segmenter, type SegmenterOptions, type SelectableGridProps, type SequenceItem, type SequenceTimelineProps, type SetClockProps, type SetOptions, type ShareBox, type SharedCursor, type Shortcut, type ShortcutOverrides, type SkipAction, type SkipLevel, type SkipSteps, type SliderProps, type SolidProps, type SolidShape, type Sort, type SortableListProps, type SourceAttacher, SpanActions, type SpanActionsNotice, type SpanBehaviour, type SpanKind, type SpanOutcome, SpanStrip, type SpanTone, type SpanWords, type SpeakOptions, type Speech, type SpeechLevel, type SpeechPart, StageGuides, type StageState, type StageWords, type Stale, type StrataToastRegionProps, type StreamAttachment, type StreamContext, type StreamStats, type Stroke, type StrokeChange, type StrokeNoteWords, type StrokePoint, type StrokeShape, type SwitchProps, type SystemFact, type SystemFolder, type SystemInfoLike, type SystemPanelProps, type SystemService, type TabItem, type TakeLevelProps, type TextDifference, type TextLinkProps, type TextMedia, type TextSegment, ThemeProvider, type ThumbnailProps, type TileAspect, type TileGridProps, type TileSize, TimeReadout, type TimelineChange, type TimelineClock, type TimelineClockOptions, type TimelineDrop, type TimelineItem, type TimelineLane, type TimelineMarker, type TimelinePlayerProps, type TimelineProps, type ToastContentProps, type ToggleGroupProps, type ToggleOption, type ToggleProps, type Tone, type ToolChoice, type ToolbarProps, type TooltipProps, type TranscriptGroup, type TranscriptPhrase, type TranscriptPhraseState, type TranscriptSeek, type TranscriptViewProps, type TranscriptWord, Transport, type TransportProps, type TreeNodeState, type TreeProps, type Turn, type TurnArrowProps, type TypedApi, type Undoable, type UndoableOptions, type UseAutoRecorderOptions, type UseRecorderOptions, type UseSpeechOptions, type VideoLoop, type VideoMedia, type VideoMode, type ViewGroup, type ViewGroupRows, type ViewOptionsConfig, type ViewOptionsProps, type ViewOptionsState, type ViewPointerOptions, type ViewSort, type Viewport, type ViewportFrameProps, type ViewportState, VolumeControl, type VolumeControlProps, type WaveformMark, type WaveformMarkKind, type WaveformPeaks, type WaveformProps, type WaveformSpan, type WaveformTone, type WorkContext, type WorkPhase, type WorkflowRunLike, type WorkflowRunOptions, type WorkflowStage, type WorkflowStepsProps, type WorkflowSummaryData, type WorkflowSummaryProps, type WorkflowSummaryState, type WorkflowSummaryWords, type WorkspaceBarProps, type WorkspaceState, type YScale, browserMicrophone, buttonVariants, colorSchemeScript, explainMicrophoneError, format$1 as format, geo, isTypingTarget, keyName, logScale, marksFor, mediaStatRows, paletteScript, palettes, readPixels$1 as readPixels, skipAction, transportShortcuts, useAsyncAction, useAttachedSource, useColorScheme, useHotkeys, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, usePalette, usePlayerWarnings, useSharedCursor, useSystemColorScheme, valueAt };
6411
+ export { type ActiveItem, type AlertDialogProps, type AlertProps, type Api, type ApiOptions, type ApiPage, type AspectRatio, type AsyncAction, type AsyncActionOptions, AsyncButton, type AsyncLabels, type AudioMedia, type AutoRecorder, type AutoRecorderState, type AutoSave, type AutoSaveOptions, type AutoTake, type BalanceProps, type BalanceSide, type BinaryByteUnit, type BookPage, type BookUrl, type BookViewerProps, type BoxListProps, type BoxOverlayProps, type BoxSource, type BoxTone, type BoxedPictureProps, type BoxesState, type Brush, type BrushControl, type BrushKind, Button, type ButtonLinkProps, type ButtonProps, type ByteHighlight, type ByteRange, type ByteUnit, type ByteViewProps, type BytesOptions, COLOR_SCHEME_STORAGE_KEY, type Candidate, type CellValue, type ChartMark, type ChartSpan, type CheckboxGesture, type CheckboxProps, type Choice, type ChoiceCounts, type ChoiceGridProps, type ChoiceGroupProps, type ChoiceMarks, type ChoiceSize, type ChoiceState, type Choices, type ClientWork, type Clips, type ClipsContext, type ClipsProviderProps, type ClockFaceProps, type ClockFaceStyle, type ClockHands, type ClockMarks, type ClockNumbers, type ClockNumerals, type ClockParts, type ClockProps, type ClockStyle, type ClockTime, type ClockWordsOptions, type ColorFieldProps, type ColorScheme, ColorSchemeChoice, type ColorSchemeLabels, type ColorSchemePreference, type ColorSchemeState, type Column, type Command, type CommandMenuProps, type CommandsOptions, type CompareAudioProps, type CompareGridProps, type CompareMode, type CompareProps, type CompareTextProps, type CompareVideoGridProps, type CompareVideoProps, type ComposerProps, type CompositionBarProps, type CompositionPart, type ConcealedProps, type ConsoleLevel, type ConsoleLine, type ConsoleProps, type ContextMenuProps, type ControlSize, type ConversationImage, type ConversationProps, type ConversationTurn, type CountOptions, type CountdownOptions, type CurrencyOptions, type CursorMapping, type CursorOwner, CursorScope, type CursorScopeProps, type CutChange, type CutLimit, type CutRoom, DEFAULT_PALETTE, type DataTableProps, type DateFormatter, type DateInput, type DecodedAudio, type Delivery, Density, type DensityName, type DensityProps, type DescribeError, type DialogProps, type Difference, type DifferenceState, type DigitalClockProps, type DigitalClockStyle, type DigitalTimeOptions, type DisclosureOpenProps, type DisclosureProps, type DragData, type DragSourceProps, type DrawTool, type Drawing, type Box as DrawingBox, type DrawingLayerProps, type DrawingOp, type DrawingOptions, type DrawingState, type DrawingToolbarProps, type DropTarget, type Easing, type EditClip, type EditListOptions, type EditListPlayerProps, type EditListSlot, type EditListState, type EditTimes, type EditableRegion, type EntityMatch, type EntityMatcher, type ErrorBody, type EventLogEntry, type EventLogImage, type EventLogProps, type Expanded, type ExpandedOptions, type Facing, type FailedRemoval, type FetchJsonInit, type FetchJsonOptions, type FieldErrors, type FieldProps, type FileIntake, type FileIntakeOptions, type FileOutcome, type FillLevelProps, type FilmFrame, type FilmStripProps, type Folder, type FolderListing, type FolderPickerProps, type Format, type FormatOptions, type FractionCut, type FractionOutline, type FractionShapeProps, type FullscreenFrameProps, type GlimpseLook, type GlimpseProps, type GlimpseWhy, type Grid, type GroupMember, type GroupedChart, type Handle, type History, type HistoryOptions, type HistoryStateOptions, type HistoryStep, type HotkeysOptions, IconButton, type IconButtonProps, type IconComponent, type ImageMedia, type Implies, type InViewOptions, type InfiniteListProps, type InfiniteLoad, type InfiniteLoadOptions, type InitialSelection, type InkColours, type InkMatch, type InkMatchState, type InputLevelProps, type InspectorProps, type InspectorSectionProps, type Job, type JobAction, type JobActionOptions, type JobFailure, type JobOptions, type JobProgress, type JobRow, type JobStatusProps, type JobWords, type JobsTableProps, type JsonViewProps, type KeyCheck, KeysLegend, type LatLng, type LengthBarProps, type LengthLook, type LightboxItem, type LightboxProps, type LightboxUrl, LineChart, LineChartGroup, type LineChartGroupProps, type LineChartProps, type LinkCardProps, type ListeningLevelProps, type Load, type LoadFailure, type LoadMoreProps, type Loudness, type MarkKind, type MarkPattern, type MarkTone, type MarkableTextProps, type MediaContentsItem, type MediaContentsProps, type MediaElementOptions, type MediaElementState, type MediaHeading, type MediaMark, MediaPlayer, type MediaPlayerProps, type MediaProblem, type MediaProgress, type MediaSession, type MediaSource, type MediaSpanData, type MediaSpansState, MediaStage, type MediaStat, type MediaStats, type MediaWindow, type MenuEntry, type MenuProps, type MeterProps, type MeterThreshold, type MetricProps, type Microphone, MicrophoneContext, MicrophoneError, type MicrophoneStream, type MoneyProps, type MoneyValue, type More, type NativeSelectProps, type NavItem, type Nib, type NumberFieldProps, type NumberFormatter, type Outbox, type OutboxItem, type OutboxOptions, type OutboxRefusal, type OutboxRequest, type OutboxSnapshot, type OutboxStatusProps, PALETTE_STORAGE_KEY, type PageNames, type Pair, type PairAnswer, type PairJudgeProps, type PairVoteProps, type PairVoteSlot, type PairVoteWords, PaletteChoice, type PaletteOption, type PaletteState, type PaneProps, type PartialDateFieldProps, type PartialDateParseResult, type PartialDatePrecision, type PartialDateValue, type PeakPair, type PendingRemoval, type Phase, type PictureBox, type PictureRegion, type PixelImageProps, type Pixels, type PlaceBoardProps, type PlaceState, type Platform, type PlayWindowButtonProps, PlayerNotice, type PlayerWarning, type PlayerWarningEvent, type Point, type Poll, type PopoverProps, type Precision, type Property, type PropertyListProps, type PropertyRowProps, type RangeProps, type RangeSliderProps, RateChoice, type ReadAlongPart, type ReadAlongProps, type ReadAloud, type ReadAloudOptions, type ReadPixels, type Rebinding, type Recorder, type RecorderState, type Recording, type Rect, type RectLimits, type Region, type RegionEditorProps, type RegionTone, type Reserve, type ReserveOptions, type ResumeWords, type Revealed, type Block as RichBlock, type Inline as RichInline, type RichTextProps, RowAction, type RowActionProps, type RowExpansion, type RowSelection, SPEECH_RATES, type SaveState, type SayAgainProps, type SayOnShowOptions, type SayPictureProps, type Saying, type ScheduleRow, type ScheduleTableProps, type SearchParam, type SearchParamOptions, type SecretFieldProps, type SecretTestResult, SeekBar, type SeekBarProps, type SeekBarSpan, type Segment, type Segmenter, type SegmenterOptions, type SelectableGridProps, type SequenceItem, type SequenceTimelineProps, type SetClockProps, type SetOptions, type ShareBox, type SharedCursor, type Shortcut, type ShortcutOverrides, type SkipAction, type SkipLevel, type SkipSteps, type SliderProps, type SolidProps, type SolidShape, type Sort, type SortableListProps, type SourceAttacher, SpanActions, type SpanActionsNotice, type SpanBehaviour, type SpanKind, type SpanOutcome, SpanStrip, type SpanTone, type SpanWords, type SpeakOptions, type SpeakerReference, type SpeakerTimelineProps, type SpeakerTurn, type Speech, type SpeechLevel, type SpeechPart, StageGuides, type StageState, type StageWords, type Stale, type StrataToastRegionProps, type StreamAttachment, type StreamContext, type StreamStats, type Stroke, type StrokeChange, type StrokeNoteWords, type StrokePoint, type StrokeShape, type SwitchProps, type SystemFact, type SystemFolder, type SystemInfoLike, type SystemPanelProps, type SystemService, type TabItem, type TakeLevelProps, type TextDifference, type TextLinkProps, type TextMedia, type TextSegment, ThemeProvider, type ThumbnailProps, type TileAspect, type TileGridProps, type TileSize, TimeReadout, type TimelineChange, type TimelineClock, type TimelineClockOptions, type TimelineDrop, type TimelineItem, type TimelineLane, type TimelineMarker, type TimelinePlayerProps, type TimelineProps, type ToastContentProps, type ToggleGroupProps, type ToggleOption, type ToggleProps, type Tone, type ToolChoice, type ToolbarProps, type TooltipProps, type TranscriptGroup, type TranscriptPhrase, type TranscriptPhraseState, type TranscriptSeek, type TranscriptViewProps, type TranscriptWord, Transport, type TransportProps, type TreeNodeState, type TreeProps, type Turn, type TurnArrowProps, type TurnEdit, type TypedApi, type Undoable, type UndoableOptions, type UseAutoRecorderOptions, type UseRecorderOptions, type UseSpeechOptions, type VideoLoop, type VideoMedia, type VideoMode, type ViewGroup, type ViewGroupRows, type ViewOptionsConfig, type ViewOptionsProps, type ViewOptionsState, type ViewPointerOptions, type ViewSort, type Viewport, type ViewportFrameProps, type ViewportState, VolumeControl, type VolumeControlProps, type WaveformMark, type WaveformMarkKind, type WaveformPeaks, type WaveformProps, type WaveformSpan, type WaveformTone, type WorkContext, type WorkPhase, type WorkflowRunLike, type WorkflowRunOptions, type WorkflowStage, type WorkflowStepsProps, type WorkflowSummaryData, type WorkflowSummaryProps, type WorkflowSummaryState, type WorkflowSummaryWords, type WorkspaceBarProps, type WorkspaceState, type YScale, browserMicrophone, buttonVariants, colorSchemeScript, explainMicrophoneError, format$1 as format, geo, isTypingTarget, keyName, logScale, marksFor, mediaStatRows, paletteScript, palettes, readPixels$1 as readPixels, skipAction, transportShortcuts, useAsyncAction, useAttachedSource, useColorScheme, useHotkeys, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, usePalette, usePlayerWarnings, useSharedCursor, useSystemColorScheme, valueAt };
6337
6412
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -8797,7 +8797,7 @@ const tidy = (n) => Math.round(n * 1e6) / 1e6;
8797
8797
  // src/components/timeline.tsx
8798
8798
  const EDGE_PX = 8;
8799
8799
  const DRAG_THRESHOLD = 3;
8800
- const defaultFormat = (t) => tickLabel(t, 1);
8800
+ const defaultFormat$1 = (t) => tickLabel(t, 1);
8801
8801
  /** Zoom state for a timeline: `zoomIn`, `zoomOut`, and `fit` to a viewport width. Pass `zoom` and `setZoom` as the timeline's `zoom` and `onZoomChange`. */
8802
8802
  function useTimelineZoom({ initial = 20, min = .5, max = 400 } = {}) {
8803
8803
  const [zoom, set] = React.useState(initial);
@@ -8846,7 +8846,7 @@ function noOverlap(items) {
8846
8846
  };
8847
8847
  }
8848
8848
  /** Items placed on a zoomable time axis in lanes, with a current-time rule and markers. Reports every move, trim, selection and time change; the app applies them. Keyboard-complete, and only the items near the view are rendered. */
8849
- function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, position, onPositionChange, follow, markers = [], selectedIds, onSelect, onItemChange, onDelete, validate, snapPoints = [], snap = true, step = 1, minLength, renderItem, kindColours, laneRows = 1, dropTypes, dropLength, onDrop, validateDrop, formatTime = defaultFormat, empty, className }) {
8849
+ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, position, onPositionChange, follow, markers = [], selectedIds, onSelect, onItemChange, onDelete, validate, snapPoints = [], snap = true, step = 1, minLength, renderItem, kindColours, laneRows = 1, dropTypes, dropLength, onDrop, validateDrop, formatTime = defaultFormat$1, empty, className }) {
8850
8850
  const min = minLength ?? step;
8851
8851
  const scroller = React.useRef(null);
8852
8852
  const laneRefs = React.useRef(/* @__PURE__ */ new Map());
@@ -9300,7 +9300,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
9300
9300
  borderLeftWidth: last ? 0 : 1,
9301
9301
  paddingRight: last ? 4 : 0
9302
9302
  },
9303
- children: formatTime === defaultFormat ? tickLabel(t, stepSize) : formatTime(t)
9303
+ children: formatTime === defaultFormat$1 ? tickLabel(t, stepSize) : formatTime(t)
9304
9304
  }, t);
9305
9305
  }),
9306
9306
  markers.map((m) => /* @__PURE__ */ jsx("button", {
@@ -9485,6 +9485,360 @@ function LaneRow({ label, register, types, onHover, onLeave, onDropItems, childr
9485
9485
  });
9486
9486
  }
9487
9487
 
9488
+ // src/lib/speaker-turns.ts
9489
+ /** The speaker of a stretch nobody could make out: kept, not scored (strata-python `speakers.UNCLEAR`). */
9490
+ const UNCLEAR = "?";
9491
+ const byTime = (a, b) => a.start - b.start || a.end - b.end || a.id.localeCompare(b.id);
9492
+ const sorted = (turns) => [...turns].sort(byTime);
9493
+ const nameOf = (speaker) => speaker === "?" ? "unclear" : speaker;
9494
+ /** An id not yet in `turns`: `base`, else `base-2`, `base-3`… */
9495
+ function freshId(turns, base) {
9496
+ const taken = new Set(turns.map((t) => t.id));
9497
+ if (!taken.has(base)) return base;
9498
+ let n = 2;
9499
+ while (taken.has(`${base}-${n}`)) n++;
9500
+ return `${base}-${n}`;
9501
+ }
9502
+ /** The voices in order of first speech (the unclear stretches last), as a person reads down the lanes. */
9503
+ function voicesOf(turns) {
9504
+ const first = /* @__PURE__ */ new Map();
9505
+ for (const t of turns) if (t.speaker !== "?") first.set(t.speaker, Math.min(first.get(t.speaker) ?? Infinity, t.start));
9506
+ return [...first.entries()].sort((a, b) => a[1] - b[1] || a[0].localeCompare(b[0])).map(([s]) => s);
9507
+ }
9508
+ /** A name for a new voice that is not taken: "Voice 3" when two are named. */
9509
+ function newVoiceName(turns, word = "Voice") {
9510
+ const taken = new Set(turns.map((t) => t.speaker));
9511
+ let n = voicesOf(turns).length + 1;
9512
+ while (taken.has(`${word} ${n}`)) n++;
9513
+ return `${word} ${n}`;
9514
+ }
9515
+ /** The turns that cover `time` (a turn holds its start, not its end), latest start first. */
9516
+ function turnsAt(turns, time) {
9517
+ return turns.filter((t) => t.start <= time && time < t.end).sort((a, b) => b.start - a.start);
9518
+ }
9519
+ /** Cut the turn in two at `time`; the second half gets a fresh id. Nothing to do when `time` is not inside it. */
9520
+ function splitTurn(turns, id, time, format) {
9521
+ const t = turns.find((x) => x.id === id);
9522
+ if (!t || time <= t.start || time >= t.end) return null;
9523
+ const rest = {
9524
+ ...t,
9525
+ id: freshId(turns, `${t.id}b`),
9526
+ start: time
9527
+ };
9528
+ return {
9529
+ turns: sorted(turns.flatMap((x) => x.id === id ? [{
9530
+ ...x,
9531
+ end: time
9532
+ }, rest] : [x])),
9533
+ step: `Split ${nameOf(t.speaker)} at ${format(time)}`
9534
+ };
9535
+ }
9536
+ /** Give the turns to `speaker` (an existing voice, a new one, or `UNCLEAR`). */
9537
+ function assignTurns(turns, ids, speaker) {
9538
+ const chosen = new Set(ids);
9539
+ const moving = turns.filter((t) => chosen.has(t.id) && t.speaker !== speaker);
9540
+ if (!moving.length) return null;
9541
+ const what = moving.length === 1 ? "turn" : `${moving.length} turns`;
9542
+ return {
9543
+ turns: sorted(turns.map((t) => chosen.has(t.id) ? {
9544
+ ...t,
9545
+ speaker
9546
+ } : t)),
9547
+ step: speaker === "?" ? `Marked ${what} unclear` : `Gave ${what} to ${speaker}`
9548
+ };
9549
+ }
9550
+ /** Join the turn with the next turn of the same voice: one turn from the first's start to the later end. */
9551
+ function mergeWithNext(turns, id) {
9552
+ const t = turns.find((x) => x.id === id);
9553
+ if (!t) return null;
9554
+ const next = sorted(turns.filter((x) => x.speaker === t.speaker && x.id !== id && x.start >= t.start))[0];
9555
+ if (!next) return null;
9556
+ return {
9557
+ turns: sorted(turns.filter((x) => x.id !== next.id).map((x) => x.id === id ? {
9558
+ ...x,
9559
+ end: Math.max(x.end, next.end)
9560
+ } : x)),
9561
+ step: `Joined two turns of ${nameOf(t.speaker)}`
9562
+ };
9563
+ }
9564
+ /** Move the turn's start or end to `time`; refused (null) where it would leave the turn with no length. */
9565
+ function setEdge(turns, id, edge, time, format) {
9566
+ const t = turns.find((x) => x.id === id);
9567
+ if (!t || (edge === "start" ? time >= t.end : time <= t.start) || t[edge] === time) return null;
9568
+ return {
9569
+ turns: sorted(turns.map((x) => x.id === id ? {
9570
+ ...x,
9571
+ [edge]: time
9572
+ } : x)),
9573
+ step: `${nameOf(t.speaker)}'s turn ${edge === "start" ? "starts" : "ends"} at ${format(time)}`
9574
+ };
9575
+ }
9576
+ /** Rename a voice in every turn; joining two voices is renaming one to the other's name. */
9577
+ function renameVoice(turns, from, to) {
9578
+ const name = to.trim();
9579
+ if (!name || name === from || !turns.some((t) => t.speaker === from)) return null;
9580
+ const joined = turns.some((t) => t.speaker === name);
9581
+ return {
9582
+ turns: sorted(turns.map((t) => t.speaker === from ? {
9583
+ ...t,
9584
+ speaker: name
9585
+ } : t)),
9586
+ step: joined ? `Joined ${from} into ${name}` : `Renamed ${from} to ${name}`
9587
+ };
9588
+ }
9589
+ /** Take the turns out. */
9590
+ function removeTurns(turns, ids) {
9591
+ const gone = new Set(ids);
9592
+ const n = turns.filter((t) => gone.has(t.id)).length;
9593
+ if (!n) return null;
9594
+ return {
9595
+ turns: turns.filter((t) => !gone.has(t.id)),
9596
+ step: n === 1 ? "Removed a turn" : `Removed ${n} turns`
9597
+ };
9598
+ }
9599
+ /** Add copies of other turns (another answer's) under `speaker`, or under their own speaker's name when none is given. */
9600
+ function copyTurns(turns, from, speaker) {
9601
+ if (!from.length) return null;
9602
+ const out = [...turns];
9603
+ for (const t of from) out.push({
9604
+ ...t,
9605
+ id: freshId(out, `${t.id}c`),
9606
+ speaker: speaker ?? t.speaker
9607
+ });
9608
+ return {
9609
+ turns: sorted(out),
9610
+ step: from.length === 1 ? "Copied a turn" : `Copied ${from.length} turns`
9611
+ };
9612
+ }
9613
+
9614
+ // src/components/speaker-timeline.tsx
9615
+ const voiceLane = (name) => `v:${name}`;
9616
+ const UNCLEAR_LANE = "u";
9617
+ const refLane = (ref) => `r:${ref}`;
9618
+ const ownItem = (turn) => `t:${turn}`;
9619
+ const refItem = (ref, turn) => `r:${ref.length}:${ref}:${turn}`;
9620
+ const isOwnItem = (id) => id.startsWith("t:");
9621
+ const turnOf = (id) => id.slice(2);
9622
+ const laneOf = (speaker) => speaker === "?" ? UNCLEAR_LANE : voiceLane(speaker);
9623
+ const speakerOf = (lane) => lane === UNCLEAR_LANE ? "?" : lane.startsWith("v:") ? lane.slice(2) : null;
9624
+ const defaultFormat = (t) => {
9625
+ const s = Math.max(0, Math.round(t * 10) / 10);
9626
+ const m = Math.floor(s / 60);
9627
+ const sec = s - m * 60;
9628
+ return `${m}:${Number.isInteger(sec) ? String(sec).padStart(2, "0") : sec.toFixed(1).padStart(4, "0")}`;
9629
+ };
9630
+ /** Correct who spoke when: the person's turns as a lane per voice, other answers read-only beneath, and keys to split at the playhead, give turns to a voice, join, mark unclear and copy. Reports each edit with its name; the app holds the turns. */
9631
+ function SpeakerTimeline({ label, turns, onChange, references = [], from = 0, to, zoom, onZoomChange, position, onPositionChange, follow, selectedIds, onSelect, unclearLabel = "Unclear", legend = true, formatTime = defaultFormat, className }) {
9632
+ const region = React.useRef(null);
9633
+ const [ownSelection, setOwnSelection] = React.useState(/* @__PURE__ */ new Set());
9634
+ const outside = selectedIds ?? ownSelection;
9635
+ const turnIds = new Set(turns.map((t) => t.id));
9636
+ const selected = new Set([...outside].map((id) => turnIds.has(id) ? ownItem(id) : id));
9637
+ const select = (ids) => {
9638
+ const out = ids.map((id) => isOwnItem(id) ? turnOf(id) : id);
9639
+ if (!selectedIds) setOwnSelection(new Set(out));
9640
+ onSelect?.(out);
9641
+ };
9642
+ const voices = voicesOf(turns);
9643
+ const refocus = React.useRef(null);
9644
+ React.useEffect(() => {
9645
+ const id = refocus.current;
9646
+ refocus.current = null;
9647
+ if (id) region.current?.querySelector(`[data-item="${CSS.escape(ownItem(id))}"]`)?.focus();
9648
+ }, [turns]);
9649
+ const apply = (edit, focus) => {
9650
+ if (!edit) return;
9651
+ refocus.current = focus ?? null;
9652
+ onChange(edit);
9653
+ };
9654
+ const [renaming, setRenaming] = React.useState(null);
9655
+ const [name, setName] = React.useState("");
9656
+ const rename = (from) => {
9657
+ apply(renameVoice(turns, from, name));
9658
+ setRenaming(null);
9659
+ };
9660
+ const lanes = [
9661
+ ...voices.map((v, i) => ({
9662
+ id: voiceLane(v),
9663
+ label: v,
9664
+ header: /* @__PURE__ */ jsxs("span", {
9665
+ className: "flex items-center gap-1",
9666
+ children: [i < 9 && /* @__PURE__ */ jsx("kbd", {
9667
+ "aria-hidden": true,
9668
+ className: "type-caption text-muted-foreground",
9669
+ children: i + 1
9670
+ }), /* @__PURE__ */ jsx(Popover, {
9671
+ label: `Rename ${v}`,
9672
+ size: "sm",
9673
+ open: renaming === v,
9674
+ onOpenChange: (open) => {
9675
+ setRenaming(open ? v : null);
9676
+ setName(v);
9677
+ },
9678
+ trigger: /* @__PURE__ */ jsx(IconButton, {
9679
+ icon: Pencil,
9680
+ size: "sm",
9681
+ label: `Rename ${v}`
9682
+ }),
9683
+ children: /* @__PURE__ */ jsxs("form", {
9684
+ className: "grid gap-2",
9685
+ onSubmit: (e) => {
9686
+ e.preventDefault();
9687
+ rename(v);
9688
+ },
9689
+ children: [/* @__PURE__ */ jsx(Field, {
9690
+ label: "Name",
9691
+ hint: "A name already in use joins the two voices.",
9692
+ children: /* @__PURE__ */ jsx(Input, {
9693
+ value: name,
9694
+ onChange: (e) => setName(e.target.value),
9695
+ autoFocus: true
9696
+ })
9697
+ }), /* @__PURE__ */ jsx(Button, {
9698
+ type: "submit",
9699
+ children: "Rename"
9700
+ })]
9701
+ })
9702
+ })]
9703
+ })
9704
+ })),
9705
+ {
9706
+ id: UNCLEAR_LANE,
9707
+ label: unclearLabel
9708
+ },
9709
+ ...references.map((r) => ({
9710
+ id: refLane(r.id),
9711
+ label: r.label
9712
+ }))
9713
+ ];
9714
+ const items = [...turns.map((t) => ({
9715
+ id: ownItem(t.id),
9716
+ lane: laneOf(t.speaker),
9717
+ start: t.start,
9718
+ length: t.end - t.start,
9719
+ label: t.speaker === "?" ? unclearLabel : t.speaker
9720
+ })), ...references.flatMap((r) => r.turns.map((t) => ({
9721
+ id: refItem(r.id, t.id),
9722
+ lane: refLane(r.id),
9723
+ start: t.start,
9724
+ length: t.end - t.start,
9725
+ label: `${r.label}: ${t.speaker}`,
9726
+ kind: t.speaker
9727
+ })))];
9728
+ const own = (ids) => [...ids].filter(isOwnItem).map(turnOf);
9729
+ const refTurns = new Map(references.flatMap((r) => r.turns.map((t) => [refItem(r.id, t.id), t])));
9730
+ const fromRefs = (ids) => [...ids].flatMap((id) => refTurns.get(id) ?? []);
9731
+ const readOnly = "Another answer is read-only: choose its turns and press C to copy them into the voices above.";
9732
+ const validate = (item, next) => !isOwnItem(item) || speakerOf(next.lane) === null ? readOnly : null;
9733
+ const onItemChange = (item, next) => {
9734
+ const id = turnOf(item);
9735
+ const t = turns.find((x) => x.id === id);
9736
+ const to = speakerOf(next.lane);
9737
+ if (!isOwnItem(item) || !t || to === null) return;
9738
+ if (to !== t.speaker) {
9739
+ const moved = turns.map((x) => x.id === id ? {
9740
+ ...x,
9741
+ start: next.start,
9742
+ end: next.start + next.length
9743
+ } : x);
9744
+ return apply(assignTurns(moved, [id], to), id);
9745
+ }
9746
+ const end = next.start + next.length;
9747
+ const what = t.speaker === "?" ? unclearLabel : `${t.speaker}'s turn`;
9748
+ onChange({
9749
+ turns: turns.map((x) => x.id === id ? {
9750
+ ...x,
9751
+ start: next.start,
9752
+ end
9753
+ } : x).sort((a, b) => a.start - b.start),
9754
+ step: next.length === t.end - t.start ? `Moved ${what} to ${formatTime(next.start)}` : `Trimmed ${what}`
9755
+ });
9756
+ };
9757
+ const chosen = own(selected);
9758
+ const one = chosen.length === 1 ? chosen[0] : null;
9759
+ const focused = () => {
9760
+ const at = document.activeElement?.closest("[data-item]")?.dataset.item;
9761
+ return at && isOwnItem(at) && chosen.includes(turnOf(at)) ? turnOf(at) : one;
9762
+ };
9763
+ const atPlayhead = turnsAt(turns, position)[0]?.id ?? null;
9764
+ const shortcuts = [
9765
+ {
9766
+ keys: ["s"],
9767
+ label: "Split at the playhead",
9768
+ run: () => apply(splitTurn(turns, one ?? atPlayhead ?? "", position, formatTime))
9769
+ },
9770
+ ...voices.slice(0, 9).map((v, i) => ({
9771
+ keys: [String(i + 1)],
9772
+ label: `Give to ${v}`,
9773
+ id: `voice-${i + 1}`,
9774
+ run: () => apply(assignTurns(turns, chosen, v), focused()),
9775
+ disabled: !chosen.length
9776
+ })),
9777
+ {
9778
+ keys: ["n"],
9779
+ label: "Give to a new voice",
9780
+ run: () => apply(assignTurns(turns, chosen, newVoiceName(turns)), focused()),
9781
+ disabled: !chosen.length
9782
+ },
9783
+ {
9784
+ keys: ["u"],
9785
+ label: `Mark ${unclearLabel.toLowerCase()}`,
9786
+ run: () => apply(assignTurns(turns, chosen, "?"), focused()),
9787
+ disabled: !chosen.length
9788
+ },
9789
+ {
9790
+ keys: ["m"],
9791
+ label: "Join with the voice's next turn",
9792
+ run: () => one && apply(mergeWithNext(turns, one)),
9793
+ disabled: !one
9794
+ },
9795
+ {
9796
+ keys: ["["],
9797
+ label: "Start at the playhead",
9798
+ run: () => one && apply(setEdge(turns, one, "start", position, formatTime)),
9799
+ disabled: !one
9800
+ },
9801
+ {
9802
+ keys: ["]"],
9803
+ label: "End at the playhead",
9804
+ run: () => one && apply(setEdge(turns, one, "end", position, formatTime)),
9805
+ disabled: !one
9806
+ },
9807
+ {
9808
+ keys: ["c"],
9809
+ label: "Copy into the voices",
9810
+ run: () => apply(copyTurns(turns, fromRefs(selected))),
9811
+ disabled: !fromRefs(selected).length
9812
+ }
9813
+ ];
9814
+ useHotkeys(shortcuts, { within: region });
9815
+ return /* @__PURE__ */ jsxs("div", {
9816
+ ref: region,
9817
+ className: cn("grid min-w-0 gap-2", className),
9818
+ children: [/* @__PURE__ */ jsx(Timeline, {
9819
+ label,
9820
+ lanes,
9821
+ items,
9822
+ from,
9823
+ to,
9824
+ zoom,
9825
+ onZoomChange,
9826
+ position,
9827
+ onPositionChange,
9828
+ follow,
9829
+ selectedIds: selected,
9830
+ onSelect: select,
9831
+ onItemChange,
9832
+ onDelete: (ids) => apply(removeTurns(turns, own(ids))),
9833
+ validate,
9834
+ step: .1,
9835
+ minLength: .1,
9836
+ snap: false,
9837
+ formatTime
9838
+ }), legend && /* @__PURE__ */ jsx(KeysLegend, { shortcuts })]
9839
+ });
9840
+ }
9841
+
9488
9842
  // src/components/sortable-list.tsx
9489
9843
  const KIND = "strata-kind/";
9490
9844
  const ID = "strata-item/id";
@@ -25874,5 +26228,5 @@ function PartialDateField({ value, onChange, placeholder = "YYYY, YYYY-MM or YYY
25874
26228
  });
25875
26229
  }
25876
26230
 
25877
- export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BRUSHES, Balance, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, CLOCK_FACE_STYLES, CLOCK_STYLES, COINS, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, Clock, ClockFace, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Concealed, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DIGITAL_CLOCK_STYLES, DataTable, DataView$1 as DataView, Density, Dialog, DigitalClock, Disclosure, Done, DragSource, DrawingLayer, DrawingToolbar, EditListPlayer, EmptyState, EventLog, FACINGS, FIT, FRACTION_OUTLINES, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FillLevel, FilmStrip, FolderPicker, FractionShape, FullscreenFrame, Glimpse, HttpError, INK_COLOURS, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, JsonView, KeysLegend, LEVEL_FLOOR_DB, LengthBar, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaContents, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, Money, NBSP, NOTES, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PartialDateField, PauseButton, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RangeSlider, RateChoice, ReadAlong, RegionEditor, RichText, RowAction, SOLID_SHAPES, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, SayPicture, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SetClock, ShortcutEditor, SideNav, Skeleton, Slider, Solid, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelinePlayer, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, TurnArrow, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, applyOp, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, checkKey, clampToRoom, clampViewport, clipsQueryKey, clockParts, clockWords, cn, coinOutline, colorSchemeScript, commandShortcut, continues, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, currentOf, curvePoints, dayPart, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, diffWords, differences, digitalTime, diskThresholds, drawRect, drawingToSvg, ease, editTimeOf, editTimes, emptyDrawing, encodeWav, errorPayload, explainMicrophoneError, feedbackMarker, fetchJson, fieldErrorsOf, fillWords, filterMarkup, findPage, fitPoints, fitRect, followAim, format, formatChord, formatPartialDate, fractionParts, fractionWords, frameAt, gainToVolume, geo, gridPoints, gutterOf, hitsStroke, hourAt, inkMatch, inputLevelThresholds, invertOp, isDigitalStyle, isDoubtful, isRefusal, isReservedChord, isSpeaking, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, jsonBranchPaths, keyName, labelOf, lerpRect, locateInEdit, logScale, loudnessOf, marksFor, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, mediaStatRows, minutesAt, moneyWords, moveGutter, moveMinuteHand, movePoints, moveRect, newStrokeId, nextBreak, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parsePartialDate, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, pointsBox, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, replay, resample, resamplePeaks, rescaleDrawing, resizeRect, rgbaToBlob, rmsDb, romanHour, safeHref, sayPosition, serialiseSort, settleCut, simplifyPoints, skipAction, smoothPath, snapToGrid, solidWords, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepMinuteHand, stepOnGrid, stopSpeaking, strokeAt, strokeBox, strokeShape, summariseWorkflow, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnWords, turned, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useCountdown, useDifference, useDrawing, useEditList, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useInkMatch, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useReadAloud, useRebindableShortcuts, useRecorder, useReserve, useRevealed, useSayOnShow, useSearchParam, useSelection, useSettledStatus, useSharedCursor, useSpeaking, useSpeech, useSystemColorScheme, useSystemInfo, useTimeline, useTimelineZoom, useUndoable, useViewOptions, useViewPointers, useViewport, useWheelZoom, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, widthsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
26231
+ export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BRUSHES, Balance, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, CLOCK_FACE_STYLES, CLOCK_STYLES, COINS, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, Clock, ClockFace, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Concealed, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DIGITAL_CLOCK_STYLES, DataTable, DataView$1 as DataView, Density, Dialog, DigitalClock, Disclosure, Done, DragSource, DrawingLayer, DrawingToolbar, EditListPlayer, EmptyState, EventLog, FACINGS, FIT, FRACTION_OUTLINES, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FillLevel, FilmStrip, FolderPicker, FractionShape, FullscreenFrame, Glimpse, HttpError, INK_COLOURS, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, JsonView, KeysLegend, LEVEL_FLOOR_DB, LengthBar, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaContents, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, Money, NBSP, NOTES, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PartialDateField, PauseButton, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RangeSlider, RateChoice, ReadAlong, RegionEditor, RichText, RowAction, SOLID_SHAPES, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, SayPicture, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SetClock, ShortcutEditor, SideNav, Skeleton, Slider, Solid, SortableList, SpanActions, SpanStrip, SpeakerTimeline, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelinePlayer, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, TurnArrow, UNCLEAR, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, applyOp, assignTurns, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, checkKey, clampToRoom, clampViewport, clipsQueryKey, clockParts, clockWords, cn, coinOutline, colorSchemeScript, commandShortcut, continues, copyTurns, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, currentOf, curvePoints, dayPart, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, diffWords, differences, digitalTime, diskThresholds, drawRect, drawingToSvg, ease, editTimeOf, editTimes, emptyDrawing, encodeWav, errorPayload, explainMicrophoneError, feedbackMarker, fetchJson, fieldErrorsOf, fillWords, filterMarkup, findPage, fitPoints, fitRect, followAim, format, formatChord, formatPartialDate, fractionParts, fractionWords, frameAt, freshId, gainToVolume, geo, gridPoints, gutterOf, hitsStroke, hourAt, inkMatch, inputLevelThresholds, invertOp, isDigitalStyle, isDoubtful, isRefusal, isReservedChord, isSpeaking, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, jsonBranchPaths, keyName, labelOf, lerpRect, locateInEdit, logScale, loudnessOf, marksFor, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, mediaStatRows, mergeWithNext, minutesAt, moneyWords, moveGutter, moveMinuteHand, movePoints, moveRect, newStrokeId, newVoiceName, nextBreak, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parsePartialDate, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, pointsBox, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, removeTurns, renameVoice, replay, resample, resamplePeaks, rescaleDrawing, resizeRect, rgbaToBlob, rmsDb, romanHour, safeHref, sayPosition, serialiseSort, setEdge, settleCut, simplifyPoints, skipAction, smoothPath, snapToGrid, solidWords, sortRows, speak, speechLevel, splitRect, splitTurn, staleOf, stepId, stepMinuteHand, stepOnGrid, stopSpeaking, strokeAt, strokeBox, strokeShape, summariseWorkflow, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnWords, turned, turnedSize, turnsAt, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useCountdown, useDifference, useDrawing, useEditList, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useInkMatch, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useReadAloud, useRebindableShortcuts, useRecorder, useReserve, useRevealed, useSayOnShow, useSearchParam, useSelection, useSettledStatus, useSharedCursor, useSpeaking, useSpeech, useSystemColorScheme, useSystemInfo, useTimeline, useTimelineZoom, useUndoable, useViewOptions, useViewPointers, useViewport, useWheelZoom, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, voicesOf, widthsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
25878
26232
  //# sourceMappingURL=index.js.map