import type { VideoQuality, VideoFormat, ISources, IExternalTextTrack } from '@vkontakte/videoplayer-core';
import type { IValueObservable, InterfaceLanguage, Subscription, IRectangle, DevNullEntry } from '@vkontakte/videoplayer-shared';
import type { Manifest, VideoInfo, Interactives, IInteractiveOptions } from '@vkontakte/videoplayer-interactive';
import { PlaybackState } from '@vkontakte/videoplayer-core';
import type { Writable, Readable } from 'svelte/store';
import type { ISDKConfig, IUIConfig } from '../config';
import type { IStore } from '../store';
import { Controls, GridTypes, type SeekToInteractiveDisabledTooltipKey } from '../constans';
import type { Key } from '../translation/types';
import type { IUIStatistics } from '../services/statistics';
import { UISentry } from '../services/sentry';
import type { AdditionalContextMenuItem, AdditionalSettingsMenuItem } from '../components/Menus/subMenuTabs/types';
export declare const enum UIType {
    DESKTOP = "desktop",
    MOBILE = "mobile"
}
export declare const enum AdditionalVideoQuality {
    AUTO = "auto"
}
export type VideoQualityUI = VideoQuality | AdditionalVideoQuality;
export interface IVKVideoPlayerCallbacks {
    onInited?: () => void;
    onStarted?: () => void;
    onEnded?: () => void;
    onPlay?: () => void;
    onLooped?: () => void;
    onPause?: () => void;
    onVolumeChange?: (volume: number) => void;
    onFullscreenEnter?: () => void;
    onFullscreenExit?: () => void;
    onMute?: () => void;
    onUnmute?: () => void;
    onAudioDisabledHint?: () => void;
    onAudioDoesNotExistHint?: () => void;
    onEpisodeClicked?: (byKeyboard: boolean) => void;
    onEpisodeChanged?: (episode: IVideoEpisode) => void;
    onTimeupdate?: (duration: number, position: number) => void;
    onSeek?: (from: number, to: number) => void;
    onCrashed?: (reason?: string) => void;
    onRecoverableError?: (reason?: string) => void;
    onCurrentFormatChanged?: (currentFormat: VideoFormat | undefined) => void;
    onThroughputEstimationChanged?: (throughputEstimation: number | undefined) => void;
    onVideoBitrateChanged?: (videoBitrate: number | undefined) => void;
    onPlayerPhaseChanged?: (value?: PlayerPhase) => void;
    onPlaybackStateChanged?: (value?: PlaybackState) => void;
    onIsLiveChanged?: (value?: boolean) => void;
    onIsActiveLiveChanged?: (value?: boolean) => void;
    onIsAudioAvailableChanged?: (value?: boolean) => void;
    onCopyVideoLink?: (withTimestamp: boolean, currentTimestamp: number) => string;
    onOpenHotKeyMap?: (mapData: HotKeyMapData) => void;
    onCurrentQualityChanged?: (currentQuality: VideoQuality | undefined) => void;
    onAvailableQualitiesChanged?: (availableQualities: VideoQuality[]) => void;
    onAudioLanguagesAvailable?: () => void;
    onPiPEnter?: () => void;
    onPiPExit?: () => void;
    onLiveTime?: (liveTime: number | undefined) => void;
    onLiveEnded?: () => void;
    onReplayInteractiveVideo?: () => void;
    onInteractiveHistoryChanged?: (chapterIds: string[]) => void;
    onDisabledInteractiveClick?: () => void;
    onDisabledPlayPrevChapterClick?: (message: string | undefined) => void;
    onDisabledSeekToInteractiveClick?: (message: string | undefined) => void;
    onDisabledTimelineClick?: (position: number) => void;
    onInteractiveTimeIndicatorClick?: () => void;
    onInteractiveTimeIndicatorHintDeactivated?: () => void;
    onExternalFullscreenExit?: () => void;
    onPrevVideoClick?: () => boolean;
    onNextVideoClick?: () => boolean;
    onNextVideoAnnouncementShow?: () => void;
    onNextVideoAnnouncementClick?: () => void;
    onNextVideoAnnouncementAuto?: () => void;
    onNextVideoAnnouncementCancel?: () => void;
    onSetAutoplayNextEnabled?: (state: boolean) => void;
    onTrafficSavingEnabledChanged?: (isEnabled: boolean) => void;
    onCurrentPlaybackRateChanged?: (rate: number) => void;
    onStalledChanged?: (isStalled: boolean) => void;
    onLogoClicked?: () => void;
    onCopyEmbedCodeClicked?: () => string;
    onVSIDChanged?: (vsid?: string) => void;
    onAutoplaySoundProhibited?: () => void;
    onDevNullLog?: (entry: DevNullEntry) => void;
    uiInfo?: {
        onControlsVisibleChanged?: (value?: boolean) => void;
        onIsMobileChanged?: (value?: boolean) => void;
        onPrevButtonChanged?: (value?: IControlInfo) => void;
        onPlayButtonChanged?: (value?: IControlInfo) => void;
        onReplayButtonChanged?: (value?: IControlInfo) => void;
        onNextButtonChanged?: (value?: IControlInfo) => void;
        onPlayPrevChapterChanged?: (value?: IControlInfo) => void;
        onSeekToInteractiveButtonChanged?: (value?: IControlInfo) => void;
        onGraphButtonChanged?: (value?: IControlInfo) => void;
        onLiveButtonChanged?: (value?: IControlInfo) => void;
        onTimeUpdateChanged?: (value?: IControlInfo) => void;
        onEpisodesChanged?: (value?: IControlInfo) => void;
        onVolumeChanged?: (value?: IControlInfo) => void;
        onSubtitlesChanged?: (value?: IControlInfo) => void;
        onSettingsChanged?: (value?: IControlInfo) => void;
        onFullscreenChanged?: (value?: IControlInfo) => void;
        onChromecastChanged?: (value?: IControlInfo) => void;
        onPipChanged?: (value?: IControlInfo) => void;
        onVkLogoChanged?: (value?: IControlInfo) => void;
        onTimelineChanged?: (value?: IControlInfo) => void;
        onInteractiveTimeIndicatorChanged?: (value?: IControlInfo) => void;
        onPlayerSizeChanged?: (value?: {
            width: number;
            height: number;
        }) => void;
        onReportProblem?: () => void;
        onSettingsMenu?: (value: {
            name?: string;
            visible: boolean;
            size: IRectangle;
            position: Position;
        }) => void;
    };
    adsInfo?: {
        onLoadStarted?: () => void;
        onLoadEnded?: () => void;
        onLoadError?: () => void;
        onInit?: () => void;
        onReady?: () => void;
        onStarted?: (adsSection: AdsSection) => void;
        onPaused?: () => void;
        onResumed?: () => void;
        onTimeRemained?: (timeRemained: AdsTimeRemained) => void;
        onCompleted?: (adsSection: AdsSection) => void;
        onEmpty?: () => void;
        onClicked?: (adsSection: AdsSection) => void;
        onClosed?: (adsSection: AdsSection) => void;
        onError?: (message: string) => void;
    };
}
export interface IVKVideoPlayerUICallbacks {
    onStarted?: (isMuted: boolean) => void;
}
export interface IVKVideoPlayerStatistics extends Partial<IUIStatistics> {
    config: ISDKConfig['statistics'];
}
export interface IVKVideoPlayerSentry extends Partial<UISentry> {
    config: ISDKConfig['ui']['sentry'];
}
export type AdsParams = Record<string, unknown>;
export interface IVideoEpisodesNormalizedTimeline {
    from: number;
    width: number;
    loadedWidth: number;
    filledWidth: number;
    interactive?: boolean;
    completed?: boolean;
}
export interface IVideoEpisode {
    time: number;
    text: string;
    interactive?: boolean;
    completed?: boolean;
}
export interface ITimelinePreviewThumbsData {
    countPerImage: number;
    countPerRow: number;
    countTotal: number;
    frameHeight: number;
    frameWidth: number;
    frequency: number;
    isUV: boolean;
    links: string[];
}
export interface IVideoLive {
    status: 'started' | 'upcoming' | 'waiting' | 'finished' | 'postlive' | 'failed';
    startTime?: number;
}
export interface IVideoDataBase {
    title: string;
    thumbUrl?: string;
    unitedVideoId?: number;
    duration: number;
    adsParams?: AdsParams;
    videoEpisodes?: IVideoEpisode[];
    previewThumbsData?: ITimelinePreviewThumbsData;
    isClip?: boolean;
    subtitles?: Array<Omit<IExternalTextTrack, 'type'>>;
}
export interface IVideoDataWithSources extends IVideoDataBase {
    sources: ISources;
    live?: never;
}
export interface IVideoDataWithLive extends IVideoDataBase {
    live: IVideoLive;
    sources?: never;
}
export type IVideoData = IVideoDataWithSources | IVideoDataWithLive;
export interface IInteractiveData extends Pick<IInteractiveOptions, 'initChapterId' | 'historyApi' | 'projectInfo'> {
    manifest: string | Manifest;
    visitedChapters?: string[];
    videosInfo?: VideoInfo[];
    videoLoader?: IInteractiveOptions['vkVideoLoader'];
    tooltipHelpHintActive?: boolean;
}
/**
 * @deprecated
 *
 * Старый механизм добавления кнопок, будет удален в будущих релизах
 */
export interface AdditionalButtonDeprecated {
    iconUrl: string;
    onClick?: (event?: MouseEvent) => void;
    tooltip?: string;
    ariaLabel?: string;
    testId?: string;
    hideOnDesktopGridTypes?: GridTypes[];
    hideOnMobile?: boolean;
}
export interface IVKVideoPlayerConfig {
    videos: IVideoData[];
    videoIndex?: number;
    interactiveData?: IInteractiveData;
    albumId?: string;
    statPlace?: 'embed' | 'direct' | string;
    statAuthToken?: string;
    statUserSalt?: string;
    statTrackCode?: string;
    statVKAppId?: string;
    refreshStatAuthToken?: () => Promise<string | undefined>;
    preload?: boolean;
    autoplay?: boolean;
    repeat?: boolean;
    volume?: number;
    muted?: boolean;
    fromTime?: number;
    canRewindLive?: boolean;
    supportLink?: string;
    showAds?: boolean;
    adsSlotId?: number;
    adsParams?: AdsParams;
    adsPreviewParam?: number;
    adsAutoplayParam?: boolean;
    interfaceLanguage?: InterfaceLanguage | string;
    isCyrillicRelatedInterface?: boolean;
    logoClickable?: boolean;
    logoHidden?: boolean;
    /** @deprecated */
    isMobile?: boolean;
    isTouch?: boolean;
    /** @deprecated */
    isMediaSessionEnabled?: boolean;
    /** @deprecated */
    isPictureInPictureEnabled?: boolean;
    isAudioDisabled?: boolean;
    isLiveCatchUpMode?: boolean;
    canDownload?: boolean;
    fullScreenTarget?: HTMLElement;
    failoverHosts?: string[];
    showThumbTimer?: boolean;
    is3DVideo?: boolean;
    callbacks?: IVKVideoPlayerCallbacks;
    additionalButtons?: AdditionalButtonDeprecated[];
    additionalSettingsMenuItems?: AdditionalSettingsMenuItem[];
    additionalContextMenuItems?: AdditionalContextMenuItem[];
    refDomain?: string;
    volumeMultiplier?: number;
    saveRate?: boolean;
    deviceId?: string;
    showEndScreen?: boolean;
    showAutoplayNext?: boolean;
    showNextPrevButtons?: boolean;
    pipEnabled?: boolean;
}
export interface IControlInfo {
    /** @deprecated Используйте новое поле left */
    positionStartX: number;
    /** @deprecated Используйте новое поле right */
    positionEndX: number;
    left: number;
    right: number;
    top: number;
    bottom: number;
    isDisplayed: boolean;
}
export interface IPlayerControlsRef {
    prevButton?: HTMLButtonElement;
    playButton?: HTMLButtonElement;
    replayButton?: HTMLElement | HTMLButtonElement;
    nextButton?: HTMLButtonElement;
    playPrevChapterButton?: HTMLButtonElement;
    seekToInteractiveButton?: HTMLButtonElement;
    interactiveGraphButton?: HTMLButtonElement;
    liveButton?: HTMLElement;
    time?: HTMLElement;
    episodes?: HTMLElement;
    volume?: HTMLButtonElement;
    subtitles?: HTMLButtonElement;
    settings?: HTMLElement;
    context?: HTMLButtonElement;
    fullscreen?: HTMLElement;
    chromecast?: HTMLButtonElement;
    pip?: HTMLButtonElement;
    vkLogo?: HTMLButtonElement;
    interactiveTimeIndicator?: HTMLElement;
    timeline?: HTMLElement;
    autoplayNextToggle?: HTMLButtonElement;
}
export interface IPlayerDesktopControlsWidth {
    prevButton: number;
    playButton: number;
    replayButton: number;
    nextButton: number;
    playPrevChapterButton: number;
    seekToInteractiveButton: number;
    interactiveGraphButton: number;
    liveButton: number;
    time: number;
    episodes: number;
    volume: number;
    subtitles: number;
    settings: number;
    context: number;
    fullscreen: number;
    chromecast: number;
    vkLogo: number;
    additionalButtons: number[];
}
export declare const enum PlayerPhase {
    Thumb = "thumb",
    Video = "video",
    Ads = "ads",
    Crashed = "crashed",
    LiveWaitingStart = "LiveWaitingStart",
    LiveWaitingRecover = "LiveWaitingRecover",
    LiveWaitingRecord = "LiveWaitingRecord"
}
export declare const enum AdsSection {
    Preroll = "preroll",
    Midroll = "midroll",
    Postroll = "postroll"
}
export declare const enum AdsPlaybackState {
    INACTIVE = "inactive",
    PLAYING = "playing",
    PAUSED = "paused"
}
export type AdsTimeRemained = {
    currentTime: number;
    duration: number;
    percent: number;
    remained: number;
};
export type VideoQualityForRender = {
    value: VideoQualityUI;
    displayValue: string;
    selected: boolean;
};
export type VideoPlaybackRate = {
    value: number;
    displayValue: string;
    selected: boolean;
};
export type MediaSessionApiMetadata = {
    title: string;
    artist?: string;
    thumbUrl?: string;
};
export type MediaSessionApiActionHandler = [MediaSessionAction, MediaSessionActionHandler];
export interface PictureInPictureResizeEvent extends Event {
    target: PictureInPictureWindow;
}
export interface DocumentPictureInPictureRequestWindow {
    width?: number;
    height?: number;
    initialAspectRatio?: number;
    copyStyleSheets: boolean;
}
export interface DocumentPictureInPicture {
    onenter?: (event: Event) => void;
    window: Window;
    requestWindow: (params: DocumentPictureInPictureRequestWindow) => Promise<Window>;
}
export declare enum PictureInPictureType {
    PictureInPicture = 0,
    DocumentPictureInPicture = 1
}
export interface IPictureInPictureApiInfo {
    isActive$: IValueObservable<boolean>;
    isEnabled$: IValueObservable<boolean>;
    type: PictureInPictureType;
}
export type PictureInPictureSettings = {
    enabled?: boolean;
};
export interface IPictureInPictureApi {
    isSupported: () => boolean;
    isActive: () => boolean;
    setContext: (svelteContext: Map<unknown, unknown>) => void;
    request: () => Promise<void>;
    remove: () => Promise<void>;
    info: IPictureInPictureApiInfo;
    setEnabled: (enabled: boolean) => void;
    dispose: () => Promise<void>;
}
export interface IAnnotationsApi {
    /** @deprecated Больше не используется. Контейнер теперь определяется самостоятельно */
    registryRootContainer: (container: HTMLElement) => void;
    /** @deprecated Логики со слоями больше нет. Теперь все аннотации добавляются на единый общий слой */
    addLayer: (layerName: string) => HTMLElement | never;
    /** @deprecated Логики со слоями больше нет. Теперь все аннотации добавляются на единый общий слой */
    getLayer: (layerName: string) => HTMLElement | undefined;
    /** @deprecated Логики со слоями больше нет. Теперь все аннотации добавляются на единый общий слой */
    removeLayer: (layerName: string) => void;
    /** @deprecated Логики со слоями больше нет. Теперь все аннотации добавляются на единый общий слой */
    clearLayer: (layerName: string) => void;
    /** @deprecated Метод больше не является публичным */
    detach: () => void;
    /** @deprecated Больше нет необходимости переназначать контейнер для аннотаций в ходе работы плеера */
    reattach: () => void;
    /** @private */
    init: (container: HTMLElement) => void;
    add: (annotationName: string, annotation: HTMLElement) => void | never;
    get: (annotationName: string) => HTMLElement | never;
    remove: (annotationName: string) => void | never;
    clear: () => void;
    destroy: () => void;
}
export type VideoSubtitle = {
    value: string;
    displayValue: string;
    selected: boolean;
    isAuto?: boolean;
};
export type VideoSubtitleParsed = {
    startTime: number;
    endTime: number;
    lang: string;
    texts: ({
        type: 'text';
        value: string;
    } | {
        type: 'timestamp';
        value: number;
    })[];
};
export type VideoSubtitlesParsed = {
    id: string;
    lang: string;
    isAuto: boolean;
    subtitles: VideoSubtitleParsed[];
}[];
export type ControlsEnumType = keyof typeof Controls;
export type ControlsKeys = ControlsEnumType[];
export interface IPlayerPhase extends Readable<PlayerPhase> {
    is: (playerPhase: PlayerPhase) => boolean;
}
export interface IDisabledControls extends Writable<Set<ControlsEnumType>> {
    add: (addData: ControlsEnumType | ControlsKeys) => void;
    remove: (removeData: ControlsEnumType | ControlsKeys) => void;
    includes: (includeData: ControlsEnumType | ControlsKeys) => boolean;
}
export interface HotKeyMapItem {
    description: string;
    value: string;
}
export interface HotKeyMapGroup {
    title: string;
    items: HotKeyMapItem[];
}
export interface HotKeyMapData {
    title: string;
    groups: HotKeyMapGroup[];
    closeBtnText: string;
}
export declare enum HotKeyHelperType {
    PLAY = "PLAY",
    PAUSE = "PAUSE",
    REPLAY = "REPLAY",
    BACKWARD_SEEK = "BACKWARD_SEEK",
    FORWARD_SEEK = "FORWARD_SEEK",
    SUBTITLES_ON = "SUBTITLES_ON",
    SUBTITLES_OFF = "SUBTITLES_OFF",
    RATE_UP = "RATE_UP",
    RATE_DOWN = "RATE_DOWN",
    EPISODE_PREV = "EPISODE_PREV",
    EPISODE_NEXT = "EPISODE_NEXT",
    MUTE = "MUTE",
    VOLUME = "VOLUME"
}
export interface HotKeyHelperData {
    type: HotKeyHelperType;
    text?: string;
    t?: {
        key: Key;
        value?: string;
    };
}
export declare enum EpisodesModes {
    FULL = "FULL",
    COUNT = "COUNT",
    SHORT = "SHORT"
}
export type IToggleable<T> = T & {
    toggle: () => void;
};
type MicroStoreWritableBase<T = unknown> = Writable<T>;
type ToggleableMicroStore = IToggleable<MicroStoreWritableBase<boolean | null>>;
export type PictureInPictureMicroStore = {
    isActive$: Writable<boolean>;
    isEnabled$: Writable<boolean>;
    type$: Writable<PictureInPictureType | undefined>;
};
export type NotificationsMicroStore = {
    notificationsToShow$: Writable<Partial<Record<NotificationId, boolean>>>;
    showNotification: (id: NotificationId) => void;
    closeNotification: (id: NotificationId) => void;
};
export interface IMicroStores {
    fakeIsPlaying$: ToggleableMicroStore;
    interactiveControlsOpacity$: ToggleableMicroStore;
    seekToInteractiveDisabledTooltip$: MicroStoreWritableBase<SeekToInteractiveDisabledTooltipKey>;
    showInteractiveTimeIndicatorTooltip$: MicroStoreWritableBase<boolean> & {
        set: (newValue: boolean, useTimeout: boolean) => void;
        clearTimeout: () => void;
    };
    graphIsOpened$: ToggleableMicroStore;
    pictureInPicture$: PictureInPictureMicroStore;
    notifications$: NotificationsMicroStore;
}
export interface InitMicroStoreParams {
    store: IStore;
    microStores: IMicroStores;
    config: IVKVideoPlayerConfig;
    uiConfig: IUIConfig;
    interactiveController?: Interactives;
}
export interface IMicroStore<StateName extends keyof IMicroStores = keyof IMicroStores> {
    readonly stateName: StateName;
    state$: IMicroStores[StateName];
    subscription: Subscription;
    init: (initStoreParams: InitMicroStoreParams) => Subscription;
}
export type IMicroStoresRoot = {
    subscribers: IMicroStore[];
    stores: IMicroStores;
};
export type Position = {
    top?: number;
    left?: number;
    bottom?: number;
    right?: number;
};
export interface Caption {
    timeAppeared?: number | null;
    value: string;
}
export type NotificationId = 'slow_video';
export {};
