import { DataURLOptions } from '@posthog/rrweb-types';
import { IMirror } from '@posthog/rrweb-types';
import { serializedElementNodeWithId as serializedElementNodeWithId_2 } from '@posthog/rrweb-types';
import { serializedNode as serializedNode_2 } from '@posthog/rrweb-types';
import { serializedNodeWithId } from '@posthog/rrweb-types';

export declare function absolutifyURLs(cssText: string | null, href: string): string;

export declare type attributes = {
    [key: string]: string | number | true | null;
};

export declare type BuildCache = {
    stylesWithHoverClass: Map<string, string>;
};

export declare type cdataNode = {
    type: NodeType.CDATA;
    textContent: '';
};

export declare function checkDataURLSize(dataURL: string, maxLength: number | undefined): string;

export declare function classMatchesRegex(node: Node | null, regex: RegExp, checkAncestors: boolean): boolean;

export declare function cleanupSnapshot(): void;

export declare type commentNode = {
    type: NodeType.Comment;
    textContent: string;
};

export declare function createMirror(): Mirror;

declare interface CSSImportRule_2 extends CSSRule {
    readonly href: string;
    readonly layerName: string | null;
    readonly media: MediaList;
    readonly styleSheet: CSSStyleSheet;
    readonly supportsText?: string | null;
}

export declare const DEFAULT_MAX_DEPTH = 50;

export declare type DialogAttributes = {
    open: string;
    rr_open_mode: 'modal' | 'non-modal';
};

export declare type documentNode = {
    type: NodeType.Document;
    childNodes: serializedNodeWithId[];
    compatMode?: string;
};

export declare type documentTypeNode = {
    type: NodeType.DocumentType;
    name: string;
    publicId: string;
    systemId: string;
};

export declare type elementNode = {
    type: NodeType.Element;
    tagName: string;
    attributes: attributes;
    childNodes: serializedNodeWithId[];
    isSVG?: true;
    needBlock?: boolean;
    isCustom?: true;
};

export declare function escapeImportStatement(rule: CSSImportRule_2): string;

export declare function extractFileExtension(path: string, baseURL?: string): string | null;

export declare function fixSafariColons(cssStringified: string): string;

export declare function genId(): number;

export declare function getInputType(element: HTMLElement): Lowercase<string> | null;

export declare interface ICanvas extends HTMLCanvasElement {
    __context: string;
}

export declare type idNodeMap = Map<number, Node>;

export declare function ignoreAttribute(tagName: string, name: string, _value: unknown): boolean;

export declare const IGNORED_NODE = -2;

export declare function is2DCanvasBlank(canvas: HTMLCanvasElement): boolean;

export declare function isCSSImportRule(rule: CSSRule): rule is CSSImportRule_2;

export declare function isCSSStyleRule(rule: CSSRule): rule is CSSStyleRule;

export declare function isElement(n: Node): n is Element;

export declare function isNativeShadowDom(shadowRoot: ShadowRoot): boolean;

export declare function isNodeMetaEqual(a: serializedNode_2, b: serializedNode_2): boolean;

export declare function isShadowRoot(n: Node): n is ShadowRoot;

export declare type KeepIframeSrcFn = (src: string) => boolean;

export declare type legacyAttributes = {
    selected: false;
};

export declare type MaskInputFn = (text: string, element: HTMLElement) => string;

export 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;
}>;

export declare function maskInputValue({ element, maskInputOptions, tagName, type, value, maskInputFn, }: {
    element: HTMLElement;
    maskInputOptions: MaskInputOptions;
    tagName: string;
    type: string | null;
    value: string | null;
    maskInputFn?: MaskInputFn;
}): string;

export declare type MaskTextFn = (text: string, element: HTMLElement | null) => string;

export declare class Mirror 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;
}

export declare function needMaskingText(node: Node, maskTextClass: string | RegExp, maskTextSelector: string | null, checkAncestors: boolean): boolean;

export declare type nodeMetaMap = WeakMap<Node, serializedNodeWithId>;

export declare enum NodeType {
    Document = 0,
    DocumentType = 1,
    Element = 2,
    Text = 3,
    CDATA = 4,
    Comment = 5
}

export declare function recompressBase64Image(img: HTMLImageElement, dataURL: string, type?: string, quality?: number): string;

export declare function resetMaxDepthState(): void;

export declare type serializedElementNodeWithId = Extract<serializedNodeWithId, Record<'type', NodeType.Element>>;

export declare type serializedNode = (documentNode | documentTypeNode | elementNode | textNode | cdataNode | commentNode) & {
    rootId?: number;
    isShadowHost?: boolean;
    isShadow?: boolean;
};

export declare function serializeNodeWithId(n: Node, options: {
    doc: Document;
    mirror: Mirror;
    blockClass: string | RegExp;
    blockSelector: string | null;
    maskTextClass: string | RegExp;
    maskTextSelector: string | null;
    skipChild: boolean;
    inlineStylesheet: boolean;
    newlyAddedElement?: boolean;
    maskInputOptions?: MaskInputOptions;
    needsMask?: boolean;
    maskTextFn: MaskTextFn | undefined;
    maskInputFn: MaskInputFn | undefined;
    slimDOMOptions: SlimDOMOptions;
    dataURLOptions?: DataURLOptions;
    keepIframeSrcFn?: KeepIframeSrcFn;
    inlineImages?: boolean;
    recordCanvas?: boolean;
    preserveWhiteSpace?: boolean;
    onSerialize?: (n: Node) => unknown;
    onIframeLoad?: (iframeNode: HTMLIFrameElement, node: serializedElementNodeWithId_2) => unknown;
    iframeLoadTimeout?: number;
    onStylesheetLoad?: (linkNode: HTMLLinkElement, node: serializedElementNodeWithId_2) => unknown;
    stylesheetLoadTimeout?: number;
    depth?: number;
    maxDepth?: number;
    onMaxDepthReached?: () => void;
}): serializedNodeWithId | null;

export declare function slimDOMDefaults(slimDOM: 'all' | boolean | SlimDOMOptions): SlimDOMOptions;

export 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;
}>;

export declare function snapshot(n: Document, options?: {
    mirror?: Mirror;
    blockClass?: string | RegExp;
    blockSelector?: string | null;
    maskTextClass?: string | RegExp;
    maskTextSelector?: string | null;
    inlineStylesheet?: boolean;
    maskAllInputs?: boolean | MaskInputOptions;
    maskTextFn?: MaskTextFn;
    maskInputFn?: MaskInputFn;
    slimDOM?: 'all' | boolean | SlimDOMOptions;
    dataURLOptions?: DataURLOptions;
    inlineImages?: boolean;
    recordCanvas?: boolean;
    preserveWhiteSpace?: boolean;
    onSerialize?: (n: Node) => unknown;
    onIframeLoad?: (iframeNode: HTMLIFrameElement, node: serializedElementNodeWithId_2) => unknown;
    iframeLoadTimeout?: number;
    onStylesheetLoad?: (linkNode: HTMLLinkElement, node: serializedElementNodeWithId_2) => unknown;
    stylesheetLoadTimeout?: number;
    keepIframeSrcFn?: KeepIframeSrcFn;
    maxDepth?: number;
}): serializedNodeWithId | null;

export declare function stringifyRule(rule: CSSRule, sheetHref: string | null): string;

export declare function stringifyStylesheet(s: CSSStyleSheet): string | null;

export declare type tagMap = {
    [key: string]: string;
};

export declare type textNode = {
    type: NodeType.Text;
    textContent: string;
    isStyle?: true;
};

export declare function toLowerCase<T extends string>(str: T): Lowercase<T>;

export declare function transformAttribute(doc: Document, tagName: Lowercase<string>, name: Lowercase<string>, value: string | null, element?: HTMLElement, dataURLOptions?: DataURLOptions): string | null;

export declare function visitSnapshot(node: serializedNodeWithId, onVisit: (node: serializedNodeWithId) => unknown): void;

export declare function wasMaxDepthReached(): boolean;

export { }
