{
  "version": 3,
  "sources": ["../src/types.ts", "../src/utils.ts", "../src/snapshot.ts", "../src/css.ts", "../src/rebuild.ts"],
  "sourcesContent": ["export enum NodeType {\n  Document,\n  DocumentType,\n  Element,\n  Text,\n  CDATA,\n  Comment,\n}\n\nexport type documentNode = {\n  type: NodeType.Document;\n  childNodes: serializedNodeWithId[];\n  compatMode?: string;\n};\n\nexport type documentTypeNode = {\n  type: NodeType.DocumentType;\n  name: string;\n  publicId: string;\n  systemId: string;\n};\n\nexport type attributes = {\n  [key: string]: string | number | true | null;\n};\nexport type legacyAttributes = {\n  /**\n   * @deprecated old bug in rrweb was causing these to always be set\n   * @see https://github.com/rrweb-io/rrweb/pull/651\n   */\n  selected: false;\n};\n\nexport type elementNode = {\n  type: NodeType.Element;\n  tagName: string;\n  attributes: attributes;\n  childNodes: serializedNodeWithId[];\n  isSVG?: true;\n  needBlock?: boolean;\n  // This is a custom element or not.\n  isCustom?: true;\n};\n\nexport type textNode = {\n  type: NodeType.Text;\n  textContent: string;\n  isStyle?: true;\n};\n\nexport type cdataNode = {\n  type: NodeType.CDATA;\n  textContent: '';\n};\n\nexport type commentNode = {\n  type: NodeType.Comment;\n  textContent: string;\n};\n\nexport type serializedNode = (\n  | documentNode\n  | documentTypeNode\n  | elementNode\n  | textNode\n  | cdataNode\n  | commentNode\n) & {\n  rootId?: number;\n  isShadowHost?: boolean;\n  isShadow?: boolean;\n};\n\nexport type serializedNodeWithId = serializedNode & { id: number };\n\nexport type serializedElementNodeWithId = Extract<\n  serializedNodeWithId,\n  Record<'type', NodeType.Element>\n>;\n\nexport type tagMap = {\n  [key: string]: string;\n};\n\n// @deprecated\nexport interface INode extends Node {\n  __sn: serializedNodeWithId;\n}\n\nexport interface ICanvas extends HTMLCanvasElement {\n  __context: string;\n}\n\nexport interface IMirror<TNode> {\n  getId(n: TNode | undefined | null): number;\n\n  getNode(id: number): TNode | null;\n\n  getIds(): number[];\n\n  getMeta(n: TNode): serializedNodeWithId | null;\n\n  removeNodeFromMap(n: TNode): void;\n\n  has(id: number): boolean;\n\n  hasNode(node: TNode): boolean;\n\n  add(n: TNode, meta: serializedNodeWithId): void;\n\n  replace(id: number, n: TNode): void;\n\n  reset(): void;\n}\n\nexport type idNodeMap = Map<number, Node>;\n\nexport type nodeMetaMap = WeakMap<Node, serializedNodeWithId>;\n\nexport type MaskInputOptions = Partial<{\n  color: boolean;\n  date: boolean;\n  'datetime-local': boolean;\n  email: boolean;\n  month: boolean;\n  number: boolean;\n  range: boolean;\n  search: boolean;\n  tel: boolean;\n  text: boolean;\n  time: boolean;\n  url: boolean;\n  week: boolean;\n  // unify textarea and select element with text input\n  textarea: boolean;\n  select: boolean;\n  // password is _always_ masked, can't opt out of this\n  radio: boolean;\n  checkbox: boolean;\n}>;\n\nexport type SlimDOMOptions = Partial<{\n  script: boolean;\n  comment: boolean;\n  headFavicon: boolean;\n  headWhitespace: boolean;\n  headMetaDescKeywords: boolean;\n  headMetaSocial: boolean;\n  headMetaRobots: boolean;\n  headMetaHttpEquiv: boolean;\n  headMetaAuthorship: boolean;\n  headMetaVerification: boolean;\n}>;\n\nexport type DataURLOptions = Partial<{\n  type: string;\n  quality: number;\n}>;\n\nexport type MaskTextFn = (text: string, element: HTMLElement | null) => string;\nexport type MaskInputFn = (text: string, element: HTMLElement) => string;\nexport type MaskAttributeFn = (\n  attributeName: string,\n  attributeValue: string,\n  element: HTMLElement,\n) => string;\n\nexport type KeepIframeSrcFn = (src: string) => boolean;\n\nexport type BuildCache = {\n  stylesWithHoverClass: Map<string, string>;\n};\n", "import {\n  idNodeMap,\n  MaskInputFn,\n  MaskInputOptions,\n  nodeMetaMap,\n  IMirror,\n  serializedNodeWithId,\n  serializedNode,\n  NodeType,\n  documentNode,\n  documentTypeNode,\n  textNode,\n  elementNode,\n} from './types';\n\nexport function isElement(n: Node): n is Element {\n  return n.nodeType === n.ELEMENT_NODE;\n}\n\nexport function isShadowRoot(n: Node): n is ShadowRoot {\n  const host: Element | null = (n as ShadowRoot)?.host;\n  return Boolean(host?.shadowRoot === n);\n}\n\n/**\n * To fix the issue https://github.com/rrweb-io/rrweb/issues/933.\n * Some websites use polyfilled shadow dom and this function is used to detect this situation.\n */\nexport function isNativeShadowDom(shadowRoot: ShadowRoot): boolean {\n  return Object.prototype.toString.call(shadowRoot) === '[object ShadowRoot]';\n}\n\n/**\n * Browsers sometimes destructively modify the css rules they receive.\n * This function tries to rectify the modifications the browser made to make it more cross platform compatible.\n * @param cssText - output of `CSSStyleRule.cssText`\n * @returns `cssText` with browser inconsistencies fixed.\n */\nfunction fixBrowserCompatibilityIssuesInCSS(cssText: string): string {\n  /**\n   * Chrome outputs `-webkit-background-clip` as `background-clip` in `CSSStyleRule.cssText`.\n   * But then Chrome ignores `background-clip` as css input.\n   * Re-introduce `-webkit-background-clip` to fix this issue.\n   */\n  if (\n    cssText.includes(' background-clip: text;') &&\n    !cssText.includes(' -webkit-background-clip: text;')\n  ) {\n    cssText = cssText.replace(\n      /\\sbackground-clip:\\s*text;/g,\n      ' -webkit-background-clip: text; background-clip: text;',\n    );\n  }\n  return cssText;\n}\n\n// Remove this declaration once typescript has added `CSSImportRule.supportsText` to the lib.\ndeclare interface CSSImportRule extends CSSRule {\n  readonly href: string;\n  readonly layerName: string | null;\n  readonly media: MediaList;\n  readonly styleSheet: CSSStyleSheet;\n  /**\n   * experimental API, currently only supported in firefox\n   * https://developer.mozilla.org/en-US/docs/Web/API/CSSImportRule/supportsText\n   */\n  readonly supportsText?: string | null;\n}\n\n/**\n * Browsers sometimes incorrectly escape `@import` on `.cssText` statements.\n * This function tries to correct the escaping.\n * more info: https://bugs.chromium.org/p/chromium/issues/detail?id=1472259\n * @param cssImportRule\n * @returns `cssText` with browser inconsistencies fixed, or null if not applicable.\n */\nexport function escapeImportStatement(rule: CSSImportRule): string {\n  const { cssText } = rule;\n  if (cssText.split('\"').length < 3) return cssText;\n\n  const statement = ['@import', `url(${JSON.stringify(rule.href)})`];\n  if (rule.layerName === '') {\n    statement.push(`layer`);\n  } else if (rule.layerName) {\n    statement.push(`layer(${rule.layerName})`);\n  }\n  if (rule.supportsText) {\n    statement.push(`supports(${rule.supportsText})`);\n  }\n  if (rule.media.length) {\n    statement.push(rule.media.mediaText);\n  }\n  return statement.join(' ') + ';';\n}\n\nexport function stringifyStylesheet(s: CSSStyleSheet): string | null {\n  try {\n    const rules = s.rules || s.cssRules;\n    return rules\n      ? fixBrowserCompatibilityIssuesInCSS(\n          Array.from(rules, stringifyRule).join(''),\n        )\n      : null;\n  } catch (error) {\n    return null;\n  }\n}\n\n/**\n * There is a bug in chrome (https://issues.chromium.org/issues/41416124) with the `all` property where we can't use `cssText` because it is wrong.\n * Instead, attempt to serialize the css string using `CSSStyleDeclaration`.\n */\nexport function fixAllCssProperty(rule: CSSStyleRule) {\n  let styles = '';\n  for (let i = 0; i < rule.style.length; i++) {\n    const styleDeclaration = rule.style;\n    const attribute = styleDeclaration[i];\n    const isImportant = styleDeclaration.getPropertyPriority(attribute);\n    styles += `${attribute}:${styleDeclaration.getPropertyValue(attribute)}${\n      isImportant ? ` !important` : ''\n    };`;\n  }\n\n  return `${rule.selectorText} { ${styles} }`;\n}\n\nexport function stringifyRule(rule: CSSRule): string {\n  let importStringified;\n  if (isCSSImportRule(rule)) {\n    try {\n      importStringified =\n        // for same-origin stylesheets,\n        // we can access the imported stylesheet rules directly\n        stringifyStylesheet(rule.styleSheet) ||\n        // work around browser issues with the raw string `@import url(...)` statement\n        escapeImportStatement(rule);\n    } catch (error) {\n      // ignore\n    }\n  } else if (isCSSStyleRule(rule)) {\n    let cssText = rule.cssText;\n    const needsSafariColonFix = rule.selectorText.includes(':');\n    const needsAllFix =\n      typeof rule.style['all'] === 'string' && rule.style['all'];\n\n    if (needsAllFix) {\n      cssText = fixAllCssProperty(rule);\n    }\n\n    if (needsSafariColonFix) {\n      // Safari does not escape selectors with : properly\n      // see https://bugs.webkit.org/show_bug.cgi?id=184604\n      //\n      // This needs to be after `fixAllCssProperty()` which requires a\n      // `CssStylRule` and generates a string (i.e. `cssText`) and the below\n      // operates on `cssText`\n      cssText = fixSafariColons(cssText);\n    }\n\n    if (needsSafariColonFix || needsAllFix) {\n      return cssText;\n    }\n  }\n\n  return importStringified || rule.cssText;\n}\n\nexport function fixSafariColons(cssStringified: string): string {\n  // Replace e.g. [aa:bb] with [aa\\\\:bb]\n  const regex = /(\\[(?:[\\w-]+)[^\\\\])(:(?:[\\w-]+)\\])/gm;\n  return cssStringified.replace(regex, '$1\\\\$2');\n}\n\nexport function isCSSImportRule(rule: CSSRule): rule is CSSImportRule {\n  return 'styleSheet' in rule;\n}\n\nexport function isCSSStyleRule(rule: CSSRule): rule is CSSStyleRule {\n  return 'selectorText' in rule;\n}\n\nexport class Mirror implements IMirror<Node> {\n  private idNodeMap: idNodeMap = new Map();\n  private nodeMetaMap: nodeMetaMap = new WeakMap();\n\n  getId(n: Node | undefined | null): number {\n    if (!n) return -1;\n\n    const id = this.getMeta(n)?.id;\n\n    // if n is not a serialized Node, use -1 as its id.\n    return id ?? -1;\n  }\n\n  getNode(id: number): Node | null {\n    return this.idNodeMap.get(id) || null;\n  }\n\n  getIds(): number[] {\n    return Array.from(this.idNodeMap.keys());\n  }\n\n  getMeta(n: Node): serializedNodeWithId | null {\n    return this.nodeMetaMap.get(n) || null;\n  }\n\n  // removes the node from idNodeMap\n  // doesn't remove the node from nodeMetaMap\n  removeNodeFromMap(n: Node) {\n    const id = this.getId(n);\n    this.idNodeMap.delete(id);\n\n    if (n.childNodes) {\n      n.childNodes.forEach((childNode) =>\n        this.removeNodeFromMap(childNode as unknown as Node),\n      );\n    }\n  }\n  has(id: number): boolean {\n    return this.idNodeMap.has(id);\n  }\n\n  hasNode(node: Node): boolean {\n    return this.nodeMetaMap.has(node);\n  }\n\n  add(n: Node, meta: serializedNodeWithId) {\n    const id = meta.id;\n    this.idNodeMap.set(id, n);\n    this.nodeMetaMap.set(n, meta);\n  }\n\n  replace(id: number, n: Node) {\n    const oldNode = this.getNode(id);\n    if (oldNode) {\n      const meta = this.nodeMetaMap.get(oldNode);\n      if (meta) this.nodeMetaMap.set(n, meta);\n    }\n    this.idNodeMap.set(id, n);\n  }\n\n  reset() {\n    this.idNodeMap = new Map();\n    this.nodeMetaMap = new WeakMap();\n  }\n}\n\nexport function createMirror(): Mirror {\n  return new Mirror();\n}\n\nexport function shouldMaskInput({\n  maskInputOptions,\n  tagName,\n  type,\n}: {\n  maskInputOptions: MaskInputOptions;\n  tagName: Uppercase<string>;\n  type: Lowercase<string> | null;\n}): boolean {\n  // Handle `option` like `select\n  if (tagName === 'OPTION') {\n    tagName = 'SELECT';\n  }\n  return Boolean(\n    maskInputOptions[tagName.toLowerCase() as keyof MaskInputOptions] ||\n      (type && maskInputOptions[type as keyof MaskInputOptions]) ||\n      type === 'password' ||\n      // Default to \"text\" option for inputs without a \"type\" attribute defined\n      (tagName === 'INPUT' && !type && maskInputOptions['text']),\n  );\n}\n\nexport function maskInputValue({\n  isMasked,\n  element,\n  value,\n  maskInputFn,\n}: {\n  isMasked: boolean;\n  element: HTMLElement;\n  value: string | null;\n  maskInputFn?: MaskInputFn;\n}): string {\n  let text = value || '';\n\n  if (!isMasked) {\n    return text;\n  }\n\n  if (maskInputFn) {\n    text = maskInputFn(text, element);\n  }\n\n  return '*'.repeat(text.length);\n}\n\nexport function toLowerCase<T extends string>(str: T): Lowercase<T> {\n  return str.toLowerCase() as unknown as Lowercase<T>;\n}\n\nexport function toUpperCase<T extends string>(str: T): Uppercase<T> {\n  return str.toUpperCase() as unknown as Uppercase<T>;\n}\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedGetImageData = {\n  [ORIGINAL_ATTRIBUTE_NAME]: CanvasImageData['getImageData'];\n} & CanvasImageData['getImageData'];\n\nexport function is2DCanvasBlank(canvas: HTMLCanvasElement): boolean {\n  const ctx = canvas.getContext('2d');\n  if (!ctx) return true;\n\n  const chunkSize = 50;\n\n  // get chunks of the canvas and check if it is blank\n  for (let x = 0; x < canvas.width; x += chunkSize) {\n    for (let y = 0; y < canvas.height; y += chunkSize) {\n      // eslint-disable-next-line @typescript-eslint/unbound-method\n      const getImageData = ctx.getImageData as PatchedGetImageData;\n      const originalGetImageData =\n        ORIGINAL_ATTRIBUTE_NAME in getImageData\n          ? getImageData[ORIGINAL_ATTRIBUTE_NAME]\n          : getImageData;\n      // by getting the canvas in chunks we avoid an expensive\n      // `getImageData` call that retrieves everything\n      // even if we can already tell from the first chunk(s) that\n      // the canvas isn't blank\n      const pixelBuffer = new Uint32Array(\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access\n        originalGetImageData.call(\n          ctx,\n          x,\n          y,\n          Math.min(chunkSize, canvas.width - x),\n          Math.min(chunkSize, canvas.height - y),\n        ).data.buffer,\n      );\n      if (pixelBuffer.some((pixel) => pixel !== 0)) return false;\n    }\n  }\n  return true;\n}\n\nexport function isNodeMetaEqual(a: serializedNode, b: serializedNode): boolean {\n  if (!a || !b || a.type !== b.type) return false;\n  if (a.type === NodeType.Document)\n    return a.compatMode === (b as documentNode).compatMode;\n  else if (a.type === NodeType.DocumentType)\n    return (\n      a.name === (b as documentTypeNode).name &&\n      a.publicId === (b as documentTypeNode).publicId &&\n      a.systemId === (b as documentTypeNode).systemId\n    );\n  else if (\n    a.type === NodeType.Comment ||\n    a.type === NodeType.Text ||\n    a.type === NodeType.CDATA\n  )\n    return a.textContent === (b as textNode).textContent;\n  else if (a.type === NodeType.Element)\n    return (\n      a.tagName === (b as elementNode).tagName &&\n      JSON.stringify(a.attributes) ===\n        JSON.stringify((b as elementNode).attributes) &&\n      a.isSVG === (b as elementNode).isSVG &&\n      a.needBlock === (b as elementNode).needBlock\n    );\n  return false;\n}\n\n/**\n * Get the type of an input element.\n * This takes care of the case where a password input is changed to a text input.\n * In this case, we continue to consider this of type password, in order to avoid leaking sensitive data\n * where passwords should be masked.\n */\nexport function getInputType(element: HTMLElement): Lowercase<string> | null {\n  // when omitting the type of input element(e.g. <input />), the type is treated as text\n  const type = (element as HTMLInputElement).type;\n\n  return element.hasAttribute('data-rr-is-password')\n    ? 'password'\n    : type\n    ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n      toLowerCase(type)\n    : null;\n}\n\nexport function getInputValue(\n  el:\n    | HTMLInputElement\n    | HTMLTextAreaElement\n    | HTMLSelectElement\n    | HTMLOptionElement,\n  tagName: Uppercase<string>,\n  type: Lowercase<string> | null,\n): string {\n  if (tagName === 'INPUT' && (type === 'radio' || type === 'checkbox')) {\n    // checkboxes & radio buttons return `on` as their el.value when no value is specified\n    // we only want to get the value if it is specified as `value='xxx'`\n    return el.getAttribute('value') || '';\n  }\n\n  return el.value;\n}\n\n/**\n * Extracts the file extension from an a path, considering search parameters and fragments.\n * @param path - Path to file\n * @param baseURL - [optional] Base URL of the page, used to resolve relative paths. Defaults to current page URL.\n */\nexport function extractFileExtension(\n  path: string,\n  baseURL?: string,\n): string | null {\n  let url;\n  try {\n    url = new URL(path, baseURL ?? window.location.href);\n  } catch (err) {\n    return null;\n  }\n  const regex = /\\.([0-9a-z]+)(?:$)/i;\n  const match = url.pathname.match(regex);\n  return match?.[1] ?? null;\n}\n\n/**\n * We generally want to use window.requestAnimationFrame / window.setTimeout / window.clearTimeout.\n * However, in some cases this may be wrapped (e.g. by Zone.js for Angular),\n * so we try to get an unpatched version of this from a sandboxed iframe.\n *\n * TODO(sentry): This is duplicated from rrweb utils, ideally we extract this to a new package.\n */\n\ninterface CacheableImplementations {\n  requestAnimationFrame: typeof requestAnimationFrame;\n  setTimeout: typeof setTimeout;\n  clearTimeout: typeof clearTimeout;\n}\n\nconst cachedImplementations: Partial<CacheableImplementations> = {};\n\nfunction getImplementation<T extends keyof CacheableImplementations>(\n  name: T,\n): CacheableImplementations[T] {\n  const cached = cachedImplementations[name];\n  if (cached) {\n    return cached;\n  }\n\n  const document = window.document;\n  let impl = window[name] as CacheableImplementations[T];\n  if (document && typeof document.createElement === 'function') {\n    try {\n      const sandbox = document.createElement('iframe');\n      sandbox.hidden = true;\n      document.head.appendChild(sandbox);\n      const contentWindow = sandbox.contentWindow;\n      if (contentWindow && contentWindow[name]) {\n        impl =\n          // eslint-disable-next-line @typescript-eslint/unbound-method\n          contentWindow[name] as CacheableImplementations[T];\n      }\n      document.head.removeChild(sandbox);\n    } catch (e) {\n      // Could not create sandbox iframe, just use window.xxx\n    }\n  }\n\n  return (cachedImplementations[name] = impl.bind(\n    window,\n  ) as CacheableImplementations[T]);\n}\n\nexport function onRequestAnimationFrame(\n  ...rest: Parameters<typeof requestAnimationFrame>\n): ReturnType<typeof requestAnimationFrame> {\n  return getImplementation('requestAnimationFrame')(...rest);\n}\n\nexport function setTimeout(\n  ...rest: Parameters<typeof window.setTimeout>\n): ReturnType<typeof window.setTimeout> {\n  return getImplementation('setTimeout')(...rest);\n}\n\nexport function clearTimeout(\n  ...rest: Parameters<typeof window.clearTimeout>\n): ReturnType<typeof window.clearTimeout> {\n  return getImplementation('clearTimeout')(...rest);\n}\n\n/**\n * Get the content document of an iframe.\n * Catching errors is necessary because some older browsers block access to the content document of a sandboxed iframe.\n */\nexport function getIFrameContentDocument(iframe?: HTMLIFrameElement) {\n  try {\n    return (iframe as HTMLIFrameElement).contentDocument;\n  } catch {\n    // noop\n  }\n}\n\n/**\n * Get the content window of an iframe.\n * Catching errors is necessary because iOS 18.5 Safari WebView throws SecurityError\n * when accessing contentWindow on cross-origin iframes (instead of returning null).\n */\nexport function getIFrameContentWindow(iframe?: HTMLIFrameElement) {\n  try {\n    return (iframe as HTMLIFrameElement).contentWindow;\n  } catch {\n    // noop\n  }\n}\n", "import {\n  serializedNode,\n  serializedNodeWithId,\n  NodeType,\n  attributes,\n  MaskInputOptions,\n  SlimDOMOptions,\n  DataURLOptions,\n  MaskTextFn,\n  MaskInputFn,\n  KeepIframeSrcFn,\n  ICanvas,\n  serializedElementNodeWithId,\n  MaskAttributeFn,\n} from './types';\nimport {\n  Mirror,\n  is2DCanvasBlank,\n  isElement,\n  isShadowRoot,\n  maskInputValue,\n  isNativeShadowDom,\n  stringifyStylesheet,\n  getInputType,\n  getInputValue,\n  toLowerCase,\n  extractFileExtension,\n  toUpperCase,\n  shouldMaskInput,\n  setTimeout,\n  clearTimeout,\n  getIFrameContentDocument,\n  getIFrameContentWindow,\n} from './utils';\n\nlet _id = 1;\nconst tagNameRegex = new RegExp('[^a-z0-9-_:]');\n\nexport const IGNORED_NODE = -2;\n\nexport function genId(): number {\n  return _id++;\n}\n\nfunction getValidTagName(element: HTMLElement): Lowercase<string> {\n  if (element instanceof HTMLFormElement) {\n    return 'form';\n  }\n\n  const processedTagName = toLowerCase(element.tagName);\n\n  if (tagNameRegex.test(processedTagName)) {\n    // if the tag name is odd and we cannot extract\n    // anything from the string, then we return a\n    // generic div\n    return 'div';\n  }\n\n  return processedTagName;\n}\n\nfunction extractOrigin(url: string): string {\n  let origin = '';\n  if (url.indexOf('//') > -1) {\n    origin = url.split('/').slice(0, 3).join('/');\n  } else {\n    origin = url.split('/')[0];\n  }\n  origin = origin.split('?')[0];\n  return origin;\n}\n\nlet canvasService: HTMLCanvasElement | null;\nlet canvasCtx: CanvasRenderingContext2D | null;\n\nconst URL_IN_CSS_REF = /url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm;\nconst URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\\/\\//i;\nconst URL_WWW_MATCH = /^www\\..*/i;\nconst DATA_URI = /^(data:)([^,]*),(.*)/i;\nexport function filterCSSPropertiesFromInlineStyle(\n  cssText: string,\n  ignoredProperties: Set<string>,\n): string {\n  if (!cssText || ignoredProperties.size === 0) {\n    return cssText;\n  }\n\n  try {\n    // Split CSS by semicolons to get individual property-value pairs\n    const properties = cssText.split(';');\n    const filteredProperties = [];\n\n    for (let property of properties) {\n      property = property.trim();\n      if (!property) continue;\n\n      const colonIndex = property.indexOf(':');\n      if (colonIndex === -1) {\n        // Invalid property, keep it as is\n        filteredProperties.push(property);\n        continue;\n      }\n\n      const propertyName = property.slice(0, colonIndex).trim();\n\n      // If this property is not in the ignore set, keep it\n      if (!ignoredProperties.has(propertyName)) {\n        filteredProperties.push(property);\n      }\n    }\n\n    return (\n      filteredProperties.join('; ') +\n      (filteredProperties.length > 0 && cssText.endsWith(';') ? ';' : '')\n    );\n  } catch (error) {\n    console.warn('Error filtering CSS properties:', error);\n    return cssText;\n  }\n}\n\nexport function absoluteToStylesheet(\n  cssText: string | null,\n  href: string,\n): string {\n  return (cssText || '').replace(\n    URL_IN_CSS_REF,\n    (\n      origin: string,\n      quote1: string,\n      path1: string,\n      quote2: string,\n      path2: string,\n      path3: string,\n    ) => {\n      const filePath = path1 || path2 || path3;\n      const maybeQuote = quote1 || quote2 || '';\n      if (!filePath) {\n        return origin;\n      }\n      if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {\n        return `url(${maybeQuote}${filePath}${maybeQuote})`;\n      }\n      if (DATA_URI.test(filePath)) {\n        return `url(${maybeQuote}${filePath}${maybeQuote})`;\n      }\n      if (filePath[0] === '/') {\n        return `url(${maybeQuote}${\n          extractOrigin(href) + filePath\n        }${maybeQuote})`;\n      }\n      const stack = href.split('/');\n      const parts = filePath.split('/');\n      stack.pop();\n      for (const part of parts) {\n        if (part === '.') {\n          continue;\n        } else if (part === '..') {\n          stack.pop();\n        } else {\n          stack.push(part);\n        }\n      }\n      return `url(${maybeQuote}${stack.join('/')}${maybeQuote})`;\n    },\n  );\n}\n\n// eslint-disable-next-line no-control-regex\nconst SRCSET_NOT_SPACES = /^[^ \\t\\n\\r\\u000c]+/; // Don't use \\s, to avoid matching non-breaking space\n// eslint-disable-next-line no-control-regex\nconst SRCSET_COMMAS_OR_SPACES = /^[, \\t\\n\\r\\u000c]+/;\nfunction getAbsoluteSrcsetString(doc: Document, attributeValue: string) {\n  /*\n    run absoluteToDoc over every url in the srcset\n\n    this is adapted from https://github.com/albell/parse-srcset/\n    without the parsing of the descriptors (we return these as-is)\n    parce-srcset is in turn based on\n    https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute\n  */\n  if (attributeValue.trim() === '') {\n    return attributeValue;\n  }\n\n  let pos = 0;\n\n  function collectCharacters(regEx: RegExp) {\n    let chars: string;\n    const match = regEx.exec(attributeValue.substring(pos));\n    if (match) {\n      chars = match[0];\n      pos += chars.length;\n      return chars;\n    }\n    return '';\n  }\n\n  const output = [];\n  // eslint-disable-next-line no-constant-condition\n  while (true) {\n    collectCharacters(SRCSET_COMMAS_OR_SPACES);\n    if (pos >= attributeValue.length) {\n      break;\n    }\n    // don't split on commas within urls\n    let url = collectCharacters(SRCSET_NOT_SPACES);\n    if (url.slice(-1) === ',') {\n      // aside: according to spec more than one comma at the end is a parse error, but we ignore that\n      url = absoluteToDoc(doc, url.substring(0, url.length - 1));\n      // the trailing comma splits the srcset, so the interpretion is that\n      // another url will follow, and the descriptor is empty\n      output.push(url);\n    } else {\n      let descriptorsStr = '';\n      url = absoluteToDoc(doc, url);\n      let inParens = false;\n      // eslint-disable-next-line no-constant-condition\n      while (true) {\n        const c = attributeValue.charAt(pos);\n        if (c === '') {\n          output.push((url + descriptorsStr).trim());\n          break;\n        } else if (!inParens) {\n          if (c === ',') {\n            pos += 1;\n            output.push((url + descriptorsStr).trim());\n            break; // parse the next url\n          } else if (c === '(') {\n            inParens = true;\n          }\n        } else {\n          // in parenthesis; ignore commas\n          // (parenthesis may be supported by future additions to spec)\n          if (c === ')') {\n            inParens = false;\n          }\n        }\n        descriptorsStr += c;\n        pos += 1;\n      }\n    }\n  }\n  return output.join(', ');\n}\n\nconst cachedDocument = new WeakMap<Document, HTMLAnchorElement>();\n\nexport function absoluteToDoc(doc: Document, attributeValue: string): string {\n  if (!attributeValue || attributeValue.trim() === '') {\n    return attributeValue;\n  }\n\n  return getHref(doc, attributeValue);\n}\n\nfunction isSVGElement(el: Element): boolean {\n  return Boolean(el.tagName === 'svg' || (el as SVGElement).ownerSVGElement);\n}\n\nfunction getHref(doc: Document, customHref?: string) {\n  let a = cachedDocument.get(doc);\n  if (!a) {\n    a = doc.createElement('a');\n    cachedDocument.set(doc, a);\n  }\n  if (!customHref) {\n    customHref = '';\n  } else if (customHref.startsWith('blob:') || customHref.startsWith('data:')) {\n    return customHref;\n  }\n  // note: using `new URL` is slower. See #1434 or https://jsbench.me/uqlud17rxo/1\n  a.setAttribute('href', customHref);\n  return a.href;\n}\n\nexport function transformAttribute(\n  doc: Document,\n  tagName: Lowercase<string>,\n  name: Lowercase<string>,\n  value: string | null,\n  element: HTMLElement,\n  maskAttributeFn: MaskAttributeFn | undefined,\n  ignoreCSSAttributes?: Set<string>,\n): string | null {\n  if (!value) {\n    return value;\n  }\n\n  // relative path in attribute\n  if (\n    name === 'src' ||\n    (name === 'href' && !(tagName === 'use' && value[0] === '#'))\n  ) {\n    // href starts with a # is an id pointer for svg\n    return absoluteToDoc(doc, value);\n  } else if (name === 'xlink:href' && value[0] !== '#') {\n    // xlink:href starts with # is an id pointer\n    return absoluteToDoc(doc, value);\n  } else if (\n    name === 'background' &&\n    (tagName === 'table' || tagName === 'td' || tagName === 'th')\n  ) {\n    return absoluteToDoc(doc, value);\n  } else if (name === 'srcset') {\n    return getAbsoluteSrcsetString(doc, value);\n  } else if (name === 'style') {\n    let processedStyle = absoluteToStylesheet(value, getHref(doc));\n    if (ignoreCSSAttributes && ignoreCSSAttributes.size > 0) {\n      processedStyle = filterCSSPropertiesFromInlineStyle(\n        processedStyle,\n        ignoreCSSAttributes,\n      );\n    }\n    return processedStyle;\n  } else if (tagName === 'object' && name === 'data') {\n    return absoluteToDoc(doc, value);\n  }\n\n  // Custom attribute masking\n  if (typeof maskAttributeFn === 'function') {\n    return maskAttributeFn(name, value, element);\n  }\n\n  return value;\n}\n\nexport function ignoreAttribute(\n  tagName: string,\n  name: string,\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  _value: unknown,\n): boolean {\n  return (tagName === 'video' || tagName === 'audio') && name === 'autoplay';\n}\n\nexport function _isBlockedElement(\n  element: HTMLElement,\n  blockClass: string | RegExp,\n  blockSelector: string | null,\n  unblockSelector: string | null,\n): boolean {\n  try {\n    if (unblockSelector && element.matches(unblockSelector)) {\n      return false;\n    }\n\n    if (typeof blockClass === 'string') {\n      if (element.classList.contains(blockClass)) {\n        return true;\n      }\n    } else {\n      for (let eIndex = element.classList.length; eIndex--; ) {\n        const className = element.classList[eIndex];\n        if (blockClass.test(className)) {\n          return true;\n        }\n      }\n    }\n    if (blockSelector) {\n      return element.matches(blockSelector);\n    }\n  } catch (e) {\n    //\n  }\n\n  return false;\n}\n\nfunction elementClassMatchesRegex(el: HTMLElement, regex: RegExp): boolean {\n  for (let eIndex = el.classList.length; eIndex--; ) {\n    const className = el.classList[eIndex];\n    if (regex.test(className)) {\n      return true;\n    }\n  }\n  return false;\n}\n\nexport function classMatchesRegex(\n  node: Node | null,\n  regex: RegExp,\n  checkAncestors: boolean,\n): boolean {\n  if (!node) return false;\n  if (checkAncestors) {\n    return (\n      distanceToMatch(node, (node) =>\n        elementClassMatchesRegex(node as HTMLElement, regex),\n      ) >= 0\n    );\n  } else if (node.nodeType === node.ELEMENT_NODE) {\n    return elementClassMatchesRegex(node as HTMLElement, regex);\n  }\n  return false;\n}\n\nexport function distanceToMatch(\n  node: Node | null,\n  matchPredicate: (node: Node) => boolean,\n  limit = Infinity,\n  distance = 0,\n): number {\n  if (!node) return -1;\n  if (node.nodeType !== node.ELEMENT_NODE) return -1;\n  if (distance > limit) return -1;\n  if (matchPredicate(node)) return distance;\n  return distanceToMatch(node.parentNode, matchPredicate, limit, distance + 1);\n}\n\nexport function createMatchPredicate(\n  className: string | RegExp | null,\n  selector: string | null,\n): (node: Node) => boolean {\n  return (node: Node) => {\n    const el = node as HTMLElement;\n    if (el === null) return false;\n\n    try {\n      if (className) {\n        if (typeof className === 'string') {\n          if (el.matches(`.${className}`)) return true;\n        } else if (elementClassMatchesRegex(el, className)) {\n          return true;\n        }\n      }\n\n      if (selector && el.matches(selector)) return true;\n\n      return false;\n    } catch {\n      return false;\n    }\n  };\n}\n\nexport function needMaskingText(\n  node: Node,\n  maskTextClass: string | RegExp,\n  maskTextSelector: string | null,\n  unmaskTextClass: string | RegExp | null,\n  unmaskTextSelector: string | null,\n  maskAllText: boolean,\n): boolean {\n  try {\n    const el: HTMLElement | null =\n      node.nodeType === node.ELEMENT_NODE\n        ? (node as HTMLElement)\n        : node.parentElement;\n    if (el === null) return false;\n\n    if (el.tagName === 'INPUT') {\n      // Special cases: We want to enforce some masking for password & credit-card related fields,\n      // no matter the settings\n      const autocomplete = el.getAttribute('autocomplete');\n      const disallowedAutocompleteValues = [\n        'current-password',\n        'new-password',\n        'cc-number',\n        'cc-exp',\n        'cc-exp-month',\n        'cc-exp-year',\n        'cc-csc',\n      ];\n      if (disallowedAutocompleteValues.includes(autocomplete as string)) {\n        return true;\n      }\n    }\n\n    let maskDistance = -1;\n    let unmaskDistance = -1;\n\n    if (maskAllText) {\n      unmaskDistance = distanceToMatch(\n        el,\n        createMatchPredicate(unmaskTextClass, unmaskTextSelector),\n      );\n\n      if (unmaskDistance < 0) {\n        return true;\n      }\n\n      maskDistance = distanceToMatch(\n        el,\n        createMatchPredicate(maskTextClass, maskTextSelector),\n        unmaskDistance >= 0 ? unmaskDistance : Infinity,\n      );\n    } else {\n      maskDistance = distanceToMatch(\n        el,\n        createMatchPredicate(maskTextClass, maskTextSelector),\n      );\n\n      if (maskDistance < 0) {\n        return false;\n      }\n\n      unmaskDistance = distanceToMatch(\n        el,\n        createMatchPredicate(unmaskTextClass, unmaskTextSelector),\n        maskDistance >= 0 ? maskDistance : Infinity,\n      );\n    }\n\n    return maskDistance >= 0\n      ? unmaskDistance >= 0\n        ? maskDistance <= unmaskDistance\n        : true\n      : unmaskDistance >= 0\n      ? false\n      : !!maskAllText;\n  } catch (e) {\n    //\n  }\n\n  return !!maskAllText;\n}\n\n// https://stackoverflow.com/a/36155560\nfunction onceIframeLoaded(\n  iframeEl: HTMLIFrameElement,\n  listener: () => unknown,\n  iframeLoadTimeout: number,\n) {\n  const win = getIFrameContentWindow(iframeEl);\n  if (!win) {\n    return;\n  }\n  // document is loading\n  let fired = false;\n\n  let readyState: DocumentReadyState;\n  try {\n    readyState = win.document.readyState;\n  } catch (error) {\n    return;\n  }\n  if (readyState !== 'complete') {\n    const timer = setTimeout(() => {\n      if (!fired) {\n        listener();\n        fired = true;\n      }\n    }, iframeLoadTimeout);\n    iframeEl.addEventListener('load', () => {\n      clearTimeout(timer);\n      fired = true;\n      listener();\n    });\n    return;\n  }\n  // check blank frame for Chrome\n  const blankUrl = 'about:blank';\n  if (\n    win.location.href !== blankUrl ||\n    iframeEl.src === blankUrl ||\n    iframeEl.src === ''\n  ) {\n    // iframe was already loaded, make sure we wait to trigger the listener\n    // till _after_ the mutation that found this iframe has had time to process\n    setTimeout(listener, 0);\n\n    return iframeEl.addEventListener('load', listener); // keep listing for future loads\n  }\n  // use default listener\n  iframeEl.addEventListener('load', listener);\n}\n\nfunction onceStylesheetLoaded(\n  link: HTMLLinkElement,\n  listener: () => unknown,\n  styleSheetLoadTimeout: number,\n) {\n  let fired = false;\n  let styleSheetLoaded: StyleSheet | null;\n  try {\n    styleSheetLoaded = link.sheet;\n  } catch (error) {\n    // CORS stylesheets throw SecurityError when accessing .sheet\n    // before they're loaded — fall through to attach load listener\n    styleSheetLoaded = null;\n  }\n\n  if (styleSheetLoaded) return;\n\n  const timer = setTimeout(() => {\n    if (!fired) {\n      listener();\n      fired = true;\n    }\n  }, styleSheetLoadTimeout);\n\n  link.addEventListener('load', () => {\n    clearTimeout(timer);\n    fired = true;\n    listener();\n  });\n}\n\nfunction serializeNode(\n  n: Node,\n  options: {\n    doc: Document;\n    mirror: Mirror;\n    blockClass: string | RegExp;\n    blockSelector: string | null;\n    unblockSelector: string | null;\n    maskAllText: boolean;\n    maskAttributeFn: MaskAttributeFn | undefined;\n    maskTextClass: string | RegExp;\n    unmaskTextClass: string | RegExp | null;\n    maskTextSelector: string | null;\n    unmaskTextSelector: string | null;\n    inlineStylesheet: boolean;\n    maskInputOptions: MaskInputOptions;\n    maskTextFn: MaskTextFn | undefined;\n    maskInputFn: MaskInputFn | undefined;\n    dataURLOptions?: DataURLOptions;\n    inlineImages: boolean;\n    recordCanvas: boolean;\n    keepIframeSrcFn: KeepIframeSrcFn;\n    /**\n     * `newlyAddedElement: true` skips scrollTop and scrollLeft check\n     */\n    newlyAddedElement?: boolean;\n    ignoreCSSAttributes?: Set<string>;\n  },\n): serializedNode | false {\n  const {\n    doc,\n    mirror,\n    blockClass,\n    blockSelector,\n    unblockSelector,\n    maskAllText,\n    maskAttributeFn,\n    maskTextClass,\n    unmaskTextClass,\n    maskTextSelector,\n    unmaskTextSelector,\n    inlineStylesheet,\n    maskInputOptions = {},\n    maskTextFn,\n    maskInputFn,\n    dataURLOptions = {},\n    inlineImages,\n    recordCanvas,\n    keepIframeSrcFn,\n    newlyAddedElement = false,\n    ignoreCSSAttributes,\n  } = options;\n  // Only record root id when document object is not the base document\n  const rootId = getRootId(doc, mirror);\n  switch (n.nodeType) {\n    case n.DOCUMENT_NODE:\n      if ((n as Document).compatMode !== 'CSS1Compat') {\n        return {\n          type: NodeType.Document,\n          childNodes: [],\n          compatMode: (n as Document).compatMode, // probably \"BackCompat\"\n        };\n      } else {\n        return {\n          type: NodeType.Document,\n          childNodes: [],\n        };\n      }\n    case n.DOCUMENT_TYPE_NODE:\n      return {\n        type: NodeType.DocumentType,\n        name: (n as DocumentType).name,\n        publicId: (n as DocumentType).publicId,\n        systemId: (n as DocumentType).systemId,\n        rootId,\n      };\n    case n.ELEMENT_NODE:\n      return serializeElementNode(n as HTMLElement, {\n        doc,\n        blockClass,\n        blockSelector,\n        unblockSelector,\n        inlineStylesheet,\n        maskAttributeFn,\n        maskInputOptions,\n        maskInputFn,\n        dataURLOptions,\n        inlineImages,\n        recordCanvas,\n        keepIframeSrcFn,\n        newlyAddedElement,\n        rootId,\n        maskAllText,\n        maskTextClass,\n        unmaskTextClass,\n        maskTextSelector,\n        unmaskTextSelector,\n        ignoreCSSAttributes,\n      });\n    case n.TEXT_NODE:\n      return serializeTextNode(n as Text, {\n        doc,\n        maskAllText,\n        maskTextClass,\n        unmaskTextClass,\n        maskTextSelector,\n        unmaskTextSelector,\n        maskTextFn,\n        maskInputOptions,\n        maskInputFn,\n        rootId,\n      });\n    case n.CDATA_SECTION_NODE:\n      return {\n        type: NodeType.CDATA,\n        textContent: '',\n        rootId,\n      };\n    case n.COMMENT_NODE:\n      return {\n        type: NodeType.Comment,\n        textContent: (n as Comment).textContent || '',\n        rootId,\n      };\n    default:\n      return false;\n  }\n}\n\nfunction getRootId(doc: Document, mirror: Mirror): number | undefined {\n  if (!mirror.hasNode(doc)) return undefined;\n  const docId = mirror.getId(doc);\n  return docId === 1 ? undefined : docId;\n}\n\nfunction serializeTextNode(\n  n: Text,\n  options: {\n    doc: Document;\n    maskAllText: boolean;\n    maskTextClass: string | RegExp;\n    unmaskTextClass: string | RegExp | null;\n    maskTextSelector: string | null;\n    unmaskTextSelector: string | null;\n    maskTextFn: MaskTextFn | undefined;\n    maskInputOptions: MaskInputOptions;\n    maskInputFn: MaskInputFn | undefined;\n    rootId: number | undefined;\n  },\n): serializedNode {\n  const {\n    maskAllText,\n    maskTextClass,\n    unmaskTextClass,\n    maskTextSelector,\n    unmaskTextSelector,\n    maskTextFn,\n    maskInputOptions,\n    maskInputFn,\n    rootId,\n  } = options;\n  // The parent node may not be a html element which has a tagName attribute.\n  // So just let it be undefined which is ok in this use case.\n  const parentTagName = n.parentNode && (n.parentNode as HTMLElement).tagName;\n  let textContent = n.textContent;\n  const isStyle = parentTagName === 'STYLE' ? true : undefined;\n  const isScript = parentTagName === 'SCRIPT' ? true : undefined;\n  const isTextarea = parentTagName === 'TEXTAREA' ? true : undefined;\n  if (isStyle && textContent) {\n    try {\n      // try to read style sheet\n      if (n.nextSibling || n.previousSibling) {\n        // This is not the only child of the stylesheet.\n        // We can't read all of the sheet's .cssRules and expect them\n        // to _only_ include the current rule(s) added by the text node.\n        // So we'll be conservative and keep textContent as-is.\n      } else if ((n.parentNode as HTMLStyleElement).sheet?.cssRules) {\n        textContent = stringifyStylesheet(\n          (n.parentNode as HTMLStyleElement).sheet!,\n        );\n      }\n    } catch (err) {\n      console.warn(\n        `Cannot get CSS styles from text's parentNode. Error: ${err as string}`,\n        n,\n      );\n    }\n    textContent = absoluteToStylesheet(textContent, getHref(options.doc));\n  }\n  if (isScript) {\n    textContent = 'SCRIPT_PLACEHOLDER';\n  }\n  const forceMask = needMaskingText(\n    n,\n    maskTextClass,\n    maskTextSelector,\n    unmaskTextClass,\n    unmaskTextSelector,\n    maskAllText,\n  );\n\n  if (!isStyle && !isScript && !isTextarea && textContent && forceMask) {\n    textContent = maskTextFn\n      ? maskTextFn(textContent, n.parentElement)\n      : textContent.replace(/[\\S]/g, '*');\n  }\n  if (isTextarea && textContent && (maskInputOptions.textarea || forceMask)) {\n    textContent = maskInputFn\n      ? maskInputFn(textContent, n.parentNode as HTMLElement)\n      : textContent.replace(/[\\S]/g, '*');\n  }\n\n  // Handle <option> text like an input value\n  if (parentTagName === 'OPTION' && textContent) {\n    const isInputMasked = shouldMaskInput({\n      type: null,\n      tagName: parentTagName,\n      maskInputOptions,\n    });\n\n    textContent = maskInputValue({\n      isMasked: needMaskingText(\n        n,\n        maskTextClass,\n        maskTextSelector,\n        unmaskTextClass,\n        unmaskTextSelector,\n        isInputMasked,\n      ),\n      element: n as unknown as HTMLElement,\n      value: textContent,\n      maskInputFn,\n    });\n  }\n\n  return {\n    type: NodeType.Text,\n    textContent: textContent || '',\n    isStyle,\n    rootId,\n  };\n}\n\nfunction serializeElementNode(\n  n: HTMLElement,\n  options: {\n    doc: Document;\n    blockClass: string | RegExp;\n    blockSelector: string | null;\n    unblockSelector: string | null;\n    inlineStylesheet: boolean;\n    maskAttributeFn: MaskAttributeFn | undefined;\n    maskInputOptions: MaskInputOptions;\n    maskInputFn: MaskInputFn | undefined;\n    dataURLOptions?: DataURLOptions;\n    inlineImages: boolean;\n    recordCanvas: boolean;\n    keepIframeSrcFn: KeepIframeSrcFn;\n    /**\n     * `newlyAddedElement: true` skips scrollTop and scrollLeft check\n     */\n    newlyAddedElement?: boolean;\n    rootId: number | undefined;\n    maskAllText: boolean;\n    maskTextClass: string | RegExp;\n    unmaskTextClass: string | RegExp | null;\n    maskTextSelector: string | null;\n    unmaskTextSelector: string | null;\n    ignoreCSSAttributes?: Set<string>;\n  },\n): serializedNode | false {\n  const {\n    doc,\n    blockClass,\n    blockSelector,\n    unblockSelector,\n    inlineStylesheet,\n    maskInputOptions = {},\n    maskAttributeFn,\n    maskInputFn,\n    dataURLOptions = {},\n    inlineImages,\n    recordCanvas,\n    keepIframeSrcFn,\n    newlyAddedElement = false,\n    rootId,\n    maskTextClass,\n    unmaskTextClass,\n    maskTextSelector,\n    unmaskTextSelector,\n    ignoreCSSAttributes,\n  } = options;\n  const needBlock = _isBlockedElement(\n    n,\n    blockClass,\n    blockSelector,\n    unblockSelector,\n  );\n  const tagName = getValidTagName(n);\n  let attributes: attributes = {};\n  const len = n.attributes.length;\n  for (let i = 0; i < len; i++) {\n    const attr = n.attributes[i];\n    // Looks like `attr.name` can be undefined although the types say differently\n    // see: https://github.com/getsentry/sentry-javascript/issues/10292\n    if (attr.name && !ignoreAttribute(tagName, attr.name, attr.value)) {\n      attributes[attr.name] = transformAttribute(\n        doc,\n        tagName,\n        toLowerCase(attr.name),\n        attr.value,\n        n,\n        maskAttributeFn,\n        ignoreCSSAttributes,\n      );\n    }\n  }\n  // remote css\n  if (tagName === 'link' && inlineStylesheet) {\n    const stylesheet = Array.from(doc.styleSheets).find((s) => {\n      return s.href === (n as HTMLLinkElement).href;\n    });\n    let cssText: string | null = null;\n    if (stylesheet) {\n      cssText = stringifyStylesheet(stylesheet);\n    }\n    if (cssText) {\n      attributes.rel = null;\n      attributes.href = null;\n      attributes.crossorigin = null;\n      attributes._cssText = absoluteToStylesheet(cssText, stylesheet!.href!);\n    }\n  }\n  // dynamic stylesheet\n  if (\n    tagName === 'style' &&\n    (n as HTMLStyleElement).sheet &&\n    // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element\n    !(n.innerText || n.textContent || '').trim().length\n  ) {\n    const cssText = stringifyStylesheet(\n      (n as HTMLStyleElement).sheet as CSSStyleSheet,\n    );\n    if (cssText) {\n      attributes._cssText = absoluteToStylesheet(cssText, getHref(doc));\n    }\n  }\n  // form fields\n  if (\n    tagName === 'input' ||\n    tagName === 'textarea' ||\n    tagName === 'select' ||\n    tagName === 'option'\n  ) {\n    const el = n as\n      | HTMLInputElement\n      | HTMLTextAreaElement\n      | HTMLSelectElement\n      | HTMLOptionElement;\n\n    const type = getInputType(el);\n    const value = getInputValue(el, toUpperCase(tagName), type);\n    const checked = (el as HTMLInputElement).checked;\n    if (type !== 'submit' && type !== 'button' && value) {\n      const forceMask = needMaskingText(\n        el,\n        maskTextClass,\n        maskTextSelector,\n        unmaskTextClass,\n        unmaskTextSelector,\n        shouldMaskInput({\n          type,\n          tagName: toUpperCase(tagName),\n          maskInputOptions,\n        }),\n      );\n\n      attributes.value = maskInputValue({\n        isMasked: forceMask,\n        element: el,\n        value,\n        maskInputFn,\n      });\n    }\n    if (checked) {\n      attributes.checked = checked;\n    }\n  }\n  if (tagName === 'option') {\n    if ((n as HTMLOptionElement).selected && !maskInputOptions['select']) {\n      attributes.selected = true;\n    } else {\n      // ignore the html attribute (which corresponds to DOM (n as HTMLOptionElement).defaultSelected)\n      // if it's already been changed\n      delete attributes.selected;\n    }\n  }\n  // canvas image data\n  if (tagName === 'canvas' && recordCanvas) {\n    if ((n as ICanvas).__context === '2d') {\n      // only record this on 2d canvas\n      if (!is2DCanvasBlank(n as HTMLCanvasElement)) {\n        attributes.rr_dataURL = (n as HTMLCanvasElement).toDataURL(\n          dataURLOptions.type,\n          dataURLOptions.quality,\n        );\n      }\n    } else if (!('__context' in n)) {\n      // context is unknown, better not call getContext to trigger it\n      const canvasDataURL = (n as HTMLCanvasElement).toDataURL(\n        dataURLOptions.type,\n        dataURLOptions.quality,\n      );\n\n      // create blank canvas of same dimensions\n      const blankCanvas = doc.createElement('canvas');\n      blankCanvas.width = (n as HTMLCanvasElement).width;\n      blankCanvas.height = (n as HTMLCanvasElement).height;\n      const blankCanvasDataURL = blankCanvas.toDataURL(\n        dataURLOptions.type,\n        dataURLOptions.quality,\n      );\n\n      // no need to save dataURL if it's the same as blank canvas\n      if (canvasDataURL !== blankCanvasDataURL) {\n        attributes.rr_dataURL = canvasDataURL;\n      }\n    }\n  }\n  // save image offline\n  if (tagName === 'img' && inlineImages) {\n    if (!canvasService) {\n      canvasService = doc.createElement('canvas');\n      canvasCtx = canvasService.getContext('2d');\n    }\n    const image = n as HTMLImageElement;\n    const imageSrc: string =\n      image.currentSrc || image.getAttribute('src') || '<unknown-src>';\n    const priorCrossOrigin = image.crossOrigin;\n    const recordInlineImage = () => {\n      image.removeEventListener('load', recordInlineImage);\n      try {\n        canvasService!.width = image.naturalWidth;\n        canvasService!.height = image.naturalHeight;\n        canvasCtx!.drawImage(image, 0, 0);\n        attributes.rr_dataURL = canvasService!.toDataURL(\n          dataURLOptions.type,\n          dataURLOptions.quality,\n        );\n      } catch (err) {\n        if (image.crossOrigin !== 'anonymous') {\n          image.crossOrigin = 'anonymous';\n          if (image.complete && image.naturalWidth !== 0)\n            recordInlineImage(); // too early due to image reload\n          else image.addEventListener('load', recordInlineImage);\n          return;\n        } else {\n          console.warn(\n            `Cannot inline img src=${imageSrc}! Error: ${err as string}`,\n          );\n        }\n      }\n      if (image.crossOrigin === 'anonymous') {\n        priorCrossOrigin\n          ? (attributes.crossOrigin = priorCrossOrigin)\n          : image.removeAttribute('crossorigin');\n      }\n    };\n    // The image content may not have finished loading yet.\n    if (image.complete && image.naturalWidth !== 0) recordInlineImage();\n    else image.addEventListener('load', recordInlineImage);\n  }\n  // media elements\n  if (tagName === 'audio' || tagName === 'video') {\n    attributes.rr_mediaState = (n as HTMLMediaElement).paused\n      ? 'paused'\n      : 'played';\n    attributes.rr_mediaCurrentTime = (n as HTMLMediaElement).currentTime;\n  }\n  // Scroll\n  if (!newlyAddedElement) {\n    // `scrollTop` and `scrollLeft` are expensive calls because they trigger reflow.\n    // Since `scrollTop` & `scrollLeft` are always 0 when an element is added to the DOM.\n    // And scrolls also get picked up by rrweb's ScrollObserver\n    // So we can safely skip the `scrollTop/Left` calls for newly added elements\n    if (n.scrollLeft) {\n      attributes.rr_scrollLeft = n.scrollLeft;\n    }\n    if (n.scrollTop) {\n      attributes.rr_scrollTop = n.scrollTop;\n    }\n  }\n  // block element\n  if (needBlock) {\n    const { width, height } = n.getBoundingClientRect();\n    attributes = {\n      class: attributes.class,\n      rr_width: `${width}px`,\n      rr_height: `${height}px`,\n    };\n  }\n  // iframe\n  if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src as string)) {\n    // Don't try to access `contentDocument` if iframe is blocked, otherwise it\n    // will trigger browser warnings.\n    if (!needBlock && !getIFrameContentDocument(n as HTMLIFrameElement)) {\n      // we can't record it directly as we can't see into it\n      // preserve the src attribute so a decision can be taken at replay time\n      attributes.rr_src = attributes.src;\n    }\n    delete attributes.src; // prevent auto loading\n  }\n\n  let isCustomElement: true | undefined;\n  try {\n    if (customElements.get(tagName)) isCustomElement = true;\n  } catch (e) {\n    // In case old browsers don't support customElements\n  }\n\n  return {\n    type: NodeType.Element,\n    tagName,\n    attributes,\n    childNodes: [],\n    isSVG: isSVGElement(n as Element) || undefined,\n    needBlock,\n    rootId,\n    isCustom: isCustomElement,\n  };\n}\n\nfunction lowerIfExists(\n  maybeAttr: string | number | boolean | undefined | null,\n): string {\n  if (maybeAttr === undefined || maybeAttr === null) {\n    return '';\n  } else {\n    return (maybeAttr as string).toLowerCase();\n  }\n}\n\nfunction slimDOMExcluded(\n  sn: serializedNode,\n  slimDOMOptions: SlimDOMOptions,\n): boolean {\n  if (slimDOMOptions.comment && sn.type === NodeType.Comment) {\n    // TODO: convert IE conditional comments to real nodes\n    return true;\n  } else if (sn.type === NodeType.Element) {\n    if (\n      slimDOMOptions.script &&\n      // script tag\n      (sn.tagName === 'script' ||\n        // (module)preload link\n        (sn.tagName === 'link' &&\n          (sn.attributes.rel === 'preload' ||\n            sn.attributes.rel === 'modulepreload')) ||\n        // prefetch link\n        (sn.tagName === 'link' &&\n          sn.attributes.rel === 'prefetch' &&\n          typeof sn.attributes.href === 'string' &&\n          extractFileExtension(sn.attributes.href) === 'js'))\n    ) {\n      return true;\n    } else if (\n      slimDOMOptions.headFavicon &&\n      ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||\n        (sn.tagName === 'meta' &&\n          (lowerIfExists(sn.attributes.name).match(\n            /^msapplication-tile(image|color)$/,\n          ) ||\n            lowerIfExists(sn.attributes.name) === 'application-name' ||\n            lowerIfExists(sn.attributes.rel) === 'icon' ||\n            lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||\n            lowerIfExists(sn.attributes.rel) === 'shortcut icon')))\n    ) {\n      return true;\n    } else if (sn.tagName === 'meta') {\n      if (\n        slimDOMOptions.headMetaDescKeywords &&\n        lowerIfExists(sn.attributes.name).match(/^description|keywords$/)\n      ) {\n        return true;\n      } else if (\n        slimDOMOptions.headMetaSocial &&\n        (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)\n          lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||\n          lowerIfExists(sn.attributes.name) === 'pinterest')\n      ) {\n        return true;\n      } else if (\n        slimDOMOptions.headMetaRobots &&\n        (lowerIfExists(sn.attributes.name) === 'robots' ||\n          lowerIfExists(sn.attributes.name) === 'googlebot' ||\n          lowerIfExists(sn.attributes.name) === 'bingbot')\n      ) {\n        return true;\n      } else if (\n        slimDOMOptions.headMetaHttpEquiv &&\n        sn.attributes['http-equiv'] !== undefined\n      ) {\n        // e.g. X-UA-Compatible, Content-Type, Content-Language,\n        // cache-control, X-Translated-By\n        return true;\n      } else if (\n        slimDOMOptions.headMetaAuthorship &&\n        (lowerIfExists(sn.attributes.name) === 'author' ||\n          lowerIfExists(sn.attributes.name) === 'generator' ||\n          lowerIfExists(sn.attributes.name) === 'framework' ||\n          lowerIfExists(sn.attributes.name) === 'publisher' ||\n          lowerIfExists(sn.attributes.name) === 'progid' ||\n          lowerIfExists(sn.attributes.property).match(/^article:/) ||\n          lowerIfExists(sn.attributes.property).match(/^product:/))\n      ) {\n        return true;\n      } else if (\n        slimDOMOptions.headMetaVerification &&\n        (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||\n          lowerIfExists(sn.attributes.name) === 'yandex-verification' ||\n          lowerIfExists(sn.attributes.name) === 'csrf-token' ||\n          lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||\n          lowerIfExists(sn.attributes.name) === 'verify-v1' ||\n          lowerIfExists(sn.attributes.name) === 'verification' ||\n          lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')\n      ) {\n        return true;\n      }\n    }\n  }\n  return false;\n}\n\nexport function serializeNodeWithId(\n  n: Node,\n  options: {\n    doc: Document;\n    mirror: Mirror;\n    blockClass: string | RegExp;\n    blockSelector: string | null;\n    unblockSelector: string | null;\n    maskTextClass: string | RegExp;\n    unmaskTextClass: string | RegExp | null;\n    maskTextSelector: string | null;\n    unmaskTextSelector: string | null;\n    skipChild: boolean;\n    inlineStylesheet: boolean;\n    newlyAddedElement?: boolean;\n    maskInputOptions?: MaskInputOptions;\n    maskAllText: boolean;\n    maskAttributeFn: MaskAttributeFn | undefined;\n    maskTextFn: MaskTextFn | undefined;\n    maskInputFn: MaskInputFn | undefined;\n    slimDOMOptions: SlimDOMOptions;\n    dataURLOptions?: DataURLOptions;\n    keepIframeSrcFn?: KeepIframeSrcFn;\n    inlineImages?: boolean;\n    recordCanvas?: boolean;\n    preserveWhiteSpace?: boolean;\n    onSerialize?: (n: Node) => unknown;\n    onIframeLoad?: (\n      iframeNode: HTMLIFrameElement,\n      node: serializedElementNodeWithId,\n    ) => unknown;\n    iframeLoadTimeout?: number;\n    onBlockedImageLoad?: (\n      imageEl: HTMLImageElement,\n      node: serializedElementNodeWithId,\n      rect: DOMRect,\n    ) => unknown;\n    onStylesheetLoad?: (\n      linkNode: HTMLLinkElement,\n      node: serializedElementNodeWithId,\n    ) => unknown;\n    stylesheetLoadTimeout?: number;\n    ignoreCSSAttributes?: Set<string>;\n  },\n): serializedNodeWithId | null {\n  const {\n    doc,\n    mirror,\n    blockClass,\n    blockSelector,\n    unblockSelector,\n    maskAllText,\n    maskTextClass,\n    unmaskTextClass,\n    maskTextSelector,\n    unmaskTextSelector,\n    skipChild = false,\n    inlineStylesheet = true,\n    maskInputOptions = {},\n    maskAttributeFn,\n    maskTextFn,\n    maskInputFn,\n    slimDOMOptions,\n    dataURLOptions = {},\n    inlineImages = false,\n    recordCanvas = false,\n    onSerialize,\n    onIframeLoad,\n    iframeLoadTimeout = 5000,\n    onBlockedImageLoad,\n    onStylesheetLoad,\n    stylesheetLoadTimeout = 5000,\n    keepIframeSrcFn = () => false,\n    newlyAddedElement = false,\n    ignoreCSSAttributes,\n  } = options;\n  let { preserveWhiteSpace = true } = options;\n  const _serializedNode = serializeNode(n, {\n    doc,\n    mirror,\n    blockClass,\n    blockSelector,\n    maskAllText,\n    unblockSelector,\n    maskTextClass,\n    unmaskTextClass,\n    maskTextSelector,\n    unmaskTextSelector,\n    inlineStylesheet,\n    maskInputOptions,\n    maskAttributeFn,\n    maskTextFn,\n    maskInputFn,\n    dataURLOptions,\n    inlineImages,\n    recordCanvas,\n    keepIframeSrcFn,\n    newlyAddedElement,\n    ignoreCSSAttributes,\n  });\n  if (!_serializedNode) {\n    // TODO: dev only\n    console.warn(n, 'not serialized');\n    return null;\n  }\n\n  let id: number | undefined;\n  if (mirror.hasNode(n)) {\n    // Reuse the previous id\n    id = mirror.getId(n);\n  } else if (\n    slimDOMExcluded(_serializedNode, slimDOMOptions) ||\n    (!preserveWhiteSpace &&\n      _serializedNode.type === NodeType.Text &&\n      !_serializedNode.isStyle &&\n      !_serializedNode.textContent.trim().length)\n  ) {\n    id = IGNORED_NODE;\n  } else {\n    id = genId();\n  }\n\n  const serializedNode = Object.assign(_serializedNode, { id });\n  // add IGNORED_NODE to mirror to track nextSiblings\n  mirror.add(n, serializedNode);\n\n  if (id === IGNORED_NODE) {\n    return null; // slimDOM\n  }\n\n  if (onSerialize) {\n    onSerialize(n);\n  }\n  let recordChild = !skipChild;\n  if (serializedNode.type === NodeType.Element) {\n    recordChild = recordChild && !serializedNode.needBlock;\n    const shadowRoot = (n as HTMLElement).shadowRoot;\n    if (shadowRoot && isNativeShadowDom(shadowRoot))\n      serializedNode.isShadowHost = true;\n  }\n  if (\n    (serializedNode.type === NodeType.Document ||\n      serializedNode.type === NodeType.Element) &&\n    recordChild\n  ) {\n    if (\n      slimDOMOptions.headWhitespace &&\n      serializedNode.type === NodeType.Element &&\n      serializedNode.tagName === 'head'\n      // would impede performance: || getComputedStyle(n)['white-space'] === 'normal'\n    ) {\n      preserveWhiteSpace = false;\n    }\n    const bypassOptions = {\n      doc,\n      mirror,\n      blockClass,\n      blockSelector,\n      maskAllText,\n      unblockSelector,\n      maskTextClass,\n      unmaskTextClass,\n      maskTextSelector,\n      unmaskTextSelector,\n      skipChild,\n      inlineStylesheet,\n      maskInputOptions,\n      maskAttributeFn,\n      maskTextFn,\n      maskInputFn,\n      slimDOMOptions,\n      dataURLOptions,\n      inlineImages,\n      recordCanvas,\n      preserveWhiteSpace,\n      onSerialize,\n      onIframeLoad,\n      iframeLoadTimeout,\n      onBlockedImageLoad,\n      onStylesheetLoad,\n      stylesheetLoadTimeout,\n      keepIframeSrcFn,\n      ignoreCSSAttributes,\n    };\n    const childNodes = n.childNodes ? Array.from(n.childNodes) : [];\n    for (const childN of childNodes) {\n      const serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n      if (serializedChildNode) {\n        serializedNode.childNodes.push(serializedChildNode);\n      }\n    }\n\n    if (isElement(n) && n.shadowRoot) {\n      for (const childN of Array.from(n.shadowRoot.childNodes)) {\n        const serializedChildNode = serializeNodeWithId(childN, bypassOptions);\n        if (serializedChildNode) {\n          isNativeShadowDom(n.shadowRoot) &&\n            (serializedChildNode.isShadow = true);\n          serializedNode.childNodes.push(serializedChildNode);\n        }\n      }\n    }\n  }\n\n  if (\n    n.parentNode &&\n    isShadowRoot(n.parentNode) &&\n    isNativeShadowDom(n.parentNode)\n  ) {\n    serializedNode.isShadow = true;\n  }\n\n  if (\n    serializedNode.type === NodeType.Element &&\n    serializedNode.tagName === 'iframe' &&\n    !serializedNode.needBlock\n  ) {\n    onceIframeLoaded(\n      n as HTMLIFrameElement,\n      () => {\n        const iframeDoc = getIFrameContentDocument(n as HTMLIFrameElement);\n        if (iframeDoc && onIframeLoad) {\n          const serializedIframeNode = serializeNodeWithId(iframeDoc, {\n            doc: iframeDoc,\n            mirror,\n            blockClass,\n            blockSelector,\n            unblockSelector,\n            maskAllText,\n            maskTextClass,\n            unmaskTextClass,\n            maskTextSelector,\n            unmaskTextSelector,\n            skipChild: false,\n            inlineStylesheet,\n            maskInputOptions,\n            maskAttributeFn,\n            maskTextFn,\n            maskInputFn,\n            slimDOMOptions,\n            dataURLOptions,\n            inlineImages,\n            recordCanvas,\n            preserveWhiteSpace,\n            onSerialize,\n            onIframeLoad,\n            iframeLoadTimeout,\n            onStylesheetLoad,\n            stylesheetLoadTimeout,\n            keepIframeSrcFn,\n            ignoreCSSAttributes,\n          });\n\n          if (serializedIframeNode) {\n            onIframeLoad(\n              n as HTMLIFrameElement,\n              serializedIframeNode as serializedElementNodeWithId,\n            );\n          }\n        }\n      },\n      iframeLoadTimeout,\n    );\n  }\n\n  if (\n    serializedNode.type === NodeType.Element &&\n    serializedNode.tagName === 'img' &&\n    !(n as HTMLImageElement).complete &&\n    serializedNode.needBlock\n  ) {\n    const image = n as HTMLImageElement;\n    const updateImageDimensions = () => {\n      // Check if the element is still in the DOM and not already complete\n      if (image.isConnected && !image.complete && onBlockedImageLoad) {\n        try {\n          const rect = image.getBoundingClientRect();\n          // Only proceed if we have valid dimensions\n          if (rect.width > 0 && rect.height > 0) {\n            onBlockedImageLoad(image, serializedNode, rect);\n          }\n        } catch (error) {\n          // Silently handle errors from getBoundingClientRect\n        }\n      }\n      image.removeEventListener('load', updateImageDimensions);\n    };\n\n    // Only add listener if element is still in DOM\n    if (image.isConnected) {\n      image.addEventListener('load', updateImageDimensions);\n    }\n  }\n\n  // <link rel=stylesheet href=...>\n  if (\n    serializedNode.type === NodeType.Element &&\n    serializedNode.tagName === 'link' &&\n    typeof serializedNode.attributes.rel === 'string' &&\n    (serializedNode.attributes.rel === 'stylesheet' ||\n      (serializedNode.attributes.rel === 'preload' &&\n        typeof serializedNode.attributes.href === 'string' &&\n        extractFileExtension(serializedNode.attributes.href) === 'css'))\n  ) {\n    onceStylesheetLoaded(\n      n as HTMLLinkElement,\n      () => {\n        if (onStylesheetLoad) {\n          const serializedLinkNode = serializeNodeWithId(n, {\n            doc,\n            mirror,\n            blockClass,\n            blockSelector,\n            unblockSelector,\n            maskAllText,\n            maskTextClass,\n            unmaskTextClass,\n            maskTextSelector,\n            unmaskTextSelector,\n            skipChild: false,\n            inlineStylesheet,\n            maskInputOptions,\n            maskAttributeFn,\n            maskTextFn,\n            maskInputFn,\n            slimDOMOptions,\n            dataURLOptions,\n            inlineImages,\n            recordCanvas,\n            preserveWhiteSpace,\n            onSerialize,\n            onIframeLoad,\n            iframeLoadTimeout,\n            onStylesheetLoad,\n            stylesheetLoadTimeout,\n            keepIframeSrcFn,\n            ignoreCSSAttributes,\n          });\n\n          if (serializedLinkNode) {\n            onStylesheetLoad(\n              n as HTMLLinkElement,\n              serializedLinkNode as serializedElementNodeWithId,\n            );\n          }\n        }\n      },\n      stylesheetLoadTimeout,\n    );\n  }\n\n  if (serializedNode.type === NodeType.Element) {\n    // this property was not needed in replay side\n    delete serializedNode.needBlock;\n  }\n\n  return serializedNode;\n}\n\nfunction snapshot(\n  n: Document,\n  options?: {\n    mirror?: Mirror;\n    blockClass?: string | RegExp;\n    blockSelector?: string | null;\n    unblockSelector?: string | null;\n    maskAllText?: boolean;\n    maskTextClass?: string | RegExp;\n    unmaskTextClass?: string | RegExp | null;\n    maskTextSelector?: string | null;\n    unmaskTextSelector?: string | null;\n    inlineStylesheet?: boolean;\n    maskAllInputs?: boolean | MaskInputOptions;\n    maskAttributeFn?: MaskAttributeFn;\n    maskTextFn?: MaskTextFn;\n    maskInputFn?: MaskInputFn;\n    slimDOM?: 'all' | boolean | SlimDOMOptions;\n    dataURLOptions?: DataURLOptions;\n    inlineImages?: boolean;\n    recordCanvas?: boolean;\n    preserveWhiteSpace?: boolean;\n    onSerialize?: (n: Node) => unknown;\n    onIframeLoad?: (\n      iframeNode: HTMLIFrameElement,\n      node: serializedElementNodeWithId,\n    ) => unknown;\n    iframeLoadTimeout?: number;\n    onBlockedImageLoad?: (\n      imageEl: HTMLImageElement,\n      node: serializedElementNodeWithId,\n      rect: DOMRect,\n    ) => unknown;\n    onStylesheetLoad?: (\n      linkNode: HTMLLinkElement,\n      node: serializedElementNodeWithId,\n    ) => unknown;\n    stylesheetLoadTimeout?: number;\n    keepIframeSrcFn?: KeepIframeSrcFn;\n    ignoreCSSAttributes?: Set<string>;\n  },\n): serializedNodeWithId | null {\n  const {\n    mirror = new Mirror(),\n    blockClass = 'rr-block',\n    blockSelector = null,\n    unblockSelector = null,\n    maskAllText = false,\n    maskTextClass = 'rr-mask',\n    unmaskTextClass = null,\n    maskTextSelector = null,\n    unmaskTextSelector = null,\n    inlineStylesheet = true,\n    inlineImages = false,\n    recordCanvas = false,\n    maskAllInputs = false,\n    maskAttributeFn,\n    maskTextFn,\n    maskInputFn,\n    slimDOM = false,\n    dataURLOptions,\n    preserveWhiteSpace,\n    onSerialize,\n    onIframeLoad,\n    iframeLoadTimeout,\n    onBlockedImageLoad,\n    onStylesheetLoad,\n    stylesheetLoadTimeout,\n    keepIframeSrcFn = () => false,\n    ignoreCSSAttributes = new Set([]),\n  } = options || {};\n  const maskInputOptions: MaskInputOptions =\n    maskAllInputs === true\n      ? {\n          color: true,\n          date: true,\n          'datetime-local': true,\n          email: true,\n          month: true,\n          number: true,\n          range: true,\n          search: true,\n          tel: true,\n          text: true,\n          time: true,\n          url: true,\n          week: true,\n          textarea: true,\n          select: true,\n        }\n      : maskAllInputs === false\n      ? {}\n      : maskAllInputs;\n  const slimDOMOptions: SlimDOMOptions =\n    slimDOM === true || slimDOM === 'all'\n      ? // if true: set of sensible options that should not throw away any information\n        {\n          script: true,\n          comment: true,\n          headFavicon: true,\n          headWhitespace: true,\n          headMetaDescKeywords: slimDOM === 'all', // destructive\n          headMetaSocial: true,\n          headMetaRobots: true,\n          headMetaHttpEquiv: true,\n          headMetaAuthorship: true,\n          headMetaVerification: true,\n        }\n      : slimDOM === false\n      ? {}\n      : slimDOM;\n  return serializeNodeWithId(n, {\n    doc: n,\n    mirror,\n    blockClass,\n    blockSelector,\n    unblockSelector,\n    maskAllText,\n    maskTextClass,\n    unmaskTextClass,\n    maskTextSelector,\n    unmaskTextSelector,\n    skipChild: false,\n    inlineStylesheet,\n    maskInputOptions,\n    maskAttributeFn,\n    maskTextFn,\n    maskInputFn,\n    slimDOMOptions,\n    dataURLOptions,\n    inlineImages,\n    recordCanvas,\n    preserveWhiteSpace,\n    onSerialize,\n    onIframeLoad,\n    iframeLoadTimeout,\n    onBlockedImageLoad,\n    onStylesheetLoad,\n    stylesheetLoadTimeout,\n    keepIframeSrcFn,\n    newlyAddedElement: false,\n    ignoreCSSAttributes,\n  });\n}\n\nexport function visitSnapshot(\n  node: serializedNodeWithId,\n  onVisit: (node: serializedNodeWithId) => unknown,\n) {\n  function walk(current: serializedNodeWithId) {\n    onVisit(current);\n    if (\n      current.type === NodeType.Document ||\n      current.type === NodeType.Element\n    ) {\n      current.childNodes.forEach(walk);\n    }\n  }\n\n  walk(node);\n}\n\nexport function cleanupSnapshot() {\n  // allow a new recording to start numbering nodes from scratch\n  _id = 1;\n}\n\nexport default snapshot;\n", "/**\n * This file is a fork of https://github.com/reworkcss/css/blob/master/lib/parse/index.js\n * I fork it because:\n * 1. The css library was built for node.js which does not have tree-shaking supports.\n * 2. Rewrites into typescript give us a better type interface.\n */\n/* eslint-disable tsdoc/syntax */\n\nexport interface ParserOptions {\n  /** Silently fail on parse errors */\n  silent?: boolean;\n  /**\n   * The path to the file containing css.\n   * Makes errors and source maps more helpful, by letting them know where code comes from.\n   */\n  source?: string;\n}\n\n/**\n * Error thrown during parsing.\n */\nexport interface ParserError {\n  /** The full error message with the source position. */\n  message?: string;\n  /** The error message without position. */\n  reason?: string;\n  /** The value of options.source if passed to css.parse. Otherwise undefined. */\n  filename?: string;\n  line?: number;\n  column?: number;\n  /** The portion of code that couldn't be parsed. */\n  source?: string;\n}\n\nexport interface Loc {\n  line?: number;\n  column?: number;\n}\n\n/**\n * Base AST Tree Node.\n */\nexport interface Node {\n  /** The possible values are the ones listed in the Types section on https://github.com/reworkcss/css page. */\n  type?: string;\n  /** A reference to the parent node, or null if the node has no parent. */\n  parent?: Node;\n  /** Information about the position in the source string that corresponds to the node. */\n  position?: {\n    start?: Loc;\n    end?: Loc;\n    /** The value of options.source if passed to css.parse. Otherwise undefined. */\n    source?: string;\n    /** The full source string passed to css.parse. */\n    content?: string;\n  };\n}\n\nexport interface Rule extends Node {\n  /** The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments. */\n  selectors?: string[];\n  /** Array of nodes with the types declaration and comment. */\n  declarations?: Array<Declaration | Comment>;\n}\n\nexport interface Declaration extends Node {\n  /** The property name, trimmed from whitespace and comments. May not be empty. */\n  property?: string;\n  /** The value of the property, trimmed from whitespace and comments. Empty values are allowed. */\n  value?: string;\n}\n\n/**\n * A rule-level or declaration-level comment. Comments inside selectors, properties and values etc. are lost.\n */\nexport interface Comment extends Node {\n  comment?: string;\n}\n\n/**\n * The @charset at-rule.\n */\nexport interface Charset extends Node {\n  /** The part following @charset. */\n  charset?: string;\n}\n\n/**\n * The @custom-media at-rule\n */\nexport interface CustomMedia extends Node {\n  /** The ---prefixed name. */\n  name?: string;\n  /** The part following the name. */\n  media?: string;\n}\n\n/**\n * The @document at-rule.\n */\nexport interface Document extends Node {\n  /** The part following @document. */\n  document?: string;\n  /** The vendor prefix in @document, or undefined if there is none. */\n  vendor?: string;\n  /** Array of nodes with the types rule, comment and any of the at-rule types. */\n  rules?: Array<Rule | Comment | AtRule>;\n}\n\n/**\n * The @font-face at-rule.\n */\nexport interface FontFace extends Node {\n  /** Array of nodes with the types declaration and comment. */\n  declarations?: Array<Declaration | Comment>;\n}\n\n/**\n * The @host at-rule.\n */\nexport interface Host extends Node {\n  /** Array of nodes with the types rule, comment and any of the at-rule types. */\n  rules?: Array<Rule | Comment | AtRule>;\n}\n\n/**\n * The @import at-rule.\n */\nexport interface Import extends Node {\n  /** The part following @import. */\n  import?: string;\n}\n\n/**\n * The @keyframes at-rule.\n */\nexport interface KeyFrames extends Node {\n  /** The name of the keyframes rule. */\n  name?: string;\n  /** The vendor prefix in @keyframes, or undefined if there is none. */\n  vendor?: string;\n  /** Array of nodes with the types keyframe and comment. */\n  keyframes?: Array<KeyFrame | Comment>;\n}\n\nexport interface KeyFrame extends Node {\n  /** The list of \"selectors\" of the keyframe rule, split on commas. Each “selector” is trimmed from whitespace. */\n  values?: string[];\n  /** Array of nodes with the types declaration and comment. */\n  declarations?: Array<Declaration | Comment>;\n}\n\n/**\n * The @media at-rule.\n */\nexport interface Media extends Node {\n  /** The part following @media. */\n  media?: string;\n  /** Array of nodes with the types rule, comment and any of the at-rule types. */\n  rules?: Array<Rule | Comment | AtRule>;\n}\n\n/**\n * The @namespace at-rule.\n */\nexport interface Namespace extends Node {\n  /** The part following @namespace. */\n  namespace?: string;\n}\n\n/**\n * The @page at-rule.\n */\nexport interface Page extends Node {\n  /** The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments. */\n  selectors?: string[];\n  /** Array of nodes with the types declaration and comment. */\n  declarations?: Array<Declaration | Comment>;\n}\n\n/**\n * The @supports at-rule.\n */\nexport interface Supports extends Node {\n  /** The part following @supports. */\n  supports?: string;\n  /** Array of nodes with the types rule, comment and any of the at-rule types. */\n  rules?: Array<Rule | Comment | AtRule>;\n}\n\n/** All at-rules. */\nexport type AtRule =\n  | Charset\n  | CustomMedia\n  | Document\n  | FontFace\n  | Host\n  | Import\n  | KeyFrames\n  | Media\n  | Namespace\n  | Page\n  | Supports;\n\n/**\n * A collection of rules\n */\nexport interface StyleRules {\n  source?: string;\n  /** Array of nodes with the types rule, comment and any of the at-rule types. */\n  rules: Array<Rule | Comment | AtRule>;\n  /** Array of Errors. Errors collected during parsing when option silent is true. */\n  parsingErrors?: ParserError[];\n}\n\n/**\n * The root node returned by css.parse.\n */\nexport interface Stylesheet extends Node {\n  stylesheet?: StyleRules;\n}\n\n// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nconst commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nexport function parse(css: string, options: ParserOptions = {}) {\n  /**\n   * Positional.\n   */\n\n  let lineno = 1;\n  let column = 1;\n\n  /**\n   * Update lineno and column based on `str`.\n   */\n\n  function updatePosition(str: string) {\n    const lines = str.match(/\\n/g);\n    if (lines) {\n      lineno += lines.length;\n    }\n    const i = str.lastIndexOf('\\n');\n    column = i === -1 ? column + str.length : str.length - i;\n  }\n\n  /**\n   * Mark position and patch `node.position`.\n   */\n\n  function position() {\n    const start = { line: lineno, column };\n    return (\n      node: Rule | Declaration | Comment | AtRule | Stylesheet | KeyFrame,\n    ) => {\n      node.position = new Position(start);\n      whitespace();\n      return node;\n    };\n  }\n\n  /**\n   * Store position information for a node\n   */\n\n  class Position {\n    public static content: string;\n    public content!: string;\n    public start!: Loc;\n    public end!: Loc;\n    public source?: string;\n\n    constructor(start: Loc) {\n      this.start = start;\n      this.end = { line: lineno, column };\n      this.source = options.source;\n      this.content = Position.content;\n    }\n  }\n\n  /**\n   * Non-enumerable source string\n   */\n\n  Position.content = css;\n\n  const errorsList: ParserError[] = [];\n\n  function error(msg: string) {\n    const err = new Error(\n      `${options.source || ''}:${lineno}:${column}: ${msg}`,\n    ) as ParserError;\n    err.reason = msg;\n    err.filename = options.source;\n    err.line = lineno;\n    err.column = column;\n    err.source = css;\n\n    if (options.silent) {\n      errorsList.push(err);\n    } else {\n      throw err;\n    }\n  }\n\n  /**\n   * Parse stylesheet.\n   */\n\n  function stylesheet(): Stylesheet {\n    const rulesList = rules();\n\n    return {\n      type: 'stylesheet',\n      stylesheet: {\n        source: options.source,\n        rules: rulesList,\n        parsingErrors: errorsList,\n      },\n    };\n  }\n\n  /**\n   * Opening brace.\n   */\n\n  function open() {\n    return match(/^{\\s*/);\n  }\n\n  /**\n   * Closing brace.\n   */\n\n  function close() {\n    return match(/^}/);\n  }\n\n  /**\n   * Parse ruleset.\n   */\n\n  function rules() {\n    let node: Rule | void;\n    const rules: Rule[] = [];\n    whitespace();\n    comments(rules);\n    while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n      if (node) {\n        rules.push(node);\n        comments(rules);\n      }\n    }\n    return rules;\n  }\n\n  /**\n   * Match `re` and return captures.\n   */\n\n  function match(re: RegExp) {\n    const m = re.exec(css);\n    if (!m) {\n      return;\n    }\n    const str = m[0];\n    updatePosition(str);\n    css = css.slice(str.length);\n    return m;\n  }\n\n  /**\n   * Parse whitespace.\n   */\n\n  function whitespace() {\n    match(/^\\s*/);\n  }\n\n  /**\n   * Parse comments;\n   */\n\n  function comments(rules: Rule[] = []) {\n    let c: Comment | void;\n    while ((c = comment())) {\n      if (c) {\n        rules.push(c);\n      }\n      c = comment();\n    }\n    return rules;\n  }\n\n  /**\n   * Parse comment.\n   */\n\n  function comment() {\n    const pos = position();\n    if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n      return;\n    }\n\n    let i = 2;\n    while (\n      '' !== css.charAt(i) &&\n      ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))\n    ) {\n      ++i;\n    }\n    i += 2;\n\n    if ('' === css.charAt(i - 1)) {\n      return error('End of comment missing');\n    }\n\n    const str = css.slice(2, i - 2);\n    column += 2;\n    updatePosition(str);\n    css = css.slice(i);\n    column += 2;\n\n    return pos({\n      type: 'comment',\n      comment: str,\n    });\n  }\n\n  /**\n   * Parse selector.\n   */\n\n  function selector() {\n    const m = match(/^([^{]+)/);\n\n    if (!m) {\n      return;\n    }\n\n    /* @fix Remove all comments from selectors */\n    const splitSelectors = trim(m[0])\n      .replace(/\\/\\*[\\s\\S]*?\\*\\/+/g, '')\n      .replace(/\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'/g, (m) => {\n        return m.replace(/,/g, '\\u200C');\n      })\n      .split(/\\s*(?![^(]*\\)),\\s*/);\n\n    if (splitSelectors.length <= 1) {\n      return splitSelectors.map((s) => {\n        return s.replace(/\\u200C/g, ',');\n      });\n    }\n\n    // For each selector, need to check if we properly split on `,`\n    // Example case where selector is:\n    // .bar:has(input:is(:disabled), button:is(:disabled))\n    let i = 0;\n    let j = 0;\n    const len = splitSelectors.length;\n    const finalSelectors = [];\n    while (i < len) {\n      // Look for selectors with opening parens - `(` and search rest of\n      // selectors for the first one with matching number of closing\n      // parens `)`\n      const openingParensCount = (splitSelectors[i].match(/\\(/g) || []).length;\n      const closingParensCount = (splitSelectors[i].match(/\\)/g) || []).length;\n      let unbalancedParens = openingParensCount - closingParensCount;\n\n      if (unbalancedParens >= 1) {\n        // At least one opening parens was found, prepare to look through\n        // rest of selectors\n        let foundClosingSelector = false;\n\n        // Loop starting with next item in array, until we find matching\n        // number of ending parens\n        j = i + 1;\n        while (j < len) {\n          // peek into next item to count the number of closing brackets\n          const nextOpeningParensCount = (splitSelectors[j].match(/\\(/g) || [])\n            .length;\n          const nextClosingParensCount = (splitSelectors[j].match(/\\)/g) || [])\n            .length;\n          const nextUnbalancedParens =\n            nextClosingParensCount - nextOpeningParensCount;\n\n          if (nextUnbalancedParens === unbalancedParens) {\n            // Matching # of closing parens was found, join all elements\n            // from i to j\n            finalSelectors.push(splitSelectors.slice(i, j + 1).join(','));\n\n            // we will want to skip the items that we have joined together\n            i = j + 1;\n\n            // Use to continue the outer loop\n            foundClosingSelector = true;\n\n            // break out of inner loop so we found matching closing parens\n            break;\n          }\n\n          // No matching closing parens found, keep moving through index, but\n          // update the # of unbalanced parents still outstanding\n          j++;\n          unbalancedParens -= nextUnbalancedParens;\n        }\n\n        if (foundClosingSelector) {\n          // Matching closing selector was found, move to next selector\n          continue;\n        }\n\n        // No matching closing selector was found, either invalid CSS,\n        // or unbalanced number of opening parens were used as CSS\n        // selectors. Assume that rest of the list of selectors are\n        // selectors and break to avoid iterating through the list of\n        // selectors again.\n        splitSelectors\n          .slice(i, len)\n          .forEach((selector) => selector && finalSelectors.push(selector));\n        break;\n      }\n\n      // No opening parens found, contiue looking through list\n      splitSelectors[i] && finalSelectors.push(splitSelectors[i]);\n      i++;\n    }\n\n    return finalSelectors.map((s) => {\n      return s.replace(/\\u200C/g, ',');\n    });\n  }\n\n  /**\n   * Parse declaration.\n   */\n\n  function declaration(): Declaration | void | never {\n    const pos = position();\n\n    // prop\n    // eslint-disable-next-line no-useless-escape\n    const propMatch = match(/^(\\*?[-#\\/\\*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n    if (!propMatch) {\n      return;\n    }\n    const prop = trim(propMatch[0]);\n\n    // :\n    if (!match(/^:\\s*/)) {\n      return error(`property missing ':'`);\n    }\n\n    // val\n    // eslint-disable-next-line no-useless-escape\n    const val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^\\)]*?\\)|[^};])+)/);\n\n    const ret = pos({\n      type: 'declaration',\n      property: prop.replace(commentre, ''),\n      value: val ? trim(val[0]).replace(commentre, '') : '',\n    });\n\n    // ;\n    match(/^[;\\s]*/);\n\n    return ret;\n  }\n\n  /**\n   * Parse declarations.\n   */\n\n  function declarations() {\n    const decls: Array<object> = [];\n\n    if (!open()) {\n      return error(`missing '{'`);\n    }\n    comments(decls);\n\n    // declarations\n    let decl;\n    while ((decl = declaration())) {\n      if ((decl as unknown) !== false) {\n        decls.push(decl);\n        comments(decls);\n      }\n      decl = declaration();\n    }\n\n    if (!close()) {\n      return error(`missing '}'`);\n    }\n    return decls;\n  }\n\n  /**\n   * Parse keyframe.\n   */\n\n  function keyframe() {\n    let m;\n    const vals = [];\n    const pos = position();\n\n    while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n      vals.push(m[1]);\n      match(/^,\\s*/);\n    }\n\n    if (!vals.length) {\n      return;\n    }\n\n    return pos({\n      type: 'keyframe',\n      values: vals,\n      declarations: declarations() as Declaration[],\n    });\n  }\n\n  /**\n   * Parse keyframes.\n   */\n\n  function atkeyframes() {\n    const pos = position();\n    let m = match(/^@([-\\w]+)?keyframes\\s*/);\n\n    if (!m) {\n      return;\n    }\n    const vendor = m[1];\n\n    // identifier\n    m = match(/^([-\\w]+)\\s*/);\n    if (!m) {\n      return error('@keyframes missing name');\n    }\n    const name = m[1];\n\n    if (!open()) {\n      return error(`@keyframes missing '{'`);\n    }\n\n    let frame;\n    let frames = comments();\n    while ((frame = keyframe())) {\n      frames.push(frame);\n      frames = frames.concat(comments());\n    }\n\n    if (!close()) {\n      return error(`@keyframes missing '}'`);\n    }\n\n    return pos({\n      type: 'keyframes',\n      name,\n      vendor,\n      keyframes: frames,\n    });\n  }\n\n  /**\n   * Parse supports.\n   */\n\n  function atsupports() {\n    const pos = position();\n    const m = match(/^@supports *([^{]+)/);\n\n    if (!m) {\n      return;\n    }\n    const supports = trim(m[1]);\n\n    if (!open()) {\n      return error(`@supports missing '{'`);\n    }\n\n    const style = comments().concat(rules());\n\n    if (!close()) {\n      return error(`@supports missing '}'`);\n    }\n\n    return pos({\n      type: 'supports',\n      supports,\n      rules: style,\n    });\n  }\n\n  /**\n   * Parse host.\n   */\n\n  function athost() {\n    const pos = position();\n    const m = match(/^@host\\s*/);\n\n    if (!m) {\n      return;\n    }\n\n    if (!open()) {\n      return error(`@host missing '{'`);\n    }\n\n    const style = comments().concat(rules());\n\n    if (!close()) {\n      return error(`@host missing '}'`);\n    }\n\n    return pos({\n      type: 'host',\n      rules: style,\n    });\n  }\n\n  /**\n   * Parse media.\n   */\n\n  function atmedia() {\n    const pos = position();\n    const m = match(/^@media *([^{]+)/);\n\n    if (!m) {\n      return;\n    }\n    const media = trim(m[1]);\n\n    if (!open()) {\n      return error(`@media missing '{'`);\n    }\n\n    const style = comments().concat(rules());\n\n    if (!close()) {\n      return error(`@media missing '}'`);\n    }\n\n    return pos({\n      type: 'media',\n      media,\n      rules: style,\n    });\n  }\n\n  /**\n   * Parse custom-media.\n   */\n\n  function atcustommedia() {\n    const pos = position();\n    const m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n    if (!m) {\n      return;\n    }\n\n    return pos({\n      type: 'custom-media',\n      name: trim(m[1]),\n      media: trim(m[2]),\n    });\n  }\n\n  /**\n   * Parse paged media.\n   */\n\n  function atpage() {\n    const pos = position();\n    const m = match(/^@page */);\n    if (!m) {\n      return;\n    }\n\n    const sel = selector() || [];\n\n    if (!open()) {\n      return error(`@page missing '{'`);\n    }\n    let decls = comments();\n\n    // declarations\n    let decl;\n    while ((decl = declaration())) {\n      decls.push(decl);\n      decls = decls.concat(comments());\n    }\n\n    if (!close()) {\n      return error(`@page missing '}'`);\n    }\n\n    return pos({\n      type: 'page',\n      selectors: sel,\n      declarations: decls,\n    });\n  }\n\n  /**\n   * Parse document.\n   */\n\n  function atdocument() {\n    const pos = position();\n    const m = match(/^@([-\\w]+)?document *([^{]+)/);\n    if (!m) {\n      return;\n    }\n\n    const vendor = trim(m[1]);\n    const doc = trim(m[2]);\n\n    if (!open()) {\n      return error(`@document missing '{'`);\n    }\n\n    const style = comments().concat(rules());\n\n    if (!close()) {\n      return error(`@document missing '}'`);\n    }\n\n    return pos({\n      type: 'document',\n      document: doc,\n      vendor,\n      rules: style,\n    });\n  }\n\n  /**\n   * Parse font-face.\n   */\n\n  function atfontface() {\n    const pos = position();\n    const m = match(/^@font-face\\s*/);\n    if (!m) {\n      return;\n    }\n\n    if (!open()) {\n      return error(`@font-face missing '{'`);\n    }\n    let decls = comments();\n\n    // declarations\n    let decl;\n    while ((decl = declaration())) {\n      decls.push(decl);\n      decls = decls.concat(comments());\n    }\n\n    if (!close()) {\n      return error(`@font-face missing '}'`);\n    }\n\n    return pos({\n      type: 'font-face',\n      declarations: decls,\n    });\n  }\n\n  /**\n   * Parse import\n   */\n\n  const atimport = _compileAtrule('import');\n\n  /**\n   * Parse charset\n   */\n\n  const atcharset = _compileAtrule('charset');\n\n  /**\n   * Parse namespace\n   */\n\n  const atnamespace = _compileAtrule('namespace');\n\n  /**\n   * Parse non-block at-rules\n   */\n\n  function _compileAtrule(name: string) {\n    const re = new RegExp(\n      '^@' +\n        name +\n        '\\\\s*((?:' +\n        [\n          /[^\\\\]\"(?:\\\\\"|[^\"])*\"/.source, // consume any quoted parts (checking that the double quote isn't itself escaped)\n          /[^\\\\]'(?:\\\\'|[^'])*'/.source, // same but for single quotes\n          '[^;]',\n        ].join('|') +\n        ')+);',\n    );\n    return () => {\n      const pos = position();\n      const m = match(re);\n      if (!m) {\n        return;\n      }\n      const ret: Record<string, string> = { type: name };\n      ret[name] = m[1].trim();\n      return pos(ret);\n    };\n  }\n\n  /**\n   * Parse at rule.\n   */\n\n  function atrule() {\n    if (css[0] !== '@') {\n      return;\n    }\n\n    return (\n      atkeyframes() ||\n      atmedia() ||\n      atcustommedia() ||\n      atsupports() ||\n      atimport() ||\n      atcharset() ||\n      atnamespace() ||\n      atdocument() ||\n      atpage() ||\n      athost() ||\n      atfontface()\n    );\n  }\n\n  /**\n   * Parse rule.\n   */\n\n  function rule() {\n    const pos = position();\n    const sel = selector();\n\n    if (!sel) {\n      return error('selector missing');\n    }\n    comments();\n\n    return pos({\n      type: 'rule',\n      selectors: sel,\n      declarations: declarations() as Declaration[],\n    });\n  }\n\n  return addParent(stylesheet());\n}\n\n/**\n * Trim `str`.\n */\n\nfunction trim(str: string) {\n  return str ? str.replace(/^\\s+|\\s+$/g, '') : '';\n}\n\n/**\n * Adds non-enumerable parent node reference to each node.\n */\n\nfunction addParent(obj: Stylesheet, parent?: Stylesheet) {\n  const isNode = obj && typeof obj.type === 'string';\n  const childParent = isNode ? obj : parent;\n\n  for (const k of Object.keys(obj)) {\n    const value = obj[k as keyof Stylesheet];\n    if (Array.isArray(value)) {\n      value.forEach((v) => {\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n        addParent(v, childParent);\n      });\n    } else if (value && typeof value === 'object') {\n      addParent(value as Stylesheet, childParent);\n    }\n  }\n\n  if (isNode) {\n    Object.defineProperty(obj, 'parent', {\n      configurable: true,\n      writable: true,\n      enumerable: false,\n      value: parent || null,\n    });\n  }\n\n  return obj;\n}\n", "import { parse } from './css';\nimport {\n  serializedNodeWithId,\n  NodeType,\n  tagMap,\n  elementNode,\n  BuildCache,\n  legacyAttributes,\n} from './types';\nimport {\n  isElement,\n  Mirror,\n  isNodeMetaEqual,\n  extractFileExtension,\n} from './utils';\n\nconst tagMap: tagMap = {\n  script: 'noscript',\n  // camel case svg element tag names\n  altglyph: 'altGlyph',\n  altglyphdef: 'altGlyphDef',\n  altglyphitem: 'altGlyphItem',\n  animatecolor: 'animateColor',\n  animatemotion: 'animateMotion',\n  animatetransform: 'animateTransform',\n  clippath: 'clipPath',\n  feblend: 'feBlend',\n  fecolormatrix: 'feColorMatrix',\n  fecomponenttransfer: 'feComponentTransfer',\n  fecomposite: 'feComposite',\n  feconvolvematrix: 'feConvolveMatrix',\n  fediffuselighting: 'feDiffuseLighting',\n  fedisplacementmap: 'feDisplacementMap',\n  fedistantlight: 'feDistantLight',\n  fedropshadow: 'feDropShadow',\n  feflood: 'feFlood',\n  fefunca: 'feFuncA',\n  fefuncb: 'feFuncB',\n  fefuncg: 'feFuncG',\n  fefuncr: 'feFuncR',\n  fegaussianblur: 'feGaussianBlur',\n  feimage: 'feImage',\n  femerge: 'feMerge',\n  femergenode: 'feMergeNode',\n  femorphology: 'feMorphology',\n  feoffset: 'feOffset',\n  fepointlight: 'fePointLight',\n  fespecularlighting: 'feSpecularLighting',\n  fespotlight: 'feSpotLight',\n  fetile: 'feTile',\n  feturbulence: 'feTurbulence',\n  foreignobject: 'foreignObject',\n  glyphref: 'glyphRef',\n  lineargradient: 'linearGradient',\n  radialgradient: 'radialGradient',\n};\nfunction getTagName(n: elementNode): string {\n  let tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;\n  if (tagName === 'link' && n.attributes._cssText) {\n    tagName = 'style';\n  }\n  return tagName;\n}\n\n// based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\nfunction escapeRegExp(str: string) {\n  return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n}\n\nconst HOVER_SELECTOR = /([^\\\\]):hover/;\nconst HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');\nexport function addHoverClass(cssText: string, cache: BuildCache): string {\n  const cachedStyle = cache?.stylesWithHoverClass.get(cssText);\n  if (cachedStyle) return cachedStyle;\n\n  if (cssText.length >= 1_000_000) {\n    // Skip adding hover class for large stylesheets, otherwise we will run\n    // into perf issues that will block main thread\n    return cssText;\n  }\n\n  const ast = parse(cssText, {\n    silent: true,\n  });\n\n  if (!ast.stylesheet) {\n    return cssText;\n  }\n\n  const selectors: string[] = [];\n  ast.stylesheet.rules.forEach((rule) => {\n    if ('selectors' in rule) {\n      (rule.selectors || []).forEach((selector: string) => {\n        if (HOVER_SELECTOR.test(selector)) {\n          selectors.push(selector);\n        }\n      });\n    }\n  });\n\n  if (selectors.length === 0) {\n    return cssText;\n  }\n\n  const selectorMatcher = new RegExp(\n    selectors\n      .filter((selector, index) => selectors.indexOf(selector) === index)\n      .sort((a, b) => b.length - a.length)\n      .map((selector) => {\n        return escapeRegExp(selector);\n      })\n      .join('|'),\n    'g',\n  );\n\n  const result = cssText.replace(selectorMatcher, (selector) => {\n    const newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\\\:hover');\n    return `${selector}, ${newSelector}`;\n  });\n  cache?.stylesWithHoverClass.set(cssText, result);\n  return result;\n}\n\nexport function createCache(): BuildCache {\n  const stylesWithHoverClass: Map<string, string> = new Map();\n  return {\n    stylesWithHoverClass,\n  };\n}\n\nfunction buildNode(\n  n: serializedNodeWithId,\n  options: {\n    doc: Document;\n    hackCss: boolean;\n    cache: BuildCache;\n  },\n): Node | null {\n  const { doc, hackCss, cache } = options;\n  switch (n.type) {\n    case NodeType.Document:\n      return doc.implementation.createDocument(null, '', null);\n    case NodeType.DocumentType:\n      return doc.implementation.createDocumentType(\n        n.name || 'html',\n        n.publicId,\n        n.systemId,\n      );\n    case NodeType.Element: {\n      const tagName = getTagName(n);\n      let node: Element;\n      if (n.isSVG) {\n        node = doc.createElementNS('http://www.w3.org/2000/svg', tagName);\n      } else {\n        if (\n          // If the tag name is a custom element name\n          n.isCustom &&\n          // If the browser supports custom elements\n          doc.defaultView?.customElements &&\n          // If the custom element hasn't been defined yet\n          !doc.defaultView.customElements.get(n.tagName)\n        )\n          try {\n            doc.defaultView.customElements.define(\n              n.tagName,\n              class extends doc.defaultView.HTMLElement {},\n            );\n          } catch (e) {\n            console.warn('Cannot define custom element', e);\n            // Some elements (e.g. Electron's <webview>) are registered as custom\n            // elements but have names that are not valid for customElements.define()\n            // (missing hyphen). Silently ignore — the element will be created as\n            // an HTMLUnknownElement instead.\n          }\n        node = doc.createElement(tagName);\n      }\n      /**\n       * Attribute names start with `rr_` are internal attributes added by rrweb.\n       * They often overwrite other attributes on the element.\n       * We need to parse them last so they can overwrite conflicting attributes.\n       */\n      const specialAttributes: { [key: string]: string | number } = {};\n      for (const name in n.attributes) {\n        if (!Object.prototype.hasOwnProperty.call(n.attributes, name)) {\n          continue;\n        }\n        let value = n.attributes[name];\n        if (\n          tagName === 'option' &&\n          name === 'selected' &&\n          (value as legacyAttributes[typeof name]) === false\n        ) {\n          // legacy fix (TODO: if `value === false` can be generated for other attrs,\n          // should we also omit those other attrs from build ?)\n          continue;\n        }\n\n        // null values mean the attribute was removed\n        if (value === null) {\n          continue;\n        }\n\n        /**\n         * Boolean attributes are considered to be true if they're present on the element at all.\n         * We should set value to the empty string (\"\") or the attribute's name, with no leading or trailing whitespace.\n         * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute#parameters\n         */\n        if (value === true) value = '';\n\n        if (name.startsWith('rr_')) {\n          specialAttributes[name] = value;\n          continue;\n        }\n\n        const isTextarea = tagName === 'textarea' && name === 'value';\n        const isRemoteOrDynamicCss = tagName === 'style' && name === '_cssText';\n        if (isRemoteOrDynamicCss && hackCss && typeof value === 'string') {\n          value = addHoverClass(value, cache);\n        }\n        if ((isTextarea || isRemoteOrDynamicCss) && typeof value === 'string') {\n          const child = doc.createTextNode(value);\n          // https://github.com/rrweb-io/rrweb/issues/112\n          for (const c of Array.from(node.childNodes)) {\n            if (c.nodeType === node.TEXT_NODE) {\n              node.removeChild(c);\n            }\n          }\n          node.appendChild(child);\n          continue;\n        }\n\n        try {\n          if (n.isSVG && name === 'xlink:href') {\n            node.setAttributeNS(\n              'http://www.w3.org/1999/xlink',\n              name,\n              value.toString(),\n            );\n          } else if (\n            name === 'onload' ||\n            name === 'onclick' ||\n            name.substring(0, 7) === 'onmouse'\n          ) {\n            // Rename some of the more common atttributes from https://www.w3schools.com/tags/ref_eventattributes.asp\n            // as setting them triggers a console.error (which shows up despite the try/catch)\n            // Assumption: these attributes are not used to css\n            node.setAttribute('_' + name, value.toString());\n          } else if (\n            tagName === 'meta' &&\n            n.attributes['http-equiv'] === 'Content-Security-Policy' &&\n            name === 'content'\n          ) {\n            // If CSP contains style-src and inline-style is disabled, there will be an error \"Refused to apply inline style because it violates the following Content Security Policy directive: style-src '*'\".\n            // And the function insertStyleRules in rrweb replayer will throw an error \"Uncaught TypeError: Cannot read property 'insertRule' of null\".\n            node.setAttribute('csp-content', value.toString());\n            continue;\n          } else if (\n            tagName === 'link' &&\n            (n.attributes.rel === 'preload' ||\n              n.attributes.rel === 'modulepreload')\n          ) {\n            // ignore\n          } else if (\n            tagName === 'link' &&\n            n.attributes.rel === 'prefetch' &&\n            typeof n.attributes.href === 'string' &&\n            extractFileExtension(n.attributes.href) === 'js'\n          ) {\n            // ignore\n          } else if (\n            tagName === 'img' &&\n            n.attributes.srcset &&\n            n.attributes.rr_dataURL\n          ) {\n            // backup original img srcset\n            node.setAttribute(\n              'rrweb-original-srcset',\n              n.attributes.srcset as string,\n            );\n          } else {\n            node.setAttribute(name, value.toString());\n          }\n        } catch (error) {\n          // skip invalid attribute\n        }\n      }\n\n      for (const name in specialAttributes) {\n        const value = specialAttributes[name];\n        // handle internal attributes\n        if (tagName === 'canvas' && name === 'rr_dataURL') {\n          const image = doc.createElement('img');\n          image.onload = () => {\n            const ctx = (node as HTMLCanvasElement).getContext('2d');\n            if (ctx) {\n              ctx.drawImage(image, 0, 0, image.width, image.height);\n            }\n          };\n          image.src = value.toString();\n          type RRCanvasElement = {\n            RRNodeType: NodeType;\n            rr_dataURL: string;\n          };\n          // If the canvas element is created in RRDom runtime (seeking to a time point), the canvas context isn't supported. So the data has to be stored and not handled until diff process. https://github.com/rrweb-io/rrweb/pull/944\n          if ((node as unknown as RRCanvasElement).RRNodeType)\n            (node as unknown as RRCanvasElement).rr_dataURL = value.toString();\n        } else if (tagName === 'img' && name === 'rr_dataURL') {\n          const image = node as HTMLImageElement;\n          if (!image.currentSrc.startsWith('data:')) {\n            // Backup original img src. It may not have been set yet.\n            image.setAttribute(\n              'rrweb-original-src',\n              n.attributes.src as string,\n            );\n            image.src = value.toString();\n          }\n        }\n\n        if (name === 'rr_width') {\n          (node as HTMLElement).style.setProperty('width', value.toString());\n        } else if (name === 'rr_height') {\n          (node as HTMLElement).style.setProperty('height', value.toString());\n        } else if (\n          name === 'rr_mediaCurrentTime' &&\n          typeof value === 'number'\n        ) {\n          (node as HTMLMediaElement).currentTime = value;\n        } else if (name === 'rr_mediaState') {\n          switch (value) {\n            case 'played':\n              (node as HTMLMediaElement)\n                .play()\n                .catch((e) => console.warn('media playback error', e));\n              break;\n            case 'paused':\n              (node as HTMLMediaElement).pause();\n              break;\n            default:\n          }\n        }\n      }\n\n      if (n.isShadowHost) {\n        /**\n         * Since node is newly rebuilt, it should be a normal element\n         * without shadowRoot.\n         * But if there are some weird situations that has defined\n         * custom element in the scope before we rebuild node, it may\n         * register the shadowRoot earlier.\n         * The logic in the 'else' block is just a try-my-best solution\n         * for the corner case, please let we know if it is wrong and\n         * we can remove it.\n         */\n        if (!node.shadowRoot) {\n          node.attachShadow({ mode: 'open' });\n        } else {\n          while (node.shadowRoot.firstChild) {\n            node.shadowRoot.removeChild(node.shadowRoot.firstChild);\n          }\n        }\n      }\n      return node;\n    }\n    case NodeType.Text:\n      return doc.createTextNode(\n        n.isStyle && hackCss\n          ? addHoverClass(n.textContent, cache)\n          : n.textContent,\n      );\n    case NodeType.CDATA:\n      // `createCDATASection` only works for XML documents (not HTML)\n      // https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection#notes\n      if (!(doc instanceof XMLDocument)) {\n        return null;\n      }\n\n      return doc.createCDATASection(n.textContent);\n    case NodeType.Comment:\n      return doc.createComment(n.textContent);\n    default:\n      return null;\n  }\n}\n\nexport function buildNodeWithSN(\n  n: serializedNodeWithId,\n  options: {\n    doc: Document;\n    mirror: Mirror;\n    skipChild?: boolean;\n    hackCss: boolean;\n    /**\n     * This callback will be called for each of this nodes' `.childNodes` after they are appended to _this_ node.\n     * Caveat: This callback _doesn't_ get called when this node is appended to the DOM.\n     */\n    afterAppend?: (n: Node, id: number) => unknown;\n    cache: BuildCache;\n  },\n): Node | null {\n  const {\n    doc,\n    mirror,\n    skipChild = false,\n    hackCss = true,\n    afterAppend,\n    cache,\n  } = options;\n  /**\n   * Add a check to see if the node is already in the mirror. If it is, we can skip the whole process.\n   * This situation (duplicated nodes) can happen when recorder has some unfixed bugs and the same node is recorded twice. Or something goes wrong when saving or transferring event data.\n   * Duplicated node creation may cause unexpected errors in replayer. This check tries best effort to prevent the errors.\n   */\n  if (mirror.has(n.id)) {\n    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n    const nodeInMirror = mirror.getNode(n.id)!;\n    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n    const meta = mirror.getMeta(nodeInMirror)!;\n    // For safety concern, check if the node in mirror is the same as the node we are trying to build\n    if (isNodeMetaEqual(meta, n)) return mirror.getNode(n.id);\n  }\n  let node = buildNode(n, { doc, hackCss, cache });\n  if (!node) {\n    return null;\n  }\n  // If the snapshot is created by checkout, the rootId doesn't change but the iframe's document can be changed automatically when a new iframe element is created.\n  if (n.rootId && (mirror.getNode(n.rootId) as Document) !== doc) {\n    mirror.replace(n.rootId, doc);\n  }\n  // use target document as root document\n  if (n.type === NodeType.Document) {\n    // close before open to make sure document was closed\n    doc.close();\n    doc.open();\n    if (\n      n.compatMode === 'BackCompat' &&\n      n.childNodes &&\n      n.childNodes[0].type !== NodeType.DocumentType // there isn't one already defined\n    ) {\n      // Trigger compatMode in the iframe\n      // this is needed as document.createElement('iframe') otherwise inherits a CSS1Compat mode from the parent replayer environment\n      if (\n        n.childNodes[0].type === NodeType.Element &&\n        'xmlns' in n.childNodes[0].attributes &&\n        n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml'\n      ) {\n        // might as well use an xhtml doctype if we've got an xhtml namespace\n        doc.write(\n          '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"\">',\n        );\n      } else {\n        doc.write(\n          '<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"\">',\n        );\n      }\n    }\n    node = doc;\n  }\n\n  mirror.add(node, n);\n\n  if (\n    (n.type === NodeType.Document || n.type === NodeType.Element) &&\n    !skipChild\n  ) {\n    for (const childN of n.childNodes) {\n      const childNode = buildNodeWithSN(childN, {\n        doc,\n        mirror,\n        skipChild: false,\n        hackCss,\n        afterAppend,\n        cache,\n      });\n      if (!childNode) {\n        console.warn('Failed to rebuild', childN);\n        continue;\n      }\n\n      if (childN.isShadow && isElement(node) && node.shadowRoot) {\n        node.shadowRoot.appendChild(childNode);\n      } else if (\n        n.type === NodeType.Document &&\n        childN.type == NodeType.Element\n      ) {\n        const htmlElement = childNode as HTMLElement;\n        let body: HTMLBodyElement | null = null;\n        htmlElement.childNodes.forEach((child) => {\n          if (child.nodeName === 'BODY') body = child as HTMLBodyElement;\n        });\n        if (body) {\n          // this branch solves a problem in Firefox where css transitions are incorrectly\n          // being applied upon rebuild.  Presumably FF doesn't finished parsing the styles\n          // in time, and applies e.g. a default margin:0 to elements which have a non-zero\n          // margin set in CSS, along with a transition on them\n          htmlElement.removeChild(body);\n          // append <head> and <style>s\n          node.appendChild(childNode);\n          // now append <body>\n          htmlElement.appendChild(body);\n        } else {\n          node.appendChild(childNode);\n        }\n      } else {\n        node.appendChild(childNode);\n      }\n      if (afterAppend) {\n        afterAppend(childNode, childN.id);\n      }\n    }\n  }\n\n  return node;\n}\n\nfunction visit(mirror: Mirror, onVisit: (node: Node) => void) {\n  function walk(node: Node) {\n    onVisit(node);\n  }\n\n  for (const id of mirror.getIds()) {\n    if (mirror.has(id)) {\n      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n      walk(mirror.getNode(id)!);\n    }\n  }\n}\n\nfunction handleScroll(node: Node, mirror: Mirror) {\n  const n = mirror.getMeta(node);\n  if (n?.type !== NodeType.Element) {\n    return;\n  }\n  const el = node as HTMLElement;\n  for (const name in n.attributes) {\n    if (\n      !(\n        Object.prototype.hasOwnProperty.call(n.attributes, name) &&\n        name.startsWith('rr_')\n      )\n    ) {\n      continue;\n    }\n    const value = n.attributes[name];\n    if (name === 'rr_scrollLeft') {\n      el.scrollLeft = value as number;\n    }\n    if (name === 'rr_scrollTop') {\n      el.scrollTop = value as number;\n    }\n  }\n}\n\nfunction rebuild(\n  n: serializedNodeWithId,\n  options: {\n    doc: Document;\n    onVisit?: (node: Node) => unknown;\n    hackCss?: boolean;\n    afterAppend?: (n: Node, id: number) => unknown;\n    cache: BuildCache;\n    mirror: Mirror;\n  },\n): Node | null {\n  const {\n    doc,\n    onVisit,\n    hackCss = true,\n    afterAppend,\n    cache,\n    mirror = new Mirror(),\n  } = options;\n  const node = buildNodeWithSN(n, {\n    doc,\n    mirror,\n    skipChild: false,\n    hackCss,\n    afterAppend,\n    cache,\n  });\n  visit(mirror, (visitedNode) => {\n    if (onVisit) {\n      onVisit(visitedNode);\n    }\n    handleScroll(visitedNode, mirror);\n  });\n  return node;\n}\n\nexport default rebuild;\n"],
  "mappings": ";;;;;;;;AAAO,IAAK,WAAA,kBAAAA,cAAL;AACLA,YAAAA,UAAA,UAAA,IAAA,CAAA,IAAA;AACAA,YAAAA,UAAA,cAAA,IAAA,CAAA,IAAA;AACAA,YAAAA,UAAA,SAAA,IAAA,CAAA,IAAA;AACAA,YAAAA,UAAA,MAAA,IAAA,CAAA,IAAA;AACAA,YAAAA,UAAA,OAAA,IAAA,CAAA,IAAA;AACAA,YAAAA,UAAA,SAAA,IAAA,CAAA,IAAA;AANU,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;ACeL,SAAS,UAAU,GAAuB;AAC/C,SAAO,EAAE,aAAa,EAAE;AAC1B;AAEO,SAAS,aAAa,GAA0B;AACrD,QAAM,OAAwB,GAAkB;AAChD,SAAO,QAAQ,MAAM,eAAe,CAAC;AACvC;AAMO,SAAS,kBAAkB,YAAiC;AACjE,SAAO,OAAO,UAAU,SAAS,KAAK,UAAU,MAAM;AACxD;AAQA,SAAS,mCAAmC,SAAyB;AAMnE,MACE,QAAQ,SAAS,yBAAyB,KAC1C,CAAC,QAAQ,SAAS,iCAAiC,GACnD;AACA,cAAU,QAAQ;MAChB;MACA;IAAA;EAEJ;AACA,SAAO;AACT;AAsBO,SAAS,sBAAsB,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IAC1B;EACF;AACF;AAEA,SAAS,aAAa,MAAY,QAAgB;AAChD,QAAM,IAAI,OAAO,QAAQ,IAAI;AAC7B,MAAI,GAAG,SAAS,SAAS,SAAS;AAChC;EACF;AACA,QAAM,KAAK;AACX,aAAW,QAAQ,EAAE,YAAY;AAC/B,QACE,EACE,OAAO,UAAU,eAAe,KAAK,EAAE,YAAY,IAAI,KACvD,KAAK,WAAW,KAAK,IAEvB;AACA;IACF;AACA,UAAM,QAAQ,EAAE,WAAW,IAAI;AAC/B,QAAI,SAAS,iBAAiB;AAC5B,SAAG,aAAa;IAClB;AACA,QAAI,SAAS,gBAAgB;AAC3B,SAAG,YAAY;IACjB;EACF;AACF;AAEA,SAAS,QACP,GACA,SAQa;AACb,QAAM;IACJ;IACA;IACA,UAAU;IACV;IACA;IACA,SAAS,IAAI,OAAA;EAAO,IAClB;AACJ,QAAM,OAAO,gBAAgB,GAAG;IAC9B;IACA;IACA,WAAW;IACX;IACA;IACA;EAAA,CACD;AACD,QAAM,QAAQ,CAAC,gBAAgB;AAC7B,QAAI,SAAS;AACX,cAAQ,WAAW;IACrB;AACA,iBAAa,aAAa,MAAM;EAClC,CAAC;AACD,SAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
  "names": ["NodeType", "node", "attributes", "serializedNode", "_Position", "rules", "m", "selector"]
}
