import type { ChapterContainer, Control, ChapterBranch, ControlEvent, ContainerEvent, ChapterEvent } from "../../../manifest"; import type { EventEmitter } from "../../../utils/EventEmitter"; import type { IPlayer } from "@vkontakte/videoplayer-core"; import type { InteractiveEventsType } from "./InteractiveEvents"; import type { GlobalEvents } from "./events"; import type { Nullable } from "@vkontakte/videoplayer-shared"; export type SubjectName = "chapter" | "container" | "control"; export type AfterExpectActionType = "after-expect"; export type Behaviour = "change-chapter" | "change-manifest"; export type ControlAfterExpectCallbackType = () => ExpectEventHandlerArg<"control">; export type SelectBranchesArg = { globalEventEmitter: EventEmitter; globalEvents: GlobalEvents; player: IPlayer; interactiveEvents: InteractiveEventsType; }; export type OnControlEventArg = { action: ControlEvent["action"]; controlType: Control["type"]; controlId: Control["id"]; containerId: ChapterContainer["id"]; onEvent: AnyFn; branches?: ChapterBranch[]; isEOV?: () => boolean; isDisabled?: () => boolean; }; export type OnContainerEventArg = { action: ContainerEvent["action"]; container: ChapterContainer; autoSelected?: boolean; branches?: ChapterBranch[]; isEOV?: boolean; }; export type OnChapterEventArg = { action: ChapterEvent["action"]; chapterId: string; branches?: ChapterBranch[]; }; export type SetManifestContainerEventsArg = { container: ChapterContainer; branches: ChapterBranch[]; isEOV?: boolean; }; export type AnyAction = ControlEvent["action"] | ContainerEvent["action"] | ChapterEvent["action"]; export type ActionMap = { control: ControlEvent["action"]; container: ContainerEvent["action"]; chapter: ChapterEvent["action"]; }; export type SubjectType = T extends "control" ? Control["type"] : undefined; export type EventActionCommon = { subjectId: string; subjectName: T; subjectType?: SubjectType; }; export type EventActionCommonWithAction = EventActionCommon & { action: ActionMap[T]; }; export type OpenURIArg = EventActionCommonWithAction & { payload: { URI?: Nullable; }; }; export type ChangeManifestArg = EventActionCommonWithAction & { payload: { behaviour?: Behaviour; }; }; export type ChangeChapterArg = EventActionCommonWithAction & { payload: { chapterId: string; autoSelect: boolean; behaviour?: Behaviour; }; }; export type ContinuePlaybackArg = EventActionCommonWithAction; export type OnExpectEventArg = EventActionCommon; export type ExpectEventHandlerArg = EventActionCommon;