declare type actionWithDelay = {
    doAction: () => void;
    delay: number;
};

declare type addedNodeMutation = {
    parentId: number;
    previousId?: number | null;
    nextId: number | null;
    node: serializedNodeWithId;
};

declare type adoptedStyleSheetData = {
    source: IncrementalSource.AdoptedStyleSheet;
} & adoptedStyleSheetParam;

declare type adoptedStyleSheetParam = {
    id: number;
    styles?: {
        styleId: number;
        rules: styleSheetAddRule[];
    }[];
    styleIds: number[];
};

declare type attributeMutation = {
    id: number;
    attributes: {
        [key: string]: string | styleOMValue | null;
    };
};

declare type attributes = cssTextKeyAttr & {
    [key: string]: string | number | true | null;
};

declare type blockClass = string | RegExp;

declare enum CanvasContext {
    '2D' = 0,
    WebGL = 1,
    WebGL2 = 2
}

declare type canvasEventWithTime = eventWithTime & {
    type: EventType.IncrementalSnapshot;
    data: canvasMutationData;
};

declare type canvasMutationCallback = (p: canvasMutationParam) => void;

declare type canvasMutationCommand = {
    property: string;
    args: Array<unknown>;
    setter?: true;
};

declare type canvasMutationData = {
    source: IncrementalSource.CanvasMutation;
} & canvasMutationParam;

declare type canvasMutationParam = {
    id: number;
    type: CanvasContext;
    commands: canvasMutationCommand[];
    displayWidth?: number;
    displayHeight?: number;
} | ({
    id: number;
    type: CanvasContext;
    displayWidth?: number;
    displayHeight?: number;
} & canvasMutationCommand);

declare type cdataNode = {
    type: NodeType.CDATA;
    textContent: '';
};

declare type commentNode = {
    type: NodeType.Comment;
    textContent: string;
};

declare type cssTextKeyAttr = {
    _cssText?: string;
};

declare type customElementCallback = (c: customElementParam) => void;

declare type customElementData = {
    source: IncrementalSource.CustomElement;
} & customElementParam;

declare type customElementParam = {
    define?: {
        name: string;
    };
};

declare type customEvent<T = unknown> = {
    type: EventType.Custom;
    data: {
        tag: string;
        payload: T;
    };
};

declare type DataURLOptions = Partial<{
    type: string;
    quality: number;
    maxBase64ImageLength: number;
}>;

declare type DeprecatedMirror = {
    map: {
        [key: number]: INode;
    };
    getId: (n: Node) => number;
    getNode: (id: number) => INode | null;
    removeNodeFromMap: (n: Node) => void;
    has: (id: number) => boolean;
    reset: () => void;
};

declare type DocumentDimension = {
    x: number;
    y: number;
    relativeScale: number;
    absoluteScale: number;
};

declare type documentNode = {
    type: NodeType.Document;
    childNodes: serializedNodeWithId[];
    compatMode?: string;
};

declare type documentTypeNode = {
    type: NodeType.DocumentType;
    name: string;
    publicId: string;
    systemId: string;
};

declare type domContentLoadedEvent = {
    type: EventType.DomContentLoaded;
    data: unknown;
};

declare type elementNode = {
    type: NodeType.Element;
    tagName: string;
    attributes: attributes;
    childNodes: serializedNodeWithId[];
    isSVG?: true;
    needBlock?: boolean;
    isCustom?: true;
};

declare type Emitter = {
    on(type: string, handler: Handler): void;
    emit(type: string, event?: unknown): void;
    off(type: string, handler: Handler): void;
};

declare enum EventType {
    DomContentLoaded = 0,
    Load = 1,
    FullSnapshot = 2,
    IncrementalSnapshot = 3,
    Meta = 4,
    Custom = 5,
    Plugin = 6
}

declare type eventWithoutTime = domContentLoadedEvent | loadedEvent | fullSnapshotEvent | incrementalSnapshotEvent | metaEvent | customEvent | pluginEvent;

declare type eventWithTime = eventWithoutTime & {
    timestamp: number;
    delay?: number;
};

declare type fontCallback = (p: fontParam) => void;

declare type fontData = {
    source: IncrementalSource.Font;
} & fontParam;

declare type fontParam = {
    family: string;
    fontSource: string;
    buffer: boolean;
    descriptors?: FontFaceDescriptors;
};

declare type fullSnapshotEvent = {
    type: EventType.FullSnapshot;
    data: {
        node: serializedNodeWithId;
        initialOffset: {
            top: number;
            left: number;
        };
    };
};

declare type Handler = (event?: unknown) => void;

declare type hookResetter = () => void;

declare type hooksParam = {
    mutation?: mutationCallBack;
    mousemove?: mousemoveCallBack;
    mouseInteraction?: mouseInteractionCallBack;
    scroll?: scrollCallback;
    viewportResize?: viewportResizeCallback;
    input?: inputCallback;
    mediaInteaction?: mediaInteractionCallback;
    styleSheetRule?: styleSheetRuleCallback;
    styleDeclaration?: styleDeclarationCallback;
    canvasMutation?: canvasMutationCallback;
    font?: fontCallback;
    selection?: selectionCallback;
    customElement?: customElementCallback;
};

declare interface ICrossOriginIframeMirror {
    getId(iframe: HTMLIFrameElement, remoteId: number, parentToRemoteMap?: Map<number, number>, remoteToParentMap?: Map<number, number>): number;
    getIds(iframe: HTMLIFrameElement, remoteId: number[]): number[];
    getRemoteId(iframe: HTMLIFrameElement, parentId: number, map?: Map<number, number>): number;
    getRemoteIds(iframe: HTMLIFrameElement, parentId: number[]): number[];
    reset(iframe?: HTMLIFrameElement): void;
}

declare interface IMirror<TNode> {
    getId(n: TNode | undefined | null): number;
    getNode(id: number): TNode | null;
    getIds(): number[];
    getMeta(n: TNode): serializedNodeWithId | null;
    removeNodeFromMap(n: TNode): void;
    has(id: number): boolean;
    hasNode(node: TNode): boolean;
    add(n: TNode, meta: serializedNodeWithId): void;
    replace(id: number, n: TNode): void;
    reset(): void;
}

declare type incrementalData = mutationData | mousemoveData | mouseInteractionData | scrollData | viewportResizeData | inputData | mediaInteractionData | styleSheetRuleData | canvasMutationData | fontData | selectionData | styleDeclarationData | adoptedStyleSheetData | customElementData;

declare type incrementalSnapshotEvent = {
    type: EventType.IncrementalSnapshot;
    data: incrementalData;
};

declare enum IncrementalSource {
    Mutation = 0,
    MouseMove = 1,
    MouseInteraction = 2,
    Scroll = 3,
    ViewportResize = 4,
    Input = 5,
    TouchMove = 6,
    MediaInteraction = 7,
    StyleSheetRule = 8,
    CanvasMutation = 9,
    Font = 10,
    Log = 11,
    Drag = 12,
    StyleDeclaration = 13,
    Selection = 14,
    AdoptedStyleSheet = 15,
    CustomElement = 16
}

declare interface INode extends Node {
    __sn: serializedNodeWithId;
}

declare type inputCallback = (v: inputValue & {
    id: number;
}) => void;

declare type inputData = {
    source: IncrementalSource.Input;
    id: number;
} & inputValue;

declare type inputValue = {
    text: string;
    isChecked: boolean;
    userTriggered?: boolean;
};

declare type IWindow = Window & typeof globalThis;

declare type KeepIframeSrcFn = (src: string) => boolean;

declare type listenerHandler = () => void;

declare type loadedEvent = {
    type: EventType.Load;
    data: unknown;
};

declare type maskTextClass = string | RegExp;

declare type mediaInteractionCallback = (p: mediaInteractionParam) => void;

declare type mediaInteractionData = {
    source: IncrementalSource.MediaInteraction;
} & mediaInteractionParam;

declare type mediaInteractionParam = {
    type: MediaInteractions;
    id: number;
    currentTime?: number;
    volume?: number;
    muted?: boolean;
    loop?: boolean;
    playbackRate?: number;
};

declare enum MediaInteractions {
    Play = 0,
    Pause = 1,
    Seeked = 2,
    VolumeChange = 3,
    RateChange = 4
}

declare type metaEvent = {
    type: EventType.Meta;
    data: {
        href: string;
        width: number;
        height: number;
    };
};

declare type mouseInteractionCallBack = (d: mouseInteractionParam) => void;

declare type mouseInteractionData = {
    source: IncrementalSource.MouseInteraction;
} & mouseInteractionParam;

declare type mouseInteractionParam = {
    type: MouseInteractions;
    id: number;
    x?: number;
    y?: number;
    pointerType?: PointerTypes;
};

declare enum MouseInteractions {
    MouseUp = 0,
    MouseDown = 1,
    Click = 2,
    ContextMenu = 3,
    DblClick = 4,
    Focus = 5,
    Blur = 6,
    TouchStart = 7,
    TouchMove_Departed = 8,
    TouchEnd = 9,
    TouchCancel = 10
}

declare type mousemoveCallBack = (p: mousePosition[], source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag) => void;

declare type mousemoveData = {
    source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag;
    positions: mousePosition[];
};

declare type mousePosition = {
    x: number;
    y: number;
    id: number;
    timeOffset: number;
};

declare type mutationCallBack = (m: mutationCallbackParam) => void;

declare type mutationCallbackParam = {
    texts: textMutation[];
    attributes: attributeMutation[];
    removes: removedNodeMutation[];
    adds: addedNodeMutation[];
    isAttachIframe?: true;
};

declare type mutationData = {
    source: IncrementalSource.Mutation;
} & mutationCallbackParam;

declare enum NodeType {
    Document = 0,
    DocumentType = 1,
    Element = 2,
    Text = 3,
    CDATA = 4,
    Comment = 5
}

declare type PackFn = (event: eventWithTime) => string;

declare type playerMetaData = {
    startTime: number;
    endTime: number;
    totalTime: number;
};

declare type pluginEvent<T = unknown> = {
    type: EventType.Plugin;
    data: {
        plugin: string;
        payload: T;
    };
};

declare enum PointerTypes {
    Mouse = 0,
    Pen = 1,
    Touch = 2
}

declare type RecordPlugin<TOptions = unknown> = {
    name: string;
    observer?: (cb: (...args: Array<unknown>) => void, win: IWindow, options: TOptions) => listenerHandler;
    eventProcessor?: <TExtend>(event: eventWithTime) => eventWithTime & TExtend;
    getMirror?: (mirrors: {
        nodeMirror: IMirror<Node>;
        crossOriginIframeMirror: ICrossOriginIframeMirror;
        crossOriginIframeStyleMirror: ICrossOriginIframeMirror;
    }) => void;
    options: TOptions;
};

declare type removedNodeMutation = {
    parentId: number;
    id: number;
    isShadow?: boolean;
};

declare enum ReplayerEvents {
    Start = "start",
    Pause = "pause",
    Resume = "resume",
    Resize = "resize",
    Finish = "finish",
    FullsnapshotRebuilded = "fullsnapshot-rebuilded",
    LoadStylesheetStart = "load-stylesheet-start",
    LoadStylesheetEnd = "load-stylesheet-end",
    SkipStart = "skip-start",
    SkipEnd = "skip-end",
    MouseInteraction = "mouse-interaction",
    EventCast = "event-cast",
    CustomEvent = "custom-event",
    Flush = "flush",
    StateChange = "state-change",
    PlayBack = "play-back",
    Destroy = "destroy"
}

declare type SamplingStrategy = Partial<{
    mousemove: boolean | number;
    mousemoveCallback: number;
    mouseInteraction: boolean | Record<string, boolean | undefined>;
    scroll: number;
    media: number;
    input: 'all' | 'last';
    canvas: 'all' | number;
}>;

declare type scrollCallback = (p: scrollPosition) => void;

declare type scrollData = {
    source: IncrementalSource.Scroll;
} & scrollPosition;

declare type scrollPosition = {
    id: number;
    x: number;
    y: number;
};

declare type selectionCallback = (p: selectionParam) => void;

declare type selectionData = {
    source: IncrementalSource.Selection;
} & selectionParam;

declare type selectionParam = {
    ranges: Array<SelectionRange>;
};

declare type SelectionRange = {
    start: number;
    startOffset: number;
    end: number;
    endOffset: number;
};

declare type serializedNode = (documentNode | documentTypeNode | elementNode | textNode | cdataNode | commentNode) & {
    rootId?: number;
    isShadowHost?: boolean;
    isShadow?: boolean;
};

declare type serializedNodeWithId = serializedNode & {
    id: number;
};

declare type styleDeclarationCallback = (s: styleDeclarationParam) => void;

declare type styleDeclarationData = {
    source: IncrementalSource.StyleDeclaration;
} & styleDeclarationParam;

declare type styleDeclarationParam = {
    id?: number;
    styleId?: number;
    index: number[];
    set?: {
        property: string;
        value: string | null;
        priority: string | undefined;
    };
    remove?: {
        property: string;
    };
};

declare type styleOMValue = {
    [key: string]: styleValueWithPriority | string | false;
};

declare type styleSheetAddRule = {
    rule: string;
    index?: number | number[];
};

declare type styleSheetDeleteRule = {
    index: number | number[];
};

declare type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;

declare type styleSheetRuleData = {
    source: IncrementalSource.StyleSheetRule;
} & styleSheetRuleParam;

declare type styleSheetRuleParam = {
    id?: number;
    styleId?: number;
    removes?: styleSheetDeleteRule[];
    adds?: styleSheetAddRule[];
    replace?: string;
    replaceSync?: string;
};

declare type styleValueWithPriority = [string, string];

declare type textMutation = {
    id: number;
    value: string | null;
};

declare type textNode = {
    type: NodeType.Text;
    textContent: string;
    isStyle?: true;
};

declare type throttleOptions = {
    leading?: boolean;
    trailing?: boolean;
};

declare type UnpackFn = (raw: string) => eventWithTime;

declare type viewportResizeCallback = (d: viewportResizeDimension) => void;

declare type viewportResizeData = {
    source: IncrementalSource.ViewportResize;
} & viewportResizeDimension;

declare type viewportResizeDimension = {
    width: number;
    height: number;
};

declare type MaskInputFn = (text: string, element: HTMLElement) => string;

declare type MaskInputOptions = Partial<{
    color: boolean;
    date: boolean;
    'datetime-local': boolean;
    email: boolean;
    month: boolean;
    number: boolean;
    range: boolean;
    search: boolean;
    tel: boolean;
    text: boolean;
    time: boolean;
    url: boolean;
    week: boolean;
    textarea: boolean;
    select: boolean;
    password: boolean;
}>;

declare type MaskTextFn = (text: string, element: HTMLElement | null) => string;

declare class Mirror$1 implements IMirror<Node> {
    private idNodeMap;
    private nodeMetaMap;
    getId(n: Node | undefined | null): number;
    getNode(id: number): Node | null;
    getIds(): number[];
    getMeta(n: Node): serializedNodeWithId | null;
    removeNodeFromMap(n: Node): void;
    has(id: number): boolean;
    hasNode(node: Node): boolean;
    add(n: Node, meta: serializedNodeWithId): void;
    replace(id: number, n: Node): void;
    reset(): void;
}

declare function resetMaxDepthState(): void;

declare type SlimDOMOptions = Partial<{
    script: boolean;
    comment: boolean;
    headFavicon: boolean;
    headWhitespace: boolean;
    headMetaDescKeywords: boolean;
    headMetaSocial: boolean;
    headMetaRobots: boolean;
    headMetaHttpEquiv: boolean;
    headMetaAuthorship: boolean;
    headMetaVerification: boolean;
    headTitleMutations: boolean;
}>;

declare function wasMaxDepthReached(): boolean;

declare class BaseRRCDATASection extends BaseRRNode implements IRRCDATASection {
    readonly nodeName: "#cdata-section";
    readonly nodeType: number;
    readonly RRNodeType = NodeType.CDATA;
    data: string;
    constructor(data: string);
    get textContent(): string;
    set textContent(textContent: string);
    toString(): string;
}

declare class BaseRRComment extends BaseRRNode implements IRRComment {
    readonly nodeType: number;
    readonly nodeName: "#comment";
    readonly RRNodeType = NodeType.Comment;
    data: string;
    constructor(data: string);
    get textContent(): string;
    set textContent(textContent: string);
    toString(): string;
}

declare class BaseRRDocument extends BaseRRNode implements IRRDocument {
    readonly nodeType: number;
    readonly nodeName: "#document";
    readonly compatMode: 'BackCompat' | 'CSS1Compat';
    readonly RRNodeType = NodeType.Document;
    textContent: string | null;
    constructor(...args: any[]);
    get documentElement(): IRRElement | null;
    get body(): IRRElement | null;
    get head(): IRRElement | null;
    get implementation(): IRRDocument;
    get firstElementChild(): IRRElement | null;
    appendChild(newChild: IRRNode): IRRNode;
    insertBefore(newChild: IRRNode, refChild: IRRNode | null): IRRNode;
    removeChild(node: IRRNode): IRRNode;
    open(): void;
    close(): void;
    write(content: string): void;
    createDocument(_namespace: string | null, _qualifiedName: string | null, _doctype?: DocumentType | null): IRRDocument;
    createDocumentType(qualifiedName: string, publicId: string, systemId: string): IRRDocumentType;
    createElement(tagName: string): IRRElement;
    createElementNS(_namespaceURI: string, qualifiedName: string): IRRElement;
    createTextNode(data: string): IRRText;
    createComment(data: string): IRRComment;
    createCDATASection(data: string): IRRCDATASection;
    toString(): string;
}

declare class BaseRRDocumentType extends BaseRRNode implements IRRDocumentType {
    readonly nodeType: number;
    readonly RRNodeType = NodeType.DocumentType;
    readonly nodeName: string;
    readonly name: string;
    readonly publicId: string;
    readonly systemId: string;
    textContent: string | null;
    constructor(qualifiedName: string, publicId: string, systemId: string);
    toString(): string;
}

declare class BaseRRElement extends BaseRRNode implements IRRElement {
    readonly nodeType: number;
    readonly RRNodeType = NodeType.Element;
    readonly nodeName: string;
    tagName: string;
    attributes: Record<string, string>;
    shadowRoot: IRRElement | null;
    scrollLeft?: number;
    scrollTop?: number;
    constructor(tagName: string);
    get textContent(): string;
    set textContent(textContent: string);
    get classList(): ClassList;
    get id(): string;
    get className(): string;
    get style(): CSSStyleDeclaration_2;
    getAttribute(name: string): string | null;
    setAttribute(name: string, attribute: string): void;
    setAttributeNS(_namespace: string | null, qualifiedName: string, value: string): void;
    removeAttribute(name: string): void;
    appendChild(newChild: IRRNode): IRRNode;
    insertBefore(newChild: IRRNode, refChild: IRRNode | null): IRRNode;
    removeChild(node: IRRNode): IRRNode;
    attachShadow(_init: ShadowRootInit): IRRElement;
    dispatchEvent(_event: Event): boolean;
    toString(): string;
}

declare class BaseRRMediaElement extends BaseRRElement {
    currentTime?: number;
    volume?: number;
    paused?: boolean;
    muted?: boolean;
    playbackRate?: number;
    loop?: boolean;
    attachShadow(_init: ShadowRootInit): IRRElement;
    play(): void;
    pause(): void;
}

declare abstract class BaseRRNode implements IRRNode {
    parentElement: IRRNode | null;
    parentNode: IRRNode | null;
    ownerDocument: IRRDocument;
    firstChild: IRRNode | null;
    lastChild: IRRNode | null;
    previousSibling: IRRNode | null;
    nextSibling: IRRNode | null;
    abstract textContent: string | null;
    readonly ELEMENT_NODE: number;
    readonly TEXT_NODE: number;
    readonly nodeType: number;
    readonly nodeName: string;
    readonly RRNodeType: NodeType;
    constructor(..._args: any[]);
    get childNodes(): IRRNode[];
    contains(node: IRRNode): boolean;
    appendChild(_newChild: IRRNode): IRRNode;
    insertBefore(_newChild: IRRNode, _refChild: IRRNode | null): IRRNode;
    removeChild(_node: IRRNode): IRRNode;
    toString(): string;
}


declare class BaseRRText extends BaseRRNode implements IRRText {
    readonly nodeType: number;
    readonly nodeName: "#text";
    readonly RRNodeType = NodeType.Text;
    data: string;
    constructor(data: string);
    get textContent(): string;
    set textContent(textContent: string);
    toString(): string;
}

declare class ClassList {
    private onChange;
    classes: string[];
    constructor(classText?: string, onChange?: ((newClassText: string) => void) | undefined);
    add: (...classNames: string[]) => void;
    remove: (...classNames: string[]) => void;
}

declare type CSSStyleDeclaration_2 = Record<string, string> & {
    setProperty: (name: string, value: string | null, priority?: string | null) => void;
    removeProperty: (name: string) => string;
};


declare interface IRRCDATASection extends IRRNode {
    readonly nodeName: '#cdata-section';
    data: string;
}

declare interface IRRComment extends IRRNode {
    readonly nodeName: '#comment';
    data: string;
}

declare interface IRRDocument extends IRRNode {
    documentElement: IRRElement | null;
    body: IRRElement | null;
    head: IRRElement | null;
    implementation: IRRDocument;
    firstElementChild: IRRElement | null;
    readonly nodeName: '#document';
    compatMode: 'BackCompat' | 'CSS1Compat';
    createDocument(_namespace: string | null, _qualifiedName: string | null, _doctype?: DocumentType | null): IRRDocument;
    createDocumentType(qualifiedName: string, publicId: string, systemId: string): IRRDocumentType;
    createElement(tagName: string): IRRElement;
    createElementNS(_namespaceURI: string, qualifiedName: string): IRRElement;
    createTextNode(data: string): IRRText;
    createComment(data: string): IRRComment;
    createCDATASection(data: string): IRRCDATASection;
    open(): void;
    close(): void;
    write(content: string): void;
}

declare interface IRRDocumentType extends IRRNode {
    readonly name: string;
    readonly publicId: string;
    readonly systemId: string;
}

declare interface IRRElement extends IRRNode {
    tagName: string;
    attributes: Record<string, string>;
    shadowRoot: IRRElement | null;
    scrollLeft?: number;
    scrollTop?: number;
    id: string;
    className: string;
    classList: ClassList;
    style: CSSStyleDeclaration_2;
    attachShadow(init: ShadowRootInit): IRRElement;
    getAttribute(name: string): string | null;
    setAttribute(name: string, attribute: string): void;
    setAttributeNS(namespace: string | null, qualifiedName: string, value: string): void;
    removeAttribute(name: string): void;
    dispatchEvent(event: Event): boolean;
}

declare interface IRRNode {
    parentElement: IRRNode | null;
    parentNode: IRRNode | null;
    ownerDocument: IRRDocument;
    readonly childNodes: IRRNode[];
    readonly ELEMENT_NODE: number;
    readonly TEXT_NODE: number;
    readonly nodeType: number;
    readonly nodeName: string;
    readonly RRNodeType: NodeType;
    firstChild: IRRNode | null;
    lastChild: IRRNode | null;
    previousSibling: IRRNode | null;
    nextSibling: IRRNode | null;
    textContent: string | null;
    contains(node: IRRNode): boolean;
    appendChild(newChild: IRRNode): IRRNode;
    insertBefore(newChild: IRRNode, refChild: IRRNode | null): IRRNode;
    removeChild(node: IRRNode): IRRNode;
    toString(): string;
}

declare interface IRRText extends IRRNode {
    readonly nodeName: '#text';
    data: string;
}

declare class Mirror implements IMirror<BaseRRNode> {
    private idNodeMap;
    private nodeMetaMap;
    getId(n: BaseRRNode | undefined | null): number;
    getNode(id: number): BaseRRNode | null;
    getIds(): number[];
    getMeta(n: BaseRRNode): serializedNodeWithId | null;
    removeNodeFromMap(n: BaseRRNode): void;
    has(id: number): boolean;
    hasNode(node: BaseRRNode): boolean;
    add(n: BaseRRNode, meta: serializedNodeWithId): void;
    replace(id: number, n: BaseRRNode): void;
    reset(): void;
}

declare class RRCanvasElement extends RRElement implements IRRElement {
    rr_dataURL: string | null;
    canvasMutations: {
        event: canvasEventWithTime;
        mutation: canvasMutationData;
    }[];
    getContext(): RenderingContext | null;
}

declare class RRDocument extends BaseRRDocument {
    private UNSERIALIZED_STARTING_ID;
    private _unserializedId;
    get unserializedId(): number;
    mirror: Mirror;
    scrollData: scrollData | null;
    constructor(mirror?: Mirror);
    createDocument(_namespace: string | null, _qualifiedName: string | null, _doctype?: DocumentType | null): RRDocument;
    createDocumentType(qualifiedName: string, publicId: string, systemId: string): BaseRRDocumentType;
    createElement<K extends keyof HTMLElementTagNameMap>(tagName: K): RRElementType<K>;
    createElement(tagName: string): RRElement;
    createComment(data: string): BaseRRComment;
    createCDATASection(data: string): BaseRRCDATASection;
    createTextNode(data: string): BaseRRText;
    destroyTree(): void;
    open(): void;
}

declare class RRElement extends BaseRRElement {
    inputData: inputData | null;
    scrollData: scrollData | null;
}

declare interface RRElementTagNameMap {
    audio: RRMediaElement;
    canvas: RRCanvasElement;
    iframe: RRIFrameElement;
    style: RRStyleElement;
    video: RRMediaElement;
}

declare type RRElementType<K extends keyof HTMLElementTagNameMap> = K extends keyof RRElementTagNameMap ? RRElementTagNameMap[K] : RRElement;

declare class RRIFrameElement extends RRElement {
    contentDocument: RRDocument;
    constructor(upperTagName: string, mirror: Mirror);
}

declare class RRMediaElement extends BaseRRMediaElement {
}

declare class RRStyleElement extends RRElement {
    rules: (styleSheetRuleData | styleDeclarationData)[];
}

declare enum InterpreterStatus {
    NotStarted = 0,
    Running = 1,
    Stopped = 2
}
declare type SingleOrArray<T> = T[] | T;
interface EventObject {
    type: string;
}
declare type InitEvent = {
    type: 'xstate.init';
};
declare namespace StateMachine {
    type Action<TContext extends object, TEvent extends EventObject> = string | AssignActionObject<TContext, TEvent> | ActionObject<TContext, TEvent> | ActionFunction<TContext, TEvent>;
    type ActionMap<TContext extends object, TEvent extends EventObject> = Record<string, Exclude<Action<TContext, TEvent>, string>>;
    interface ActionObject<TContext extends object, TEvent extends EventObject> {
        type: string;
        exec?: ActionFunction<TContext, TEvent>;
        [key: string]: any;
    }
    type ActionFunction<TContext extends object, TEvent extends EventObject> = (context: TContext, event: TEvent | InitEvent) => void;
    type AssignAction = 'xstate.assign';
    interface AssignActionObject<TContext extends object, TEvent extends EventObject> extends ActionObject<TContext, TEvent> {
        type: AssignAction;
        assignment: Assigner<TContext, TEvent> | PropertyAssigner<TContext, TEvent>;
    }
    type Transition<TContext extends object, TEvent extends EventObject> = string | {
        target?: string;
        actions?: SingleOrArray<Action<TContext, TEvent>>;
        cond?: (context: TContext, event: TEvent) => boolean;
    };
    interface State<TContext extends object, TEvent extends EventObject, TState extends Typestate<TContext>> {
        value: TState['value'];
        context: TContext;
        actions: Array<ActionObject<TContext, TEvent>>;
        changed?: boolean | undefined;
        matches: <TSV extends TState['value']>(value: TSV) => this is TState extends {
            value: TSV;
        } ? TState : never;
    }
    interface Config<TContext extends object, TEvent extends EventObject, TState extends Typestate<TContext> = {
        value: any;
        context: TContext;
    }> {
        id?: string;
        initial: string;
        context?: TContext;
        states: {
            [key in TState['value']]: {
                on?: {
                    [K in TEvent['type']]?: SingleOrArray<Transition<TContext, TEvent extends {
                        type: K;
                    } ? TEvent : never>>;
                };
                exit?: SingleOrArray<Action<TContext, TEvent>>;
                entry?: SingleOrArray<Action<TContext, TEvent>>;
            };
        };
    }
    interface Machine<TContext extends object, TEvent extends EventObject, TState extends Typestate<TContext>> {
        config: StateMachine.Config<TContext, TEvent, TState>;
        initialState: State<TContext, TEvent, TState>;
        transition: (state: string | State<TContext, TEvent, TState>, event: TEvent['type'] | TEvent) => State<TContext, TEvent, TState>;
    }
    type StateListener<T extends State<any, any, any>> = (state: T) => void;
    interface Service<TContext extends object, TEvent extends EventObject, TState extends Typestate<TContext> = {
        value: any;
        context: TContext;
    }> {
        send: (event: TEvent | TEvent['type']) => void;
        subscribe: (listener: StateListener<State<TContext, TEvent, TState>>) => {
            unsubscribe: () => void;
        };
        start: (initialState?: TState['value'] | {
            context: TContext;
            value: TState['value'];
        }) => Service<TContext, TEvent, TState>;
        stop: () => Service<TContext, TEvent, TState>;
        readonly status: InterpreterStatus;
        readonly state: State<TContext, TEvent, TState>;
    }
    type Assigner<TContext extends object, TEvent extends EventObject> = (context: TContext, event: TEvent) => Partial<TContext>;
    type PropertyAssigner<TContext extends object, TEvent extends EventObject> = {
        [K in keyof TContext]?: ((context: TContext, event: TEvent) => TContext[K]) | TContext[K];
    };
}
interface Typestate<TContext extends object> {
    value: string;
    context: TContext;
}

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

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

declare function callSafely(fn: () => void): void;

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;


declare const freezePage: () => void;

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

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

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 | BaseRRNode>(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;


declare function inDom(n: Node): boolean;

declare function isAncestorRemoved(target: Node, mirror: Mirror$1): boolean;

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

declare function isIgnored(n: Node, mirror: Mirror$1, slimDOMOptions: SlimDOMOptions): boolean;

declare function isSerialized(n: Node, mirror: Mirror$1): boolean;

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

declare function isSerializedStylesheet<TNode extends Node | BaseRRNode>(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;

declare let mirror: DeprecatedMirror;


declare let nowTimestamp: () => number;

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

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

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[];
};

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

declare type PlayerEvent = {
    type: 'PLAY';
    payload: {
        timeOffset: number;
    };
} | {
    type: 'CAST_EVENT';
    payload: {
        event: eventWithTime;
    };
} | {
    type: 'PAUSE';
} | {
    type: 'TO_LIVE';
    payload: {
        baselineTime?: number;
    };
} | {
    type: 'ADD_EVENT';
    payload: {
        event: eventWithTime;
        applyPastEventSynchronously?: boolean;
    };
} | {
    type: 'END';
};

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 function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[];

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

declare namespace record {
    var addCustomEvent: <T>(tag: string, payload: T) => void;
    var freezePage: () => void;
    var takeFullSnapshot: (isCheckout?: boolean) => void;
    var mirror: Mirror$1;
}

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;
    plugins?: RecordPlugin[];
    mousemoveWait?: number;
    keepIframeSrcFn?: KeepIframeSrcFn;
    errorHandler?: ErrorHandler;
};

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 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 lastScrollMap;
    private constructedStyleMutations;
    private adoptedStyleSheets;
    private emitterHandlers;
    private serviceSubscription?;
    private speedServiceSubscription?;
    private timeouts;
    private styleSheetLoadListeners;
    constructor(events: Array<eventWithTime | string>, config?: Partial<playerConfig>);
    on(event: string, handler: Handler): this;
    off(event: string, handler: Handler): this;
    private addEmitterHandler;
    private addTimeout;
    setConfig(config: Partial<playerConfig>): void;
    getMetaData(): playerMetaData;
    getCurrentTime(): number;
    getTimeOffset(): number;
    getMirror(): Mirror$1;
    play(timeOffset?: number): void;
    pause(timeOffset?: number): void;
    resume(timeOffset?: number): void;
    destroy(): void;
    startLive(baselineTime?: number): void;
    addEvent(rawEvent: eventWithTime | string): void;
    enableInteract(): void;
    disableInteract(): void;
    resetCache(): void;
    private setupDom;
    private handleResize;
    private applyEventsSynchronously;
    private getCastFn;
    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;
}


declare type ReplayPlugin = {
    handler?: (event: eventWithTime, isSync: boolean, context: {
        replayer: Replayer;
    }) => void;
    onBuild?: (node: Node | BaseRRNode, context: {
        id: number;
        replayer: Replayer;
    }) => void;
    getMirror?: (mirrors: {
        nodeMirror: Mirror$1;
    }) => 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'];
    };
};

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;
}

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;
    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, callSafely, 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, StyleSheetMirror };
export type { AppendedIframe };
}

export { EventType, IncrementalSource, MouseInteractions, Replayer, ReplayerEvents, addCustomEvent, canvasMutation, freezePage, mirror, record, resetMaxDepthState, takeFullSnapshot, utils, wasMaxDepthReached };
export type { PlayerMachineState, ReplayPlugin, SpeedMachineState, eventWithTime, playerConfig, recordOptions };
