@posthog/rrweb-snapshot 0.0.41 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -556,983 +556,1021 @@ var require_types_B7TTv7Jc = __commonJS({
556
556
  }
557
557
  });
558
558
 
559
- // dist/record.cjs
560
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
561
- var types = require_types_B7TTv7Jc();
562
- var _id = 1;
563
- var tagNameRegex = new RegExp("[^a-z0-9-_:]");
564
- var IGNORED_NODE = -2;
565
- function genId() {
566
- return _id++;
567
- }
568
- function getValidTagName(element) {
569
- if (element instanceof HTMLFormElement) {
570
- return "form";
571
- }
572
- const processedTagName = types.toLowerCase(element.tagName);
573
- if (tagNameRegex.test(processedTagName)) {
574
- return "div";
575
- }
576
- return processedTagName;
577
- }
578
- var canvasService;
579
- var canvasCtx;
580
- var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
581
- var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
582
- function getAbsoluteSrcsetString(doc, attributeValue) {
583
- if (attributeValue.trim() === "") {
584
- return attributeValue;
585
- }
586
- let pos = 0;
587
- function collectCharacters(regEx) {
588
- let chars;
589
- const match = regEx.exec(attributeValue.substring(pos));
590
- if (match) {
591
- chars = match[0];
592
- pos += chars.length;
593
- return chars;
594
- }
595
- return "";
596
- }
597
- const output = [];
598
- while (true) {
599
- collectCharacters(SRCSET_COMMAS_OR_SPACES);
600
- if (pos >= attributeValue.length) {
601
- break;
602
- }
603
- let url = collectCharacters(SRCSET_NOT_SPACES);
604
- if (url.slice(-1) === ",") {
605
- url = absoluteToDoc(doc, url.substring(0, url.length - 1));
606
- output.push(url);
607
- } else {
608
- let descriptorsStr = "";
609
- url = absoluteToDoc(doc, url);
610
- let inParens = false;
559
+ // dist/record-oACzRSl-.cjs
560
+ var require_record_oACzRSl = __commonJS({
561
+ "dist/record-oACzRSl-.cjs"(exports2) {
562
+ "use strict";
563
+ var types2 = require_types_B7TTv7Jc();
564
+ var _id = 1;
565
+ var tagNameRegex = new RegExp("[^a-z0-9-_:]");
566
+ var IGNORED_NODE = -2;
567
+ function genId() {
568
+ return _id++;
569
+ }
570
+ function getValidTagName(element) {
571
+ if (element instanceof HTMLFormElement) {
572
+ return "form";
573
+ }
574
+ const processedTagName = types2.toLowerCase(element.tagName);
575
+ if (tagNameRegex.test(processedTagName)) {
576
+ return "div";
577
+ }
578
+ return processedTagName;
579
+ }
580
+ var canvasService;
581
+ var canvasCtx;
582
+ var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
583
+ var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
584
+ function getAbsoluteSrcsetString(doc, attributeValue) {
585
+ if (attributeValue.trim() === "") {
586
+ return attributeValue;
587
+ }
588
+ let pos = 0;
589
+ function collectCharacters(regEx) {
590
+ let chars;
591
+ const match = regEx.exec(attributeValue.substring(pos));
592
+ if (match) {
593
+ chars = match[0];
594
+ pos += chars.length;
595
+ return chars;
596
+ }
597
+ return "";
598
+ }
599
+ const output = [];
611
600
  while (true) {
612
- const c = attributeValue.charAt(pos);
613
- if (c === "") {
614
- output.push((url + descriptorsStr).trim());
601
+ collectCharacters(SRCSET_COMMAS_OR_SPACES);
602
+ if (pos >= attributeValue.length) {
615
603
  break;
616
- } else if (!inParens) {
617
- if (c === ",") {
618
- pos += 1;
619
- output.push((url + descriptorsStr).trim());
620
- break;
621
- } else if (c === "(") {
622
- inParens = true;
623
- }
604
+ }
605
+ let url = collectCharacters(SRCSET_NOT_SPACES);
606
+ if (url.slice(-1) === ",") {
607
+ url = absoluteToDoc(doc, url.substring(0, url.length - 1));
608
+ output.push(url);
624
609
  } else {
625
- if (c === ")") {
626
- inParens = false;
610
+ let descriptorsStr = "";
611
+ url = absoluteToDoc(doc, url);
612
+ let inParens = false;
613
+ while (true) {
614
+ const c = attributeValue.charAt(pos);
615
+ if (c === "") {
616
+ output.push((url + descriptorsStr).trim());
617
+ break;
618
+ } else if (!inParens) {
619
+ if (c === ",") {
620
+ pos += 1;
621
+ output.push((url + descriptorsStr).trim());
622
+ break;
623
+ } else if (c === "(") {
624
+ inParens = true;
625
+ }
626
+ } else {
627
+ if (c === ")") {
628
+ inParens = false;
629
+ }
630
+ }
631
+ descriptorsStr += c;
632
+ pos += 1;
627
633
  }
628
634
  }
629
- descriptorsStr += c;
630
- pos += 1;
631
635
  }
636
+ return output.join(", ");
632
637
  }
633
- }
634
- return output.join(", ");
635
- }
636
- var cachedDocument = /* @__PURE__ */ new WeakMap();
637
- function absoluteToDoc(doc, attributeValue) {
638
- if (!attributeValue || attributeValue.trim() === "") {
639
- return attributeValue;
640
- }
641
- return getHref(doc, attributeValue);
642
- }
643
- function isSVGElement(el) {
644
- return Boolean(el.tagName === "svg" || el.ownerSVGElement);
645
- }
646
- function getHref(doc, customHref) {
647
- let a = cachedDocument.get(doc);
648
- if (!a) {
649
- a = doc.createElement("a");
650
- cachedDocument.set(doc, a);
651
- }
652
- if (!customHref) {
653
- customHref = "";
654
- } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
655
- return customHref;
656
- }
657
- a.setAttribute("href", customHref);
658
- return a.href;
659
- }
660
- function transformAttribute(doc, tagName, name, value, element, dataURLOptions) {
661
- if (!value) {
662
- return value;
663
- }
664
- if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
665
- const transformedValue = absoluteToDoc(doc, value);
666
- if (tagName === "img" && transformedValue.startsWith("data:") && element) {
667
- const img = element;
668
- let processedDataURL = transformedValue;
669
- if ((dataURLOptions == null ? void 0 : dataURLOptions.type) || (dataURLOptions == null ? void 0 : dataURLOptions.quality) !== void 0) {
670
- processedDataURL = types.recompressBase64Image(
671
- img,
672
- transformedValue,
673
- dataURLOptions.type,
674
- dataURLOptions.quality
675
- );
638
+ var cachedDocument = /* @__PURE__ */ new WeakMap();
639
+ function absoluteToDoc(doc, attributeValue) {
640
+ if (!attributeValue || attributeValue.trim() === "") {
641
+ return attributeValue;
676
642
  }
677
- if (dataURLOptions == null ? void 0 : dataURLOptions.maxBase64ImageLength) {
678
- processedDataURL = types.checkDataURLSize(
679
- processedDataURL,
680
- dataURLOptions.maxBase64ImageLength
681
- );
643
+ return getHref(doc, attributeValue);
644
+ }
645
+ function isSVGElement(el) {
646
+ return Boolean(el.tagName === "svg" || el.ownerSVGElement);
647
+ }
648
+ function getHref(doc, customHref) {
649
+ let a = cachedDocument.get(doc);
650
+ if (!a) {
651
+ a = doc.createElement("a");
652
+ cachedDocument.set(doc, a);
682
653
  }
683
- return processedDataURL;
684
- }
685
- return transformedValue;
686
- } else if (name === "xlink:href" && value[0] !== "#") {
687
- return absoluteToDoc(doc, value);
688
- } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
689
- return absoluteToDoc(doc, value);
690
- } else if (name === "srcset") {
691
- return getAbsoluteSrcsetString(doc, value);
692
- } else if (name === "style") {
693
- return types.absolutifyURLs(value, getHref(doc));
694
- } else if (tagName === "object" && name === "data") {
695
- return absoluteToDoc(doc, value);
696
- }
697
- return value;
698
- }
699
- function ignoreAttribute(tagName, name, _value) {
700
- return (tagName === "video" || tagName === "audio") && name === "autoplay";
701
- }
702
- function _isBlockedElement(element, blockClass, blockSelector) {
703
- try {
704
- if (typeof blockClass === "string") {
705
- if (element.classList.contains(blockClass)) {
706
- return true;
654
+ if (!customHref) {
655
+ customHref = "";
656
+ } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
657
+ return customHref;
707
658
  }
708
- } else {
709
- for (let eIndex = element.classList.length; eIndex--; ) {
710
- const className = element.classList[eIndex];
711
- if (blockClass.test(className)) {
712
- return true;
659
+ a.setAttribute("href", customHref);
660
+ return a.href;
661
+ }
662
+ function transformAttribute(doc, tagName, name, value, element, dataURLOptions) {
663
+ if (!value) {
664
+ return value;
665
+ }
666
+ if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
667
+ const transformedValue = absoluteToDoc(doc, value);
668
+ if (tagName === "img" && transformedValue.startsWith("data:") && element) {
669
+ const img = element;
670
+ let processedDataURL = transformedValue;
671
+ if ((dataURLOptions == null ? void 0 : dataURLOptions.type) || (dataURLOptions == null ? void 0 : dataURLOptions.quality) !== void 0) {
672
+ processedDataURL = types2.recompressBase64Image(
673
+ img,
674
+ transformedValue,
675
+ dataURLOptions.type,
676
+ dataURLOptions.quality
677
+ );
678
+ }
679
+ if (dataURLOptions == null ? void 0 : dataURLOptions.maxBase64ImageLength) {
680
+ processedDataURL = types2.checkDataURLSize(
681
+ processedDataURL,
682
+ dataURLOptions.maxBase64ImageLength
683
+ );
684
+ }
685
+ return processedDataURL;
713
686
  }
687
+ return transformedValue;
688
+ } else if (name === "xlink:href" && value[0] !== "#") {
689
+ return absoluteToDoc(doc, value);
690
+ } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
691
+ return absoluteToDoc(doc, value);
692
+ } else if (name === "srcset") {
693
+ return getAbsoluteSrcsetString(doc, value);
694
+ } else if (name === "style") {
695
+ return types2.absolutifyURLs(value, getHref(doc));
696
+ } else if (tagName === "object" && name === "data") {
697
+ return absoluteToDoc(doc, value);
714
698
  }
699
+ return value;
715
700
  }
716
- if (blockSelector) {
717
- return element.matches(blockSelector);
701
+ function ignoreAttribute(tagName, name, _value) {
702
+ return (tagName === "video" || tagName === "audio") && name === "autoplay";
718
703
  }
719
- } catch (e) {
720
- }
721
- return false;
722
- }
723
- function classMatchesRegex(node, regex, checkAncestors) {
724
- if (!node) return false;
725
- if (node.nodeType !== node.ELEMENT_NODE) {
726
- if (!checkAncestors) return false;
727
- return classMatchesRegex(types.index.parentNode(node), regex, checkAncestors);
728
- }
729
- for (let eIndex = node.classList.length; eIndex--; ) {
730
- const className = node.classList[eIndex];
731
- if (regex.test(className)) {
732
- return true;
733
- }
734
- }
735
- if (!checkAncestors) return false;
736
- return classMatchesRegex(types.index.parentNode(node), regex, checkAncestors);
737
- }
738
- function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) {
739
- let el;
740
- if (types.isElement(node)) {
741
- el = node;
742
- if (!types.index.childNodes(el).length) {
704
+ function _isBlockedElement(element, blockClass, blockSelector) {
705
+ try {
706
+ if (typeof blockClass === "string") {
707
+ if (element.classList.contains(blockClass)) {
708
+ return true;
709
+ }
710
+ } else {
711
+ for (let eIndex = element.classList.length; eIndex--; ) {
712
+ const className = element.classList[eIndex];
713
+ if (blockClass.test(className)) {
714
+ return true;
715
+ }
716
+ }
717
+ }
718
+ if (blockSelector) {
719
+ return element.matches(blockSelector);
720
+ }
721
+ } catch (e) {
722
+ }
743
723
  return false;
744
724
  }
745
- } else if (types.index.parentElement(node) === null) {
746
- return false;
747
- } else {
748
- el = types.index.parentElement(node);
749
- }
750
- try {
751
- if (typeof maskTextClass === "string") {
752
- if (checkAncestors) {
753
- if (el.closest(`.${maskTextClass}`)) return true;
725
+ function classMatchesRegex(node, regex, checkAncestors) {
726
+ if (!node) return false;
727
+ if (node.nodeType !== node.ELEMENT_NODE) {
728
+ if (!checkAncestors) return false;
729
+ return classMatchesRegex(types2.index.parentNode(node), regex, checkAncestors);
730
+ }
731
+ for (let eIndex = node.classList.length; eIndex--; ) {
732
+ const className = node.classList[eIndex];
733
+ if (regex.test(className)) {
734
+ return true;
735
+ }
736
+ }
737
+ if (!checkAncestors) return false;
738
+ return classMatchesRegex(types2.index.parentNode(node), regex, checkAncestors);
739
+ }
740
+ function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) {
741
+ let el;
742
+ if (types2.isElement(node)) {
743
+ el = node;
744
+ if (!types2.index.childNodes(el).length) {
745
+ return false;
746
+ }
747
+ } else if (types2.index.parentElement(node) === null) {
748
+ return false;
754
749
  } else {
755
- if (el.classList.contains(maskTextClass)) return true;
750
+ el = types2.index.parentElement(node);
751
+ }
752
+ try {
753
+ if (typeof maskTextClass === "string") {
754
+ if (checkAncestors) {
755
+ if (el.closest(`.${maskTextClass}`)) return true;
756
+ } else {
757
+ if (el.classList.contains(maskTextClass)) return true;
758
+ }
759
+ } else {
760
+ if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
761
+ }
762
+ if (maskTextSelector) {
763
+ if (checkAncestors) {
764
+ if (el.closest(maskTextSelector)) return true;
765
+ } else {
766
+ if (el.matches(maskTextSelector)) return true;
767
+ }
768
+ }
769
+ } catch (e) {
756
770
  }
757
- } else {
758
- if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
771
+ return false;
759
772
  }
760
- if (maskTextSelector) {
761
- if (checkAncestors) {
762
- if (el.closest(maskTextSelector)) return true;
763
- } else {
764
- if (el.matches(maskTextSelector)) return true;
773
+ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
774
+ const win = iframeEl.contentWindow;
775
+ if (!win) {
776
+ return;
777
+ }
778
+ let fired = false;
779
+ let readyState;
780
+ try {
781
+ readyState = win.document.readyState;
782
+ } catch (error) {
783
+ return;
784
+ }
785
+ if (readyState !== "complete") {
786
+ const timer = setTimeout(() => {
787
+ if (!fired) {
788
+ listener();
789
+ fired = true;
790
+ }
791
+ }, iframeLoadTimeout);
792
+ iframeEl.addEventListener("load", () => {
793
+ clearTimeout(timer);
794
+ fired = true;
795
+ listener();
796
+ });
797
+ return;
798
+ }
799
+ const blankUrl = "about:blank";
800
+ if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
801
+ setTimeout(listener, 0);
802
+ return iframeEl.addEventListener("load", listener);
765
803
  }
804
+ iframeEl.addEventListener("load", listener);
766
805
  }
767
- } catch (e) {
768
- }
769
- return false;
770
- }
771
- function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
772
- const win = iframeEl.contentWindow;
773
- if (!win) {
774
- return;
775
- }
776
- let fired = false;
777
- let readyState;
778
- try {
779
- readyState = win.document.readyState;
780
- } catch (error) {
781
- return;
782
- }
783
- if (readyState !== "complete") {
784
- const timer = setTimeout(() => {
785
- if (!fired) {
786
- listener();
806
+ function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
807
+ let fired = false;
808
+ let styleSheetLoaded;
809
+ try {
810
+ styleSheetLoaded = link.sheet;
811
+ } catch (error) {
812
+ return;
813
+ }
814
+ if (styleSheetLoaded) return;
815
+ const timer = setTimeout(() => {
816
+ if (!fired) {
817
+ listener();
818
+ fired = true;
819
+ }
820
+ }, styleSheetLoadTimeout);
821
+ link.addEventListener("load", () => {
822
+ clearTimeout(timer);
787
823
  fired = true;
824
+ listener();
825
+ });
826
+ }
827
+ function serializeNode(n, options) {
828
+ const {
829
+ doc,
830
+ mirror,
831
+ blockClass,
832
+ blockSelector,
833
+ needsMask,
834
+ inlineStylesheet,
835
+ maskInputOptions = {},
836
+ maskTextFn,
837
+ maskInputFn,
838
+ dataURLOptions = {},
839
+ inlineImages,
840
+ recordCanvas,
841
+ keepIframeSrcFn,
842
+ newlyAddedElement = false
843
+ } = options;
844
+ const rootId = getRootId(doc, mirror);
845
+ switch (n.nodeType) {
846
+ case n.DOCUMENT_NODE:
847
+ if (n.compatMode !== "CSS1Compat") {
848
+ return {
849
+ type: types2.NodeType$1.Document,
850
+ childNodes: [],
851
+ compatMode: n.compatMode
852
+ // probably "BackCompat"
853
+ };
854
+ } else {
855
+ return {
856
+ type: types2.NodeType$1.Document,
857
+ childNodes: []
858
+ };
859
+ }
860
+ case n.DOCUMENT_TYPE_NODE:
861
+ return {
862
+ type: types2.NodeType$1.DocumentType,
863
+ name: n.name,
864
+ publicId: n.publicId,
865
+ systemId: n.systemId,
866
+ rootId
867
+ };
868
+ case n.ELEMENT_NODE:
869
+ return serializeElementNode(n, {
870
+ doc,
871
+ blockClass,
872
+ blockSelector,
873
+ inlineStylesheet,
874
+ maskInputOptions,
875
+ maskInputFn,
876
+ dataURLOptions,
877
+ inlineImages,
878
+ recordCanvas,
879
+ keepIframeSrcFn,
880
+ newlyAddedElement,
881
+ rootId
882
+ });
883
+ case n.TEXT_NODE:
884
+ return serializeTextNode(n, {
885
+ doc,
886
+ needsMask,
887
+ maskTextFn,
888
+ rootId
889
+ });
890
+ case n.CDATA_SECTION_NODE:
891
+ return {
892
+ type: types2.NodeType$1.CDATA,
893
+ textContent: "",
894
+ rootId
895
+ };
896
+ case n.COMMENT_NODE:
897
+ return {
898
+ type: types2.NodeType$1.Comment,
899
+ textContent: types2.index.textContent(n) || "",
900
+ rootId
901
+ };
902
+ default:
903
+ return false;
788
904
  }
789
- }, iframeLoadTimeout);
790
- iframeEl.addEventListener("load", () => {
791
- clearTimeout(timer);
792
- fired = true;
793
- listener();
794
- });
795
- return;
796
- }
797
- const blankUrl = "about:blank";
798
- if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
799
- setTimeout(listener, 0);
800
- return iframeEl.addEventListener("load", listener);
801
- }
802
- iframeEl.addEventListener("load", listener);
803
- }
804
- function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
805
- let fired = false;
806
- let styleSheetLoaded;
807
- try {
808
- styleSheetLoaded = link.sheet;
809
- } catch (error) {
810
- return;
811
- }
812
- if (styleSheetLoaded) return;
813
- const timer = setTimeout(() => {
814
- if (!fired) {
815
- listener();
816
- fired = true;
817
- }
818
- }, styleSheetLoadTimeout);
819
- link.addEventListener("load", () => {
820
- clearTimeout(timer);
821
- fired = true;
822
- listener();
823
- });
824
- }
825
- function serializeNode(n, options) {
826
- const {
827
- doc,
828
- mirror,
829
- blockClass,
830
- blockSelector,
831
- needsMask,
832
- inlineStylesheet,
833
- maskInputOptions = {},
834
- maskTextFn,
835
- maskInputFn,
836
- dataURLOptions = {},
837
- inlineImages,
838
- recordCanvas,
839
- keepIframeSrcFn,
840
- newlyAddedElement = false
841
- } = options;
842
- const rootId = getRootId(doc, mirror);
843
- switch (n.nodeType) {
844
- case n.DOCUMENT_NODE:
845
- if (n.compatMode !== "CSS1Compat") {
846
- return {
847
- type: types.NodeType$1.Document,
848
- childNodes: [],
849
- compatMode: n.compatMode
850
- // probably "BackCompat"
851
- };
852
- } else {
853
- return {
854
- type: types.NodeType$1.Document,
855
- childNodes: []
856
- };
905
+ }
906
+ function getRootId(doc, mirror) {
907
+ if (!mirror.hasNode(doc)) return void 0;
908
+ const docId = mirror.getId(doc);
909
+ return docId === 1 ? void 0 : docId;
910
+ }
911
+ function serializeTextNode(n, options) {
912
+ var _a;
913
+ const { needsMask, maskTextFn, rootId } = options;
914
+ const parent = types2.index.parentNode(n);
915
+ const parentTagName = parent && parent.tagName;
916
+ let text = types2.index.textContent(n);
917
+ const isStyle = parentTagName === "STYLE" ? true : void 0;
918
+ const isScript = parentTagName === "SCRIPT" ? true : void 0;
919
+ if (isStyle && text) {
920
+ try {
921
+ if (n.nextSibling || n.previousSibling) {
922
+ } else if ((_a = parent.sheet) == null ? void 0 : _a.cssRules) {
923
+ text = types2.stringifyStylesheet(parent.sheet);
924
+ }
925
+ } catch (err) {
926
+ console.warn(
927
+ `Cannot get CSS styles from text's parentNode. Error: ${err}`,
928
+ n
929
+ );
930
+ }
931
+ text = types2.absolutifyURLs(text, getHref(options.doc));
932
+ }
933
+ if (isScript) {
934
+ text = "SCRIPT_PLACEHOLDER";
935
+ }
936
+ if (!isStyle && !isScript && text && needsMask) {
937
+ text = maskTextFn ? maskTextFn(text, types2.index.parentElement(n)) : text.replace(/[\S]/g, "*");
857
938
  }
858
- case n.DOCUMENT_TYPE_NODE:
859
939
  return {
860
- type: types.NodeType$1.DocumentType,
861
- name: n.name,
862
- publicId: n.publicId,
863
- systemId: n.systemId,
940
+ type: types2.NodeType$1.Text,
941
+ textContent: text || "",
942
+ isStyle,
864
943
  rootId
865
944
  };
866
- case n.ELEMENT_NODE:
867
- return serializeElementNode(n, {
945
+ }
946
+ function findStylesheet(doc, href) {
947
+ return Array.from(doc.styleSheets).find((s) => s.href === href);
948
+ }
949
+ function hrefFrom(n) {
950
+ return n.href;
951
+ }
952
+ function serializeElementNode(n, options) {
953
+ var _a, _b;
954
+ const {
868
955
  doc,
869
956
  blockClass,
870
957
  blockSelector,
871
958
  inlineStylesheet,
872
- maskInputOptions,
959
+ maskInputOptions = {},
873
960
  maskInputFn,
874
- dataURLOptions,
961
+ dataURLOptions = {},
875
962
  inlineImages,
876
963
  recordCanvas,
877
964
  keepIframeSrcFn,
878
- newlyAddedElement,
879
- rootId
880
- });
881
- case n.TEXT_NODE:
882
- return serializeTextNode(n, {
883
- doc,
884
- needsMask,
885
- maskTextFn,
886
- rootId
887
- });
888
- case n.CDATA_SECTION_NODE:
889
- return {
890
- type: types.NodeType$1.CDATA,
891
- textContent: "",
965
+ newlyAddedElement = false,
892
966
  rootId
893
- };
894
- case n.COMMENT_NODE:
895
- return {
896
- type: types.NodeType$1.Comment,
897
- textContent: types.index.textContent(n) || "",
898
- rootId
899
- };
900
- default:
901
- return false;
902
- }
903
- }
904
- function getRootId(doc, mirror) {
905
- if (!mirror.hasNode(doc)) return void 0;
906
- const docId = mirror.getId(doc);
907
- return docId === 1 ? void 0 : docId;
908
- }
909
- function serializeTextNode(n, options) {
910
- var _a;
911
- const { needsMask, maskTextFn, rootId } = options;
912
- const parent = types.index.parentNode(n);
913
- const parentTagName = parent && parent.tagName;
914
- let text = types.index.textContent(n);
915
- const isStyle = parentTagName === "STYLE" ? true : void 0;
916
- const isScript = parentTagName === "SCRIPT" ? true : void 0;
917
- if (isStyle && text) {
918
- try {
919
- if (n.nextSibling || n.previousSibling) {
920
- } else if ((_a = parent.sheet) == null ? void 0 : _a.cssRules) {
921
- text = types.stringifyStylesheet(parent.sheet);
922
- }
923
- } catch (err) {
924
- console.warn(
925
- `Cannot get CSS styles from text's parentNode. Error: ${err}`,
926
- n
927
- );
928
- }
929
- text = types.absolutifyURLs(text, getHref(options.doc));
930
- }
931
- if (isScript) {
932
- text = "SCRIPT_PLACEHOLDER";
933
- }
934
- if (!isStyle && !isScript && text && needsMask) {
935
- text = maskTextFn ? maskTextFn(text, types.index.parentElement(n)) : text.replace(/[\S]/g, "*");
936
- }
937
- return {
938
- type: types.NodeType$1.Text,
939
- textContent: text || "",
940
- isStyle,
941
- rootId
942
- };
943
- }
944
- function findStylesheet(doc, href) {
945
- return Array.from(doc.styleSheets).find((s) => s.href === href);
946
- }
947
- function hrefFrom(n) {
948
- return n.href;
949
- }
950
- function serializeElementNode(n, options) {
951
- var _a, _b;
952
- const {
953
- doc,
954
- blockClass,
955
- blockSelector,
956
- inlineStylesheet,
957
- maskInputOptions = {},
958
- maskInputFn,
959
- dataURLOptions = {},
960
- inlineImages,
961
- recordCanvas,
962
- keepIframeSrcFn,
963
- newlyAddedElement = false,
964
- rootId
965
- } = options;
966
- const needBlock = _isBlockedElement(n, blockClass, blockSelector);
967
- const tagName = getValidTagName(n);
968
- let attributes = {};
969
- const len = n.attributes.length;
970
- for (let i = 0; i < len; i++) {
971
- const attr = n.attributes[i];
972
- if (!ignoreAttribute(tagName, attr.name, attr.value)) {
973
- attributes[attr.name] = transformAttribute(
974
- doc,
975
- tagName,
976
- types.toLowerCase(attr.name),
977
- attr.value,
978
- n,
979
- dataURLOptions
980
- );
981
- }
982
- }
983
- if (tagName === "link" && inlineStylesheet) {
984
- const href = hrefFrom(n);
985
- if (href) {
986
- let stylesheet = findStylesheet(doc, href);
987
- if (!stylesheet && href.includes(".css")) {
988
- const rootDomain = window.location.origin;
989
- const stylesheetPath = href.replace(window.location.href, "");
990
- const potentialStylesheetHref = rootDomain + "/" + stylesheetPath;
991
- stylesheet = findStylesheet(doc, potentialStylesheetHref);
992
- }
993
- let cssText = null;
994
- if (stylesheet) {
995
- cssText = types.stringifyStylesheet(stylesheet);
996
- }
997
- if (cssText) {
998
- delete attributes.rel;
999
- delete attributes.href;
1000
- attributes._cssText = cssText;
967
+ } = options;
968
+ const needBlock = _isBlockedElement(n, blockClass, blockSelector);
969
+ const tagName = getValidTagName(n);
970
+ let attributes = {};
971
+ const len = n.attributes.length;
972
+ for (let i = 0; i < len; i++) {
973
+ const attr = n.attributes[i];
974
+ if (!ignoreAttribute(tagName, attr.name, attr.value)) {
975
+ attributes[attr.name] = transformAttribute(
976
+ doc,
977
+ tagName,
978
+ types2.toLowerCase(attr.name),
979
+ attr.value,
980
+ n,
981
+ dataURLOptions
982
+ );
983
+ }
1001
984
  }
1002
- }
1003
- }
1004
- if (tagName === "style" && n.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
1005
- !(n.innerText || types.index.textContent(n) || "").trim().length) {
1006
- const cssText = types.stringifyStylesheet(
1007
- n.sheet
1008
- );
1009
- if (cssText) {
1010
- attributes._cssText = cssText;
1011
- }
1012
- }
1013
- if (tagName === "input" || tagName === "textarea" || tagName === "select") {
1014
- const value = n.value;
1015
- const checked = n.checked;
1016
- if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
1017
- attributes.value = types.maskInputValue({
1018
- element: n,
1019
- type: types.getInputType(n),
1020
- tagName,
1021
- value,
1022
- maskInputOptions,
1023
- maskInputFn
1024
- });
1025
- } else if (checked) {
1026
- attributes.checked = checked;
1027
- }
1028
- }
1029
- if (tagName === "option") {
1030
- if (n.selected && !maskInputOptions["select"]) {
1031
- attributes.selected = true;
1032
- } else {
1033
- delete attributes.selected;
1034
- }
1035
- }
1036
- if (tagName === "dialog" && n.open) {
1037
- try {
1038
- attributes.rr_open_mode = n.matches("dialog:modal") ? "modal" : "non-modal";
1039
- } catch (e) {
1040
- attributes.rr_open_mode = "modal";
1041
- attributes.ph_rr_could_not_detect_modal = true;
1042
- }
1043
- }
1044
- if (tagName === "canvas" && recordCanvas) {
1045
- if (n.__context === "2d") {
1046
- if (!types.is2DCanvasBlank(n)) {
1047
- attributes.rr_dataURL = n.toDataURL(
1048
- dataURLOptions.type,
1049
- dataURLOptions.quality
985
+ if (tagName === "link" && inlineStylesheet) {
986
+ const href = hrefFrom(n);
987
+ if (href) {
988
+ let stylesheet = findStylesheet(doc, href);
989
+ if (!stylesheet && href.includes(".css")) {
990
+ const rootDomain = window.location.origin;
991
+ const stylesheetPath = href.replace(window.location.href, "");
992
+ const potentialStylesheetHref = rootDomain + "/" + stylesheetPath;
993
+ stylesheet = findStylesheet(doc, potentialStylesheetHref);
994
+ }
995
+ let cssText = null;
996
+ if (stylesheet) {
997
+ cssText = types2.stringifyStylesheet(stylesheet);
998
+ }
999
+ if (cssText) {
1000
+ delete attributes.rel;
1001
+ delete attributes.href;
1002
+ attributes._cssText = cssText;
1003
+ }
1004
+ }
1005
+ }
1006
+ if (tagName === "style" && n.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
1007
+ !(n.innerText || types2.index.textContent(n) || "").trim().length) {
1008
+ const cssText = types2.stringifyStylesheet(
1009
+ n.sheet
1050
1010
  );
1011
+ if (cssText) {
1012
+ attributes._cssText = cssText;
1013
+ }
1051
1014
  }
1052
- } else if (!("__context" in n)) {
1053
- const canvasDataURL = n.toDataURL(
1054
- dataURLOptions.type,
1055
- dataURLOptions.quality
1056
- );
1057
- const blankCanvas = doc.createElement("canvas");
1058
- blankCanvas.width = n.width;
1059
- blankCanvas.height = n.height;
1060
- const blankCanvasDataURL = blankCanvas.toDataURL(
1061
- dataURLOptions.type,
1062
- dataURLOptions.quality
1063
- );
1064
- if (canvasDataURL !== blankCanvasDataURL) {
1065
- attributes.rr_dataURL = canvasDataURL;
1015
+ if (tagName === "input" || tagName === "textarea" || tagName === "select") {
1016
+ const value = n.value;
1017
+ const checked = n.checked;
1018
+ if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
1019
+ attributes.value = types2.maskInputValue({
1020
+ element: n,
1021
+ type: types2.getInputType(n),
1022
+ tagName,
1023
+ value,
1024
+ maskInputOptions,
1025
+ maskInputFn
1026
+ });
1027
+ } else if (checked) {
1028
+ attributes.checked = checked;
1029
+ }
1066
1030
  }
1067
- }
1068
- }
1069
- if (tagName === "img" && inlineImages) {
1070
- if (!canvasService) {
1071
- canvasService = doc.createElement("canvas");
1072
- canvasCtx = canvasService.getContext("2d");
1073
- }
1074
- const image = n;
1075
- const imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
1076
- const priorCrossOrigin = image.crossOrigin;
1077
- const recordInlineImage = () => {
1078
- image.removeEventListener("load", recordInlineImage);
1079
- try {
1080
- canvasService.width = image.naturalWidth;
1081
- canvasService.height = image.naturalHeight;
1082
- canvasCtx.drawImage(image, 0, 0);
1083
- attributes.rr_dataURL = canvasService.toDataURL(
1084
- dataURLOptions.type,
1085
- dataURLOptions.quality
1086
- );
1087
- } catch (err) {
1088
- if (image.crossOrigin !== "anonymous") {
1089
- image.crossOrigin = "anonymous";
1090
- if (image.complete && image.naturalWidth !== 0)
1091
- recordInlineImage();
1092
- else image.addEventListener("load", recordInlineImage);
1093
- return;
1031
+ if (tagName === "option") {
1032
+ if (n.selected && !maskInputOptions["select"]) {
1033
+ attributes.selected = true;
1094
1034
  } else {
1095
- console.warn(
1096
- `Cannot inline img src=${imageSrc}! Error: ${err}`
1035
+ delete attributes.selected;
1036
+ }
1037
+ }
1038
+ if (tagName === "dialog" && n.open) {
1039
+ try {
1040
+ attributes.rr_open_mode = n.matches("dialog:modal") ? "modal" : "non-modal";
1041
+ } catch (e) {
1042
+ attributes.rr_open_mode = "modal";
1043
+ attributes.ph_rr_could_not_detect_modal = true;
1044
+ }
1045
+ }
1046
+ if (tagName === "canvas" && recordCanvas) {
1047
+ if (n.__context === "2d") {
1048
+ if (!types2.is2DCanvasBlank(n)) {
1049
+ attributes.rr_dataURL = n.toDataURL(
1050
+ dataURLOptions.type,
1051
+ dataURLOptions.quality
1052
+ );
1053
+ }
1054
+ } else if (!("__context" in n)) {
1055
+ const canvasDataURL = n.toDataURL(
1056
+ dataURLOptions.type,
1057
+ dataURLOptions.quality
1058
+ );
1059
+ const blankCanvas = doc.createElement("canvas");
1060
+ blankCanvas.width = n.width;
1061
+ blankCanvas.height = n.height;
1062
+ const blankCanvasDataURL = blankCanvas.toDataURL(
1063
+ dataURLOptions.type,
1064
+ dataURLOptions.quality
1097
1065
  );
1066
+ if (canvasDataURL !== blankCanvasDataURL) {
1067
+ attributes.rr_dataURL = canvasDataURL;
1068
+ }
1098
1069
  }
1099
1070
  }
1100
- if (image.crossOrigin === "anonymous") {
1101
- priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
1071
+ if (tagName === "img" && inlineImages) {
1072
+ if (!canvasService) {
1073
+ canvasService = doc.createElement("canvas");
1074
+ canvasCtx = canvasService.getContext("2d");
1075
+ }
1076
+ const image = n;
1077
+ const imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
1078
+ const priorCrossOrigin = image.crossOrigin;
1079
+ const recordInlineImage = () => {
1080
+ image.removeEventListener("load", recordInlineImage);
1081
+ try {
1082
+ canvasService.width = image.naturalWidth;
1083
+ canvasService.height = image.naturalHeight;
1084
+ canvasCtx.drawImage(image, 0, 0);
1085
+ attributes.rr_dataURL = canvasService.toDataURL(
1086
+ dataURLOptions.type,
1087
+ dataURLOptions.quality
1088
+ );
1089
+ } catch (err) {
1090
+ if (image.crossOrigin !== "anonymous") {
1091
+ image.crossOrigin = "anonymous";
1092
+ if (image.complete && image.naturalWidth !== 0)
1093
+ recordInlineImage();
1094
+ else image.addEventListener("load", recordInlineImage);
1095
+ return;
1096
+ } else {
1097
+ console.warn(
1098
+ `Cannot inline img src=${imageSrc}! Error: ${err}`
1099
+ );
1100
+ }
1101
+ }
1102
+ if (image.crossOrigin === "anonymous") {
1103
+ priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
1104
+ }
1105
+ };
1106
+ if (image.complete && image.naturalWidth !== 0) recordInlineImage();
1107
+ else image.addEventListener("load", recordInlineImage);
1102
1108
  }
1103
- };
1104
- if (image.complete && image.naturalWidth !== 0) recordInlineImage();
1105
- else image.addEventListener("load", recordInlineImage);
1106
- }
1107
- if (tagName === "audio" || tagName === "video") {
1108
- const mediaAttributes = attributes;
1109
- mediaAttributes.rr_mediaState = n.paused ? "paused" : "played";
1110
- mediaAttributes.rr_mediaCurrentTime = n.currentTime;
1111
- mediaAttributes.rr_mediaPlaybackRate = n.playbackRate;
1112
- mediaAttributes.rr_mediaMuted = n.muted;
1113
- mediaAttributes.rr_mediaLoop = n.loop;
1114
- mediaAttributes.rr_mediaVolume = n.volume;
1115
- }
1116
- if (!newlyAddedElement) {
1117
- if (n.scrollLeft) {
1118
- attributes.rr_scrollLeft = n.scrollLeft;
1119
- }
1120
- if (n.scrollTop) {
1121
- attributes.rr_scrollTop = n.scrollTop;
1109
+ if (tagName === "audio" || tagName === "video") {
1110
+ const mediaAttributes = attributes;
1111
+ mediaAttributes.rr_mediaState = n.paused ? "paused" : "played";
1112
+ mediaAttributes.rr_mediaCurrentTime = n.currentTime;
1113
+ mediaAttributes.rr_mediaPlaybackRate = n.playbackRate;
1114
+ mediaAttributes.rr_mediaMuted = n.muted;
1115
+ mediaAttributes.rr_mediaLoop = n.loop;
1116
+ mediaAttributes.rr_mediaVolume = n.volume;
1117
+ }
1118
+ if (!newlyAddedElement) {
1119
+ if (n.scrollLeft) {
1120
+ attributes.rr_scrollLeft = n.scrollLeft;
1121
+ }
1122
+ if (n.scrollTop) {
1123
+ attributes.rr_scrollTop = n.scrollTop;
1124
+ }
1125
+ }
1126
+ if (needBlock) {
1127
+ const { width, height, left, top } = n.getBoundingClientRect();
1128
+ attributes = {
1129
+ class: attributes.class,
1130
+ rr_width: `${width}px`,
1131
+ rr_height: `${height}px`,
1132
+ rr_left: `${Math.floor(left + (((_a = doc.defaultView) == null ? void 0 : _a.scrollX) || 0))}px`,
1133
+ rr_top: `${Math.floor(top + (((_b = doc.defaultView) == null ? void 0 : _b.scrollY) || 0))}px`
1134
+ };
1135
+ }
1136
+ if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
1137
+ if (!n.contentDocument) {
1138
+ attributes.rr_src = attributes.src;
1139
+ }
1140
+ delete attributes.src;
1141
+ }
1142
+ let isCustomElement;
1143
+ try {
1144
+ if (customElements.get(tagName)) isCustomElement = true;
1145
+ } catch (e) {
1146
+ }
1147
+ return {
1148
+ type: types2.NodeType$1.Element,
1149
+ tagName,
1150
+ attributes,
1151
+ childNodes: [],
1152
+ isSVG: isSVGElement(n) || void 0,
1153
+ needBlock,
1154
+ rootId,
1155
+ isCustom: isCustomElement
1156
+ };
1122
1157
  }
1123
- }
1124
- if (needBlock) {
1125
- const { width, height, left, top } = n.getBoundingClientRect();
1126
- attributes = {
1127
- class: attributes.class,
1128
- rr_width: `${width}px`,
1129
- rr_height: `${height}px`,
1130
- rr_left: `${Math.floor(left + (((_a = doc.defaultView) == null ? void 0 : _a.scrollX) || 0))}px`,
1131
- rr_top: `${Math.floor(top + (((_b = doc.defaultView) == null ? void 0 : _b.scrollY) || 0))}px`
1132
- };
1133
- }
1134
- if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
1135
- if (!n.contentDocument) {
1136
- attributes.rr_src = attributes.src;
1158
+ function lowerIfExists(maybeAttr) {
1159
+ if (maybeAttr === void 0 || maybeAttr === null) {
1160
+ return "";
1161
+ } else {
1162
+ return maybeAttr.toLowerCase();
1163
+ }
1137
1164
  }
1138
- delete attributes.src;
1139
- }
1140
- let isCustomElement;
1141
- try {
1142
- if (customElements.get(tagName)) isCustomElement = true;
1143
- } catch (e) {
1144
- }
1145
- return {
1146
- type: types.NodeType$1.Element,
1147
- tagName,
1148
- attributes,
1149
- childNodes: [],
1150
- isSVG: isSVGElement(n) || void 0,
1151
- needBlock,
1152
- rootId,
1153
- isCustom: isCustomElement
1154
- };
1155
- }
1156
- function lowerIfExists(maybeAttr) {
1157
- if (maybeAttr === void 0 || maybeAttr === null) {
1158
- return "";
1159
- } else {
1160
- return maybeAttr.toLowerCase();
1161
- }
1162
- }
1163
- function slimDOMExcluded(sn, slimDOMOptions) {
1164
- if (slimDOMOptions.comment && sn.type === types.NodeType$1.Comment) {
1165
- return true;
1166
- } else if (sn.type === types.NodeType$1.Element) {
1167
- if (slimDOMOptions.script && // script tag
1168
- (sn.tagName === "script" || // (module)preload link
1169
- sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
1170
- sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && types.extractFileExtension(sn.attributes.href) === "js")) {
1171
- return true;
1172
- } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(
1173
- /^msapplication-tile(image|color)$/
1174
- ) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) {
1175
- return true;
1176
- } else if (sn.tagName === "meta") {
1177
- if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
1178
- return true;
1179
- } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
1180
- lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
1181
- return true;
1182
- } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
1183
- return true;
1184
- } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
1185
- return true;
1186
- } else if (slimDOMOptions.headMetaAuthorship && (lowerIfExists(sn.attributes.name) === "author" || lowerIfExists(sn.attributes.name) === "generator" || lowerIfExists(sn.attributes.name) === "framework" || lowerIfExists(sn.attributes.name) === "publisher" || lowerIfExists(sn.attributes.name) === "progid" || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
1187
- return true;
1188
- } else if (slimDOMOptions.headMetaVerification && (lowerIfExists(sn.attributes.name) === "google-site-verification" || lowerIfExists(sn.attributes.name) === "yandex-verification" || lowerIfExists(sn.attributes.name) === "csrf-token" || lowerIfExists(sn.attributes.name) === "p:domain_verify" || lowerIfExists(sn.attributes.name) === "verify-v1" || lowerIfExists(sn.attributes.name) === "verification" || lowerIfExists(sn.attributes.name) === "shopify-checkout-api-token")) {
1165
+ function slimDOMExcluded(sn, slimDOMOptions) {
1166
+ if (slimDOMOptions.comment && sn.type === types2.NodeType$1.Comment) {
1189
1167
  return true;
1168
+ } else if (sn.type === types2.NodeType$1.Element) {
1169
+ if (slimDOMOptions.script && // script tag
1170
+ (sn.tagName === "script" || // (module)preload link
1171
+ sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
1172
+ sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && types2.extractFileExtension(sn.attributes.href) === "js")) {
1173
+ return true;
1174
+ } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(
1175
+ /^msapplication-tile(image|color)$/
1176
+ ) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) {
1177
+ return true;
1178
+ } else if (sn.tagName === "meta") {
1179
+ if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
1180
+ return true;
1181
+ } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
1182
+ lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
1183
+ return true;
1184
+ } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
1185
+ return true;
1186
+ } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
1187
+ return true;
1188
+ } else if (slimDOMOptions.headMetaAuthorship && (lowerIfExists(sn.attributes.name) === "author" || lowerIfExists(sn.attributes.name) === "generator" || lowerIfExists(sn.attributes.name) === "framework" || lowerIfExists(sn.attributes.name) === "publisher" || lowerIfExists(sn.attributes.name) === "progid" || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
1189
+ return true;
1190
+ } else if (slimDOMOptions.headMetaVerification && (lowerIfExists(sn.attributes.name) === "google-site-verification" || lowerIfExists(sn.attributes.name) === "yandex-verification" || lowerIfExists(sn.attributes.name) === "csrf-token" || lowerIfExists(sn.attributes.name) === "p:domain_verify" || lowerIfExists(sn.attributes.name) === "verify-v1" || lowerIfExists(sn.attributes.name) === "verification" || lowerIfExists(sn.attributes.name) === "shopify-checkout-api-token")) {
1191
+ return true;
1192
+ }
1193
+ }
1190
1194
  }
1195
+ return false;
1191
1196
  }
1192
- }
1193
- return false;
1194
- }
1195
- var DEFAULT_MAX_DEPTH = 50;
1196
- var _maxDepthWarned = false;
1197
- var _maxDepthReached = false;
1198
- function wasMaxDepthReached() {
1199
- return _maxDepthReached;
1200
- }
1201
- function serializeNodeWithId(n, options) {
1202
- const {
1203
- doc,
1204
- mirror,
1205
- blockClass,
1206
- blockSelector,
1207
- maskTextClass,
1208
- maskTextSelector,
1209
- skipChild = false,
1210
- inlineStylesheet = true,
1211
- maskInputOptions = {},
1212
- maskTextFn,
1213
- maskInputFn,
1214
- slimDOMOptions,
1215
- dataURLOptions = {},
1216
- inlineImages = false,
1217
- recordCanvas = false,
1218
- onSerialize,
1219
- onIframeLoad,
1220
- iframeLoadTimeout = 5e3,
1221
- onStylesheetLoad,
1222
- stylesheetLoadTimeout = 5e3,
1223
- keepIframeSrcFn = () => false,
1224
- newlyAddedElement = false,
1225
- depth = 0,
1226
- maxDepth = DEFAULT_MAX_DEPTH
1227
- } = options;
1228
- let { needsMask } = options;
1229
- let { preserveWhiteSpace = true } = options;
1230
- if (depth >= maxDepth) {
1231
- _maxDepthReached = true;
1232
- if (!_maxDepthWarned) {
1233
- _maxDepthWarned = true;
1234
- console.warn(
1235
- `[rrweb-snapshot] DOM tree depth exceeded max depth of ${maxDepth}. Children beyond this depth will not be recorded. This may indicate deeply nested DOM structures.`
1236
- );
1197
+ var DEFAULT_MAX_DEPTH = 50;
1198
+ var _maxDepthWarned = false;
1199
+ var _maxDepthReached = false;
1200
+ function wasMaxDepthReached() {
1201
+ return _maxDepthReached;
1237
1202
  }
1238
- return null;
1239
- }
1240
- if (!needsMask) {
1241
- const checkAncestors = needsMask === void 0;
1242
- needsMask = needMaskingText(
1243
- n,
1244
- maskTextClass,
1245
- maskTextSelector,
1246
- checkAncestors
1247
- );
1248
- }
1249
- const _serializedNode = serializeNode(n, {
1250
- doc,
1251
- mirror,
1252
- blockClass,
1253
- blockSelector,
1254
- needsMask,
1255
- inlineStylesheet,
1256
- maskInputOptions,
1257
- maskTextFn,
1258
- maskInputFn,
1259
- dataURLOptions,
1260
- inlineImages,
1261
- recordCanvas,
1262
- keepIframeSrcFn,
1263
- newlyAddedElement
1264
- });
1265
- if (!_serializedNode) {
1266
- console.warn(n, "not serialized");
1267
- return null;
1268
- }
1269
- let id;
1270
- if (mirror.hasNode(n)) {
1271
- id = mirror.getId(n);
1272
- } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === types.NodeType$1.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1273
- id = IGNORED_NODE;
1274
- } else {
1275
- id = genId();
1276
- }
1277
- const serializedNode = Object.assign(_serializedNode, { id });
1278
- mirror.add(n, serializedNode);
1279
- if (id === IGNORED_NODE) {
1280
- return null;
1281
- }
1282
- if (onSerialize) {
1283
- onSerialize(n);
1284
- }
1285
- let recordChild = !skipChild;
1286
- if (serializedNode.type === types.NodeType$1.Element) {
1287
- recordChild = recordChild && !serializedNode.needBlock;
1288
- delete serializedNode.needBlock;
1289
- const shadowRootEl = types.index.shadowRoot(n);
1290
- if (shadowRootEl && types.isNativeShadowDom(shadowRootEl))
1291
- serializedNode.isShadowHost = true;
1292
- }
1293
- if ((serializedNode.type === types.NodeType$1.Document || serializedNode.type === types.NodeType$1.Element) && recordChild) {
1294
- if (slimDOMOptions.headWhitespace && serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "head") {
1295
- preserveWhiteSpace = false;
1296
- }
1297
- const bypassOptions = {
1298
- doc,
1299
- mirror,
1300
- blockClass,
1301
- blockSelector,
1302
- needsMask,
1303
- maskTextClass,
1304
- maskTextSelector,
1305
- skipChild,
1306
- inlineStylesheet,
1307
- maskInputOptions,
1308
- maskTextFn,
1309
- maskInputFn,
1310
- slimDOMOptions,
1311
- dataURLOptions,
1312
- inlineImages,
1313
- recordCanvas,
1314
- preserveWhiteSpace,
1315
- onSerialize,
1316
- onIframeLoad,
1317
- iframeLoadTimeout,
1318
- onStylesheetLoad,
1319
- stylesheetLoadTimeout,
1320
- keepIframeSrcFn,
1321
- depth: depth + 1,
1322
- maxDepth
1323
- };
1324
- if (serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1325
- else {
1326
- for (const childN of Array.from(types.index.childNodes(n))) {
1327
- const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1328
- if (serializedChildNode) {
1329
- serializedNode.childNodes.push(serializedChildNode);
1330
- }
1331
- }
1203
+ function resetMaxDepthState() {
1204
+ _maxDepthReached = false;
1205
+ _maxDepthWarned = false;
1332
1206
  }
1333
- let shadowRootEl = null;
1334
- if (types.isElement(n) && (shadowRootEl = types.index.shadowRoot(n))) {
1335
- for (const childN of Array.from(types.index.childNodes(shadowRootEl))) {
1336
- const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1337
- if (serializedChildNode) {
1338
- types.isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
1339
- serializedNode.childNodes.push(serializedChildNode);
1207
+ function serializeNodeWithId(n, options) {
1208
+ const {
1209
+ doc,
1210
+ mirror,
1211
+ blockClass,
1212
+ blockSelector,
1213
+ maskTextClass,
1214
+ maskTextSelector,
1215
+ skipChild = false,
1216
+ inlineStylesheet = true,
1217
+ maskInputOptions = {},
1218
+ maskTextFn,
1219
+ maskInputFn,
1220
+ slimDOMOptions,
1221
+ dataURLOptions = {},
1222
+ inlineImages = false,
1223
+ recordCanvas = false,
1224
+ onSerialize,
1225
+ onIframeLoad,
1226
+ iframeLoadTimeout = 5e3,
1227
+ onStylesheetLoad,
1228
+ stylesheetLoadTimeout = 5e3,
1229
+ keepIframeSrcFn = () => false,
1230
+ newlyAddedElement = false,
1231
+ depth = 0,
1232
+ maxDepth = DEFAULT_MAX_DEPTH
1233
+ } = options;
1234
+ let { needsMask } = options;
1235
+ let { preserveWhiteSpace = true } = options;
1236
+ if (depth >= maxDepth) {
1237
+ _maxDepthReached = true;
1238
+ if (!_maxDepthWarned) {
1239
+ _maxDepthWarned = true;
1240
+ console.warn(
1241
+ `[rrweb-snapshot] DOM tree depth exceeded max depth of ${maxDepth}. Children beyond this depth will not be recorded. This may indicate deeply nested DOM structures.`
1242
+ );
1340
1243
  }
1244
+ return null;
1341
1245
  }
1342
- }
1343
- }
1344
- const parent = types.index.parentNode(n);
1345
- if (parent && types.isShadowRoot(parent) && types.isNativeShadowDom(parent)) {
1346
- serializedNode.isShadow = true;
1347
- }
1348
- if (serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "iframe") {
1349
- onceIframeLoaded(
1350
- n,
1351
- () => {
1352
- const iframeDoc = n.contentDocument;
1353
- if (iframeDoc && onIframeLoad) {
1354
- const serializedIframeNode = serializeNodeWithId(iframeDoc, {
1355
- doc: iframeDoc,
1356
- mirror,
1357
- blockClass,
1358
- blockSelector,
1359
- needsMask,
1360
- maskTextClass,
1361
- maskTextSelector,
1362
- skipChild: false,
1363
- inlineStylesheet,
1364
- maskInputOptions,
1365
- maskTextFn,
1366
- maskInputFn,
1367
- slimDOMOptions,
1368
- dataURLOptions,
1369
- inlineImages,
1370
- recordCanvas,
1371
- preserveWhiteSpace,
1372
- onSerialize,
1373
- onIframeLoad,
1374
- iframeLoadTimeout,
1375
- onStylesheetLoad,
1376
- stylesheetLoadTimeout,
1377
- keepIframeSrcFn,
1378
- depth: depth + 1,
1379
- maxDepth
1380
- });
1381
- if (serializedIframeNode) {
1382
- onIframeLoad(
1383
- n,
1384
- serializedIframeNode
1385
- );
1246
+ if (!needsMask) {
1247
+ const checkAncestors = needsMask === void 0;
1248
+ needsMask = needMaskingText(
1249
+ n,
1250
+ maskTextClass,
1251
+ maskTextSelector,
1252
+ checkAncestors
1253
+ );
1254
+ }
1255
+ const _serializedNode = serializeNode(n, {
1256
+ doc,
1257
+ mirror,
1258
+ blockClass,
1259
+ blockSelector,
1260
+ needsMask,
1261
+ inlineStylesheet,
1262
+ maskInputOptions,
1263
+ maskTextFn,
1264
+ maskInputFn,
1265
+ dataURLOptions,
1266
+ inlineImages,
1267
+ recordCanvas,
1268
+ keepIframeSrcFn,
1269
+ newlyAddedElement
1270
+ });
1271
+ if (!_serializedNode) {
1272
+ console.warn(n, "not serialized");
1273
+ return null;
1274
+ }
1275
+ let id;
1276
+ if (mirror.hasNode(n)) {
1277
+ id = mirror.getId(n);
1278
+ } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === types2.NodeType$1.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1279
+ id = IGNORED_NODE;
1280
+ } else {
1281
+ id = genId();
1282
+ }
1283
+ const serializedNode = Object.assign(_serializedNode, { id });
1284
+ mirror.add(n, serializedNode);
1285
+ if (id === IGNORED_NODE) {
1286
+ return null;
1287
+ }
1288
+ if (onSerialize) {
1289
+ onSerialize(n);
1290
+ }
1291
+ let recordChild = !skipChild;
1292
+ if (serializedNode.type === types2.NodeType$1.Element) {
1293
+ recordChild = recordChild && !serializedNode.needBlock;
1294
+ delete serializedNode.needBlock;
1295
+ const shadowRootEl = types2.index.shadowRoot(n);
1296
+ if (shadowRootEl && types2.isNativeShadowDom(shadowRootEl))
1297
+ serializedNode.isShadowHost = true;
1298
+ }
1299
+ if ((serializedNode.type === types2.NodeType$1.Document || serializedNode.type === types2.NodeType$1.Element) && recordChild) {
1300
+ if (slimDOMOptions.headWhitespace && serializedNode.type === types2.NodeType$1.Element && serializedNode.tagName === "head") {
1301
+ preserveWhiteSpace = false;
1302
+ }
1303
+ const bypassOptions = {
1304
+ doc,
1305
+ mirror,
1306
+ blockClass,
1307
+ blockSelector,
1308
+ needsMask,
1309
+ maskTextClass,
1310
+ maskTextSelector,
1311
+ skipChild,
1312
+ inlineStylesheet,
1313
+ maskInputOptions,
1314
+ maskTextFn,
1315
+ maskInputFn,
1316
+ slimDOMOptions,
1317
+ dataURLOptions,
1318
+ inlineImages,
1319
+ recordCanvas,
1320
+ preserveWhiteSpace,
1321
+ onSerialize,
1322
+ onIframeLoad,
1323
+ iframeLoadTimeout,
1324
+ onStylesheetLoad,
1325
+ stylesheetLoadTimeout,
1326
+ keepIframeSrcFn,
1327
+ depth: depth + 1,
1328
+ maxDepth
1329
+ };
1330
+ if (serializedNode.type === types2.NodeType$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1331
+ else {
1332
+ for (const childN of Array.from(types2.index.childNodes(n))) {
1333
+ const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1334
+ if (serializedChildNode) {
1335
+ serializedNode.childNodes.push(serializedChildNode);
1336
+ }
1386
1337
  }
1387
1338
  }
1388
- },
1389
- iframeLoadTimeout
1390
- );
1391
- }
1392
- if (serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && types.extractFileExtension(serializedNode.attributes.href) === "css")) {
1393
- onceStylesheetLoaded(
1394
- n,
1395
- () => {
1396
- if (onStylesheetLoad) {
1397
- const serializedLinkNode = serializeNodeWithId(n, {
1398
- doc,
1399
- mirror,
1400
- blockClass,
1401
- blockSelector,
1402
- needsMask,
1403
- maskTextClass,
1404
- maskTextSelector,
1405
- skipChild: false,
1406
- inlineStylesheet,
1407
- maskInputOptions,
1408
- maskTextFn,
1409
- maskInputFn,
1410
- slimDOMOptions,
1411
- dataURLOptions,
1412
- inlineImages,
1413
- recordCanvas,
1414
- preserveWhiteSpace,
1415
- onSerialize,
1416
- onIframeLoad,
1417
- iframeLoadTimeout,
1418
- onStylesheetLoad,
1419
- stylesheetLoadTimeout,
1420
- keepIframeSrcFn,
1421
- depth,
1422
- maxDepth
1423
- });
1424
- if (serializedLinkNode) {
1425
- onStylesheetLoad(
1426
- n,
1427
- serializedLinkNode
1428
- );
1339
+ let shadowRootEl = null;
1340
+ if (types2.isElement(n) && (shadowRootEl = types2.index.shadowRoot(n))) {
1341
+ for (const childN of Array.from(types2.index.childNodes(shadowRootEl))) {
1342
+ const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1343
+ if (serializedChildNode) {
1344
+ types2.isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
1345
+ serializedNode.childNodes.push(serializedChildNode);
1346
+ }
1429
1347
  }
1430
1348
  }
1431
- },
1432
- stylesheetLoadTimeout
1433
- );
1434
- }
1435
- return serializedNode;
1436
- }
1437
- function snapshot(n, options) {
1438
- const {
1439
- mirror = new types.Mirror(),
1440
- blockClass = "rr-block",
1441
- blockSelector = null,
1442
- maskTextClass = "rr-mask",
1443
- maskTextSelector = null,
1444
- inlineStylesheet = true,
1445
- inlineImages = false,
1446
- recordCanvas = false,
1447
- maskAllInputs = false,
1448
- maskTextFn,
1449
- maskInputFn,
1450
- slimDOM = false,
1451
- dataURLOptions,
1452
- preserveWhiteSpace,
1453
- onSerialize,
1454
- onIframeLoad,
1455
- iframeLoadTimeout,
1456
- onStylesheetLoad,
1457
- stylesheetLoadTimeout,
1458
- keepIframeSrcFn = () => false,
1459
- maxDepth
1460
- } = options || {};
1461
- const maskInputOptions = maskAllInputs === true ? {
1462
- color: true,
1463
- date: true,
1464
- "datetime-local": true,
1465
- email: true,
1466
- month: true,
1467
- number: true,
1468
- range: true,
1469
- search: true,
1470
- tel: true,
1471
- text: true,
1472
- time: true,
1473
- url: true,
1474
- week: true,
1475
- textarea: true,
1476
- select: true,
1477
- password: true
1478
- } : maskAllInputs === false ? {
1479
- password: true
1480
- } : maskAllInputs;
1481
- const slimDOMOptions = slimDOM === true || slimDOM === "all" ? (
1482
- // if true: set of sensible options that should not throw away any information
1483
- {
1484
- script: true,
1485
- comment: true,
1486
- headFavicon: true,
1487
- headWhitespace: true,
1488
- headMetaDescKeywords: slimDOM === "all",
1489
- // destructive
1490
- headMetaSocial: true,
1491
- headMetaRobots: true,
1492
- headMetaHttpEquiv: true,
1493
- headMetaAuthorship: true,
1494
- headMetaVerification: true
1495
- }
1496
- ) : slimDOM === false ? {} : slimDOM;
1497
- return serializeNodeWithId(n, {
1498
- doc: n,
1499
- mirror,
1500
- blockClass,
1501
- blockSelector,
1502
- maskTextClass,
1503
- maskTextSelector,
1504
- skipChild: false,
1505
- inlineStylesheet,
1506
- maskInputOptions,
1507
- maskTextFn,
1508
- maskInputFn,
1509
- slimDOMOptions,
1510
- dataURLOptions,
1511
- inlineImages,
1512
- recordCanvas,
1513
- preserveWhiteSpace,
1514
- onSerialize,
1515
- onIframeLoad,
1516
- iframeLoadTimeout,
1517
- onStylesheetLoad,
1518
- stylesheetLoadTimeout,
1519
- keepIframeSrcFn,
1520
- newlyAddedElement: false,
1521
- maxDepth
1522
- });
1523
- }
1524
- function visitSnapshot(node, onVisit) {
1525
- function walk(current) {
1526
- onVisit(current);
1527
- if (current.type === types.NodeType$1.Document || current.type === types.NodeType$1.Element) {
1528
- current.childNodes.forEach(walk);
1349
+ }
1350
+ const parent = types2.index.parentNode(n);
1351
+ if (parent && types2.isShadowRoot(parent) && types2.isNativeShadowDom(parent)) {
1352
+ serializedNode.isShadow = true;
1353
+ }
1354
+ if (serializedNode.type === types2.NodeType$1.Element && serializedNode.tagName === "iframe") {
1355
+ onceIframeLoaded(
1356
+ n,
1357
+ () => {
1358
+ const iframeDoc = n.contentDocument;
1359
+ if (iframeDoc && onIframeLoad) {
1360
+ const serializedIframeNode = serializeNodeWithId(iframeDoc, {
1361
+ doc: iframeDoc,
1362
+ mirror,
1363
+ blockClass,
1364
+ blockSelector,
1365
+ needsMask,
1366
+ maskTextClass,
1367
+ maskTextSelector,
1368
+ skipChild: false,
1369
+ inlineStylesheet,
1370
+ maskInputOptions,
1371
+ maskTextFn,
1372
+ maskInputFn,
1373
+ slimDOMOptions,
1374
+ dataURLOptions,
1375
+ inlineImages,
1376
+ recordCanvas,
1377
+ preserveWhiteSpace,
1378
+ onSerialize,
1379
+ onIframeLoad,
1380
+ iframeLoadTimeout,
1381
+ onStylesheetLoad,
1382
+ stylesheetLoadTimeout,
1383
+ keepIframeSrcFn,
1384
+ depth: depth + 1,
1385
+ maxDepth
1386
+ });
1387
+ if (serializedIframeNode) {
1388
+ onIframeLoad(
1389
+ n,
1390
+ serializedIframeNode
1391
+ );
1392
+ }
1393
+ }
1394
+ },
1395
+ iframeLoadTimeout
1396
+ );
1397
+ }
1398
+ if (serializedNode.type === types2.NodeType$1.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && types2.extractFileExtension(serializedNode.attributes.href) === "css")) {
1399
+ onceStylesheetLoaded(
1400
+ n,
1401
+ () => {
1402
+ if (onStylesheetLoad) {
1403
+ const serializedLinkNode = serializeNodeWithId(n, {
1404
+ doc,
1405
+ mirror,
1406
+ blockClass,
1407
+ blockSelector,
1408
+ needsMask,
1409
+ maskTextClass,
1410
+ maskTextSelector,
1411
+ skipChild: false,
1412
+ inlineStylesheet,
1413
+ maskInputOptions,
1414
+ maskTextFn,
1415
+ maskInputFn,
1416
+ slimDOMOptions,
1417
+ dataURLOptions,
1418
+ inlineImages,
1419
+ recordCanvas,
1420
+ preserveWhiteSpace,
1421
+ onSerialize,
1422
+ onIframeLoad,
1423
+ iframeLoadTimeout,
1424
+ onStylesheetLoad,
1425
+ stylesheetLoadTimeout,
1426
+ keepIframeSrcFn,
1427
+ depth,
1428
+ maxDepth
1429
+ });
1430
+ if (serializedLinkNode) {
1431
+ onStylesheetLoad(
1432
+ n,
1433
+ serializedLinkNode
1434
+ );
1435
+ }
1436
+ }
1437
+ },
1438
+ stylesheetLoadTimeout
1439
+ );
1440
+ }
1441
+ return serializedNode;
1442
+ }
1443
+ function snapshot(n, options) {
1444
+ const {
1445
+ mirror = new types2.Mirror(),
1446
+ blockClass = "rr-block",
1447
+ blockSelector = null,
1448
+ maskTextClass = "rr-mask",
1449
+ maskTextSelector = null,
1450
+ inlineStylesheet = true,
1451
+ inlineImages = false,
1452
+ recordCanvas = false,
1453
+ maskAllInputs = false,
1454
+ maskTextFn,
1455
+ maskInputFn,
1456
+ slimDOM = false,
1457
+ dataURLOptions,
1458
+ preserveWhiteSpace,
1459
+ onSerialize,
1460
+ onIframeLoad,
1461
+ iframeLoadTimeout,
1462
+ onStylesheetLoad,
1463
+ stylesheetLoadTimeout,
1464
+ keepIframeSrcFn = () => false,
1465
+ maxDepth
1466
+ } = options || {};
1467
+ const maskInputOptions = maskAllInputs === true ? {
1468
+ color: true,
1469
+ date: true,
1470
+ "datetime-local": true,
1471
+ email: true,
1472
+ month: true,
1473
+ number: true,
1474
+ range: true,
1475
+ search: true,
1476
+ tel: true,
1477
+ text: true,
1478
+ time: true,
1479
+ url: true,
1480
+ week: true,
1481
+ textarea: true,
1482
+ select: true,
1483
+ password: true
1484
+ } : maskAllInputs === false ? {
1485
+ password: true
1486
+ } : maskAllInputs;
1487
+ const slimDOMOptions = slimDOM === true || slimDOM === "all" ? (
1488
+ // if true: set of sensible options that should not throw away any information
1489
+ {
1490
+ script: true,
1491
+ comment: true,
1492
+ headFavicon: true,
1493
+ headWhitespace: true,
1494
+ headMetaDescKeywords: slimDOM === "all",
1495
+ // destructive
1496
+ headMetaSocial: true,
1497
+ headMetaRobots: true,
1498
+ headMetaHttpEquiv: true,
1499
+ headMetaAuthorship: true,
1500
+ headMetaVerification: true
1501
+ }
1502
+ ) : slimDOM === false ? {} : slimDOM;
1503
+ return serializeNodeWithId(n, {
1504
+ doc: n,
1505
+ mirror,
1506
+ blockClass,
1507
+ blockSelector,
1508
+ maskTextClass,
1509
+ maskTextSelector,
1510
+ skipChild: false,
1511
+ inlineStylesheet,
1512
+ maskInputOptions,
1513
+ maskTextFn,
1514
+ maskInputFn,
1515
+ slimDOMOptions,
1516
+ dataURLOptions,
1517
+ inlineImages,
1518
+ recordCanvas,
1519
+ preserveWhiteSpace,
1520
+ onSerialize,
1521
+ onIframeLoad,
1522
+ iframeLoadTimeout,
1523
+ onStylesheetLoad,
1524
+ stylesheetLoadTimeout,
1525
+ keepIframeSrcFn,
1526
+ newlyAddedElement: false,
1527
+ maxDepth
1528
+ });
1529
1529
  }
1530
+ function visitSnapshot(node, onVisit) {
1531
+ function walk(current) {
1532
+ onVisit(current);
1533
+ if (current.type === types2.NodeType$1.Document || current.type === types2.NodeType$1.Element) {
1534
+ current.childNodes.forEach(walk);
1535
+ }
1536
+ }
1537
+ walk(node);
1538
+ }
1539
+ function cleanupSnapshot() {
1540
+ _id = 1;
1541
+ }
1542
+ exports2.DEFAULT_MAX_DEPTH = DEFAULT_MAX_DEPTH;
1543
+ exports2.IGNORED_NODE = IGNORED_NODE;
1544
+ exports2.classMatchesRegex = classMatchesRegex;
1545
+ exports2.cleanupSnapshot = cleanupSnapshot;
1546
+ exports2.genId = genId;
1547
+ exports2.ignoreAttribute = ignoreAttribute;
1548
+ exports2.needMaskingText = needMaskingText;
1549
+ exports2.resetMaxDepthState = resetMaxDepthState;
1550
+ exports2.serializeNodeWithId = serializeNodeWithId;
1551
+ exports2.snapshot = snapshot;
1552
+ exports2.transformAttribute = transformAttribute;
1553
+ exports2.visitSnapshot = visitSnapshot;
1554
+ exports2.wasMaxDepthReached = wasMaxDepthReached;
1530
1555
  }
1531
- walk(node);
1532
- }
1533
- function cleanupSnapshot() {
1534
- _id = 1;
1535
- }
1556
+ });
1557
+
1558
+ // dist/record.cjs
1559
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1560
+ var record = require_record_oACzRSl();
1561
+ var types = require_types_B7TTv7Jc();
1562
+ exports.DEFAULT_MAX_DEPTH = record.DEFAULT_MAX_DEPTH;
1563
+ exports.IGNORED_NODE = record.IGNORED_NODE;
1564
+ exports.classMatchesRegex = record.classMatchesRegex;
1565
+ exports.cleanupSnapshot = record.cleanupSnapshot;
1566
+ exports.genId = record.genId;
1567
+ exports.ignoreAttribute = record.ignoreAttribute;
1568
+ exports.needMaskingText = record.needMaskingText;
1569
+ exports.serializeNodeWithId = record.serializeNodeWithId;
1570
+ exports.snapshot = record.snapshot;
1571
+ exports.transformAttribute = record.transformAttribute;
1572
+ exports.visitSnapshot = record.visitSnapshot;
1573
+ exports.wasMaxDepthReached = record.wasMaxDepthReached;
1536
1574
  exports.Mirror = types.Mirror;
1537
1575
  exports.NodeType = types.NodeType;
1538
1576
  exports.absolutifyURLs = types.absolutifyURLs;
@@ -1554,18 +1592,6 @@ exports.recompressBase64Image = types.recompressBase64Image;
1554
1592
  exports.stringifyRule = types.stringifyRule;
1555
1593
  exports.stringifyStylesheet = types.stringifyStylesheet;
1556
1594
  exports.toLowerCase = types.toLowerCase;
1557
- exports.DEFAULT_MAX_DEPTH = DEFAULT_MAX_DEPTH;
1558
- exports.IGNORED_NODE = IGNORED_NODE;
1559
- exports.classMatchesRegex = classMatchesRegex;
1560
- exports.cleanupSnapshot = cleanupSnapshot;
1561
- exports.genId = genId;
1562
- exports.ignoreAttribute = ignoreAttribute;
1563
- exports.needMaskingText = needMaskingText;
1564
- exports.serializeNodeWithId = serializeNodeWithId;
1565
- exports.snapshot = snapshot;
1566
- exports.transformAttribute = transformAttribute;
1567
- exports.visitSnapshot = visitSnapshot;
1568
- exports.wasMaxDepthReached = wasMaxDepthReached;
1569
1595
  ;if (typeof module.exports == "object" && typeof exports == "object") {
1570
1596
  var __cp = (to, from, except, desc) => {
1571
1597
  if ((from && typeof from === "object") || typeof from === "function") {