import type { Layer } from "./layers.types.ts"; import type { ActiveEvent, Possession, ReplayEvent, ReplayLook, ReplayObject, ReplayTeam, ReplayTimeline, ReplayTrail } from "./replay.types.ts"; import { type KyogijoWords } from "./strings.ts"; import type { Language, ScoreOptions, SurfaceOptions } from "./types.ts"; type P = [number, number]; /** Seconds as a clock, `0:12` or `1:05:09`. */ export declare function replayClock(seconds: number): string; /** Seconds as it is said aloud, in the words of the language: `0:12` in English and `12秒` in Japanese, where a clock would be read as a time of day. */ export declare function replaySpoken(seconds: number, w: KyogijoWords["replay"]): string; /** The first and last moments of a timeline, how long it is, how many frames and objects it has, and the usual gap between frames, all in seconds. */ export declare function replayInfo(timeline: ReplayTimeline): { start: number; end: number; duration: number; frames: number; objects: number; events: number; step: number; }; /** The times of the frames, and of the events, in order: the moments a step can land on. */ export declare function replayTimes(timeline: ReplayTimeline): readonly number[]; /** The events of a timeline, in time order. */ export declare function replayEvents(timeline: ReplayTimeline): readonly ReplayEvent[]; /** * Where everything is at a time: each object of the frame at or before `t` placed between that frame and the next, in a straight line or, with * `smooth`, along a curve through the frames. An object in both frames moves; one only in the earlier frame stays put until the next; one only in * the later frame appears when its frame comes. `t` is held to the first and last moments. The objects keep the order of their first appearance. * @example * ```ts * import { interpolate } from "@johnmorrisdotca/kyogijo-stadiums/replay"; * import type { ReplayTimeline } from "@johnmorrisdotca/kyogijo-stadiums/replay"; * const timeline: ReplayTimeline = { frames: [ * { t: 0, objects: [{ id: "ball", team: "ball", x: 100, y: 40 }] }, * { t: 2, objects: [{ id: "ball", team: "ball", x: 140, y: 20 }] }, * ] }; * console.log(interpolate(timeline, 0.5).map((o) => `${o.id} ${o.x} ${o.y}`).join()); * // ball 110 35 * ``` */ export declare function interpolate(timeline: ReplayTimeline, t: number, options?: { smooth?: boolean | number; }): ReplayObject[]; /** * The path each object took over the last `seconds` before `t`, oldest place first and ending at its place at `t`: the frames in between, and the places at the two ends. * Only objects that are there at `t` have a trail. `teams` and `ids` choose whose; all by default. * @example * ```ts * import { trails } from "@johnmorrisdotca/kyogijo-stadiums/replay"; * import type { ReplayTimeline } from "@johnmorrisdotca/kyogijo-stadiums/replay"; * const timeline: ReplayTimeline = { frames: [0, 1, 2, 3].map((t) => ({ t, objects: [{ id: "puck", team: "puck", x: t * 10, y: 0 }] })) }; * console.log(trails(timeline, 3, 2)[0].points.map((point) => point[0]).join()); * // 10,20,30 * ``` */ export declare function trails(timeline: ReplayTimeline, t: number, seconds: number, options?: { teams?: readonly ReplayTeam[]; ids?: readonly string[]; smooth?: boolean | number; }): ReplayTrail[]; /** * Who has the ball at a time, when the data says: the `possession` of the latest frame at or before `t` that has one. `undefined` when no frame * says, or when the latest says nobody does (`null`). * @example * ```ts * import { possession } from "@johnmorrisdotca/kyogijo-stadiums/replay"; * import type { ReplayTimeline } from "@johnmorrisdotca/kyogijo-stadiums/replay"; * const timeline: ReplayTimeline = { frames: [ * { t: 0, possession: "h7", objects: [{ id: "h7", team: "home", x: 1, y: 1 }, { id: "ball", team: "ball", x: 1, y: 1 }] }, * { t: 1, possession: null, objects: [{ id: "h7", team: "home", x: 2, y: 1 }, { id: "ball", team: "ball", x: 5, y: 1 }] }, * ] }; * console.log(possession(timeline, 0.5), possession(timeline, 1)); * // { holder: 'h7', team: 'home' } undefined * ``` */ export declare function possession(timeline: ReplayTimeline, t: number): Possession | undefined; /** * The events that are on the surface at a time: from the moment of each until `hold` seconds after it ends (3 by default), with their places worked out. * @example * ```ts * import { activeEvents } from "@johnmorrisdotca/kyogijo-stadiums/replay"; * const ball = { id: "ball", team: "ball" as const, x: 10, y: 10 }; * const timeline = { frames: [{ t: 0, objects: [ball] }, { t: 10, objects: [ball] }], events: [{ t: 4, kind: "goal", team: "home" as const }] }; * console.log(activeEvents(timeline, 3).length, activeEvents(timeline, 5).map((a) => a.event.kind).join(), activeEvents(timeline, 9).length); * // 0 goal 0 * ``` */ export declare function activeEvents(timeline: ReplayTimeline, t: number, hold?: number, smooth?: boolean | number): ActiveEvent[]; /** The events with a time in `(from, to]`, for the live region: what went by while the clock moved from `from` to `to`. */ export declare function eventsBetween(timeline: ReplayTimeline, from: number, to: number): ReplayEvent[]; /** * What is said of an event, for a live region and a tooltip: its `label`, else the word for its kind and its team, then the time. * @example * ```ts * import { describeEvent } from "@johnmorrisdotca/kyogijo-stadiums/replay"; * console.log(describeEvent({ t: 72, kind: "goal", team: "home" })); * console.log(describeEvent({ t: 72, kind: "goal", team: "home" }, "ja")); * // Goal, home, 1:12 * // ホームのゴール、1分12秒 * ``` */ export declare function describeEvent(event: ReplayEvent, language?: Language, start?: number): string; /** The same frame of a timeline always draws the same layers: this is what a frame is, before it is drawn. */ export interface ReplaySnapshot { t: number; objects: ReplayObject[]; trails: ReplayTrail[]; events: ActiveEvent[]; } /** What is on the surface at a time: the objects, the trails behind the ones `look.trailOf` names, and the events. */ export declare function replaySnapshot(timeline: ReplayTimeline, t: number, look?: ReplayLook): ReplaySnapshot; /** What a layer of the frame holds: for each mark its key, and where it is in the timeline's frame, so that the browser can move it without drawing again. */ export interface ReplayGroup { /** The layer's id, `replay-players`. */ id: string; layer: Layer; /** Whether the marks move with the clock (the objects, their numbers and trails); an event's marks stay where they are put. */ moving: boolean; kind: "points" | "text" | "lines"; keys: string[]; /** Where each mark is, in the timeline's frame: a place for a point or a text, the places of a path for a line. */ coords: (P | P[])[]; } /** The groups of a frame, in the order they are drawn: trails, event lines, event marks, officials, players, their numbers, then the ball and the puck on top. */ export declare function replayGroups(timeline: ReplayTimeline, snap: ReplaySnapshot, look?: ReplayLook, language?: Language): ReplayGroup[]; /** The data layers of one frame, to put in a drawing's `layers` (after your own): the trails, the events' marks, the players with their numbers, the ball. */ export declare function replayLayers(timeline: ReplayTimeline, t: number, look?: ReplayLook, language?: Language): Layer[]; /** The sentence a replay adds to the drawing's description: its length, what it tracks and how many events it holds. It does not change with the time. */ export declare function replaySummary(timeline: ReplayTimeline, language?: Language): string; /** A function that puts places in a timeline's frame on the surface of a drawing, in feet. */ export declare function replayPlacer(options: SurfaceOptions | ScoreOptions, timeline: ReplayTimeline): (points: readonly P[]) => P[]; /** * One frame of a replay as an SVG string: the drawing `drawKyogijo` makes of `options`, with the players, their numbers, the ball and its trail, and * the events that are on the surface at `t`, laid on it as data layers. The same options, timeline and time always give the same string. Without * an `id` the drawing's ids come from the options and the timeline, not from the time, so that every frame of a replay has the same ids. * @example * ```ts * import { drawFrame } from "@johnmorrisdotca/kyogijo-stadiums/replay"; * import type { ReplayTimeline } from "@johnmorrisdotca/kyogijo-stadiums/replay"; * const timeline: ReplayTimeline = { * from: "nhl-api", * frames: [0, 1, 2].map((t) => ({ t, objects: [ * { id: "h1", team: "home", number: 9, x: 10 + t * 12, y: 5 }, * { id: "a1", team: "away", number: 4, x: 40 - t * 5, y: -8 }, * { id: "puck", team: "puck", x: 10 + t * 12, y: 5 }, * ] })), * events: [{ t: 2, kind: "goal", team: "home", x: 34, y: 5 }], * }; * const svg = drawFrame({ sport: "nhl" }, timeline, 1.5); * console.log(svg.startsWith(" string; /** * The events of a timeline as an HTML table, for a reader who cannot see the drawing: the time, the kind, the team and what is said of it. Every cell is escaped. * @example * ```ts * import { replayTable } from "@johnmorrisdotca/kyogijo-stadiums/replay"; * const html = replayTable({ frames: [{ t: 0, objects: [] }], events: [{ t: 12, kind: "goal", team: "home", label: "Goal, Rivera" }] }); * console.log(html.includes("0:12"), html.includes("Goal, Rivera")); * // true true * ``` */ export declare function replayTable(timeline: ReplayTimeline, options?: { language?: Language; className?: string; }): string; export {};