import { actionWithDelay } from '../../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { addedNodeMutation } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { blockClass } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { canvasMutationData } from '../../../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { DataURLOptions } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { DeprecatedMirror } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { DocumentDimension } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { Emitter } from '../../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { EventType } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { eventWithTime } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { eventWithTime as eventWithTime_2 } from '../../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { Handler } from '../../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { hookResetter } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { hooksParam } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { IMirror } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { IncrementalSource } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { IWindow } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { KeepIframeSrcFn } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { listenerHandler } from '../../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { listenerHandler as listenerHandler_2 } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { MaskInputFn } from '../../../../node_modules/@highlight-run/rrweb-snapshot/dist/rrweb-snapshot.js';
import { MaskInputOptions } from '../../../../node_modules/@highlight-run/rrweb-snapshot/dist/rrweb-snapshot.js';
import { maskTextClass } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { MaskTextFn } from '../../../../node_modules/@highlight-run/rrweb-snapshot/dist/rrweb-snapshot.js';
import { Mirror } from '../../../../../node_modules/@highlight-run/rrweb-snapshot/dist/rrweb-snapshot.js';
import { Mirror as Mirror_2 } from '../../../../node_modules/@highlight-run/rrweb-snapshot/dist/rrweb-snapshot.js';
import { Mirror as Mirror_3 } from 'rrweb-snapshot';
import { MouseInteractions } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { PackFn } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { playerMetaData } from '../../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { RecordPlugin } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { ReplayerEvents } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { RRDocument } from 'rrdom';
import { RRIFrameElement } from 'rrdom';
import { RRNode } from 'rrdom';
import { SamplingStrategy } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { SessionInterval } from '../../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { SlimDOMOptions } from '../../../../node_modules/@highlight-run/rrweb-snapshot/dist/rrweb-snapshot.js';
import { StateMachine } from '@xstate/fsm';
import { textMutation } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { throttleOptions } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';
import { UnpackFn } from '../../../../node_modules/@highlight-run/rrweb-types/dist/rrweb-types.js';

export declare const addCustomEvent: <T>(tag: string, payload: T) => void;

declare type AppendedIframe = {
    mutationInQueue: addedNodeMutation;
    builtNode: HTMLIFrameElement | RRIFrameElement;
};

export declare function canvasMutation({ event, mutation, target, imageMap, canvasEventMap, errorHandler, }: {
    event: Parameters<Replayer['applyIncremental']>[0];
    mutation: canvasMutationData;
    target: HTMLCanvasElement;
    imageMap: Replayer['imageMap'];
    canvasEventMap: Replayer['canvasEventMap'];
    errorHandler: Replayer['warnCanvasMutationFailed'];
}): Promise<void>;

declare function closestElementOfNode(node: Node | null): HTMLElement | null;

declare function createPlayerService(context: PlayerContext, { getCastFn, applyEventsSynchronously, emitter }: PlayerAssets): StateMachine.Service<PlayerContext, PlayerEvent, PlayerState>;

declare function createSpeedService(context: SpeedContext): StateMachine.Service<SpeedContext, SpeedEvent, SpeedState>;

declare type ErrorHandler = (error: unknown) => void | boolean;

export { EventType }

export { eventWithTime }

export declare const freezePage: () => void;

declare function getBaseDimension(node: Node, rootIframe: Node): DocumentDimension;

declare function getNestedRule(rules: CSSRuleList, position: number[]): CSSGroupingRule;

declare function getPositionsAndIndex(nestedIndex: number[]): {
    positions: number[];
    index: number | undefined;
};

declare function getRootShadowHost(n: Node): Node;

declare function getShadowHost(n: Node): Element | null;

declare function getWindowHeight(): number;

declare function getWindowScroll(win: Window): {
    left: number;
    top: number;
};

declare function getWindowWidth(): number;

declare function hasShadowRoot<T extends Node | RRNode>(n: T): n is T & {
    shadowRoot: ShadowRoot;
};

declare function hookSetter<T>(target: T, key: string | number | symbol, d: PropertyDescriptor, isRevoked?: boolean, win?: Window & typeof globalThis): hookResetter;

export { IncrementalSource }

declare function inDom(n: Node): boolean;

declare function isAncestorRemoved(target: Node, mirror: Mirror_2): boolean;

declare function isBlocked(node: Node | null, blockClass: blockClass, blockSelector: string | null, checkAncestors: boolean): boolean;

declare const isCanvasNode: (node: Node | null) => boolean;

declare function isIgnored(n: Node, mirror: Mirror_2, slimDOMOptions: SlimDOMOptions): boolean;

declare function isSerialized(n: Node, mirror: Mirror_2): boolean;

declare function isSerializedIframe<TNode extends Node | RRNode>(n: TNode, mirror: IMirror<TNode>): boolean;

declare function isSerializedStylesheet<TNode extends Node | RRNode>(n: TNode, mirror: IMirror<TNode>): boolean;

declare function iterateResolveTree(tree: ResolveTree, cb: (mutation: addedNodeMutation) => unknown): void;

declare function legacy_isTouchEvent(event: MouseEvent | TouchEvent | PointerEvent): event is TouchEvent;

export declare let mirror: DeprecatedMirror;

export { MouseInteractions }

declare let nowTimestamp: () => number;

declare function on(type: string, fn: EventListenerOrEventListenerObject, target?: Document | IWindow): listenerHandler_2;

declare type PlayerAssets = {
    emitter: Emitter;
    applyEventsSynchronously(events: Array<eventWithTime_2>): void;
    getCastFn(event: eventWithTime_2, isSync: boolean): () => void;
};

export declare type playerConfig = {
    speed: number;
    maxSpeed: number;
    root: Element;
    loadTimeout: number;
    skipInactive: boolean;
    inactivePeriodThreshold: number;
    showWarning: boolean;
    showDebug: boolean;
    blockClass: string;
    liveMode: boolean;
    insertStyleRules: string[];
    triggerFocus: boolean;
    UNSAFE_replayCanvas: boolean;
    pauseAnimation?: boolean;
    mouseTail: boolean | {
        duration?: number;
        lineCap?: string;
        lineWidth?: number;
        strokeStyle?: string;
    };
    unpackFn?: UnpackFn;
    useVirtualDom: boolean;
    logger: {
        log: (...args: Parameters<typeof console.log>) => void;
        warn: (...args: Parameters<typeof console.warn>) => void;
    };
    plugins?: ReplayPlugin[];
    inactiveThreshold: number;
    inactiveSkipTime: number;
};

declare type PlayerContext = {
    events: eventWithTime_2[];
    timer: Timer;
    timeOffset: number;
    baselineTime: number;
    lastPlayedEvent: eventWithTime_2 | null;
};

declare type PlayerEvent = {
    type: 'PLAY';
    payload: {
        timeOffset: number;
    };
} | {
    type: 'CAST_EVENT';
    payload: {
        event: eventWithTime_2;
    };
} | {
    type: 'PAUSE';
} | {
    type: 'TO_LIVE';
    payload: {
        baselineTime?: number;
    };
} | {
    type: 'ADD_EVENT';
    payload: {
        event: eventWithTime_2;
    };
} | {
    type: 'REPLACE_EVENTS';
    payload: {
        events: eventWithTime_2[];
    };
} | {
    type: 'END';
};

export declare type PlayerMachineState = StateMachine.State<PlayerContext, PlayerEvent, PlayerState>;

declare type PlayerState = {
    value: 'playing';
    context: PlayerContext;
} | {
    value: 'paused';
    context: PlayerContext;
} | {
    value: 'live';
    context: PlayerContext;
};

declare function polyfill(win?: Window & typeof globalThis): void;

declare type PrivacySettingOption = 'strict' | 'default' | 'none';

declare function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[];

export declare function record<T = eventWithTime_2>(options?: recordOptions<T>): listenerHandler | undefined;

export declare namespace record {
    var addCustomEvent: <T>(tag: string, payload: T) => void;
    var freezePage: () => void;
    var takeFullSnapshot: (isCheckout?: boolean) => void;
    var snapshotCanvas: (element: HTMLCanvasElement) => Promise<void>;
    var mirror: Mirror_3;
}

export declare type recordOptions<T> = {
    emit?: (e: T, isCheckout?: boolean) => void;
    checkoutEveryNth?: number;
    checkoutEveryNms?: number;
    blockClass?: blockClass;
    blockSelector?: string;
    ignoreClass?: string;
    ignoreSelector?: string;
    maskTextClass?: maskTextClass;
    maskTextSelector?: string;
    maskAllInputs?: boolean;
    maskInputOptions?: MaskInputOptions;
    maskInputFn?: MaskInputFn;
    maskTextFn?: MaskTextFn;
    slimDOMOptions?: SlimDOMOptions | 'all' | true;
    ignoreCSSAttributes?: Set<string>;
    inlineStylesheet?: boolean;
    hooks?: hooksParam;
    packFn?: PackFn;
    sampling?: SamplingStrategy;
    dataURLOptions?: DataURLOptions;
    recordDOM?: boolean;
    recordCanvas?: boolean;
    recordCrossOriginIframes?: boolean;
    recordAfter?: 'DOMContentLoaded' | 'load';
    userTriggeredOnInput?: boolean;
    collectFonts?: boolean;
    inlineImages?: boolean;
    inlineVideos?: boolean;
    plugins?: RecordPlugin[];
    mousemoveWait?: number;
    keepIframeSrcFn?: KeepIframeSrcFn;
    errorHandler?: ErrorHandler;
    privacySetting?: PrivacySettingOption;
    logger?: {
        debug: (...args: Parameters<typeof console.debug>) => void;
        warn: (...args: Parameters<typeof console.warn>) => void;
    };
};

export declare class Replayer {
    wrapper: HTMLDivElement;
    iframe: HTMLIFrameElement;
    service: ReturnType<typeof createPlayerService>;
    speedService: ReturnType<typeof createSpeedService>;
    get timer(): Timer;
    config: playerConfig;
    usingVirtualDom: boolean;
    virtualDom: RRDocument;
    private mouse;
    private mouseTail;
    private tailPositions;
    private emitter;
    private nextUserInteractionEvent;
    private activityIntervals;
    private inactiveEndTimestamp;
    private legacy_missingNodeRetryMap;
    private cache;
    private imageMap;
    private canvasEventMap;
    private mirror;
    private styleMirror;
    private mediaManager;
    private firstFullSnapshot;
    private newDocumentQueue;
    private mousePos;
    private touchActive;
    private lastMouseDownEvent;
    private lastHoveredRootNode;
    private lastSelectionData;
    private constructedStyleMutations;
    private adoptedStyleSheets;
    constructor(events: Array<eventWithTime_2 | string>, config?: Partial<playerConfig>);
    on(event: string, handler: Handler): this;
    off(event: string, handler: Handler): this;
    setConfig(config: Partial<playerConfig>): void;
    getActivityIntervals(): Array<SessionInterval>;
    getMetaData(): playerMetaData;
    getCurrentTime(): number;
    getTimeOffset(): number;
    getMirror(): Mirror;
    play(timeOffset?: number): void;
    pause(timeOffset?: number): void;
    resume(timeOffset?: number): void;
    destroy(): void;
    startLive(baselineTime?: number): void;
    addEvent(rawEvent: eventWithTime_2 | string): void;
    replaceEvents(events: eventWithTime_2[]): void;
    enableInteract(): void;
    disableInteract(): void;
    resetCache(): void;
    private setupDom;
    private handleResize;
    private applyEventsSynchronously;
    private getCastFn;
    private handleInactivity;
    private rebuildFullSnapshot;
    private insertStyleRules;
    private attachDocumentToIframe;
    private collectIframeAndAttachDocument;
    private waitForStylesheetLoad;
    private preloadAllImages;
    private preloadImages;
    private deserializeAndPreloadCanvasEvents;
    private applyIncremental;
    private applyMutation;
    private applyScroll;
    private applyInput;
    private applySelection;
    private applyStyleSheetMutation;
    private applyStyleSheetRule;
    private applyStyleDeclaration;
    private applyAdoptedStyleSheet;
    private legacy_resolveMissingNode;
    private moveAndHover;
    private drawMouseTail;
    private hoverElements;
    private isUserInteraction;
    private backToNormal;
    private warnNodeNotFound;
    private warnCanvasMutationFailed;
    private debugNodeNotFound;
    private warn;
    private debug;
}

export { ReplayerEvents }

export declare type ReplayPlugin = {
    handler?: (event: eventWithTime, isSync: boolean, context: {
        replayer: Replayer;
    }) => void;
    onBuild?: (node: Node | RRNode, context: {
        id: number;
        replayer: Replayer;
    }) => void;
    getMirror?: (mirrors: {
        nodeMirror: Mirror_2;
    }) => void;
};

declare type ResolveTree = {
    value: addedNodeMutation;
    children: ResolveTree[];
    parent: ResolveTree | null;
};

declare function shadowHostInDom(n: Node): boolean;

declare type SpeedContext = {
    normalSpeed: playerConfig['speed'];
    timer: Timer;
};

declare type SpeedEvent = {
    type: 'FAST_FORWARD';
    payload: {
        speed: playerConfig['speed'];
    };
} | {
    type: 'BACK_TO_NORMAL';
} | {
    type: 'SET_SPEED';
    payload: {
        speed: playerConfig['speed'];
    };
};

export declare type SpeedMachineState = StateMachine.State<SpeedContext, SpeedEvent, SpeedState>;

declare type SpeedState = {
    value: 'normal';
    context: SpeedContext;
} | {
    value: 'skipping';
    context: SpeedContext;
};

declare class StyleSheetMirror {
    private id;
    private styleIDMap;
    private idStyleMap;
    getId(stylesheet: CSSStyleSheet): number;
    has(stylesheet: CSSStyleSheet): boolean;
    add(stylesheet: CSSStyleSheet, id?: number): number;
    getStyle(id: number): CSSStyleSheet | null;
    reset(): void;
    generateId(): number;
}

export declare const takeFullSnapshot: (isCheckout?: boolean) => void;

declare function throttle<T>(func: (arg: T) => void, wait: number, options?: throttleOptions): (...args: T[]) => void;

declare class Timer {
    timeOffset: number;
    speed: number;
    private actions;
    private raf;
    private lastTimestamp;
    constructor(actions: actionWithDelay[] | undefined, config: {
        speed: number;
    });
    addAction(action: actionWithDelay): void;
    addActions(actions: actionWithDelay[]): void;
    replaceActions(actions: actionWithDelay[]): void;
    start(): void;
    private rafCheck;
    clear(): void;
    setSpeed(speed: number): void;
    isActive(): boolean;
    private findActionIndex;
}

declare function uniqueTextMutations(mutations: textMutation[]): textMutation[];

declare namespace utils {
    export {
        on,
        throttle,
        hookSetter,
        getWindowScroll,
        getWindowHeight,
        getWindowWidth,
        closestElementOfNode,
        isBlocked,
        isSerialized,
        isIgnored,
        isAncestorRemoved,
        legacy_isTouchEvent,
        polyfill,
        queueToResolveTrees,
        iterateResolveTree,
        isSerializedIframe,
        isSerializedStylesheet,
        getBaseDimension,
        hasShadowRoot,
        getNestedRule,
        getPositionsAndIndex,
        uniqueTextMutations,
        getShadowHost,
        getRootShadowHost,
        shadowHostInDom,
        inDom,
        mirror as _mirror,
        nowTimestamp,
        isCanvasNode,
        AppendedIframe,
        StyleSheetMirror
    }
}
export { utils }

export { }


declare namespace record {
    var addCustomEvent: <T>(tag: string, payload: T) => void;
    var freezePage: () => void;
    var takeFullSnapshot: (isCheckout?: boolean) => void;
    var snapshotCanvas: (element: HTMLCanvasElement) => Promise<void>;
    var mirror: import("rrweb-snapshot").Mirror;
}


declare global {
    interface Window {
        FontFace: typeof FontFace;
        Array: typeof Array;
    }
}

