@pendo/agent 2.344.1 → 2.346.0

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.
@@ -668,7 +668,7 @@ function loadStagingAgent(config, pendo, debuggingEnabled) {
668
668
  var altAgentUrl = getAlternateAgentUrl(config, true, debuggingEnabled);
669
669
  if (altAgentUrl) {
670
670
  setupMethodCapture(pendo);
671
- includeScript(altAgentUrl, pendo);
671
+ includeScript(altAgentUrl, pendo, config.pendoGlobalKey);
672
672
  return true;
673
673
  }
674
674
  }
@@ -679,7 +679,7 @@ function loadUnminifiedAgent(config, pendo, debuggingEnabled) {
679
679
  var altAgentUrl = getAlternateAgentUrl(config, false, debuggingEnabled);
680
680
  if (altAgentUrl) {
681
681
  setupMethodCapture(pendo);
682
- includeScript(altAgentUrl, pendo);
682
+ includeScript(altAgentUrl, pendo, config.pendoGlobalKey);
683
683
  return true;
684
684
  }
685
685
  }
@@ -688,11 +688,16 @@ function loadUnminifiedAgent(config, pendo, debuggingEnabled) {
688
688
  function loadAlternateAgent(config, pendo, debuggingEnabled) {
689
689
  return loadStagingAgent(config, pendo, debuggingEnabled) || loadUnminifiedAgent(config, pendo, debuggingEnabled);
690
690
  }
691
- function includeScript(scriptUrl, pendo) {
691
+ function includeScript(scriptUrl, pendo, globalKey) {
692
692
  var scriptTagName = 'script';
693
693
  var stagingScriptTag = document.createElement(scriptTagName);
694
694
  stagingScriptTag.async = true;
695
695
  stagingScriptTag.src = getPolicy(pendo).createScriptURL(scriptUrl);
696
+ // The alternate agent reads its global key from its own script tag, and its
697
+ // bundled PendoConfig doesn't carry the key the snippet set.
698
+ if (globalKey) {
699
+ stagingScriptTag.setAttribute('data-pendo-global-key', globalKey);
700
+ }
696
701
  var otherScriptTag = document.getElementsByTagName(scriptTagName)[0];
697
702
  if (otherScriptTag && otherScriptTag.parentNode) {
698
703
  otherScriptTag.parentNode.insertBefore(stagingScriptTag, otherScriptTag);
@@ -4009,6 +4014,9 @@ function shouldWrapHashChange() {
4009
4014
  function isMobileUserAgent() {
4010
4015
  return (/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i).test(getUA());
4011
4016
  }
4017
+ function supportsPopover() {
4018
+ return !!window.HTMLElement && isNativeCode(window.HTMLElement.prototype.showPopover);
4019
+ }
4012
4020
  function isSafari(userAgent = getUA()) {
4013
4021
  return userAgent.indexOf('Safari') >= 0 && !isChromium(userAgent);
4014
4022
  }
@@ -4021,6 +4029,7 @@ function isChromium(userAgent = getUA()) {
4021
4029
  const sniffer = {
4022
4030
  supportsHistoryApi: shouldWrapNativeHistory,
4023
4031
  supportsHashChange: shouldWrapHashChange,
4032
+ supportsPopover,
4024
4033
  hasEvent(event) {
4025
4034
  // IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have
4026
4035
  // it. In particular the event is not fired when backspace or delete key are pressed or
@@ -4129,8 +4138,8 @@ let SERVER = '';
4129
4138
  let ASSET_HOST = '';
4130
4139
  let ASSET_PATH = '';
4131
4140
  let DESIGNER_SERVER = '';
4132
- let VERSION = '2.344.1_';
4133
- let PACKAGE_VERSION = '2.344.1';
4141
+ let VERSION = '2.346.0_';
4142
+ let PACKAGE_VERSION = '2.346.0';
4134
4143
  let LOADER = 'xhr';
4135
4144
  /* eslint-enable web-sdk-eslint-rules/no-gulp-env-references */
4136
4145
  /**
@@ -10113,6 +10122,16 @@ function getFontBaseUrl() {
10113
10122
  return `${FONT_HOST}/fonts`;
10114
10123
  }
10115
10124
 
10125
+ // Despite the name, this is a behavioral gate rather than an identity check: it is true whenever
10126
+ // the agent is in a parent-child sub relationship where another subscription owns this agent's
10127
+ // content and event attribution. That covers traditional Adopt training partners and, as a subtype,
10128
+ // partner-analytics-forwarding subs. Call sites rely on that meaning - the acc/oemAccountId event
10129
+ // attribution, the trusted-origin bypass, and skipping the contentHost rewrite - not on the sub
10130
+ // literally being an Adopt partner.
10131
+ // This assumes those subs only ever serve the partner's own content. If Pendo sub analytics is ever
10132
+ // turned on with guides - so a forwarding sub delivers Pendo-origin guide content - the call sites
10133
+ // that treat "partner" as "another sub owns all content" (the contentHost skip in particular) will
10134
+ // need to be revisited, likely as a per-url decision rather than this all-or-nothing gate.
10116
10135
  function treatAsAdoptPartner() {
10117
10136
  // allowPartnerAnalyticsForwarding is set on the snippet in Adopt UI to block based on the environment of the app.
10118
10137
  // adoptAnalyticsForwarding is set in pendoConfig, based on the app flag.
@@ -12592,10 +12611,10 @@ var getDesignerWindow = function () {
12592
12611
  // directly to the top window.
12593
12612
  return isPendo.test(location.href) ? window.parent : window.top;
12594
12613
  };
12595
- var announceAgentLoaded = function () {
12614
+ var announceAgentLoaded = function (url) {
12596
12615
  if (detectMaster()) {
12597
12616
  var win = getDesignerWindow();
12598
- tellMaster(win, { type: 'load', url: location.toString() }, '*');
12617
+ tellMaster(win, { type: 'load', url: url || location.toString() }, '*');
12599
12618
  }
12600
12619
  };
12601
12620
  var addSafeWindowMessageListener = function (cb) {
@@ -13930,7 +13949,7 @@ var pageLoad = makeSafe(function (url) {
13930
13949
  pageLoad.lastUrl = url;
13931
13950
  var loadTime = -1;
13932
13951
  if (!restrictP1Access()) {
13933
- announceAgentLoaded();
13952
+ announceAgentLoaded(url);
13934
13953
  }
13935
13954
  log.debug('sending load event for url ' + url);
13936
13955
  if (typeof performance !== 'undefined' &&
@@ -14557,6 +14576,14 @@ function getPendoCdnHost() {
14557
14576
  // A contentHost set up as a CNAME in app settings is delivered in the hosted config, while a
14558
14577
  // snippet value is the customer's own override of it. Same precedence getDataHost uses.
14559
14578
  function getConfiguredContentHost() {
14579
+ // Partner/OEM guide content lives in the partner's own storage buckets, so we
14580
+ // must not rewrite those urls away from the partner. This is an all-or-nothing skip that
14581
+ // assumes a partner sub never serves Pendo-origin guide content that a contentHost should
14582
+ // apply to - true while only the partner's own guides are delivered. If guides are ever
14583
+ // enabled for partner-analytics subs with content on a Pendo host, this needs to become a
14584
+ // per-url decision (skip partner-bucket urls, still rewrite Pendo-origin ones) instead.
14585
+ if (treatAsAdoptPartner())
14586
+ return undefined;
14560
14587
  return ConfigReader.getLocalConfig('contentHost') || ConfigReader.getHostedConfig('contentHost');
14561
14588
  }
14562
14589
  function replaceWithContentHost(str) {
@@ -23837,6 +23864,78 @@ var backdropVisibilityStep = {
23837
23864
  script: backdropVisibilityRuntimeScript
23838
23865
  };
23839
23866
 
23867
+ // ":modal" also matches a fullscreen element, which cannot take children
23868
+ const MODAL_DIALOG = 'dialog:modal';
23869
+ function queryModalDialogs() {
23870
+ try {
23871
+ return document.querySelectorAll(MODAL_DIALOG);
23872
+ }
23873
+ catch (e) {
23874
+ return [];
23875
+ }
23876
+ }
23877
+ function closestModalDialog(element) {
23878
+ try {
23879
+ return element && _.isFunction(element.closest) ? element.closest(MODAL_DIALOG) : null;
23880
+ }
23881
+ catch (e) {
23882
+ return null;
23883
+ }
23884
+ }
23885
+ function queryConfiguredSelector(step) {
23886
+ const selector = _.get(step, 'attributes.popover.selector');
23887
+ if (!selector)
23888
+ return null;
23889
+ try {
23890
+ return dom(selector)[0] || null;
23891
+ }
23892
+ catch (e) {
23893
+ log.info('Invalid popover selector', { contexts: ['error', 'guide', 'render'] });
23894
+ return null;
23895
+ }
23896
+ }
23897
+ function findHost(step) {
23898
+ const host = queryConfiguredSelector(step) ||
23899
+ closestModalDialog(step.targetElement) ||
23900
+ _.last(queryModalDialogs());
23901
+ // a host inside a shadow root would change the guide's root node
23902
+ return host && host.getRootNode() === document ? host : null;
23903
+ }
23904
+ function promoteToPopover(element) {
23905
+ element.setAttribute('popover', 'manual');
23906
+ try {
23907
+ element.showPopover();
23908
+ }
23909
+ catch (e) {
23910
+ element.removeAttribute('popover');
23911
+ log.info('Failed to render guide as popover', { contexts: ['error', 'guide', 'render'] });
23912
+ }
23913
+ }
23914
+ // Registered ahead of backdrop-visibility-step and autofocus-step, which mark the siblings of the
23915
+ // guide's ancestors: the guide must already be inside the dialog or the dialog ends up hidden.
23916
+ function popoverRuntimeScript(step, guide, pendo) {
23917
+ if (pendo.designer || !step.guideElement)
23918
+ return;
23919
+ if (!_.get(step, 'attributes.popover.enabled') || !sniffer.supportsPopover())
23920
+ return;
23921
+ if (_.get(guide, 'attributes.resourceCenter') || _.get(guide, 'attributes.embedConfig'))
23922
+ return;
23923
+ const guideContainer = step.guideElement.find(`#${step.containerId}`);
23924
+ if (!guideContainer.length)
23925
+ return;
23926
+ // positioned in document coordinates, which a fixed root in the top layer breaks
23927
+ if (guideContainer.attr('data-vertical-alignment') === 'Relative to Element')
23928
+ return;
23929
+ const host = findHost(step);
23930
+ if (!host)
23931
+ return;
23932
+ host.appendChild(step.guideElement[0]);
23933
+ promoteToPopover(step.guideElement[0]);
23934
+ }
23935
+ var popoverStep = {
23936
+ script: popoverRuntimeScript
23937
+ };
23938
+
23840
23939
  function isTooltip({ _ }, step) {
23841
23940
  const tooltip = 'tooltip';
23842
23941
  return _.get(step, 'attributes.calculatedType') === tooltip ||
@@ -23993,6 +24092,7 @@ function registerPostrenderScripts(runtime) {
23993
24092
  _.each([
23994
24093
  advanceOnElement,
23995
24094
  announcementMarkSeen,
24095
+ popoverStep,
23996
24096
  autofocusStep,
23997
24097
  backdropVisibilityStep,
23998
24098
  repositionOnScroll,
@@ -25948,8 +26048,14 @@ var MESSAGE_ENDED = 'pendo-live-preview::ended';
25948
26048
  var MESSAGE_END_ACK = 'pendo-live-preview::end-ack';
25949
26049
  var RELAY_END_MESSAGE_TIMEOUT = 2000;
25950
26050
  var activeRelay = null;
26051
+ // event.source alone is not enough: an ancestor page can navigate the relay frame to its own
26052
+ // document and keep the same window object, so the sender's origin has to be the relay's too.
26053
+ // An unknown relay origin ('*') cannot be matched, so it never authenticates a message.
25951
26054
  function isRelayMessage(event, relay) {
25952
- return event.source === relay.frame.contentWindow && !!event.data;
26055
+ return relay.origin !== '*' &&
26056
+ event.origin === relay.origin &&
26057
+ event.source === relay.frame.contentWindow &&
26058
+ !!event.data;
25953
26059
  }
25954
26060
  function sendConfig(relay) {
25955
26061
  if (!relay.frame.contentWindow)
@@ -28484,7 +28590,8 @@ class NetworkRequestIntercept {
28484
28590
  return MAX_RESPONSE_SIZE_MESSAGE;
28485
28591
  }
28486
28592
  }
28487
- const text = yield config.text();
28593
+ const canStream = config.body && _.isFunction(config.body.getReader) && typeof TextDecoder !== 'undefined';
28594
+ const text = canStream ? yield this.readBodyStream(config.body) : yield config.text();
28488
28595
  if (text.length > MAX_RESPONSE_SIZE) {
28489
28596
  return MAX_RESPONSE_SIZE_MESSAGE;
28490
28597
  }
@@ -28495,6 +28602,26 @@ class NetworkRequestIntercept {
28495
28602
  }
28496
28603
  });
28497
28604
  }
28605
+ // Reads chunk by chunk so a long or never-ending stream stops buffering once it passes the cap
28606
+ readBodyStream(body) {
28607
+ return __awaiter(this, void 0, void 0, function* () {
28608
+ const reader = body.getReader();
28609
+ const decoder = new TextDecoder();
28610
+ let text = '';
28611
+ let bytesRead = 0;
28612
+ let chunk = yield reader.read();
28613
+ while (!chunk.done) {
28614
+ bytesRead += chunk.value.byteLength;
28615
+ if (bytesRead > MAX_RESPONSE_SIZE) {
28616
+ reader.cancel().catch(_.noop);
28617
+ return MAX_RESPONSE_SIZE_MESSAGE;
28618
+ }
28619
+ text += decoder.decode(chunk.value, { stream: true });
28620
+ chunk = yield reader.read();
28621
+ }
28622
+ return text + decoder.decode();
28623
+ });
28624
+ }
28498
28625
  extractConfigHeaders(config) {
28499
28626
  let headers = {};
28500
28627
  if (config.headers) {
@@ -28567,33 +28694,7 @@ class NetworkRequestIntercept {
28567
28694
  // Make the actual fetch call and capture response
28568
28695
  try {
28569
28696
  const res = yield networkInterceptor._originalFetch.apply(this, args);
28570
- // Clone the response to avoid consuming the body
28571
- const responseClone = res.clone();
28572
- try {
28573
- // Capture response data
28574
- const responseBody = yield networkInterceptor.safelyReadBody(responseClone, 'response');
28575
- const { status, statusText } = res;
28576
- const headers = networkInterceptor.extractConfigHeaders(res);
28577
- _.each(networkInterceptor.callbackFns, ({ response }) => {
28578
- if (_.isFunction(response)) {
28579
- response({
28580
- requestId,
28581
- status,
28582
- statusText,
28583
- body: responseBody,
28584
- headers,
28585
- url: transformedUrl,
28586
- method
28587
- });
28588
- }
28589
- });
28590
- }
28591
- catch (e) {
28592
- _.each(networkInterceptor.callbackFns, ({ error }) => {
28593
- if (_.isFunction(error))
28594
- error({ context: 'fetchResponse', error: e });
28595
- });
28596
- }
28697
+ networkInterceptor.captureResponse(res, { requestId, url: transformedUrl, method });
28597
28698
  return res;
28598
28699
  }
28599
28700
  catch (error) {
@@ -28617,6 +28718,29 @@ class NetworkRequestIntercept {
28617
28718
  });
28618
28719
  };
28619
28720
  }
28721
+ // Not awaited by the fetch wrapper: the app gets its response before the body is read
28722
+ captureResponse(res, { requestId, url, method }) {
28723
+ return __awaiter(this, void 0, void 0, function* () {
28724
+ try {
28725
+ // Clone synchronously, before the app can consume the body
28726
+ const responseClone = res.clone();
28727
+ const body = yield this.safelyReadBody(responseClone, 'response');
28728
+ const { status, statusText } = res;
28729
+ const headers = this.extractConfigHeaders(res);
28730
+ _.each(this.callbackFns, ({ response }) => {
28731
+ if (_.isFunction(response)) {
28732
+ response({ requestId, status, statusText, body, headers, url, method });
28733
+ }
28734
+ });
28735
+ }
28736
+ catch (e) {
28737
+ _.each(this.callbackFns, ({ error }) => {
28738
+ if (_.isFunction(error))
28739
+ error({ context: 'fetchResponse', error: e });
28740
+ });
28741
+ }
28742
+ });
28743
+ }
28620
28744
  patchXHR() {
28621
28745
  const networkInterceptor = this;
28622
28746
  networkInterceptor._originalSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
@@ -36357,6 +36481,12 @@ const DebuggerModule = (() => {
36357
36481
  identity: { type: SYNC_TYPES.BOTTOM_UP, defaultValue: {} },
36358
36482
  location: { type: SYNC_TYPES.BOTTOM_UP, defaultValue: {} }
36359
36483
  };
36484
+ // frameId comes off the cross-frame channel and keys state.frames, so a key like
36485
+ // __proto__ would resolve to Object.prototype and the sync would write onto it
36486
+ const UNSAFE_FRAME_IDS = ['__proto__', 'constructor', 'prototype'];
36487
+ function isSafeFrameId(frameId) {
36488
+ return _.isString(frameId) && !_.contains(UNSAFE_FRAME_IDS, frameId);
36489
+ }
36360
36490
  const actions = {
36361
36491
  init: (context, buffer) => {
36362
36492
  context.commit('setFrameId', EventTracer.getFrameId());
@@ -36720,6 +36850,8 @@ const DebuggerModule = (() => {
36720
36850
  });
36721
36851
  setter = mutations[`_sync_${fieldName}`] || setter;
36722
36852
  mutations[`_sync_${fieldName}`] = (state, { value, frameId }) => {
36853
+ if (!isSafeFrameId(frameId))
36854
+ return;
36723
36855
  if (!state.frames[frameId]) {
36724
36856
  state.frames[frameId] = {};
36725
36857
  }
@@ -41982,11 +42114,20 @@ class DOMPrompt {
41982
42114
  }
41983
42115
  return tmp;
41984
42116
  }
42117
+ isPasswordInput(elem) {
42118
+ return !!elem && !!elem.tagName && elem.tagName.toLowerCase() === 'input' && elem.type === 'password';
42119
+ }
42120
+ getInputText(inputEl) {
42121
+ if (this.isPasswordInput(inputEl.get())) {
42122
+ return '';
42123
+ }
42124
+ return inputEl.getText();
42125
+ }
41985
42126
  getPromptValue() {
41986
42127
  const elementWithValue = this._.find(this.inputEls, (el) => {
41987
42128
  if (el) {
41988
42129
  try {
41989
- const value = el.getText();
42130
+ const value = this.getInputText(el);
41990
42131
  return value && value.trim();
41991
42132
  }
41992
42133
  catch (err) {
@@ -41997,7 +42138,7 @@ class DOMPrompt {
41997
42138
  });
41998
42139
  if (elementWithValue) {
41999
42140
  try {
42000
- const value = elementWithValue.getText();
42141
+ const value = this.getInputText(elementWithValue);
42001
42142
  return value.trim();
42002
42143
  }
42003
42144
  catch (err) { }
@@ -42132,7 +42273,7 @@ class PromptPlugin {
42132
42273
  });
42133
42274
  const currentlyActiveIds = this._.map(this._.filter(this.prompts, prompt => prompt.isActive), prompt => prompt.id);
42134
42275
  this._.each(allAgents, aiAgent => {
42135
- if (this.isConversationAgent(aiAgent)) {
42276
+ if (this.isConversationAgent(aiAgent) || this.isNetworkAgent(aiAgent)) {
42136
42277
  return;
42137
42278
  }
42138
42279
  const isCurrentlyActive = this._.contains(currentlyActiveIds, aiAgent.id);
@@ -42157,30 +42298,21 @@ class PromptPlugin {
42157
42298
  isConversationAgent(agent) {
42158
42299
  return agent.preset && agent.preset != 'chatgpt';
42159
42300
  }
42301
+ // network tracking is not supported; these agents are ignored rather than falling back to DOM.
42302
+ isNetworkAgent(agent) {
42303
+ return agent.trackingMethod === 'network';
42304
+ }
42160
42305
  onConfigLoaded(aiAgents = []) {
42161
42306
  if (!aiAgents || !this._.isArray(aiAgents) || aiAgents.length === 0) {
42162
42307
  return;
42163
42308
  }
42164
- const networkAgents = [];
42165
42309
  const domAgents = [];
42166
42310
  for (const agent of aiAgents) {
42167
- if (this.isConversationAgent(agent)) {
42311
+ if (this.isConversationAgent(agent) || this.isNetworkAgent(agent)) {
42168
42312
  continue;
42169
42313
  }
42170
- if (agent.trackingMethod === 'network') {
42171
- networkAgents.push(agent);
42172
- }
42173
- else if (agent.trackingMethod === 'dom') {
42174
- domAgents.push(agent);
42175
- }
42176
- else {
42177
- // Default to DOM if no trackingMethod specified
42178
- domAgents.push(agent);
42179
- }
42180
- }
42181
- if (networkAgents.length > 0) {
42182
- this.networkAgents = networkAgents;
42183
- this.api.NetworkRequest.on({ request: this.handleRequest, error: this.handleError });
42314
+ // Default to DOM if no trackingMethod specified
42315
+ domAgents.push(agent);
42184
42316
  }
42185
42317
  // Cache agents for fast lookup
42186
42318
  if (!this.agentsCache) {
@@ -42201,29 +42333,6 @@ class PromptPlugin {
42201
42333
  }
42202
42334
  });
42203
42335
  }
42204
- handleRequest({ method, url, body }) {
42205
- const currentUrl = getNormalizedUrl();
42206
- this._.each(this.networkAgents, aiAgent => {
42207
- if (!this.testPageRule(aiAgent.pageRule, currentUrl, aiAgent.id)) {
42208
- return;
42209
- }
42210
- const originalBody = body || '';
42211
- this.api.analytics.collectEvent('prompt', {
42212
- prompt: originalBody,
42213
- agentId: aiAgent.id,
42214
- promptType: method,
42215
- url
42216
- }, undefined, 'agentic');
42217
- });
42218
- }
42219
- handleError({ error, context }) {
42220
- if (context == 'fetch') {
42221
- this.api.log.debug('[PromptPlugin] Fetch tracking failed:', error);
42222
- }
42223
- if (context == 'xhr') {
42224
- this.api.log.debug('[PromptPlugin] XHR tracking failed:', error);
42225
- }
42226
- }
42227
42336
  observePrompt(config) {
42228
42337
  const { id, cssSelectors } = config;
42229
42338
  // Check if agent already exists
@@ -42262,7 +42371,6 @@ class PromptPlugin {
42262
42371
  if (this.agentsCache) {
42263
42372
  this.agentsCache.clear();
42264
42373
  }
42265
- this.api.NetworkRequest.off({ request: this.handleRequest, error: this.handleError });
42266
42374
  }
42267
42375
  }
42268
42376
  var PromptAnalytics = new PromptPlugin();
@@ -43077,11 +43185,28 @@ function lookupGuideButtons(domJson, buttons = []) {
43077
43185
  }
43078
43186
  return buttons;
43079
43187
  }
43188
+ function replaceFirstInTextNodes(node, textToReplace, replacementText) {
43189
+ for (let i = 0; i < node.childNodes.length; i++) {
43190
+ const child = node.childNodes[i];
43191
+ if (child.nodeType === 3) {
43192
+ const replaced = child.nodeValue.replace(textToReplace, replacementText);
43193
+ if (replaced !== child.nodeValue) {
43194
+ child.nodeValue = replaced;
43195
+ return true;
43196
+ }
43197
+ }
43198
+ else if (replaceFirstInTextNodes(child, textToReplace, replacementText)) {
43199
+ return true;
43200
+ }
43201
+ }
43202
+ return false;
43203
+ }
43080
43204
  function removeMarkdownSyntax(element, textToReplace, replacementText, pendo) {
43081
- var _a;
43082
43205
  if (pendo.dom(element).hasClass('_pendo-nps-open-text-poll-question')) {
43083
- // This prevents us from removing the message for the conditionally rendered elements
43084
- element.innerHTML = (_a = element.innerHTML) === null || _a === void 0 ? void 0 : _a.replace(textToReplace, replacementText);
43206
+ // Edit text nodes in place rather than round-tripping innerHTML: re-parsing serialized
43207
+ // guide markup can mutate it into live elements (mXSS). This also keeps child elements intact.
43208
+ element.normalize();
43209
+ replaceFirstInTextNodes(element, textToReplace, replacementText);
43085
43210
  }
43086
43211
  if (element.localName === 'button' ||
43087
43212
  element.localName === 'label' ||
@@ -43598,6 +43723,13 @@ function encodeMetadataForUrl(value, urlBeforePlaceholder = '') {
43598
43723
  }
43599
43724
  return window.encodeURI(str);
43600
43725
  }
43726
+ // Resolve through the browser's own URL parser: it strips tabs/newlines inside the scheme
43727
+ // (e.g. "java\tscript:"), which a regex over the raw string would miss.
43728
+ function hasDangerousUrlScheme(url) {
43729
+ const anchor = document.createElement('a');
43730
+ anchor.href = url;
43731
+ return DANGEROUS_URL_SCHEME.test(anchor.protocol);
43732
+ }
43601
43733
 
43602
43734
  const MetadataSubstitution = {
43603
43735
  name: 'MetadataSubstitution',
@@ -43684,27 +43816,37 @@ function processPlaceholder(placeholder, pendo) {
43684
43816
  let match;
43685
43817
  const { data, target } = placeholder;
43686
43818
  const subRegex = new RegExp(guideMarkdownUtil.substitutionRegex);
43819
+ const isUrlTarget = target === 'href' || target === 'value';
43820
+ const startedWithDangerousScheme = isUrlTarget && hasDangerousUrlScheme(getRawTargetValue(data, target));
43687
43821
  while ((match = matchPlaceholder(placeholder, subRegex))) {
43688
43822
  const usedArrayPath = Array.isArray(match) && match.length >= 2;
43689
43823
  const currentStr = target === 'textContent'
43690
43824
  ? data[target]
43691
- : decodeURI((data.getAttribute && (target === 'href' || target === 'value') ? (data.getAttribute(target) || '') : data[target]));
43825
+ : decodeURI(getRawTargetValue(data, target));
43692
43826
  const matched = usedArrayPath ? match : subRegex.exec(currentStr);
43693
43827
  if (!matched)
43694
43828
  continue;
43695
43829
  const mdValue = getSubstituteValue(matched, pendo);
43696
43830
  substituteMetadataByTarget(data, target, mdValue, matched);
43831
+ // Substituted values can carry new placeholders into the next pass, so a dangerous
43832
+ // scheme can be assembled across passes. Check the whole URL, not each fragment.
43833
+ if (isUrlTarget && !startedWithDangerousScheme && hasDangerousUrlScheme(getRawTargetValue(data, target))) {
43834
+ data[target] = '';
43835
+ return;
43836
+ }
43697
43837
  }
43698
43838
  }
43839
+ function getRawTargetValue(data, target) {
43840
+ return data.getAttribute && (target === 'href' || target === 'value')
43841
+ ? (data.getAttribute(target) || '')
43842
+ : data[target];
43843
+ }
43699
43844
  function matchPlaceholder(placeholder, regex) {
43700
43845
  if (placeholder.target === 'textContent') {
43701
43846
  return placeholder.data[placeholder.target].match(regex);
43702
43847
  }
43703
43848
  else {
43704
- const raw = placeholder.data.getAttribute && (placeholder.target === 'href' || placeholder.target === 'value')
43705
- ? (placeholder.data.getAttribute(placeholder.target) || '')
43706
- : placeholder.data[placeholder.target];
43707
- return decodeURI(raw).match(regex);
43849
+ return decodeURI(getRawTargetValue(placeholder.data, placeholder.target)).match(regex);
43708
43850
  }
43709
43851
  }
43710
43852
  function getMetadataValueCaseInsensitive(metadata, type, property) {
@@ -46408,10 +46550,72 @@ function record() { var __defProp = Object.defineProperty;
46408
46550
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
46409
46551
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
46410
46552
  var _a;
46411
- var __defProp$1 = Object.defineProperty;
46412
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
46413
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
46414
- var NodeType$3 = /* @__PURE__ */ ((NodeType2) => {
46553
+ var EventType = /* @__PURE__ */ ((EventType2) => {
46554
+ EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
46555
+ EventType2[EventType2["Load"] = 1] = "Load";
46556
+ EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
46557
+ EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
46558
+ EventType2[EventType2["Meta"] = 4] = "Meta";
46559
+ EventType2[EventType2["Custom"] = 5] = "Custom";
46560
+ EventType2[EventType2["Plugin"] = 6] = "Plugin";
46561
+ EventType2[EventType2["Asset"] = 7] = "Asset";
46562
+ return EventType2;
46563
+ })(EventType || {});
46564
+ var IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {
46565
+ IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
46566
+ IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
46567
+ IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
46568
+ IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
46569
+ IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
46570
+ IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
46571
+ IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
46572
+ IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
46573
+ IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
46574
+ IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
46575
+ IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
46576
+ IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
46577
+ IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
46578
+ IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
46579
+ IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
46580
+ IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
46581
+ IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
46582
+ return IncrementalSource2;
46583
+ })(IncrementalSource || {});
46584
+ var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
46585
+ MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
46586
+ MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
46587
+ MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
46588
+ MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
46589
+ MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
46590
+ MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
46591
+ MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
46592
+ MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
46593
+ MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
46594
+ MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
46595
+ MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
46596
+ return MouseInteractions2;
46597
+ })(MouseInteractions || {});
46598
+ var PointerTypes = /* @__PURE__ */ ((PointerTypes2) => {
46599
+ PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
46600
+ PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
46601
+ PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
46602
+ return PointerTypes2;
46603
+ })(PointerTypes || {});
46604
+ var CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {
46605
+ CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
46606
+ CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
46607
+ CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
46608
+ return CanvasContext2;
46609
+ })(CanvasContext || {});
46610
+ var MediaInteractions = /* @__PURE__ */ ((MediaInteractions2) => {
46611
+ MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
46612
+ MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
46613
+ MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
46614
+ MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
46615
+ MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
46616
+ return MediaInteractions2;
46617
+ })(MediaInteractions || {});
46618
+ var NodeType = /* @__PURE__ */ ((NodeType2) => {
46415
46619
  NodeType2[NodeType2["Document"] = 0] = "Document";
46416
46620
  NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
46417
46621
  NodeType2[NodeType2["Element"] = 2] = "Element";
@@ -46419,23 +46623,34 @@ var NodeType$3 = /* @__PURE__ */ ((NodeType2) => {
46419
46623
  NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
46420
46624
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
46421
46625
  return NodeType2;
46422
- })(NodeType$3 || {});
46423
- const testableAccessors$1 = {
46424
- Node: ["childNodes", "parentNode", "parentElement", "textContent"],
46626
+ })(NodeType || {});
46627
+ const testableAccessors = {
46628
+ Node: [
46629
+ "childNodes",
46630
+ "parentNode",
46631
+ "parentElement",
46632
+ "textContent",
46633
+ "ownerDocument",
46634
+ "firstChild",
46635
+ "lastChild",
46636
+ "nextSibling",
46637
+ "previousSibling"
46638
+ ],
46425
46639
  ShadowRoot: ["host", "styleSheets"],
46426
46640
  Element: ["shadowRoot"],
46427
46641
  MutationObserver: [],
46428
46642
  EventTarget: []
46429
46643
  };
46430
- const testableMethods$1 = {
46644
+ const testableMethods = {
46431
46645
  Node: ["contains", "getRootNode"],
46432
46646
  ShadowRoot: ["getSelection"],
46433
46647
  Element: ["querySelector", "querySelectorAll"],
46434
46648
  MutationObserver: ["constructor"],
46435
46649
  EventTarget: ["addEventListener", "removeEventListener"]
46436
46650
  };
46437
- const untaintedBasePrototype$1 = {};
46438
- function angularZoneUnpatchedAlternative$1(key) {
46651
+ const untaintedBasePrototype = {};
46652
+ const untaintedBaseIframeCleanup = {};
46653
+ function angularZoneUnpatchedAlternative(key) {
46439
46654
  var _a2, _b;
46440
46655
  const angularUnpatchedVersionSymbol = (_b = (_a2 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b.call(_a2, key);
46441
46656
  if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
@@ -46444,12 +46659,12 @@ function angularZoneUnpatchedAlternative$1(key) {
46444
46659
  return void 0;
46445
46660
  }
46446
46661
  }
46447
- function getUntaintedPrototype$1(key) {
46448
- if (untaintedBasePrototype$1[key])
46449
- return untaintedBasePrototype$1[key];
46450
- const candidate = angularZoneUnpatchedAlternative$1(key) || globalThis[key];
46662
+ function getUntaintedPrototype(key) {
46663
+ if (untaintedBasePrototype[key])
46664
+ return untaintedBasePrototype[key];
46665
+ const candidate = angularZoneUnpatchedAlternative(key) || globalThis[key];
46451
46666
  const defaultPrototype = candidate.prototype;
46452
- const accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
46667
+ const accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
46453
46668
  const isUntaintedAccessors = Boolean(
46454
46669
  accessorNames && // @ts-expect-error 2345
46455
46670
  accessorNames.every(
@@ -46461,7 +46676,7 @@ function getUntaintedPrototype$1(key) {
46461
46676
  }
46462
46677
  )
46463
46678
  );
46464
- const methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
46679
+ const methodNames = key in testableMethods ? testableMethods[key] : void 0;
46465
46680
  const isUntaintedMethods = Boolean(
46466
46681
  methodNames && methodNames.every(
46467
46682
  // @ts-expect-error 2345
@@ -46472,45 +46687,53 @@ function getUntaintedPrototype$1(key) {
46472
46687
  )
46473
46688
  );
46474
46689
  if (isUntaintedAccessors && isUntaintedMethods) {
46475
- untaintedBasePrototype$1[key] = candidate.prototype;
46690
+ untaintedBasePrototype[key] = candidate.prototype;
46476
46691
  return candidate.prototype;
46477
46692
  }
46478
46693
  try {
46479
46694
  const iframeEl = document.createElement("iframe");
46695
+ iframeEl.style.display = "none";
46480
46696
  document.body.appendChild(iframeEl);
46481
46697
  const win = iframeEl.contentWindow;
46482
46698
  if (!win) return candidate.prototype;
46483
46699
  const untaintedObject = win[key].prototype;
46484
- document.body.removeChild(iframeEl);
46485
- if (!untaintedObject) return defaultPrototype;
46486
- return untaintedBasePrototype$1[key] = untaintedObject;
46700
+ if (!untaintedObject) {
46701
+ iframeEl.remove();
46702
+ return defaultPrototype;
46703
+ }
46704
+ const ua = navigator.userAgent;
46705
+ if (ua.includes("Safari") && !ua.includes("Chrome")) {
46706
+ iframeEl.classList.add("rr-block");
46707
+ iframeEl.setAttribute("__rrwebUntaintedMutationObserver", "");
46708
+ untaintedBaseIframeCleanup[key] = () => iframeEl.remove();
46709
+ } else {
46710
+ iframeEl.remove();
46711
+ }
46712
+ return untaintedBasePrototype[key] = untaintedObject;
46487
46713
  } catch {
46488
46714
  return defaultPrototype;
46489
46715
  }
46490
46716
  }
46491
- const untaintedAccessorCache$1 = {};
46492
- function getUntaintedAccessor$1(key, instance, accessor) {
46493
- var _a2;
46494
- const cacheKey = `${key}.${String(accessor)}`;
46495
- if (untaintedAccessorCache$1[cacheKey])
46496
- return untaintedAccessorCache$1[cacheKey].call(
46497
- instance
46498
- );
46499
- const untaintedPrototype = getUntaintedPrototype$1(key);
46500
- const untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(
46717
+ const untaintedAccessorCache = {};
46718
+ function getUntaintedAccessor(key, instance, accessor) {
46719
+ var _a2, _b;
46720
+ const cached = (_a2 = untaintedAccessorCache[key]) == null ? void 0 : _a2[accessor];
46721
+ if (cached) return cached.call(instance);
46722
+ const untaintedPrototype = getUntaintedPrototype(key);
46723
+ const untaintedAccessor = (_b = Object.getOwnPropertyDescriptor(
46501
46724
  untaintedPrototype,
46502
46725
  accessor
46503
- )) == null ? void 0 : _a2.get;
46726
+ )) == null ? void 0 : _b.get;
46504
46727
  if (!untaintedAccessor) return instance[accessor];
46505
- untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
46728
+ (untaintedAccessorCache[key] || (untaintedAccessorCache[key] = {}))[accessor] = untaintedAccessor;
46506
46729
  return untaintedAccessor.call(instance);
46507
46730
  }
46508
- const untaintedMethodCache$1 = {};
46509
- function getUntaintedMethod$1(key, instance, method) {
46731
+ const untaintedMethodCache = {};
46732
+ function getUntaintedMethod(key, instance, method) {
46510
46733
  var _a2, _b, _c;
46511
46734
  const cacheKey = `${key}.${String(method)}`;
46512
- if (untaintedMethodCache$1[cacheKey])
46513
- return untaintedMethodCache$1[cacheKey].bind(
46735
+ if (untaintedMethodCache[cacheKey])
46736
+ return untaintedMethodCache[cacheKey].bind(
46514
46737
  instance
46515
46738
  );
46516
46739
  const zoneSymbol = (_b = (_a2 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b.call(
@@ -46521,67 +46744,106 @@ function getUntaintedMethod$1(key, instance, method) {
46521
46744
  const classProto = (_c = globalThis[key]) == null ? void 0 : _c.prototype;
46522
46745
  const nativeFromZone = globalThis[zoneSymbol] ?? (classProto == null ? void 0 : classProto[zoneSymbol]);
46523
46746
  if (typeof nativeFromZone === "function") {
46524
- untaintedMethodCache$1[cacheKey] = nativeFromZone;
46747
+ untaintedMethodCache[cacheKey] = nativeFromZone;
46525
46748
  return nativeFromZone.bind(
46526
46749
  instance
46527
46750
  );
46528
46751
  }
46529
46752
  }
46530
- const untaintedPrototype = getUntaintedPrototype$1(key);
46753
+ const untaintedPrototype = getUntaintedPrototype(key);
46531
46754
  const untaintedMethod = untaintedPrototype[method];
46532
46755
  if (typeof untaintedMethod !== "function") return instance[method];
46533
- untaintedMethodCache$1[cacheKey] = untaintedMethod;
46756
+ untaintedMethodCache[cacheKey] = untaintedMethod;
46534
46757
  return untaintedMethod.bind(instance);
46535
46758
  }
46536
- function childNodes$1(n2) {
46537
- return getUntaintedAccessor$1("Node", n2, "childNodes");
46759
+ function ownerDocument(n) {
46760
+ return getUntaintedAccessor("Node", n, "ownerDocument");
46761
+ }
46762
+ function childNodes(n) {
46763
+ return getUntaintedAccessor("Node", n, "childNodes");
46764
+ }
46765
+ function parentNode(n) {
46766
+ return getUntaintedAccessor("Node", n, "parentNode");
46767
+ }
46768
+ function parentElement(n) {
46769
+ return getUntaintedAccessor("Node", n, "parentElement");
46770
+ }
46771
+ function textContent(n) {
46772
+ return getUntaintedAccessor("Node", n, "textContent");
46538
46773
  }
46539
- function parentNode$1(n2) {
46540
- return getUntaintedAccessor$1("Node", n2, "parentNode");
46774
+ function firstChild(n) {
46775
+ return getUntaintedAccessor("Node", n, "firstChild");
46541
46776
  }
46542
- function parentElement$1(n2) {
46543
- return getUntaintedAccessor$1("Node", n2, "parentElement");
46777
+ function lastChild(n) {
46778
+ return getUntaintedAccessor("Node", n, "lastChild");
46544
46779
  }
46545
- function textContent$1(n2) {
46546
- return getUntaintedAccessor$1("Node", n2, "textContent");
46780
+ function nextSibling(n) {
46781
+ return getUntaintedAccessor("Node", n, "nextSibling");
46547
46782
  }
46548
- function contains$1(n2, other) {
46549
- return getUntaintedMethod$1("Node", n2, "contains")(other);
46783
+ function previousSibling(n) {
46784
+ return getUntaintedAccessor("Node", n, "previousSibling");
46550
46785
  }
46551
- function getRootNode$1(n2) {
46552
- return getUntaintedMethod$1("Node", n2, "getRootNode")();
46786
+ function contains(n, other) {
46787
+ return getUntaintedMethod("Node", n, "contains")(other);
46553
46788
  }
46554
- function host$1(n2) {
46555
- if (!n2 || !("host" in n2)) return null;
46556
- return getUntaintedAccessor$1("ShadowRoot", n2, "host");
46789
+ function getRootNode(n) {
46790
+ return getUntaintedMethod("Node", n, "getRootNode")();
46557
46791
  }
46558
- function styleSheets$1(n2) {
46559
- return n2.styleSheets;
46792
+ function host(n) {
46793
+ if (!n || !("host" in n)) return null;
46794
+ return getUntaintedAccessor("ShadowRoot", n, "host");
46560
46795
  }
46561
- function shadowRoot$1(n2) {
46562
- if (!n2 || !("shadowRoot" in n2)) return null;
46563
- return getUntaintedAccessor$1("Element", n2, "shadowRoot");
46796
+ function styleSheets(n) {
46797
+ return n.styleSheets;
46564
46798
  }
46565
- function querySelector$1(n2, selectors) {
46566
- return getUntaintedMethod$1("Element", n2, "querySelector")(selectors);
46799
+ function shadowRoot(n) {
46800
+ if (!n || !("shadowRoot" in n)) return null;
46801
+ return getUntaintedAccessor("Element", n, "shadowRoot");
46567
46802
  }
46568
- function querySelectorAll$1(n2, selectors) {
46569
- return getUntaintedMethod$1("Element", n2, "querySelectorAll")(selectors);
46803
+ function querySelector(n, selectors) {
46804
+ return getUntaintedMethod("Element", n, "querySelector")(selectors);
46570
46805
  }
46571
- function addEventListener$1(n2, type, listener, options) {
46572
- getUntaintedMethod$1("EventTarget", n2, "addEventListener")(type, listener, options);
46806
+ function querySelectorAll(n, selectors) {
46807
+ return getUntaintedMethod("Element", n, "querySelectorAll")(selectors);
46573
46808
  }
46574
- function removeEventListener$1(n2, type, listener, options) {
46575
- getUntaintedMethod$1("EventTarget", n2, "removeEventListener")(
46809
+ function addEventListener(n, type, listener, options) {
46810
+ getUntaintedMethod("EventTarget", n, "addEventListener")(type, listener, options);
46811
+ }
46812
+ function removeEventListener(n, type, listener, options) {
46813
+ getUntaintedMethod("EventTarget", n, "removeEventListener")(
46576
46814
  type,
46577
46815
  listener,
46578
46816
  options
46579
46817
  );
46580
46818
  }
46581
- function mutationObserverCtor$1() {
46582
- return getUntaintedPrototype$1("MutationObserver").constructor;
46819
+ function mutationObserverCtor() {
46820
+ return [
46821
+ getUntaintedPrototype("MutationObserver").constructor,
46822
+ untaintedBaseIframeCleanup["MutationObserver"] ?? (() => {
46823
+ })
46824
+ ];
46583
46825
  }
46584
- function patch$1(source, name, replacement) {
46826
+ function getUntaintedProxy() {
46827
+ var _a2, _b;
46828
+ let Proxy3 = window.Proxy;
46829
+ try {
46830
+ if (typeof window.Proxy !== "function" || !((_a2 = window.Proxy) == null ? void 0 : _a2.toString().includes("[native code]"))) {
46831
+ const cleanFrame = document.createElement("iframe");
46832
+ cleanFrame.style.display = "none";
46833
+ document.documentElement.appendChild(cleanFrame);
46834
+ Proxy3 = ((_b = cleanFrame.contentWindow) == null ? void 0 : _b.Proxy) || window.Proxy;
46835
+ document.documentElement.removeChild(cleanFrame);
46836
+ }
46837
+ } catch (err) {
46838
+ console.debug("Unable to get untainted Proxy from iframe", err);
46839
+ }
46840
+ return Proxy3;
46841
+ }
46842
+ let nowTimestamp = Date.now;
46843
+ if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
46844
+ nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
46845
+ }
46846
+ function patch(source, name, replacement) {
46585
46847
  try {
46586
46848
  if (!(name in source)) {
46587
46849
  return () => {
@@ -46607,40 +46869,46 @@ function patch$1(source, name, replacement) {
46607
46869
  };
46608
46870
  }
46609
46871
  }
46610
- const index$1 = {
46611
- childNodes: childNodes$1,
46612
- parentNode: parentNode$1,
46613
- parentElement: parentElement$1,
46614
- textContent: textContent$1,
46615
- contains: contains$1,
46616
- getRootNode: getRootNode$1,
46617
- host: host$1,
46618
- styleSheets: styleSheets$1,
46619
- shadowRoot: shadowRoot$1,
46620
- querySelector: querySelector$1,
46621
- querySelectorAll: querySelectorAll$1,
46622
- addEventListener: addEventListener$1,
46623
- removeEventListener: removeEventListener$1,
46624
- mutationObserver: mutationObserverCtor$1,
46625
- patch: patch$1
46626
- };
46627
- function isElement(n2) {
46628
- return n2.nodeType === n2.ELEMENT_NODE;
46629
- }
46630
- function isShadowRoot(n2) {
46872
+ const index = {
46873
+ ownerDocument,
46874
+ childNodes,
46875
+ parentNode,
46876
+ parentElement,
46877
+ textContent,
46878
+ firstChild,
46879
+ lastChild,
46880
+ nextSibling,
46881
+ previousSibling,
46882
+ contains,
46883
+ getRootNode,
46884
+ host,
46885
+ styleSheets,
46886
+ shadowRoot,
46887
+ querySelector,
46888
+ querySelectorAll,
46889
+ addEventListener,
46890
+ removeEventListener,
46891
+ nowTimestamp,
46892
+ mutationObserverCtor,
46893
+ patch
46894
+ };
46895
+ function isElement(n) {
46896
+ return n.nodeType === n.ELEMENT_NODE;
46897
+ }
46898
+ function isShadowRoot(n) {
46631
46899
  const hostEl = (
46632
46900
  // anchor and textarea elements also have a `host` property
46633
46901
  // but only shadow roots have a `mode` property
46634
- n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null
46902
+ n && "host" in n && "mode" in n && index.host(n) || null
46635
46903
  );
46636
46904
  return Boolean(
46637
- hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2
46905
+ hostEl && "shadowRoot" in hostEl && index.shadowRoot(hostEl) === n
46638
46906
  );
46639
46907
  }
46640
46908
  function isNativeShadowDom(shadowRoot2) {
46641
46909
  return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
46642
46910
  }
46643
- function getNative$1(symbolName, windowObj = window) {
46911
+ function getNative(symbolName, windowObj = window) {
46644
46912
  var _a2, _b;
46645
46913
  const windowWithZone = windowObj;
46646
46914
  const angularZoneSymbol = (_b = (_a2 = windowWithZone == null ? void 0 : windowWithZone.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b.call(_a2, symbolName);
@@ -46652,7 +46920,7 @@ function getNative$1(symbolName, windowObj = window) {
46652
46920
  }
46653
46921
  return windowWithZone[symbolName];
46654
46922
  }
46655
- const nativeSetTimeout = typeof window !== "undefined" ? getNative$1("setTimeout").bind(window) : global.setTimeout;
46923
+ const nativeSetTimeout = typeof window !== "undefined" ? getNative("setTimeout").bind(window) : global.setTimeout;
46656
46924
  function fixBrowserCompatibilityIssuesInCSS(cssText) {
46657
46925
  if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
46658
46926
  cssText = cssText.replace(
@@ -46679,18 +46947,18 @@ function escapeImportStatement(rule) {
46679
46947
  }
46680
46948
  return statement.join(" ") + ";";
46681
46949
  }
46682
- function stringifyStylesheet(s2) {
46950
+ function stringifyStylesheet(s) {
46683
46951
  try {
46684
- const rules2 = s2.rules || s2.cssRules;
46685
- if (!rules2) {
46952
+ const rules = s.rules || s.cssRules;
46953
+ if (!rules) {
46686
46954
  return null;
46687
46955
  }
46688
- let sheetHref = s2.href;
46689
- if (!sheetHref && s2.ownerNode) {
46690
- sheetHref = s2.ownerNode.baseURI;
46956
+ let sheetHref = s.href;
46957
+ if (!sheetHref && s.ownerNode) {
46958
+ sheetHref = s.ownerNode.baseURI;
46691
46959
  }
46692
46960
  const stringifiedRules = Array.from(
46693
- rules2,
46961
+ rules,
46694
46962
  (rule) => stringifyRule(rule, sheetHref)
46695
46963
  ).join("");
46696
46964
  return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
@@ -46736,8 +47004,8 @@ function replaceChromeGridTemplateAreas(rule) {
46736
47004
  );
46737
47005
  if (hasGridTemplateInCSSText && hasGridTemplateAreaInStyleRules && !hasGridTemplateAreaInCSSText) {
46738
47006
  const styleDeclarations = [];
46739
- for (let i2 = 0; i2 < rule.style.length; i2++) {
46740
- const styleName = rule.style[i2];
47007
+ for (let i = 0; i < rule.style.length; i++) {
47008
+ const styleName = rule.style[i];
46741
47009
  const styleValue = rule.style.getPropertyValue(styleName);
46742
47010
  styleDeclarations.push(`${styleName}: ${styleValue}`);
46743
47011
  }
@@ -46757,13 +47025,13 @@ function isCSSStyleRule(rule) {
46757
47025
  }
46758
47026
  class Mirror {
46759
47027
  constructor() {
46760
- __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
46761
- __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
47028
+ __publicField(this, "idNodeMap", /* @__PURE__ */ new Map());
47029
+ __publicField(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
46762
47030
  }
46763
- getId(n2) {
47031
+ getId(n) {
46764
47032
  var _a2;
46765
- if (!n2) return -1;
46766
- const id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
47033
+ if (!n) return -1;
47034
+ const id = (_a2 = this.getMeta(n)) == null ? void 0 : _a2.id;
46767
47035
  return id ?? -1;
46768
47036
  }
46769
47037
  getNode(id) {
@@ -46772,16 +47040,16 @@ class Mirror {
46772
47040
  getIds() {
46773
47041
  return Array.from(this.idNodeMap.keys());
46774
47042
  }
46775
- getMeta(n2) {
46776
- return this.nodeMetaMap.get(n2) || null;
47043
+ getMeta(n) {
47044
+ return this.nodeMetaMap.get(n) || null;
46777
47045
  }
46778
47046
  // removes the node from idNodeMap
46779
47047
  // doesn't remove the node from nodeMetaMap
46780
- removeNodeFromMap(n2) {
46781
- const id = this.getId(n2);
47048
+ removeNodeFromMap(n) {
47049
+ const id = this.getId(n);
46782
47050
  this.idNodeMap.delete(id);
46783
- if (n2.childNodes) {
46784
- n2.childNodes.forEach(
47051
+ if (n.childNodes) {
47052
+ n.childNodes.forEach(
46785
47053
  (childNode) => this.removeNodeFromMap(childNode)
46786
47054
  );
46787
47055
  }
@@ -46792,25 +47060,25 @@ class Mirror {
46792
47060
  hasNode(node) {
46793
47061
  return this.nodeMetaMap.has(node);
46794
47062
  }
46795
- add(n2, meta) {
47063
+ add(n, meta) {
46796
47064
  const id = meta.id;
46797
- this.idNodeMap.set(id, n2);
46798
- this.nodeMetaMap.set(n2, meta);
47065
+ this.idNodeMap.set(id, n);
47066
+ this.nodeMetaMap.set(n, meta);
46799
47067
  }
46800
- replace(id, n2) {
47068
+ replace(id, n) {
46801
47069
  const oldNode = this.getNode(id);
46802
47070
  if (oldNode) {
46803
47071
  const meta = this.nodeMetaMap.get(oldNode);
46804
- if (meta) this.nodeMetaMap.set(n2, meta);
47072
+ if (meta) this.nodeMetaMap.set(n, meta);
46805
47073
  }
46806
- this.idNodeMap.set(id, n2);
47074
+ this.idNodeMap.set(id, n);
46807
47075
  }
46808
47076
  reset() {
46809
47077
  this.idNodeMap = /* @__PURE__ */ new Map();
46810
47078
  this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
46811
47079
  }
46812
47080
  }
46813
- function createMirror$2() {
47081
+ function createMirror() {
46814
47082
  return new Mirror();
46815
47083
  }
46816
47084
  function maskInputValue({
@@ -46910,8 +47178,10 @@ function absolutifyURLs(cssText, href) {
46910
47178
  if (filePath[0] === "/") {
46911
47179
  return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
46912
47180
  }
46913
- const stack = href.split("/");
46914
- const parts = filePath.split("/");
47181
+ const filePathNoHash = filePath.split("#")[0];
47182
+ const maybeHash = filePath.substring(filePathNoHash.length);
47183
+ const stack = href.split("#")[0].split("/");
47184
+ const parts = filePathNoHash.split("/");
46915
47185
  stack.pop();
46916
47186
  for (const part of parts) {
46917
47187
  if (part === ".") {
@@ -46922,7 +47192,7 @@ function absolutifyURLs(cssText, href) {
46922
47192
  stack.push(part);
46923
47193
  }
46924
47194
  }
46925
- return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
47195
+ return `url(${maybeQuote}${stack.join("/")}${maybeHash}${maybeQuote})`;
46926
47196
  }
46927
47197
  );
46928
47198
  }
@@ -46940,10 +47210,10 @@ function splitCssText(cssText, style, _testNoPxNorm = false) {
46940
47210
  if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
46941
47211
  let cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
46942
47212
  const normFactor = cssTextNorm.length / cssText.length;
46943
- for (let i2 = 1; i2 < childNodes2.length; i2++) {
46944
- if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
47213
+ for (let i = 1; i < childNodes2.length; i++) {
47214
+ if (childNodes2[i].textContent && typeof childNodes2[i].textContent === "string") {
46945
47215
  const textContentNorm = normalizeCssString(
46946
- childNodes2[i2].textContent,
47216
+ childNodes2[i].textContent,
46947
47217
  _testNoPxNorm
46948
47218
  );
46949
47219
  const jLimit = 100;
@@ -46964,7 +47234,7 @@ function splitCssText(cssText, style, _testNoPxNorm = false) {
46964
47234
  let splitNorm = -1;
46965
47235
  if (cssNormSplits.length === 2) {
46966
47236
  splitNorm = cssNormSplits[0].length;
46967
- } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
47237
+ } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i - 1].textContent !== "") {
46968
47238
  splitNorm = cssTextNorm.indexOf(startSubstring, 1);
46969
47239
  } else if (cssNormSplits.length === 1) {
46970
47240
  startSubstring = startSubstring.substring(
@@ -46981,7 +47251,7 @@ function splitCssText(cssText, style, _testNoPxNorm = false) {
46981
47251
  splitNorm = cssTextNorm.indexOf(startSubstring);
46982
47252
  }
46983
47253
  if (cssNormSplits.length >= 2 && j > jLimit) {
46984
- const prevTextContent = childNodes2[i2 - 1].textContent;
47254
+ const prevTextContent = childNodes2[i - 1].textContent;
46985
47255
  if (prevTextContent && typeof prevTextContent === "string") {
46986
47256
  const prevMinLength = normalizeCssString(prevTextContent).length;
46987
47257
  splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
@@ -47037,7 +47307,7 @@ const IGNORED_NODE = -2;
47037
47307
  function genId() {
47038
47308
  return _id++;
47039
47309
  }
47040
- function getValidTagName$1(element) {
47310
+ function getValidTagName(element) {
47041
47311
  if (element instanceof HTMLFormElement) {
47042
47312
  return "form";
47043
47313
  }
@@ -47081,24 +47351,24 @@ function getAbsoluteSrcsetString(doc, attributeValue) {
47081
47351
  url = absoluteToDoc(doc, url);
47082
47352
  let inParens = false;
47083
47353
  while (true) {
47084
- const c2 = attributeValue.charAt(pos);
47085
- if (c2 === "") {
47354
+ const c = attributeValue.charAt(pos);
47355
+ if (c === "") {
47086
47356
  output.push((url + descriptorsStr).trim());
47087
47357
  break;
47088
47358
  } else if (!inParens) {
47089
- if (c2 === ",") {
47359
+ if (c === ",") {
47090
47360
  pos += 1;
47091
47361
  output.push((url + descriptorsStr).trim());
47092
47362
  break;
47093
- } else if (c2 === "(") {
47363
+ } else if (c === "(") {
47094
47364
  inParens = true;
47095
47365
  }
47096
47366
  } else {
47097
- if (c2 === ")") {
47367
+ if (c === ")") {
47098
47368
  inParens = false;
47099
47369
  }
47100
47370
  }
47101
- descriptorsStr += c2;
47371
+ descriptorsStr += c;
47102
47372
  pos += 1;
47103
47373
  }
47104
47374
  }
@@ -47116,18 +47386,18 @@ function isSVGElement(el) {
47116
47386
  return Boolean(el.tagName === "svg" || el.ownerSVGElement);
47117
47387
  }
47118
47388
  function getHref(doc, customHref) {
47119
- let a2 = cachedDocument.get(doc);
47120
- if (!a2) {
47121
- a2 = doc.createElement("a");
47122
- cachedDocument.set(doc, a2);
47389
+ let a = cachedDocument.get(doc);
47390
+ if (!a) {
47391
+ a = doc.createElement("a");
47392
+ cachedDocument.set(doc, a);
47123
47393
  }
47124
47394
  if (!customHref) {
47125
47395
  customHref = "";
47126
47396
  } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
47127
47397
  return customHref;
47128
47398
  }
47129
- a2.setAttribute("href", customHref);
47130
- return a2.href;
47399
+ a.setAttribute("href", customHref);
47400
+ return a.href;
47131
47401
  }
47132
47402
  function transformAttribute(doc, tagName, name, value) {
47133
47403
  if (!value) {
@@ -47137,7 +47407,7 @@ function transformAttribute(doc, tagName, name, value) {
47137
47407
  return absoluteToDoc(doc, value);
47138
47408
  } else if (name === "xlink:href" && value[0] !== "#") {
47139
47409
  return absoluteToDoc(doc, value);
47140
- } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
47410
+ } else if (name === "background" && ["table", "td", "th"].includes(tagName)) {
47141
47411
  return absoluteToDoc(doc, value);
47142
47412
  } else if (name === "srcset") {
47143
47413
  return getAbsoluteSrcsetString(doc, value);
@@ -47149,7 +47419,7 @@ function transformAttribute(doc, tagName, name, value) {
47149
47419
  return value;
47150
47420
  }
47151
47421
  function ignoreAttribute(tagName, name, _value) {
47152
- return (tagName === "video" || tagName === "audio") && name === "autoplay";
47422
+ return ["video", "audio"].includes(tagName) && toLowerCase(name) === "autoplay";
47153
47423
  }
47154
47424
  function _isBlockedElement(element, blockClass, blockSelector) {
47155
47425
  try {
@@ -47168,7 +47438,7 @@ function _isBlockedElement(element, blockClass, blockSelector) {
47168
47438
  if (blockSelector) {
47169
47439
  return element.matches(blockSelector);
47170
47440
  }
47171
- } catch (e2) {
47441
+ } catch (e) {
47172
47442
  }
47173
47443
  return false;
47174
47444
  }
@@ -47177,7 +47447,7 @@ function classMatchesRegex(node, regex, checkAncestors) {
47177
47447
  if (!regex) return false;
47178
47448
  if (node.nodeType !== node.ELEMENT_NODE) {
47179
47449
  if (!checkAncestors) return false;
47180
- return classMatchesRegex(index$1.parentNode(node), regex, checkAncestors);
47450
+ return classMatchesRegex(index.parentNode(node), regex, checkAncestors);
47181
47451
  }
47182
47452
  for (let eIndex = node.classList.length; eIndex--; ) {
47183
47453
  const className = node.classList[eIndex];
@@ -47186,20 +47456,20 @@ function classMatchesRegex(node, regex, checkAncestors) {
47186
47456
  }
47187
47457
  }
47188
47458
  if (!checkAncestors) return false;
47189
- return classMatchesRegex(index$1.parentNode(node), regex, checkAncestors);
47459
+ return classMatchesRegex(index.parentNode(node), regex, checkAncestors);
47190
47460
  }
47191
47461
  function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) {
47192
47462
  let el;
47193
47463
  if (isElement(node)) {
47194
47464
  el = node;
47195
47465
  if (maskTextSelector === "*") return true;
47196
- if (!index$1.childNodes(el).length) {
47466
+ if (!index.childNodes(el).length) {
47197
47467
  return false;
47198
47468
  }
47199
- } else if (index$1.parentElement(node) === null) {
47469
+ } else if (index.parentElement(node) === null) {
47200
47470
  return false;
47201
47471
  } else {
47202
- el = index$1.parentElement(node);
47472
+ el = index.parentElement(node);
47203
47473
  }
47204
47474
  try {
47205
47475
  if (typeof maskTextClass === "string") {
@@ -47218,7 +47488,7 @@ function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors)
47218
47488
  if (el.matches(maskTextSelector)) return true;
47219
47489
  }
47220
47490
  }
47221
- } catch (e2) {
47491
+ } catch (e) {
47222
47492
  }
47223
47493
  return false;
47224
47494
  }
@@ -47276,7 +47546,7 @@ function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
47276
47546
  listener();
47277
47547
  });
47278
47548
  }
47279
- function serializeNode(n2, options) {
47549
+ function serializeNode(n, options) {
47280
47550
  const {
47281
47551
  doc,
47282
47552
  mirror: mirror2,
@@ -47296,31 +47566,31 @@ function serializeNode(n2, options) {
47296
47566
  cssCaptured = false
47297
47567
  } = options;
47298
47568
  const rootId = getRootId(doc, mirror2);
47299
- switch (n2.nodeType) {
47300
- case n2.DOCUMENT_NODE:
47301
- if (n2.compatMode !== "CSS1Compat") {
47569
+ switch (n.nodeType) {
47570
+ case n.DOCUMENT_NODE:
47571
+ if (n.compatMode !== "CSS1Compat") {
47302
47572
  return {
47303
- type: NodeType$3.Document,
47573
+ type: NodeType.Document,
47304
47574
  childNodes: [],
47305
- compatMode: n2.compatMode
47575
+ compatMode: n.compatMode
47306
47576
  // probably "BackCompat"
47307
47577
  };
47308
47578
  } else {
47309
47579
  return {
47310
- type: NodeType$3.Document,
47580
+ type: NodeType.Document,
47311
47581
  childNodes: []
47312
47582
  };
47313
47583
  }
47314
- case n2.DOCUMENT_TYPE_NODE:
47584
+ case n.DOCUMENT_TYPE_NODE:
47315
47585
  return {
47316
- type: NodeType$3.DocumentType,
47317
- name: n2.name,
47318
- publicId: n2.publicId,
47319
- systemId: n2.systemId,
47586
+ type: NodeType.DocumentType,
47587
+ name: n.name,
47588
+ publicId: n.publicId,
47589
+ systemId: n.systemId,
47320
47590
  rootId
47321
47591
  };
47322
- case n2.ELEMENT_NODE:
47323
- return serializeElementNode(n2, {
47592
+ case n.ELEMENT_NODE:
47593
+ return serializeElementNode(n, {
47324
47594
  doc,
47325
47595
  blockClass,
47326
47596
  blockSelector,
@@ -47336,8 +47606,8 @@ function serializeNode(n2, options) {
47336
47606
  rootId,
47337
47607
  needsMask
47338
47608
  });
47339
- case n2.TEXT_NODE:
47340
- return serializeTextNode(n2, {
47609
+ case n.TEXT_NODE:
47610
+ return serializeTextNode(n, {
47341
47611
  doc,
47342
47612
  needsMask,
47343
47613
  maskTextFn,
@@ -47346,16 +47616,16 @@ function serializeNode(n2, options) {
47346
47616
  rootId,
47347
47617
  cssCaptured
47348
47618
  });
47349
- case n2.CDATA_SECTION_NODE:
47619
+ case n.CDATA_SECTION_NODE:
47350
47620
  return {
47351
- type: NodeType$3.CDATA,
47621
+ type: NodeType.CDATA,
47352
47622
  textContent: "",
47353
47623
  rootId
47354
47624
  };
47355
- case n2.COMMENT_NODE:
47625
+ case n.COMMENT_NODE:
47356
47626
  return {
47357
- type: NodeType$3.Comment,
47358
- textContent: index$1.textContent(n2) || "",
47627
+ type: NodeType.Comment,
47628
+ textContent: index.textContent(n) || "",
47359
47629
  rootId
47360
47630
  };
47361
47631
  default:
@@ -47367,7 +47637,7 @@ function getRootId(doc, mirror2) {
47367
47637
  const docId = mirror2.getId(doc);
47368
47638
  return docId === 1 ? void 0 : docId;
47369
47639
  }
47370
- function serializeTextNode(n2, options) {
47640
+ function serializeTextNode(n, options) {
47371
47641
  var _a2;
47372
47642
  const {
47373
47643
  needsMask,
@@ -47377,23 +47647,23 @@ function serializeTextNode(n2, options) {
47377
47647
  rootId,
47378
47648
  cssCaptured
47379
47649
  } = options;
47380
- const parentTagName = n2.parentNode && n2.parentNode.tagName;
47650
+ const parentTagName = n.parentNode && n.parentNode.tagName;
47381
47651
  let textContent2 = "";
47382
47652
  const isStyle = parentTagName === "STYLE" ? true : void 0;
47383
47653
  const isScript = parentTagName === "SCRIPT" ? true : void 0;
47384
47654
  const isTextarea = parentTagName === "TEXTAREA" ? true : void 0;
47385
47655
  if (isStyle && textContent2) {
47386
47656
  try {
47387
- if (n2.nextSibling || n2.previousSibling) {
47388
- } else if ((_a2 = n2.parentNode.sheet) == null ? void 0 : _a2.cssRules) {
47657
+ if (n.nextSibling || n.previousSibling) {
47658
+ } else if ((_a2 = n.parentNode.sheet) == null ? void 0 : _a2.cssRules) {
47389
47659
  textContent2 = stringifyStylesheet(
47390
- n2.parentNode.sheet
47660
+ n.parentNode.sheet
47391
47661
  );
47392
47662
  }
47393
47663
  } catch (err) {
47394
47664
  console.warn(
47395
47665
  `Cannot get CSS styles from text's parentNode. Error: ${err}`,
47396
- n2
47666
+ n
47397
47667
  );
47398
47668
  }
47399
47669
  textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
@@ -47401,24 +47671,24 @@ function serializeTextNode(n2, options) {
47401
47671
  if (isScript) {
47402
47672
  textContent2 = "SCRIPT_PLACEHOLDER";
47403
47673
  } else if (!cssCaptured) {
47404
- textContent2 = index$1.textContent(n2);
47674
+ textContent2 = index.textContent(n);
47405
47675
  if (isStyle && textContent2) {
47406
47676
  textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
47407
47677
  }
47408
47678
  }
47409
47679
  if (!isStyle && !isScript && textContent2 && needsMask) {
47410
- textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
47680
+ textContent2 = maskTextFn ? maskTextFn(textContent2, index.parentElement(n)) : textContent2.replace(/[\S]/g, "*");
47411
47681
  }
47412
47682
  if (isTextarea && textContent2 && maskInputOptions.textarea) {
47413
- textContent2 = maskInputFn ? maskInputFn(textContent2, n2.parentNode) : textContent2.replace(/[\S]/g, "*");
47683
+ textContent2 = maskInputFn ? maskInputFn(textContent2, n.parentNode) : textContent2.replace(/[\S]/g, "*");
47414
47684
  }
47415
47685
  return {
47416
- type: NodeType$3.Text,
47686
+ type: NodeType.Text,
47417
47687
  textContent: textContent2 || "",
47418
47688
  rootId
47419
47689
  };
47420
47690
  }
47421
- function serializeElementNode(n2, options) {
47691
+ function serializeElementNode(n, options) {
47422
47692
  const {
47423
47693
  doc,
47424
47694
  blockClass,
@@ -47435,13 +47705,13 @@ function serializeElementNode(n2, options) {
47435
47705
  rootId,
47436
47706
  needsMask
47437
47707
  } = options;
47438
- const needBlock = _isBlockedElement(n2, blockClass, blockSelector);
47439
- const needHide = needBlock && hideSelector ? _isBlockedElement(n2, "", hideSelector) : false;
47440
- const tagName = getValidTagName$1(n2);
47708
+ const needBlock = _isBlockedElement(n, blockClass, blockSelector);
47709
+ const needHide = needBlock && hideSelector ? _isBlockedElement(n, "", hideSelector) : false;
47710
+ const tagName = getValidTagName(n);
47441
47711
  let attributes = {};
47442
- const len = n2.attributes.length;
47443
- for (let i2 = 0; i2 < len; i2++) {
47444
- const attr = n2.attributes[i2];
47712
+ const len = n.attributes.length;
47713
+ for (let i = 0; i < len; i++) {
47714
+ const attr = n.attributes[i];
47445
47715
  if (!ignoreAttribute(tagName, attr.name, attr.value)) {
47446
47716
  attributes[attr.name] = transformAttribute(
47447
47717
  doc,
@@ -47452,8 +47722,8 @@ function serializeElementNode(n2, options) {
47452
47722
  }
47453
47723
  }
47454
47724
  if (tagName === "link" && inlineStylesheet) {
47455
- const stylesheet = Array.from(doc.styleSheets).find((s2) => {
47456
- return s2.href === n2.href;
47725
+ const stylesheet = Array.from(doc.styleSheets).find((s) => {
47726
+ return s.href === n.href;
47457
47727
  });
47458
47728
  let cssText = null;
47459
47729
  if (stylesheet) {
@@ -47465,24 +47735,24 @@ function serializeElementNode(n2, options) {
47465
47735
  attributes._cssText = cssText;
47466
47736
  }
47467
47737
  }
47468
- if (tagName === "style" && n2.sheet) {
47738
+ if (tagName === "style" && n.sheet) {
47469
47739
  let cssText = stringifyStylesheet(
47470
- n2.sheet
47740
+ n.sheet
47471
47741
  );
47472
47742
  if (cssText) {
47473
- if (n2.childNodes.length > 1) {
47474
- cssText = markCssSplits(cssText, n2);
47743
+ if (n.childNodes.length > 1) {
47744
+ cssText = markCssSplits(cssText, n);
47475
47745
  }
47476
47746
  attributes._cssText = cssText;
47477
47747
  }
47478
47748
  }
47479
- if (tagName === "input" || tagName === "textarea" || tagName === "select") {
47480
- const value = n2.value;
47481
- const checked = n2.checked;
47749
+ if (["input", "textarea", "select"].includes(tagName)) {
47750
+ const value = n.value;
47751
+ const checked = n.checked;
47482
47752
  if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
47483
47753
  attributes.value = maskInputValue({
47484
- element: n2,
47485
- type: getInputType(n2),
47754
+ element: n,
47755
+ type: getInputType(n),
47486
47756
  tagName,
47487
47757
  value,
47488
47758
  maskInputOptions,
@@ -47494,31 +47764,31 @@ function serializeElementNode(n2, options) {
47494
47764
  }
47495
47765
  }
47496
47766
  if (tagName === "option") {
47497
- if (n2.selected && !maskInputOptions["select"]) {
47767
+ if (n.selected && !maskInputOptions["select"]) {
47498
47768
  attributes.selected = true;
47499
47769
  } else {
47500
47770
  delete attributes.selected;
47501
47771
  }
47502
47772
  }
47503
- if (tagName === "dialog" && n2.open) {
47504
- attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
47773
+ if (tagName === "dialog" && n.open) {
47774
+ attributes.rr_open_mode = n.matches("dialog:modal") ? "modal" : "non-modal";
47505
47775
  }
47506
47776
  if (tagName === "canvas" && recordCanvas) {
47507
- if (n2.__context === "2d") {
47508
- if (!is2DCanvasBlank(n2)) {
47509
- attributes.rr_dataURL = n2.toDataURL(
47777
+ if (n.__context === "2d") {
47778
+ if (!is2DCanvasBlank(n)) {
47779
+ attributes.rr_dataURL = n.toDataURL(
47510
47780
  dataURLOptions.type,
47511
47781
  dataURLOptions.quality
47512
47782
  );
47513
47783
  }
47514
- } else if (!("__context" in n2)) {
47515
- const canvasDataURL = n2.toDataURL(
47784
+ } else if (!("__context" in n)) {
47785
+ const canvasDataURL = n.toDataURL(
47516
47786
  dataURLOptions.type,
47517
47787
  dataURLOptions.quality
47518
47788
  );
47519
47789
  const blankCanvas = doc.createElement("canvas");
47520
- blankCanvas.width = n2.width;
47521
- blankCanvas.height = n2.height;
47790
+ blankCanvas.width = n.width;
47791
+ blankCanvas.height = n.height;
47522
47792
  const blankCanvasDataURL = blankCanvas.toDataURL(
47523
47793
  dataURLOptions.type,
47524
47794
  dataURLOptions.quality
@@ -47533,7 +47803,7 @@ function serializeElementNode(n2, options) {
47533
47803
  canvasService = doc.createElement("canvas");
47534
47804
  canvasCtx = canvasService.getContext("2d");
47535
47805
  }
47536
- const image = n2;
47806
+ const image = n;
47537
47807
  const imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
47538
47808
  const priorCrossOrigin = image.crossOrigin;
47539
47809
  const recordInlineImage = () => {
@@ -47566,21 +47836,21 @@ function serializeElementNode(n2, options) {
47566
47836
  if (image.complete && image.naturalWidth !== 0) recordInlineImage();
47567
47837
  else image.addEventListener("load", recordInlineImage);
47568
47838
  }
47569
- if (tagName === "audio" || tagName === "video") {
47839
+ if (["audio", "video"].includes(tagName)) {
47570
47840
  const mediaAttributes = attributes;
47571
- mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
47572
- mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
47573
- mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
47574
- mediaAttributes.rr_mediaMuted = n2.muted;
47575
- mediaAttributes.rr_mediaLoop = n2.loop;
47576
- mediaAttributes.rr_mediaVolume = n2.volume;
47841
+ mediaAttributes.rr_mediaState = n.paused ? "paused" : "played";
47842
+ mediaAttributes.rr_mediaCurrentTime = n.currentTime;
47843
+ mediaAttributes.rr_mediaPlaybackRate = n.playbackRate;
47844
+ mediaAttributes.rr_mediaMuted = n.muted;
47845
+ mediaAttributes.rr_mediaLoop = n.loop;
47846
+ mediaAttributes.rr_mediaVolume = n.volume;
47577
47847
  }
47578
47848
  if (!newlyAddedElement) {
47579
- if (n2.scrollLeft) {
47580
- attributes.rr_scrollLeft = n2.scrollLeft;
47849
+ if (n.scrollLeft) {
47850
+ attributes.rr_scrollLeft = n.scrollLeft;
47581
47851
  }
47582
- if (n2.scrollTop) {
47583
- attributes.rr_scrollTop = n2.scrollTop;
47852
+ if (n.scrollTop) {
47853
+ attributes.rr_scrollTop = n.scrollTop;
47584
47854
  }
47585
47855
  }
47586
47856
  if (needHide) {
@@ -47589,7 +47859,7 @@ function serializeElementNode(n2, options) {
47589
47859
  rr_display: "none"
47590
47860
  };
47591
47861
  } else if (needBlock) {
47592
- const { width, height } = n2.getBoundingClientRect();
47862
+ const { width, height } = n.getBoundingClientRect();
47593
47863
  attributes = {
47594
47864
  class: attributes.class,
47595
47865
  rr_width: `${width}px`,
@@ -47597,7 +47867,7 @@ function serializeElementNode(n2, options) {
47597
47867
  };
47598
47868
  }
47599
47869
  if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
47600
- if (!n2.contentDocument) {
47870
+ if (!n.contentDocument) {
47601
47871
  attributes.rr_src = attributes.src;
47602
47872
  }
47603
47873
  delete attributes.src;
@@ -47605,14 +47875,14 @@ function serializeElementNode(n2, options) {
47605
47875
  let isCustomElement;
47606
47876
  try {
47607
47877
  if (customElements.get(tagName)) isCustomElement = true;
47608
- } catch (e2) {
47878
+ } catch (e) {
47609
47879
  }
47610
47880
  return {
47611
- type: NodeType$3.Element,
47881
+ type: NodeType.Element,
47612
47882
  tagName,
47613
47883
  attributes,
47614
47884
  childNodes: [],
47615
- isSVG: isSVGElement(n2) || void 0,
47885
+ isSVG: isSVGElement(n) || void 0,
47616
47886
  needBlock,
47617
47887
  rootId,
47618
47888
  isCustom: isCustomElement
@@ -47625,10 +47895,32 @@ function lowerIfExists(maybeAttr) {
47625
47895
  return maybeAttr.toLowerCase();
47626
47896
  }
47627
47897
  }
47898
+ function slimDOMDefaults(_slimDOMOptions) {
47899
+ if (_slimDOMOptions === true || _slimDOMOptions === "all") {
47900
+ return {
47901
+ script: true,
47902
+ comment: true,
47903
+ headFavicon: true,
47904
+ headWhitespace: true,
47905
+ headMetaSocial: true,
47906
+ headMetaRobots: true,
47907
+ headMetaHttpEquiv: true,
47908
+ headMetaVerification: true,
47909
+ // the following are off for slimDOMOptions === true,
47910
+ // as they destroy some (hidden) info:
47911
+ headMetaAuthorship: _slimDOMOptions === "all",
47912
+ headMetaDescKeywords: _slimDOMOptions === "all",
47913
+ headTitleMutations: _slimDOMOptions === "all"
47914
+ };
47915
+ } else if (_slimDOMOptions) {
47916
+ return _slimDOMOptions;
47917
+ }
47918
+ return {};
47919
+ }
47628
47920
  function slimDOMExcluded(sn, slimDOMOptions) {
47629
- if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
47921
+ if (slimDOMOptions.comment && sn.type === NodeType.Comment) {
47630
47922
  return true;
47631
- } else if (sn.type === NodeType$3.Element) {
47923
+ } else if (sn.type === NodeType.Element) {
47632
47924
  if (slimDOMOptions.script && // script tag
47633
47925
  (sn.tagName === "script" || // (module)preload link
47634
47926
  sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
@@ -47657,7 +47949,7 @@ function slimDOMExcluded(sn, slimDOMOptions) {
47657
47949
  }
47658
47950
  return false;
47659
47951
  }
47660
- function serializeNodeWithId(n2, options) {
47952
+ function serializeNodeWithId(n, options) {
47661
47953
  const {
47662
47954
  doc,
47663
47955
  mirror: mirror2,
@@ -47689,13 +47981,13 @@ function serializeNodeWithId(n2, options) {
47689
47981
  if (!needsMask) {
47690
47982
  const checkAncestors = needsMask === void 0;
47691
47983
  needsMask = needMaskingText(
47692
- n2,
47984
+ n,
47693
47985
  maskTextClass,
47694
47986
  maskTextSelector,
47695
47987
  checkAncestors
47696
47988
  );
47697
47989
  }
47698
- const _serializedNode = serializeNode(n2, {
47990
+ const _serializedNode = serializeNode(n, {
47699
47991
  doc,
47700
47992
  mirror: mirror2,
47701
47993
  blockClass,
@@ -47714,35 +48006,35 @@ function serializeNodeWithId(n2, options) {
47714
48006
  cssCaptured
47715
48007
  });
47716
48008
  if (!_serializedNode) {
47717
- console.warn(n2, "not serialized");
48009
+ console.warn(n, "not serialized");
47718
48010
  return null;
47719
48011
  }
47720
48012
  let id;
47721
- if (mirror2.hasNode(n2)) {
47722
- id = mirror2.getId(n2);
47723
- } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
48013
+ if (mirror2.hasNode(n)) {
48014
+ id = mirror2.getId(n);
48015
+ } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
47724
48016
  id = IGNORED_NODE;
47725
48017
  } else {
47726
48018
  id = genId();
47727
48019
  }
47728
48020
  const serializedNode = Object.assign(_serializedNode, { id });
47729
- mirror2.add(n2, serializedNode);
48021
+ mirror2.add(n, serializedNode);
47730
48022
  if (id === IGNORED_NODE) {
47731
48023
  return null;
47732
48024
  }
47733
48025
  if (onSerialize) {
47734
- onSerialize(n2);
48026
+ onSerialize(n);
47735
48027
  }
47736
48028
  let recordChild = !skipChild;
47737
- if (serializedNode.type === NodeType$3.Element) {
48029
+ if (serializedNode.type === NodeType.Element) {
47738
48030
  recordChild = recordChild && !serializedNode.needBlock;
47739
48031
  delete serializedNode.needBlock;
47740
- const shadowRootEl = index$1.shadowRoot(n2);
48032
+ const shadowRootEl = index.shadowRoot(n);
47741
48033
  if (shadowRootEl && isNativeShadowDom(shadowRootEl))
47742
48034
  serializedNode.isShadowHost = true;
47743
48035
  }
47744
- if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
47745
- if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
48036
+ if ((serializedNode.type === NodeType.Document || serializedNode.type === NodeType.Element) && recordChild) {
48037
+ if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType.Element && serializedNode.tagName === "head") {
47746
48038
  preserveWhiteSpace = false;
47747
48039
  }
47748
48040
  const bypassOptions = {
@@ -47772,12 +48064,12 @@ function serializeNodeWithId(n2, options) {
47772
48064
  keepIframeSrcFn,
47773
48065
  cssCaptured: false
47774
48066
  };
47775
- if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
48067
+ if (serializedNode.type === NodeType.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
47776
48068
  else {
47777
- if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
48069
+ if (serializedNode.type === NodeType.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
47778
48070
  bypassOptions.cssCaptured = true;
47779
48071
  }
47780
- for (const childN of Array.from(index$1.childNodes(n2))) {
48072
+ for (const childN of Array.from(index.childNodes(n))) {
47781
48073
  const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
47782
48074
  if (serializedChildNode) {
47783
48075
  serializedNode.childNodes.push(serializedChildNode);
@@ -47785,8 +48077,8 @@ function serializeNodeWithId(n2, options) {
47785
48077
  }
47786
48078
  }
47787
48079
  let shadowRootEl = null;
47788
- if (isElement(n2) && (shadowRootEl = index$1.shadowRoot(n2))) {
47789
- for (const childN of Array.from(index$1.childNodes(shadowRootEl))) {
48080
+ if (isElement(n) && (shadowRootEl = index.shadowRoot(n))) {
48081
+ for (const childN of Array.from(index.childNodes(shadowRootEl))) {
47790
48082
  const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
47791
48083
  if (serializedChildNode) {
47792
48084
  isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
@@ -47795,15 +48087,15 @@ function serializeNodeWithId(n2, options) {
47795
48087
  }
47796
48088
  }
47797
48089
  }
47798
- const parent = index$1.parentNode(n2);
48090
+ const parent = index.parentNode(n);
47799
48091
  if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
47800
48092
  serializedNode.isShadow = true;
47801
48093
  }
47802
- if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
48094
+ if (serializedNode.type === NodeType.Element && serializedNode.tagName === "iframe") {
47803
48095
  onceIframeLoaded(
47804
- n2,
48096
+ n,
47805
48097
  () => {
47806
- const iframeDoc = n2.contentDocument;
48098
+ const iframeDoc = n.contentDocument;
47807
48099
  if (iframeDoc && onIframeLoad) {
47808
48100
  const serializedIframeNode = serializeNodeWithId(iframeDoc, {
47809
48101
  doc: iframeDoc,
@@ -47833,7 +48125,7 @@ function serializeNodeWithId(n2, options) {
47833
48125
  });
47834
48126
  if (serializedIframeNode) {
47835
48127
  onIframeLoad(
47836
- n2,
48128
+ n,
47837
48129
  serializedIframeNode
47838
48130
  );
47839
48131
  }
@@ -47842,12 +48134,12 @@ function serializeNodeWithId(n2, options) {
47842
48134
  iframeLoadTimeout
47843
48135
  );
47844
48136
  }
47845
- if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
48137
+ if (serializedNode.type === NodeType.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
47846
48138
  onceStylesheetLoaded(
47847
- n2,
48139
+ n,
47848
48140
  () => {
47849
48141
  if (onStylesheetLoad) {
47850
- const serializedLinkNode = serializeNodeWithId(n2, {
48142
+ const serializedLinkNode = serializeNodeWithId(n, {
47851
48143
  doc,
47852
48144
  mirror: mirror2,
47853
48145
  blockClass,
@@ -47875,7 +48167,7 @@ function serializeNodeWithId(n2, options) {
47875
48167
  });
47876
48168
  if (serializedLinkNode) {
47877
48169
  onStylesheetLoad(
47878
- n2,
48170
+ n,
47879
48171
  serializedLinkNode
47880
48172
  );
47881
48173
  }
@@ -47886,7 +48178,7 @@ function serializeNodeWithId(n2, options) {
47886
48178
  }
47887
48179
  return serializedNode;
47888
48180
  }
47889
- function snapshot(n2, options) {
48181
+ function snapshot(n, options) {
47890
48182
  const {
47891
48183
  mirror: mirror2 = new Mirror(),
47892
48184
  blockClass = "rr-block",
@@ -47909,7 +48201,7 @@ function snapshot(n2, options) {
47909
48201
  onStylesheetLoad,
47910
48202
  stylesheetLoadTimeout,
47911
48203
  keepIframeSrcFn = () => false
47912
- } = options || {};
48204
+ } = options;
47913
48205
  const maskInputOptions = maskAllInputs === true ? {
47914
48206
  color: true,
47915
48207
  date: true,
@@ -47930,24 +48222,9 @@ function snapshot(n2, options) {
47930
48222
  } : maskAllInputs === false ? {
47931
48223
  password: true
47932
48224
  } : maskAllInputs;
47933
- const slimDOMOptions = slimDOM === true || slimDOM === "all" ? (
47934
- // if true: set of sensible options that should not throw away any information
47935
- {
47936
- script: true,
47937
- comment: true,
47938
- headFavicon: true,
47939
- headWhitespace: true,
47940
- headMetaDescKeywords: slimDOM === "all",
47941
- // destructive
47942
- headMetaSocial: true,
47943
- headMetaRobots: true,
47944
- headMetaHttpEquiv: true,
47945
- headMetaAuthorship: true,
47946
- headMetaVerification: true
47947
- }
47948
- ) : slimDOM === false ? {} : slimDOM;
47949
- return serializeNodeWithId(n2, {
47950
- doc: n2,
48225
+ const slimDOMOptions = slimDOMDefaults(slimDOM);
48226
+ return serializeNodeWithId(n, {
48227
+ doc: n,
47951
48228
  mirror: mirror2,
47952
48229
  blockClass,
47953
48230
  blockSelector,
@@ -47973,37 +48250,22 @@ function snapshot(n2, options) {
47973
48250
  newlyAddedElement: false
47974
48251
  });
47975
48252
  }
47976
- var __defProp2 = Object.defineProperty;
47977
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
47978
- var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
47979
- function getNative(symbolName, windowObj = window) {
47980
- var _a2, _b;
47981
- const windowWithZone = windowObj;
47982
- const angularZoneSymbol = (_b = (_a2 = windowWithZone == null ? void 0 : windowWithZone.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b.call(_a2, symbolName);
47983
- if (angularZoneSymbol) {
47984
- const zonelessImpl = windowWithZone[angularZoneSymbol];
47985
- if (zonelessImpl) {
47986
- return zonelessImpl;
47987
- }
47988
- }
47989
- return windowWithZone[symbolName];
47990
- }
47991
- typeof window !== "undefined" ? getNative("setTimeout").bind(window) : global.setTimeout;
47992
48253
  class BaseRRNode {
47993
48254
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
47994
48255
  constructor(..._args) {
47995
- __publicField2(this, "parentElement", null);
47996
- __publicField2(this, "parentNode", null);
47997
- __publicField2(this, "ownerDocument");
47998
- __publicField2(this, "firstChild", null);
47999
- __publicField2(this, "lastChild", null);
48000
- __publicField2(this, "previousSibling", null);
48001
- __publicField2(this, "nextSibling", null);
48002
- __publicField2(this, "ELEMENT_NODE", 1);
48003
- __publicField2(this, "TEXT_NODE", 3);
48004
- __publicField2(this, "nodeType");
48005
- __publicField2(this, "nodeName");
48006
- __publicField2(this, "RRNodeType");
48256
+ __publicField(this, "parentElement", null);
48257
+ __publicField(this, "parentNode", null);
48258
+ __publicField(this, "ownerDocument");
48259
+ __publicField(this, "firstChild", null);
48260
+ __publicField(this, "lastChild", null);
48261
+ __publicField(this, "previousSibling", null);
48262
+ __publicField(this, "nextSibling", null);
48263
+ __publicField(this, "ELEMENT_NODE", 1);
48264
+ __publicField(this, "TEXT_NODE", 3);
48265
+ // corresponding nodeType value of standard HTML Node
48266
+ __publicField(this, "nodeType");
48267
+ __publicField(this, "nodeName");
48268
+ __publicField(this, "RRNodeType");
48007
48269
  }
48008
48270
  get childNodes() {
48009
48271
  const childNodes2 = [];
@@ -48046,226 +48308,6 @@ class BaseRRNode {
48046
48308
  return "RRNode";
48047
48309
  }
48048
48310
  }
48049
- const testableAccessors = {
48050
- Node: ["childNodes", "parentNode", "parentElement", "textContent"],
48051
- ShadowRoot: ["host", "styleSheets"],
48052
- Element: ["shadowRoot"],
48053
- MutationObserver: [],
48054
- EventTarget: []
48055
- };
48056
- const testableMethods = {
48057
- Node: ["contains", "getRootNode"],
48058
- ShadowRoot: ["getSelection"],
48059
- Element: ["querySelector", "querySelectorAll"],
48060
- MutationObserver: ["constructor"],
48061
- EventTarget: ["addEventListener", "removeEventListener"]
48062
- };
48063
- const untaintedBasePrototype = {};
48064
- function angularZoneUnpatchedAlternative(key) {
48065
- var _a2, _b;
48066
- const angularUnpatchedVersionSymbol = (_b = (_a2 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b.call(_a2, key);
48067
- if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
48068
- return globalThis[angularUnpatchedVersionSymbol];
48069
- } else {
48070
- return void 0;
48071
- }
48072
- }
48073
- function getUntaintedPrototype(key) {
48074
- if (untaintedBasePrototype[key])
48075
- return untaintedBasePrototype[key];
48076
- const candidate = angularZoneUnpatchedAlternative(key) || globalThis[key];
48077
- const defaultPrototype = candidate.prototype;
48078
- const accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
48079
- const isUntaintedAccessors = Boolean(
48080
- accessorNames && // @ts-expect-error 2345
48081
- accessorNames.every(
48082
- (accessor) => {
48083
- var _a2, _b;
48084
- return Boolean(
48085
- (_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]")
48086
- );
48087
- }
48088
- )
48089
- );
48090
- const methodNames = key in testableMethods ? testableMethods[key] : void 0;
48091
- const isUntaintedMethods = Boolean(
48092
- methodNames && methodNames.every(
48093
- // @ts-expect-error 2345
48094
- (method) => {
48095
- var _a2;
48096
- return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
48097
- }
48098
- )
48099
- );
48100
- if (isUntaintedAccessors && isUntaintedMethods) {
48101
- untaintedBasePrototype[key] = candidate.prototype;
48102
- return candidate.prototype;
48103
- }
48104
- try {
48105
- const iframeEl = document.createElement("iframe");
48106
- document.body.appendChild(iframeEl);
48107
- const win = iframeEl.contentWindow;
48108
- if (!win) return candidate.prototype;
48109
- const untaintedObject = win[key].prototype;
48110
- document.body.removeChild(iframeEl);
48111
- if (!untaintedObject) return defaultPrototype;
48112
- return untaintedBasePrototype[key] = untaintedObject;
48113
- } catch {
48114
- return defaultPrototype;
48115
- }
48116
- }
48117
- const untaintedAccessorCache = {};
48118
- function getUntaintedAccessor(key, instance, accessor) {
48119
- var _a2;
48120
- const cacheKey = `${key}.${String(accessor)}`;
48121
- if (untaintedAccessorCache[cacheKey])
48122
- return untaintedAccessorCache[cacheKey].call(
48123
- instance
48124
- );
48125
- const untaintedPrototype = getUntaintedPrototype(key);
48126
- const untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(
48127
- untaintedPrototype,
48128
- accessor
48129
- )) == null ? void 0 : _a2.get;
48130
- if (!untaintedAccessor) return instance[accessor];
48131
- untaintedAccessorCache[cacheKey] = untaintedAccessor;
48132
- return untaintedAccessor.call(instance);
48133
- }
48134
- const untaintedMethodCache = {};
48135
- function getUntaintedMethod(key, instance, method) {
48136
- var _a2, _b, _c;
48137
- const cacheKey = `${key}.${String(method)}`;
48138
- if (untaintedMethodCache[cacheKey])
48139
- return untaintedMethodCache[cacheKey].bind(
48140
- instance
48141
- );
48142
- const zoneSymbol = (_b = (_a2 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b.call(
48143
- _a2,
48144
- String(method)
48145
- );
48146
- if (zoneSymbol) {
48147
- const classProto = (_c = globalThis[key]) == null ? void 0 : _c.prototype;
48148
- const nativeFromZone = globalThis[zoneSymbol] ?? (classProto == null ? void 0 : classProto[zoneSymbol]);
48149
- if (typeof nativeFromZone === "function") {
48150
- untaintedMethodCache[cacheKey] = nativeFromZone;
48151
- return nativeFromZone.bind(
48152
- instance
48153
- );
48154
- }
48155
- }
48156
- const untaintedPrototype = getUntaintedPrototype(key);
48157
- const untaintedMethod = untaintedPrototype[method];
48158
- if (typeof untaintedMethod !== "function") return instance[method];
48159
- untaintedMethodCache[cacheKey] = untaintedMethod;
48160
- return untaintedMethod.bind(instance);
48161
- }
48162
- function childNodes(n2) {
48163
- return getUntaintedAccessor("Node", n2, "childNodes");
48164
- }
48165
- function parentNode(n2) {
48166
- return getUntaintedAccessor("Node", n2, "parentNode");
48167
- }
48168
- function parentElement(n2) {
48169
- return getUntaintedAccessor("Node", n2, "parentElement");
48170
- }
48171
- function textContent(n2) {
48172
- return getUntaintedAccessor("Node", n2, "textContent");
48173
- }
48174
- function contains(n2, other) {
48175
- return getUntaintedMethod("Node", n2, "contains")(other);
48176
- }
48177
- function getRootNode(n2) {
48178
- return getUntaintedMethod("Node", n2, "getRootNode")();
48179
- }
48180
- function host(n2) {
48181
- if (!n2 || !("host" in n2)) return null;
48182
- return getUntaintedAccessor("ShadowRoot", n2, "host");
48183
- }
48184
- function styleSheets(n2) {
48185
- return n2.styleSheets;
48186
- }
48187
- function shadowRoot(n2) {
48188
- if (!n2 || !("shadowRoot" in n2)) return null;
48189
- return getUntaintedAccessor("Element", n2, "shadowRoot");
48190
- }
48191
- function querySelector(n2, selectors) {
48192
- return getUntaintedMethod("Element", n2, "querySelector")(selectors);
48193
- }
48194
- function querySelectorAll(n2, selectors) {
48195
- return getUntaintedMethod("Element", n2, "querySelectorAll")(selectors);
48196
- }
48197
- function addEventListener(n2, type, listener, options) {
48198
- getUntaintedMethod("EventTarget", n2, "addEventListener")(type, listener, options);
48199
- }
48200
- function removeEventListener(n2, type, listener, options) {
48201
- getUntaintedMethod("EventTarget", n2, "removeEventListener")(
48202
- type,
48203
- listener,
48204
- options
48205
- );
48206
- }
48207
- function mutationObserverCtor() {
48208
- return getUntaintedPrototype("MutationObserver").constructor;
48209
- }
48210
- function getUntaintedProxy() {
48211
- var _a2, _b;
48212
- let Proxy3 = window.Proxy;
48213
- try {
48214
- if (typeof window.Proxy !== "function" || !((_a2 = window.Proxy) == null ? void 0 : _a2.toString().includes("[native code]"))) {
48215
- const cleanFrame = document.createElement("iframe");
48216
- cleanFrame.style.display = "none";
48217
- document.documentElement.appendChild(cleanFrame);
48218
- Proxy3 = ((_b = cleanFrame.contentWindow) == null ? void 0 : _b.Proxy) || window.Proxy;
48219
- document.documentElement.removeChild(cleanFrame);
48220
- }
48221
- } catch (err) {
48222
- console.debug("Unable to get untainted Proxy from iframe", err);
48223
- }
48224
- return Proxy3;
48225
- }
48226
- function patch(source, name, replacement) {
48227
- try {
48228
- if (!(name in source)) {
48229
- return () => {
48230
- };
48231
- }
48232
- const original = source[name];
48233
- const wrapped = replacement(original);
48234
- if (typeof wrapped === "function") {
48235
- wrapped.prototype = wrapped.prototype || {};
48236
- Object.defineProperties(wrapped, {
48237
- __rrweb_original__: {
48238
- enumerable: false,
48239
- value: original
48240
- }
48241
- });
48242
- }
48243
- source[name] = wrapped;
48244
- return () => {
48245
- source[name] = original;
48246
- };
48247
- } catch {
48248
- return () => {
48249
- };
48250
- }
48251
- }
48252
- const index = {
48253
- childNodes,
48254
- parentNode,
48255
- parentElement,
48256
- textContent,
48257
- contains,
48258
- getRootNode,
48259
- host,
48260
- styleSheets,
48261
- shadowRoot,
48262
- querySelector,
48263
- querySelectorAll,
48264
- addEventListener,
48265
- removeEventListener,
48266
- mutationObserver: mutationObserverCtor,
48267
- patch
48268
- };
48269
48311
  function on(type, fn, target = document) {
48270
48312
  const options = { capture: true, passive: true };
48271
48313
  index.addEventListener(target, type, fn, options);
@@ -48348,10 +48390,6 @@ function hookSetter(target, key, d, isRevoked, win = window) {
48348
48390
  );
48349
48391
  return () => hookSetter(target, key, original || {}, true);
48350
48392
  }
48351
- let nowTimestamp = Date.now;
48352
- if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
48353
- nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
48354
- }
48355
48393
  function getWindowScroll(win) {
48356
48394
  var _a2, _b, _c, _d;
48357
48395
  const doc = win.document;
@@ -48388,7 +48426,7 @@ function isBlocked(node, blockClass, blockSelector, checkAncestors) {
48388
48426
  } else {
48389
48427
  if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
48390
48428
  }
48391
- } catch (e2) {
48429
+ } catch (e) {
48392
48430
  }
48393
48431
  if (blockSelector) {
48394
48432
  if (el.matches(blockSelector)) return true;
@@ -48396,14 +48434,14 @@ function isBlocked(node, blockClass, blockSelector, checkAncestors) {
48396
48434
  }
48397
48435
  return false;
48398
48436
  }
48399
- function isSerialized(n2, mirror2) {
48400
- return mirror2.getId(n2) !== -1;
48437
+ function isSerialized(n, mirror2) {
48438
+ return mirror2.getId(n) !== -1;
48401
48439
  }
48402
- function isIgnored(n2, mirror2, slimDOMOptions) {
48403
- if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
48440
+ function isIgnored(n, mirror2, slimDOMOptions) {
48441
+ if (n.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
48404
48442
  return true;
48405
48443
  }
48406
- return mirror2.getId(n2) === IGNORED_NODE;
48444
+ return mirror2.getId(n) === IGNORED_NODE;
48407
48445
  }
48408
48446
  function isAncestorRemoved(target, mirror2) {
48409
48447
  if (isShadowRoot(target)) {
@@ -48425,7 +48463,7 @@ function isAncestorRemoved(target, mirror2) {
48425
48463
  function legacy_isTouchEvent(event) {
48426
48464
  return Boolean(event.changedTouches);
48427
48465
  }
48428
- function polyfill$1(win = window) {
48466
+ function polyfill(win = window) {
48429
48467
  if ("NodeList" in win && !win.NodeList.prototype.forEach) {
48430
48468
  win.NodeList.prototype.forEach = Array.prototype.forEach;
48431
48469
  }
@@ -48433,20 +48471,20 @@ function polyfill$1(win = window) {
48433
48471
  win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
48434
48472
  }
48435
48473
  }
48436
- function isSerializedIframe(n2, mirror2) {
48437
- return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
48474
+ function isSerializedIframe(n, mirror2) {
48475
+ return Boolean(n.nodeName === "IFRAME" && mirror2.getMeta(n));
48438
48476
  }
48439
- function isSerializedStylesheet(n2, mirror2) {
48477
+ function isSerializedStylesheet(n, mirror2) {
48440
48478
  return Boolean(
48441
- n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2)
48479
+ n.nodeName === "LINK" && n.nodeType === n.ELEMENT_NODE && n.getAttribute && n.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n)
48442
48480
  );
48443
48481
  }
48444
- function hasShadowRoot(n2) {
48445
- if (!n2) return false;
48446
- if (n2 instanceof BaseRRNode && "shadowRoot" in n2) {
48447
- return Boolean(n2.shadowRoot);
48482
+ function hasShadowRoot(n) {
48483
+ if (!n) return false;
48484
+ if (n instanceof BaseRRNode && "shadowRoot" in n) {
48485
+ return Boolean(n.shadowRoot);
48448
48486
  }
48449
- return Boolean(index.shadowRoot(n2));
48487
+ return Boolean(index.shadowRoot(n));
48450
48488
  }
48451
48489
  class StyleSheetMirror {
48452
48490
  constructor() {
@@ -48485,206 +48523,30 @@ class StyleSheetMirror {
48485
48523
  return this.id++;
48486
48524
  }
48487
48525
  }
48488
- function getShadowHost(n2) {
48526
+ function getShadowHost(n) {
48489
48527
  var _a2;
48490
48528
  let shadowHost = null;
48491
- if ("getRootNode" in n2 && ((_a2 = index.getRootNode(n2)) == null ? void 0 : _a2.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && index.host(index.getRootNode(n2)))
48492
- shadowHost = index.host(index.getRootNode(n2));
48529
+ if ("getRootNode" in n && ((_a2 = index.getRootNode(n)) == null ? void 0 : _a2.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && index.host(index.getRootNode(n)))
48530
+ shadowHost = index.host(index.getRootNode(n));
48493
48531
  return shadowHost;
48494
48532
  }
48495
- function getRootShadowHost(n2) {
48496
- let rootShadowHost = n2;
48533
+ function getRootShadowHost(n) {
48534
+ let rootShadowHost = n;
48497
48535
  let shadowHost;
48498
48536
  while (shadowHost = getShadowHost(rootShadowHost))
48499
48537
  rootShadowHost = shadowHost;
48500
48538
  return rootShadowHost;
48501
48539
  }
48502
- function shadowHostInDom(n2) {
48503
- const doc = n2.ownerDocument;
48540
+ function shadowHostInDom(n) {
48541
+ const doc = index.ownerDocument(n);
48504
48542
  if (!doc) return false;
48505
- const shadowHost = getRootShadowHost(n2);
48543
+ const shadowHost = getRootShadowHost(n);
48506
48544
  return index.contains(doc, shadowHost);
48507
48545
  }
48508
- function inDom(n2) {
48509
- const doc = n2.ownerDocument;
48546
+ function inDom(n) {
48547
+ const doc = index.ownerDocument(n);
48510
48548
  if (!doc) return false;
48511
- return index.contains(doc, n2) || shadowHostInDom(n2);
48512
- }
48513
- var EventType = /* @__PURE__ */ ((EventType2) => {
48514
- EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
48515
- EventType2[EventType2["Load"] = 1] = "Load";
48516
- EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
48517
- EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
48518
- EventType2[EventType2["Meta"] = 4] = "Meta";
48519
- EventType2[EventType2["Custom"] = 5] = "Custom";
48520
- EventType2[EventType2["Plugin"] = 6] = "Plugin";
48521
- return EventType2;
48522
- })(EventType || {});
48523
- var IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {
48524
- IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
48525
- IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
48526
- IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
48527
- IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
48528
- IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
48529
- IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
48530
- IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
48531
- IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
48532
- IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
48533
- IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
48534
- IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
48535
- IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
48536
- IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
48537
- IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
48538
- IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
48539
- IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
48540
- IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
48541
- return IncrementalSource2;
48542
- })(IncrementalSource || {});
48543
- var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
48544
- MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
48545
- MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
48546
- MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
48547
- MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
48548
- MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
48549
- MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
48550
- MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
48551
- MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
48552
- MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
48553
- MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
48554
- MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
48555
- return MouseInteractions2;
48556
- })(MouseInteractions || {});
48557
- var PointerTypes = /* @__PURE__ */ ((PointerTypes2) => {
48558
- PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
48559
- PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
48560
- PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
48561
- return PointerTypes2;
48562
- })(PointerTypes || {});
48563
- var CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {
48564
- CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
48565
- CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
48566
- CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
48567
- return CanvasContext2;
48568
- })(CanvasContext || {});
48569
- var MediaInteractions = /* @__PURE__ */ ((MediaInteractions2) => {
48570
- MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
48571
- MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
48572
- MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
48573
- MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
48574
- MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
48575
- return MediaInteractions2;
48576
- })(MediaInteractions || {});
48577
- var NodeType = /* @__PURE__ */ ((NodeType2) => {
48578
- NodeType2[NodeType2["Document"] = 0] = "Document";
48579
- NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
48580
- NodeType2[NodeType2["Element"] = 2] = "Element";
48581
- NodeType2[NodeType2["Text"] = 3] = "Text";
48582
- NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
48583
- NodeType2[NodeType2["Comment"] = 5] = "Comment";
48584
- return NodeType2;
48585
- })(NodeType || {});
48586
- function isNodeInLinkedList(n2) {
48587
- return "__ln" in n2;
48588
- }
48589
- class DoubleLinkedList {
48590
- constructor() {
48591
- __publicField(this, "length", 0);
48592
- __publicField(this, "head", null);
48593
- __publicField(this, "tail", null);
48594
- __publicField(this, "reordered", false);
48595
- }
48596
- get(position) {
48597
- if (position >= this.length) {
48598
- throw new Error("Position outside of list range");
48599
- }
48600
- let current = this.head;
48601
- for (let index2 = 0; index2 < position; index2++) {
48602
- current = (current == null ? void 0 : current.next) || null;
48603
- }
48604
- return current;
48605
- }
48606
- addNode(n2) {
48607
- const node = {
48608
- value: n2,
48609
- previous: null,
48610
- next: null
48611
- };
48612
- n2.__ln = node;
48613
- if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
48614
- const current = n2.previousSibling.__ln.next;
48615
- node.next = current;
48616
- node.previous = n2.previousSibling.__ln;
48617
- n2.previousSibling.__ln.next = node;
48618
- if (current) {
48619
- current.previous = node;
48620
- }
48621
- } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
48622
- const current = n2.nextSibling.__ln.previous;
48623
- node.previous = current;
48624
- node.next = n2.nextSibling.__ln;
48625
- n2.nextSibling.__ln.previous = node;
48626
- if (current) {
48627
- current.next = node;
48628
- }
48629
- } else {
48630
- if (this.head) {
48631
- this.head.previous = node;
48632
- }
48633
- node.next = this.head;
48634
- this.head = node;
48635
- }
48636
- if (node.next === null) {
48637
- this.tail = node;
48638
- }
48639
- this.length++;
48640
- }
48641
- removeNode(n2) {
48642
- const current = n2.__ln;
48643
- if (!this.head) {
48644
- return;
48645
- }
48646
- if (!current.previous) {
48647
- this.head = current.next;
48648
- if (this.head) {
48649
- this.head.previous = null;
48650
- } else {
48651
- this.tail = null;
48652
- }
48653
- } else {
48654
- current.previous.next = current.next;
48655
- if (current.next) {
48656
- current.next.previous = current.previous;
48657
- } else {
48658
- this.tail = current.previous;
48659
- }
48660
- }
48661
- if (n2.__ln) {
48662
- delete n2.__ln;
48663
- }
48664
- this.length--;
48665
- }
48666
- needsReorder(_node) {
48667
- if (!this.reordered && _node.value.previousSibling && isNodeInLinkedList(_node.value.previousSibling) && _node.previous && _node.previous.value !== _node.value.previousSibling) {
48668
- return true;
48669
- }
48670
- return false;
48671
- }
48672
- reorder() {
48673
- if (this.reordered) return false;
48674
- let current = this.tail;
48675
- const head = this.head;
48676
- while (current) {
48677
- const prev = current.previous;
48678
- this.removeNode(current.value);
48679
- this.addNode(current.value);
48680
- if (current === head) {
48681
- break;
48682
- }
48683
- current = prev;
48684
- }
48685
- this.reordered = true;
48686
- return true;
48687
- }
48549
+ return index.contains(doc, n) || shadowHostInDom(n);
48688
48550
  }
48689
48551
  const moveKey = (id, parentId) => `${id}@${parentId}`;
48690
48552
  class MutationBuffer {
@@ -48697,6 +48559,23 @@ class MutationBuffer {
48697
48559
  __publicField(this, "removes", []);
48698
48560
  __publicField(this, "mapRemoves", []);
48699
48561
  __publicField(this, "movedMap", {});
48562
+ /**
48563
+ * the browser MutationObserver emits multiple mutations after
48564
+ * a delay for performance reasons, making tracing added nodes hard
48565
+ * in our `processMutations` callback function.
48566
+ * For example, if we append an element el_1 into body, and then append
48567
+ * another element el_2 into el_1, these two mutations may be passed to the
48568
+ * callback function together when the two operations were done.
48569
+ * Generally we need to trace child nodes of newly added nodes, but in this
48570
+ * case if we count el_2 as el_1's child node in the first mutation record,
48571
+ * then we will count el_2 again in the second mutation record which was
48572
+ * duplicated.
48573
+ * To avoid of duplicate counting added nodes, we use a Set to store
48574
+ * added nodes and its child nodes during iterate mutation records. Then
48575
+ * collect added nodes from the Set which have no duplicate copy. But
48576
+ * this also causes newly added nodes will not be serialized with id ASAP,
48577
+ * which means all the id related calculation should be lazy too.
48578
+ */
48700
48579
  __publicField(this, "addedSet", /* @__PURE__ */ new Set());
48701
48580
  __publicField(this, "movedSet", /* @__PURE__ */ new Set());
48702
48581
  __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
@@ -48734,36 +48613,103 @@ class MutationBuffer {
48734
48613
  }
48735
48614
  const adds = [];
48736
48615
  const addedIds = /* @__PURE__ */ new Set();
48737
- const addList = new DoubleLinkedList();
48738
- const getNextId = (n2) => {
48739
- let ns = n2;
48740
- let nextId = IGNORED_NODE;
48741
- while (nextId === IGNORED_NODE) {
48742
- ns = ns && ns.nextSibling;
48743
- nextId = ns && this.mirror.getId(ns);
48616
+ while (this.mapRemoves.length) {
48617
+ this.mirror.removeNodeFromMap(this.mapRemoves.shift());
48618
+ }
48619
+ for (const n2 of this.movedSet) {
48620
+ const parentNode22 = index.parentNode(n2);
48621
+ if (this.removesSubTreeCache.has(parentNode22) && !this.movedSet.has(parentNode22)) {
48622
+ continue;
48744
48623
  }
48745
- return nextId;
48746
- };
48747
- const pushAdd = (n2) => {
48748
- const parent = index.parentNode(n2);
48749
- if (!parent || !inDom(n2)) {
48750
- return;
48624
+ this.addedSet.add(n2);
48625
+ }
48626
+ let n = null;
48627
+ let parentNode2 = null;
48628
+ let parentId = -1;
48629
+ let nextSibling2 = null;
48630
+ let ancestorBad = false;
48631
+ const missingParents = /* @__PURE__ */ new Set();
48632
+ const iter = this.addedSet.values();
48633
+ let curr = iter.next();
48634
+ while (this.addedSet.size) {
48635
+ if (n !== null && this.addedSet.has(index.previousSibling(n))) {
48636
+ nextSibling2 = n;
48637
+ n = index.previousSibling(n);
48638
+ } else {
48639
+ if (!this.addedSet.has(curr.value)) {
48640
+ curr = iter.next();
48641
+ }
48642
+ n = curr.value;
48643
+ while (true) {
48644
+ parentNode2 = index.parentNode(n);
48645
+ if (this.addedSet.has(parentNode2)) {
48646
+ n = parentNode2;
48647
+ continue;
48648
+ }
48649
+ break;
48650
+ }
48651
+ if (missingParents.has(parentNode2)) {
48652
+ parentNode2 = null;
48653
+ } else if (parentNode2) {
48654
+ if (!inDom(parentNode2)) {
48655
+ ancestorBad = true;
48656
+ } else {
48657
+ ancestorBad = isSelfOrAncestorInSet(this.droppedSet, parentNode2) || this.removesSubTreeCache.has(parentNode2);
48658
+ if (ancestorBad && isSelfOrAncestorInSet(this.movedSet, n)) {
48659
+ ancestorBad = false;
48660
+ }
48661
+ }
48662
+ if (this.addedSet.has(index.lastChild(parentNode2))) {
48663
+ n = index.lastChild(parentNode2);
48664
+ nextSibling2 = null;
48665
+ } else {
48666
+ while (true) {
48667
+ nextSibling2 = index.nextSibling(n);
48668
+ if (this.addedSet.has(nextSibling2)) {
48669
+ n = nextSibling2;
48670
+ continue;
48671
+ }
48672
+ break;
48673
+ }
48674
+ }
48675
+ parentId = isShadowRoot(parentNode2) ? this.mirror.getId(getShadowHost(n)) : this.mirror.getId(parentNode2);
48676
+ if (parentId === -1 && parentNode2.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
48677
+ const shadowHost = index.host(parentNode2);
48678
+ parentId = this.mirror.getId(shadowHost);
48679
+ }
48680
+ }
48681
+ }
48682
+ this.addedSet.delete(n);
48683
+ if (!parentNode2 || parentId === -1) {
48684
+ missingParents.add(n);
48685
+ continue;
48686
+ } else if (ancestorBad) {
48687
+ this.droppedSet.add(n);
48688
+ continue;
48751
48689
  }
48752
48690
  let cssCaptured = false;
48753
- if (n2.nodeType === Node.TEXT_NODE) {
48754
- const parentTag = parent.tagName;
48691
+ if (n.nodeType === Node.TEXT_NODE) {
48692
+ const parentTag = parentNode2.tagName;
48755
48693
  if (parentTag === "TEXTAREA") {
48756
- return;
48757
- } else if (parentTag === "STYLE" && this.addedSet.has(parent)) {
48694
+ continue;
48695
+ } else if (parentTag === "STYLE" && addedIds.has(parentId)) {
48758
48696
  cssCaptured = true;
48759
48697
  }
48760
48698
  }
48761
- const parentId = isShadowRoot(parent) ? this.mirror.getId(getShadowHost(n2)) : this.mirror.getId(parent);
48762
- const nextId = getNextId(n2);
48763
- if (parentId === -1 || nextId === -1) {
48764
- return addList.addNode(n2);
48699
+ let nextId = nextSibling2 ? this.mirror.getId(nextSibling2) : null;
48700
+ while (nextId === IGNORED_NODE) {
48701
+ nextSibling2 = nextSibling2 && index.nextSibling(nextSibling2);
48702
+ nextId = nextSibling2 && this.mirror.getId(nextSibling2);
48765
48703
  }
48766
- const sn = serializeNodeWithId(n2, {
48704
+ if (nextId === -1) {
48705
+ console.warn(
48706
+ "Couldn't record new node. Couldn't find mirror id for nextSibling:",
48707
+ nextSibling2
48708
+ );
48709
+ n = null;
48710
+ continue;
48711
+ }
48712
+ const sn = serializeNodeWithId(n, {
48767
48713
  doc: this.doc,
48768
48714
  mirror: this.mirror,
48769
48715
  blockClass: this.blockClass,
@@ -48790,8 +48736,11 @@ class MutationBuffer {
48790
48736
  currentN
48791
48737
  );
48792
48738
  }
48793
- if (hasShadowRoot(n2)) {
48794
- this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), this.doc);
48739
+ if (hasShadowRoot(n)) {
48740
+ this.shadowDomManager.addShadowRoot(
48741
+ index.shadowRoot(n),
48742
+ this.doc
48743
+ );
48795
48744
  }
48796
48745
  },
48797
48746
  onIframeLoad: (iframe, childSn) => {
@@ -48811,76 +48760,6 @@ class MutationBuffer {
48811
48760
  });
48812
48761
  addedIds.add(sn.id);
48813
48762
  }
48814
- };
48815
- while (this.mapRemoves.length) {
48816
- this.mirror.removeNodeFromMap(this.mapRemoves.shift());
48817
- }
48818
- for (const n2 of this.movedSet) {
48819
- const parentNode2 = index.parentNode(n2);
48820
- if (isParentRemoved(this.removesSubTreeCache, n2, this.mirror) && !this.movedSet.has(parentNode2) && !this.addedSet.has(parentNode2)) {
48821
- continue;
48822
- }
48823
- pushAdd(n2);
48824
- }
48825
- for (const n2 of this.addedSet) {
48826
- if (!isAncestorInSet(this.droppedSet, n2) && !isParentRemoved(this.removesSubTreeCache, n2, this.mirror)) {
48827
- pushAdd(n2);
48828
- } else if (isAncestorInSet(this.movedSet, n2)) {
48829
- pushAdd(n2);
48830
- } else {
48831
- this.droppedSet.add(n2);
48832
- }
48833
- }
48834
- let candidate = null;
48835
- while (addList.length) {
48836
- let node = null;
48837
- if (candidate) {
48838
- const parentId = this.mirror.getId(index.parentNode(candidate.value));
48839
- const nextId = getNextId(candidate.value);
48840
- if (parentId !== -1 && nextId !== -1) {
48841
- node = candidate;
48842
- }
48843
- }
48844
- if (!node) {
48845
- let tailNode = addList.tail;
48846
- while (tailNode) {
48847
- const _node = tailNode;
48848
- tailNode = tailNode.previous;
48849
- if (_node) {
48850
- const parentId = this.mirror.getId(index.parentNode(_node.value));
48851
- const nextId = getNextId(_node.value);
48852
- if (nextId === -1) {
48853
- if (addList.needsReorder(_node) && addList.reorder()) {
48854
- tailNode = addList.tail;
48855
- }
48856
- continue;
48857
- } else if (parentId !== -1) {
48858
- node = _node;
48859
- break;
48860
- } else {
48861
- const unhandledNode = _node.value;
48862
- const parent = index.parentNode(unhandledNode);
48863
- if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
48864
- const shadowHost = index.host(parent);
48865
- const parentId2 = this.mirror.getId(shadowHost);
48866
- if (parentId2 !== -1) {
48867
- node = _node;
48868
- break;
48869
- }
48870
- }
48871
- }
48872
- }
48873
- }
48874
- }
48875
- if (!node) {
48876
- while (addList.head) {
48877
- addList.removeNode(addList.head.value);
48878
- }
48879
- break;
48880
- }
48881
- candidate = node.previous;
48882
- addList.removeNode(node.value);
48883
- pushAdd(node.value);
48884
48763
  }
48885
48764
  const payload = {
48886
48765
  texts: this.texts.map((text) => {
@@ -48985,6 +48864,7 @@ class MutationBuffer {
48985
48864
  }
48986
48865
  case "attributes": {
48987
48866
  const target = m.target;
48867
+ const tagNameLower = toLowerCase(target.tagName);
48988
48868
  let attributeName = m.attributeName;
48989
48869
  let value = m.target.getAttribute(attributeName);
48990
48870
  if (attributeName === "value") {
@@ -49009,7 +48889,7 @@ class MutationBuffer {
49009
48889
  return;
49010
48890
  }
49011
48891
  let item = this.attributeMap.get(m.target);
49012
- if (target.tagName === "IFRAME" && attributeName === "src" && !this.keepIframeSrcFn(value)) {
48892
+ if (tagNameLower === "iframe" && attributeName === "src" && !this.keepIframeSrcFn(value)) {
49013
48893
  if (!target.contentDocument) {
49014
48894
  attributeName = "rr_src";
49015
48895
  } else {
@@ -49026,13 +48906,13 @@ class MutationBuffer {
49026
48906
  this.attributes.push(item);
49027
48907
  this.attributeMap.set(m.target, item);
49028
48908
  }
49029
- if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
48909
+ if (attributeName === "type" && tagNameLower === "input" && (m.oldValue || "").toLowerCase() === "password") {
49030
48910
  target.setAttribute("data-rr-is-password", "true");
49031
48911
  }
49032
- if (!ignoreAttribute(target.tagName, attributeName)) {
48912
+ if (!ignoreAttribute(tagNameLower, attributeName)) {
49033
48913
  item.attributes[attributeName] = transformAttribute(
49034
48914
  this.doc,
49035
- toLowerCase(target.tagName),
48915
+ tagNameLower,
49036
48916
  toLowerCase(attributeName),
49037
48917
  value
49038
48918
  );
@@ -49040,7 +48920,7 @@ class MutationBuffer {
49040
48920
  if (!this.unattachedDoc) {
49041
48921
  try {
49042
48922
  this.unattachedDoc = document.implementation.createHTMLDocument();
49043
- } catch (e2) {
48923
+ } catch (e) {
49044
48924
  this.unattachedDoc = this.doc;
49045
48925
  }
49046
48926
  }
@@ -49083,59 +48963,62 @@ class MutationBuffer {
49083
48963
  this.genTextAreaValueMutation(m.target);
49084
48964
  return;
49085
48965
  }
49086
- m.addedNodes.forEach((n2) => this.genAdds(n2, m.target));
49087
- m.removedNodes.forEach((n2) => {
49088
- const nodeId = this.mirror.getId(n2);
48966
+ m.addedNodes.forEach((n) => this.genAdds(n, m.target));
48967
+ m.removedNodes.forEach((n) => {
48968
+ const nodeId = this.mirror.getId(n);
49089
48969
  const parentId = isShadowRoot(m.target) ? this.mirror.getId(index.host(m.target)) : this.mirror.getId(m.target);
49090
- if (isBlocked(m.target, this.blockClass, this.blockSelector, false) || isIgnored(n2, this.mirror, this.slimDOMOptions) || !isSerialized(n2, this.mirror)) {
48970
+ if (isBlocked(m.target, this.blockClass, this.blockSelector, false) || isIgnored(n, this.mirror, this.slimDOMOptions) || !isSerialized(n, this.mirror)) {
49091
48971
  return;
49092
48972
  }
49093
- if (this.addedSet.has(n2)) {
49094
- deepDelete(this.addedSet, n2);
49095
- this.droppedSet.add(n2);
48973
+ if (this.addedSet.has(n)) {
48974
+ deepDelete(this.addedSet, n);
48975
+ this.droppedSet.add(n);
49096
48976
  } else if (this.addedSet.has(m.target) && nodeId === -1) ;
49097
48977
  else if (isAncestorRemoved(m.target, this.mirror)) ;
49098
- else if (this.movedSet.has(n2) && this.movedMap[moveKey(nodeId, parentId)]) {
49099
- deepDelete(this.movedSet, n2);
48978
+ else if (this.movedSet.has(n) && this.movedMap[moveKey(nodeId, parentId)]) {
48979
+ deepDelete(this.movedSet, n);
49100
48980
  } else {
49101
48981
  this.removes.push({
49102
48982
  parentId,
49103
48983
  id: nodeId,
49104
48984
  isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
49105
48985
  });
49106
- processRemoves(n2, this.removesSubTreeCache);
48986
+ processRemoves(n, this.removesSubTreeCache);
49107
48987
  }
49108
- this.mapRemoves.push(n2);
48988
+ this.mapRemoves.push(n);
49109
48989
  });
49110
48990
  break;
49111
48991
  }
49112
48992
  }
49113
48993
  });
49114
- __publicField(this, "genAdds", (n2, target) => {
49115
- if (this.processedNodeManager.inOtherBuffer(n2, this)) return;
49116
- if (this.addedSet.has(n2) || this.movedSet.has(n2)) return;
49117
- if (this.mirror.hasNode(n2)) {
49118
- if (isIgnored(n2, this.mirror, this.slimDOMOptions)) {
48994
+ /**
48995
+ * Make sure you check if `n`'s parent is blocked before calling this function
48996
+ * */
48997
+ __publicField(this, "genAdds", (n, target) => {
48998
+ if (this.processedNodeManager.inOtherBuffer(n, this)) return;
48999
+ if (this.addedSet.has(n) || this.movedSet.has(n)) return;
49000
+ if (this.mirror.hasNode(n)) {
49001
+ if (isIgnored(n, this.mirror, this.slimDOMOptions)) {
49119
49002
  return;
49120
49003
  }
49121
- this.movedSet.add(n2);
49004
+ this.movedSet.add(n);
49122
49005
  let targetId = null;
49123
49006
  if (target && this.mirror.hasNode(target)) {
49124
49007
  targetId = this.mirror.getId(target);
49125
49008
  }
49126
49009
  if (targetId && targetId !== -1) {
49127
- this.movedMap[moveKey(this.mirror.getId(n2), targetId)] = true;
49010
+ this.movedMap[moveKey(this.mirror.getId(n), targetId)] = true;
49128
49011
  }
49129
49012
  } else {
49130
- this.addedSet.add(n2);
49131
- this.droppedSet.delete(n2);
49013
+ this.addedSet.add(n);
49014
+ this.droppedSet.delete(n);
49132
49015
  }
49133
- if (!isBlocked(n2, this.blockClass, this.blockSelector, false)) {
49134
- index.childNodes(n2).forEach((childN) => this.genAdds(childN));
49135
- if (hasShadowRoot(n2)) {
49136
- index.childNodes(index.shadowRoot(n2)).forEach((childN) => {
49016
+ if (!isBlocked(n, this.blockClass, this.blockSelector, false)) {
49017
+ index.childNodes(n).forEach((childN) => this.genAdds(childN));
49018
+ if (hasShadowRoot(n)) {
49019
+ index.childNodes(index.shadowRoot(n)).forEach((childN) => {
49137
49020
  this.processedNodeManager.add(childN, this);
49138
- this.genAdds(childN, n2);
49021
+ this.genAdds(childN, n);
49139
49022
  });
49140
49023
  }
49141
49024
  }
@@ -49195,42 +49078,33 @@ class MutationBuffer {
49195
49078
  this.canvasManager.reset();
49196
49079
  }
49197
49080
  }
49198
- function deepDelete(addsSet, n2) {
49199
- addsSet.delete(n2);
49200
- index.childNodes(n2).forEach((childN) => deepDelete(addsSet, childN));
49081
+ function deepDelete(addsSet, n) {
49082
+ addsSet.delete(n);
49083
+ index.childNodes(n).forEach((childN) => deepDelete(addsSet, childN));
49201
49084
  }
49202
- function processRemoves(n2, cache) {
49203
- const queue = [n2];
49085
+ function processRemoves(n, cache) {
49086
+ const queue = [n];
49204
49087
  while (queue.length) {
49205
49088
  const next = queue.pop();
49206
49089
  if (cache.has(next)) continue;
49207
49090
  cache.add(next);
49208
- index.childNodes(next).forEach((n22) => queue.push(n22));
49091
+ index.childNodes(next).forEach((n2) => queue.push(n2));
49209
49092
  }
49210
49093
  return;
49211
49094
  }
49212
- function isParentRemoved(removes, n2, mirror2) {
49213
- if (removes.size === 0) return false;
49214
- return _isParentRemoved(removes, n2);
49215
- }
49216
- function _isParentRemoved(removes, n2, _mirror2) {
49217
- const node = index.parentNode(n2);
49218
- if (!node) return false;
49219
- return removes.has(node);
49220
- }
49221
- function isAncestorInSet(set, n2) {
49095
+ function isSelfOrAncestorInSet(set, n) {
49222
49096
  if (set.size === 0) return false;
49223
- return _isAncestorInSet(set, n2);
49097
+ return _isSelfOrAncestorInSet(set, n);
49224
49098
  }
49225
- function _isAncestorInSet(set, n2) {
49226
- const parent = index.parentNode(n2);
49099
+ function _isSelfOrAncestorInSet(set, n) {
49100
+ if (set.has(n)) {
49101
+ return true;
49102
+ }
49103
+ const parent = index.parentNode(n);
49227
49104
  if (!parent) {
49228
49105
  return false;
49229
49106
  }
49230
- if (set.has(parent)) {
49231
- return true;
49232
- }
49233
- return _isAncestorInSet(set, parent);
49107
+ return _isSelfOrAncestorInSet(set, parent);
49234
49108
  }
49235
49109
  let errorHandler;
49236
49110
  function registerErrorHandler(handler) {
@@ -49275,7 +49149,8 @@ function initMutationObserver(options, rootEl) {
49275
49149
  const mutationBuffer = new MutationBuffer();
49276
49150
  mutationBuffers.push(mutationBuffer);
49277
49151
  mutationBuffer.init(options);
49278
- const observer = new (mutationObserverCtor())(
49152
+ const [ObserverCtor, iframeCleanup] = mutationObserverCtor();
49153
+ const observer = new ObserverCtor(
49279
49154
  callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer))
49280
49155
  );
49281
49156
  observer.observe(rootEl, {
@@ -49286,7 +49161,7 @@ function initMutationObserver(options, rootEl) {
49286
49161
  childList: true,
49287
49162
  subtree: true
49288
49163
  });
49289
- return observer;
49164
+ return [observer, iframeCleanup];
49290
49165
  }
49291
49166
  function initMoveObserver({
49292
49167
  mousemoveCb,
@@ -49406,12 +49281,12 @@ function initMouseInteractionObserver({
49406
49281
  pointerType = currentPointerType;
49407
49282
  currentPointerType = null;
49408
49283
  }
49409
- const e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
49410
- if (!e2) {
49284
+ const e = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
49285
+ if (!e) {
49411
49286
  return;
49412
49287
  }
49413
49288
  const id = mirror2.getId(target);
49414
- const { clientX, clientY } = e2;
49289
+ const { clientX, clientY } = e;
49415
49290
  callbackWrapper(mouseInteractionCb)({
49416
49291
  type: MouseInteractions[thisEventKey],
49417
49292
  id,
@@ -49505,11 +49380,11 @@ function initViewportResizeObserver({ viewportResizeCb }, { win }) {
49505
49380
  return on("resize", updateDimension, win);
49506
49381
  }
49507
49382
  function findAndRemoveIframeBuffer(iframeEl) {
49508
- for (let i2 = mutationBuffers.length - 1; i2 >= 0; i2--) {
49509
- const buf = mutationBuffers[i2];
49383
+ for (let i = mutationBuffers.length - 1; i >= 0; i--) {
49384
+ const buf = mutationBuffers[i];
49510
49385
  if (buf.bufferBelongsToIframe(iframeEl)) {
49511
49386
  buf.reset();
49512
- mutationBuffers.splice(i2, 1);
49387
+ mutationBuffers.splice(i, 1);
49513
49388
  }
49514
49389
  }
49515
49390
  }
@@ -49582,13 +49457,13 @@ function initInputObserver({
49582
49457
  });
49583
49458
  }
49584
49459
  }
49585
- function cbWithDedup(target, v2) {
49460
+ function cbWithDedup(target, v) {
49586
49461
  const lastInputValue = lastInputValueMap.get(target);
49587
- if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
49588
- lastInputValueMap.set(target, v2);
49462
+ if (!lastInputValue || lastInputValue.text !== v.text || lastInputValue.isChecked !== v.isChecked) {
49463
+ lastInputValueMap.set(target, v);
49589
49464
  const id = mirror2.getId(target);
49590
49465
  callbackWrapper(inputCb)({
49591
- ...v2,
49466
+ ...v,
49592
49467
  id
49593
49468
  });
49594
49469
  }
@@ -49645,15 +49520,15 @@ function getNestedCSSRulePositions(rule) {
49645
49520
  const positions = [];
49646
49521
  function recurse(childRule, pos) {
49647
49522
  if (hasNestedCSSRule("CSSGroupingRule") && childRule.parentRule instanceof CSSGroupingRule || hasNestedCSSRule("CSSMediaRule") && childRule.parentRule instanceof CSSMediaRule || hasNestedCSSRule("CSSSupportsRule") && childRule.parentRule instanceof CSSSupportsRule || hasNestedCSSRule("CSSConditionRule") && childRule.parentRule instanceof CSSConditionRule) {
49648
- const rules2 = Array.from(
49523
+ const rules = Array.from(
49649
49524
  childRule.parentRule.cssRules
49650
49525
  );
49651
- const index2 = rules2.indexOf(childRule);
49526
+ const index2 = rules.indexOf(childRule);
49652
49527
  pos.unshift(index2);
49653
49528
  return recurse(childRule.parentRule, pos);
49654
49529
  } else if (childRule.parentStyleSheet) {
49655
- const rules2 = Array.from(childRule.parentStyleSheet.cssRules);
49656
- const index2 = rules2.indexOf(childRule);
49530
+ const rules = Array.from(childRule.parentStyleSheet.cssRules);
49531
+ const index2 = rules.indexOf(childRule);
49657
49532
  pos.unshift(index2);
49658
49533
  }
49659
49534
  return pos;
@@ -49892,7 +49767,7 @@ function initAdoptedStyleSheetObserver({
49892
49767
  if (hostId !== null && hostId !== -1) {
49893
49768
  try {
49894
49769
  stylesheetManager.adoptStyleSheets(sheets, hostId);
49895
- } catch (e2) {
49770
+ } catch (e) {
49896
49771
  }
49897
49772
  }
49898
49773
  return result;
@@ -50029,7 +49904,7 @@ function initFontObserver({ fontCb, doc }) {
50029
49904
  const handlers = [];
50030
49905
  const fontMap = /* @__PURE__ */ new WeakMap();
50031
49906
  const originalFontFace = win.FontFace;
50032
- win.FontFace = function FontFace2(family, source, descriptors) {
49907
+ win.FontFace = function FontFace(family, source, descriptors) {
50033
49908
  const fontFace = new originalFontFace(family, source, descriptors);
50034
49909
  fontMap.set(fontFace, {
50035
49910
  family,
@@ -50075,8 +49950,8 @@ function initSelectionObserver(param) {
50075
49950
  collapsed = selection.isCollapsed || false;
50076
49951
  const ranges = [];
50077
49952
  const count = selection.rangeCount || 0;
50078
- for (let i2 = 0; i2 < count; i2++) {
50079
- const range = selection.getRangeAt(i2);
49953
+ for (let i = 0; i < count; i++) {
49954
+ const range = selection.getRangeAt(i);
50080
49955
  const { startContainer, startOffset, endContainer, endOffset } = range;
50081
49956
  const blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
50082
49957
  if (blocked) continue;
@@ -50110,7 +49985,7 @@ function initCustomElementObserver({
50110
49985
  name
50111
49986
  }
50112
49987
  });
50113
- } catch (e2) {
49988
+ } catch (e) {
50114
49989
  console.warn(`Custom element callback failed for ${name}`);
50115
49990
  }
50116
49991
  return original.apply(this, [name, constructor, options]);
@@ -50119,7 +49994,7 @@ function initCustomElementObserver({
50119
49994
  );
50120
49995
  return restoreHandler;
50121
49996
  }
50122
- function mergeHooks(o2, hooks) {
49997
+ function mergeHooks(o, hooks) {
50123
49998
  const {
50124
49999
  mutationCb,
50125
50000
  mousemoveCb,
@@ -50134,105 +50009,107 @@ function mergeHooks(o2, hooks) {
50134
50009
  fontCb,
50135
50010
  selectionCb,
50136
50011
  customElementCb
50137
- } = o2;
50138
- o2.mutationCb = (...p) => {
50012
+ } = o;
50013
+ o.mutationCb = (...p) => {
50139
50014
  if (hooks.mutation) {
50140
50015
  hooks.mutation(...p);
50141
50016
  }
50142
50017
  mutationCb(...p);
50143
50018
  };
50144
- o2.mousemoveCb = (...p) => {
50019
+ o.mousemoveCb = (...p) => {
50145
50020
  if (hooks.mousemove) {
50146
50021
  hooks.mousemove(...p);
50147
50022
  }
50148
50023
  mousemoveCb(...p);
50149
50024
  };
50150
- o2.mouseInteractionCb = (...p) => {
50025
+ o.mouseInteractionCb = (...p) => {
50151
50026
  if (hooks.mouseInteraction) {
50152
50027
  hooks.mouseInteraction(...p);
50153
50028
  }
50154
50029
  mouseInteractionCb(...p);
50155
50030
  };
50156
- o2.scrollCb = (...p) => {
50031
+ o.scrollCb = (...p) => {
50157
50032
  if (hooks.scroll) {
50158
50033
  hooks.scroll(...p);
50159
50034
  }
50160
50035
  scrollCb(...p);
50161
50036
  };
50162
- o2.viewportResizeCb = (...p) => {
50037
+ o.viewportResizeCb = (...p) => {
50163
50038
  if (hooks.viewportResize) {
50164
50039
  hooks.viewportResize(...p);
50165
50040
  }
50166
50041
  viewportResizeCb(...p);
50167
50042
  };
50168
- o2.inputCb = (...p) => {
50043
+ o.inputCb = (...p) => {
50169
50044
  if (hooks.input) {
50170
50045
  hooks.input(...p);
50171
50046
  }
50172
50047
  inputCb(...p);
50173
50048
  };
50174
- o2.mediaInteractionCb = (...p) => {
50049
+ o.mediaInteractionCb = (...p) => {
50175
50050
  if (hooks.mediaInteaction) {
50176
50051
  hooks.mediaInteaction(...p);
50177
50052
  }
50178
50053
  mediaInteractionCb(...p);
50179
50054
  };
50180
- o2.styleSheetRuleCb = (...p) => {
50055
+ o.styleSheetRuleCb = (...p) => {
50181
50056
  if (hooks.styleSheetRule) {
50182
50057
  hooks.styleSheetRule(...p);
50183
50058
  }
50184
50059
  styleSheetRuleCb(...p);
50185
50060
  };
50186
- o2.styleDeclarationCb = (...p) => {
50061
+ o.styleDeclarationCb = (...p) => {
50187
50062
  if (hooks.styleDeclaration) {
50188
50063
  hooks.styleDeclaration(...p);
50189
50064
  }
50190
50065
  styleDeclarationCb(...p);
50191
50066
  };
50192
- o2.canvasMutationCb = (...p) => {
50067
+ o.canvasMutationCb = (...p) => {
50193
50068
  if (hooks.canvasMutation) {
50194
50069
  hooks.canvasMutation(...p);
50195
50070
  }
50196
50071
  canvasMutationCb(...p);
50197
50072
  };
50198
- o2.fontCb = (...p) => {
50073
+ o.fontCb = (...p) => {
50199
50074
  if (hooks.font) {
50200
50075
  hooks.font(...p);
50201
50076
  }
50202
50077
  fontCb(...p);
50203
50078
  };
50204
- o2.selectionCb = (...p) => {
50079
+ o.selectionCb = (...p) => {
50205
50080
  if (hooks.selection) {
50206
50081
  hooks.selection(...p);
50207
50082
  }
50208
50083
  selectionCb(...p);
50209
50084
  };
50210
- o2.customElementCb = (...c2) => {
50085
+ o.customElementCb = (...c) => {
50211
50086
  if (hooks.customElement) {
50212
- hooks.customElement(...c2);
50087
+ hooks.customElement(...c);
50213
50088
  }
50214
- customElementCb(...c2);
50089
+ customElementCb(...c);
50215
50090
  };
50216
50091
  }
50217
- function initObservers(o2, hooks = {}) {
50218
- const currentWindow = o2.doc.defaultView;
50092
+ function initObservers(o, hooks = {}) {
50093
+ const currentWindow = o.doc.defaultView;
50219
50094
  if (!currentWindow) {
50220
50095
  return () => {
50221
50096
  };
50222
50097
  }
50223
- mergeHooks(o2, hooks);
50098
+ mergeHooks(o, hooks);
50224
50099
  let mutationObserver;
50225
- if (o2.recordDOM) {
50226
- mutationObserver = initMutationObserver(o2, o2.doc);
50100
+ let cleanupMutationIframe = () => {
50101
+ };
50102
+ if (o.recordDOM) {
50103
+ [mutationObserver, cleanupMutationIframe] = initMutationObserver(o, o.doc);
50227
50104
  }
50228
- const mousemoveHandler = initMoveObserver(o2);
50229
- const mouseInteractionHandler = initMouseInteractionObserver(o2);
50230
- const scrollHandler = initScrollObserver(o2);
50231
- const viewportResizeHandler = initViewportResizeObserver(o2, {
50105
+ const mousemoveHandler = initMoveObserver(o);
50106
+ const mouseInteractionHandler = initMouseInteractionObserver(o);
50107
+ const scrollHandler = initScrollObserver(o);
50108
+ const viewportResizeHandler = initViewportResizeObserver(o, {
50232
50109
  win: currentWindow
50233
50110
  });
50234
- const inputHandler = initInputObserver(o2);
50235
- const mediaInteractionHandler = initMediaInteractionObserver(o2);
50111
+ const inputHandler = initInputObserver(o);
50112
+ const mediaInteractionHandler = initMediaInteractionObserver(o);
50236
50113
  let styleSheetObserver = () => {
50237
50114
  };
50238
50115
  let adoptedStyleSheetObserver = () => {
@@ -50241,20 +50118,20 @@ function initObservers(o2, hooks = {}) {
50241
50118
  };
50242
50119
  let fontObserver = () => {
50243
50120
  };
50244
- if (o2.recordDOM) {
50245
- styleSheetObserver = initStyleSheetObserver(o2, { win: currentWindow });
50246
- adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
50247
- styleDeclarationObserver = initStyleDeclarationObserver(o2, {
50121
+ if (o.recordDOM) {
50122
+ styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });
50123
+ adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o, o.doc);
50124
+ styleDeclarationObserver = initStyleDeclarationObserver(o, {
50248
50125
  win: currentWindow
50249
50126
  });
50250
- if (o2.collectFonts) {
50251
- fontObserver = initFontObserver(o2);
50127
+ if (o.collectFonts) {
50128
+ fontObserver = initFontObserver(o);
50252
50129
  }
50253
50130
  }
50254
- const selectionObserver = initSelectionObserver(o2);
50255
- const customElementObserver = initCustomElementObserver(o2);
50131
+ const selectionObserver = initSelectionObserver(o);
50132
+ const customElementObserver = initCustomElementObserver(o);
50256
50133
  const pluginHandlers = [];
50257
- for (const plugin of o2.plugins) {
50134
+ for (const plugin of o.plugins) {
50258
50135
  pluginHandlers.push(
50259
50136
  plugin.observer(plugin.callback, currentWindow, plugin.options)
50260
50137
  );
@@ -50262,6 +50139,7 @@ function initObservers(o2, hooks = {}) {
50262
50139
  return callbackWrapper(() => {
50263
50140
  mutationBuffers.forEach((b) => b.reset());
50264
50141
  mutationObserver == null ? void 0 : mutationObserver.disconnect();
50142
+ cleanupMutationIframe();
50265
50143
  mousemoveHandler();
50266
50144
  mouseInteractionHandler();
50267
50145
  scrollHandler();
@@ -50385,7 +50263,7 @@ class IframeManager {
50385
50263
  this.iframes.set(iframeEl, true);
50386
50264
  if (iframeEl.contentWindow)
50387
50265
  this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
50388
- if (!iframeEl.contentDocument && iframeEl.contentWindow)
50266
+ if (this.recordCrossOriginIframes && !iframeEl.contentDocument && iframeEl.contentWindow)
50389
50267
  iframeEl.contentWindow.postMessage(
50390
50268
  {
50391
50269
  type: "rrweb",
@@ -50458,18 +50336,18 @@ class IframeManager {
50458
50336
  crossOriginMessageEvent.data.isCheckout
50459
50337
  );
50460
50338
  }
50461
- transformCrossOriginEvent(iframeEl, e2) {
50339
+ transformCrossOriginEvent(iframeEl, e) {
50462
50340
  var _a2;
50463
- switch (e2.type) {
50341
+ switch (e.type) {
50464
50342
  case EventType.FullSnapshot: {
50465
50343
  this.crossOriginIframeMirror.reset(iframeEl);
50466
50344
  this.crossOriginIframeStyleMirror.reset(iframeEl);
50467
- this.replaceIdOnNode(e2.data.node, iframeEl);
50468
- const rootId = e2.data.node.id;
50345
+ this.replaceIdOnNode(e.data.node, iframeEl);
50346
+ const rootId = e.data.node.id;
50469
50347
  this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
50470
- this.patchRootIdOnNode(e2.data.node, rootId);
50348
+ this.patchRootIdOnNode(e.data.node, rootId);
50471
50349
  return {
50472
- timestamp: e2.timestamp,
50350
+ timestamp: e.timestamp,
50473
50351
  type: EventType.IncrementalSnapshot,
50474
50352
  data: {
50475
50353
  source: IncrementalSource.Mutation,
@@ -50477,7 +50355,7 @@ class IframeManager {
50477
50355
  {
50478
50356
  parentId: this.mirror.getId(iframeEl),
50479
50357
  nextId: null,
50480
- node: e2.data.node
50358
+ node: e.data.node
50481
50359
  }
50482
50360
  ],
50483
50361
  removes: [],
@@ -50493,47 +50371,47 @@ class IframeManager {
50493
50371
  return false;
50494
50372
  }
50495
50373
  case EventType.Plugin: {
50496
- return e2;
50374
+ return e;
50497
50375
  }
50498
50376
  case EventType.Custom: {
50499
50377
  this.replaceIds(
50500
- e2.data.payload,
50378
+ e.data.payload,
50501
50379
  iframeEl,
50502
50380
  ["id", "parentId", "previousId", "nextId"]
50503
50381
  );
50504
- return e2;
50382
+ return e;
50505
50383
  }
50506
50384
  case EventType.IncrementalSnapshot: {
50507
- switch (e2.data.source) {
50385
+ switch (e.data.source) {
50508
50386
  case IncrementalSource.Mutation: {
50509
- e2.data.adds.forEach((n2) => {
50510
- this.replaceIds(n2, iframeEl, [
50387
+ e.data.adds.forEach((n) => {
50388
+ this.replaceIds(n, iframeEl, [
50511
50389
  "parentId",
50512
50390
  "nextId",
50513
50391
  "previousId"
50514
50392
  ]);
50515
- this.replaceIdOnNode(n2.node, iframeEl);
50393
+ this.replaceIdOnNode(n.node, iframeEl);
50516
50394
  const rootId = this.crossOriginIframeRootIdMap.get(iframeEl);
50517
- rootId && this.patchRootIdOnNode(n2.node, rootId);
50395
+ rootId && this.patchRootIdOnNode(n.node, rootId);
50518
50396
  });
50519
- e2.data.removes.forEach((n2) => {
50520
- this.replaceIds(n2, iframeEl, ["parentId", "id"]);
50397
+ e.data.removes.forEach((n) => {
50398
+ this.replaceIds(n, iframeEl, ["parentId", "id"]);
50521
50399
  });
50522
- e2.data.attributes.forEach((n2) => {
50523
- this.replaceIds(n2, iframeEl, ["id"]);
50400
+ e.data.attributes.forEach((n) => {
50401
+ this.replaceIds(n, iframeEl, ["id"]);
50524
50402
  });
50525
- e2.data.texts.forEach((n2) => {
50526
- this.replaceIds(n2, iframeEl, ["id"]);
50403
+ e.data.texts.forEach((n) => {
50404
+ this.replaceIds(n, iframeEl, ["id"]);
50527
50405
  });
50528
- return e2;
50406
+ return e;
50529
50407
  }
50530
50408
  case IncrementalSource.Drag:
50531
50409
  case IncrementalSource.TouchMove:
50532
50410
  case IncrementalSource.MouseMove: {
50533
- e2.data.positions.forEach((p) => {
50411
+ e.data.positions.forEach((p) => {
50534
50412
  this.replaceIds(p, iframeEl, ["id"]);
50535
50413
  });
50536
- return e2;
50414
+ return e;
50537
50415
  }
50538
50416
  case IncrementalSource.ViewportResize: {
50539
50417
  return false;
@@ -50543,31 +50421,31 @@ class IframeManager {
50543
50421
  case IncrementalSource.Scroll:
50544
50422
  case IncrementalSource.CanvasMutation:
50545
50423
  case IncrementalSource.Input: {
50546
- this.replaceIds(e2.data, iframeEl, ["id"]);
50547
- return e2;
50424
+ this.replaceIds(e.data, iframeEl, ["id"]);
50425
+ return e;
50548
50426
  }
50549
50427
  case IncrementalSource.StyleSheetRule:
50550
50428
  case IncrementalSource.StyleDeclaration: {
50551
- this.replaceIds(e2.data, iframeEl, ["id"]);
50552
- this.replaceStyleIds(e2.data, iframeEl, ["styleId"]);
50553
- return e2;
50429
+ this.replaceIds(e.data, iframeEl, ["id"]);
50430
+ this.replaceStyleIds(e.data, iframeEl, ["styleId"]);
50431
+ return e;
50554
50432
  }
50555
50433
  case IncrementalSource.Font: {
50556
- return e2;
50434
+ return e;
50557
50435
  }
50558
50436
  case IncrementalSource.Selection: {
50559
- e2.data.ranges.forEach((range) => {
50437
+ e.data.ranges.forEach((range) => {
50560
50438
  this.replaceIds(range, iframeEl, ["start", "end"]);
50561
50439
  });
50562
- return e2;
50440
+ return e;
50563
50441
  }
50564
50442
  case IncrementalSource.AdoptedStyleSheet: {
50565
- this.replaceIds(e2.data, iframeEl, ["id"]);
50566
- this.replaceStyleIds(e2.data, iframeEl, ["styleIds"]);
50567
- (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach((style) => {
50443
+ this.replaceIds(e.data, iframeEl, ["id"]);
50444
+ this.replaceStyleIds(e.data, iframeEl, ["styleIds"]);
50445
+ (_a2 = e.data.styles) == null ? void 0 : _a2.forEach((style) => {
50568
50446
  this.replaceStyleIds(style, iframeEl, ["styleId"]);
50569
50447
  });
50570
- return e2;
50448
+ return e;
50571
50449
  }
50572
50450
  }
50573
50451
  }
@@ -50633,7 +50511,7 @@ class ShadowDomManager {
50633
50511
  if (!isNativeShadowDom(shadowRoot2)) return;
50634
50512
  if (this.shadowDoms.has(shadowRoot2)) return;
50635
50513
  this.shadowDoms.add(shadowRoot2);
50636
- const observer = initMutationObserver(
50514
+ const [observer] = initMutationObserver(
50637
50515
  {
50638
50516
  ...this.bypassOptions,
50639
50517
  doc,
@@ -50706,7 +50584,7 @@ class ShadowDomManager {
50706
50584
  this.restoreHandlers.forEach((handler) => {
50707
50585
  try {
50708
50586
  handler();
50709
- } catch (e2) {
50587
+ } catch (e) {
50710
50588
  }
50711
50589
  });
50712
50590
  this.restoreHandlers = [];
@@ -50715,16 +50593,16 @@ class ShadowDomManager {
50715
50593
  }
50716
50594
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
50717
50595
  var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
50718
- for (var i$1 = 0; i$1 < chars.length; i$1++) {
50719
- lookup[chars.charCodeAt(i$1)] = i$1;
50596
+ for (var i = 0; i < chars.length; i++) {
50597
+ lookup[chars.charCodeAt(i)] = i;
50720
50598
  }
50721
50599
  var encode = function(arraybuffer) {
50722
- var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
50723
- for (i2 = 0; i2 < len; i2 += 3) {
50724
- base64 += chars[bytes[i2] >> 2];
50725
- base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
50726
- base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
50727
- base64 += chars[bytes[i2 + 2] & 63];
50600
+ var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = "";
50601
+ for (i = 0; i < len; i += 3) {
50602
+ base64 += chars[bytes[i] >> 2];
50603
+ base64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
50604
+ base64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
50605
+ base64 += chars[bytes[i + 2] & 63];
50728
50606
  }
50729
50607
  if (len % 3 === 2) {
50730
50608
  base64 = base64.substring(0, base64.length - 1) + "=";
@@ -50734,7 +50612,7 @@ var encode = function(arraybuffer) {
50734
50612
  return base64;
50735
50613
  };
50736
50614
  const canvasVarMap = /* @__PURE__ */ new Map();
50737
- function variableListFor$1(ctx, ctor) {
50615
+ function variableListFor(ctx, ctor) {
50738
50616
  let contextMap = canvasVarMap.get(ctx);
50739
50617
  if (!contextMap) {
50740
50618
  contextMap = /* @__PURE__ */ new Map();
@@ -50749,7 +50627,7 @@ const saveWebGLVar = (value, win, ctx) => {
50749
50627
  if (!value || !(isInstanceOfWebGLObject(value, win) || typeof value === "object"))
50750
50628
  return;
50751
50629
  const name = value.constructor.name;
50752
- const list = variableListFor$1(ctx, name);
50630
+ const list = variableListFor(ctx, name);
50753
50631
  let index2 = list.indexOf(value);
50754
50632
  if (index2 === -1) {
50755
50633
  index2 = list.length;
@@ -50882,11 +50760,11 @@ function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
50882
50760
  win.CanvasRenderingContext2D.prototype,
50883
50761
  prop,
50884
50762
  {
50885
- set(v2) {
50763
+ set(v) {
50886
50764
  cb(this.canvas, {
50887
50765
  type: CanvasContext["2D"],
50888
50766
  property: prop,
50889
- args: [v2],
50767
+ args: [v],
50890
50768
  setter: true
50891
50769
  });
50892
50770
  }
@@ -50980,11 +50858,11 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
50980
50858
  handlers.push(restoreHandler);
50981
50859
  } catch {
50982
50860
  const hookHandler = hookSetter(prototype, prop, {
50983
- set(v2) {
50861
+ set(v) {
50984
50862
  cb(this.canvas, {
50985
50863
  type,
50986
50864
  property: prop,
50987
- args: [v2],
50865
+ args: [v],
50988
50866
  setter: true
50989
50867
  });
50990
50868
  }
@@ -50996,16 +50874,18 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
50996
50874
  }
50997
50875
  function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
50998
50876
  const handlers = [];
50999
- handlers.push(
51000
- ...patchGLPrototype(
51001
- win.WebGLRenderingContext.prototype,
51002
- CanvasContext.WebGL,
51003
- cb,
51004
- blockClass,
51005
- blockSelector,
51006
- win
51007
- )
51008
- );
50877
+ if (typeof win.WebGLRenderingContext !== "undefined") {
50878
+ handlers.push(
50879
+ ...patchGLPrototype(
50880
+ win.WebGLRenderingContext.prototype,
50881
+ CanvasContext.WebGL,
50882
+ cb,
50883
+ blockClass,
50884
+ blockSelector,
50885
+ win
50886
+ )
50887
+ );
50888
+ }
51009
50889
  if (typeof win.WebGL2RenderingContext !== "undefined") {
51010
50890
  handlers.push(
51011
50891
  ...patchGLPrototype(
@@ -51087,11 +50967,11 @@ class CanvasManager {
51087
50967
  );
51088
50968
  const snapshotInProgressMap = /* @__PURE__ */ new Map();
51089
50969
  const worker = new WorkerWrapper();
51090
- worker.onmessage = (e2) => {
51091
- const { id } = e2.data;
50970
+ worker.onmessage = (e) => {
50971
+ const { id } = e.data;
51092
50972
  snapshotInProgressMap.set(id, false);
51093
- if (!("base64" in e2.data)) return;
51094
- const { base64, type, width, height } = e2.data;
50973
+ if (!("base64" in e.data)) return;
50974
+ const { base64, type, width, height } = e.data;
51095
50975
  this.mutationCb({
51096
50976
  id,
51097
50977
  type: CanvasContext["2D"],
@@ -51273,17 +51153,17 @@ class StylesheetManager {
51273
51153
  let styleId;
51274
51154
  if (!this.styleMirror.has(sheet)) {
51275
51155
  styleId = this.styleMirror.add(sheet);
51276
- const rules2 = [];
51277
- for (let i2 = 0; i2 < sheet.rules.length; ++i2) {
51278
- rules2.push({
51279
- rule: stringifyRule(sheet.rules[i2], sheet.href),
51280
- index: i2
51156
+ const rules = [];
51157
+ for (let i = 0; i < sheet.rules.length; ++i) {
51158
+ rules.push({
51159
+ rule: stringifyRule(sheet.rules[i], sheet.href),
51160
+ index: i
51281
51161
  });
51282
51162
  }
51283
51163
  styles.push({
51284
51164
  styleId,
51285
- rules: Array.from(sheet.rules || CSSRule, (r2, index2) => ({
51286
- rule: stringifyRule(r2, sheet.href),
51165
+ rules: Array.from(sheet.rules || CSSRule, (r, index2) => ({
51166
+ rule: stringifyRule(r, sheet.href),
51287
51167
  index: index2
51288
51168
  }))
51289
51169
  });
@@ -51324,7 +51204,7 @@ class ProcessedNodeManager {
51324
51204
  }
51325
51205
  }
51326
51206
  let wrappedEmit;
51327
- let takeFullSnapshot$1 = () => {
51207
+ let takeFullSnapshot = () => {
51328
51208
  };
51329
51209
  let canvasManager;
51330
51210
  let recording = false;
@@ -51338,7 +51218,7 @@ try {
51338
51218
  } catch (err) {
51339
51219
  console.debug("Unable to override Array.from", err);
51340
51220
  }
51341
- const mirror = createMirror$2();
51221
+ const mirror = createMirror();
51342
51222
  function record(options = {}) {
51343
51223
  const {
51344
51224
  emit,
@@ -51383,7 +51263,7 @@ function record(options = {}) {
51383
51263
  if (window.parent.document) {
51384
51264
  passEmitsToParent = false;
51385
51265
  }
51386
- } catch (e2) {
51266
+ } catch (e) {
51387
51267
  passEmitsToParent = true;
51388
51268
  }
51389
51269
  }
@@ -51416,66 +51296,52 @@ function record(options = {}) {
51416
51296
  select: true,
51417
51297
  password: true
51418
51298
  } : _maskInputOptions !== void 0 ? _maskInputOptions : { password: true };
51419
- const slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
51420
- script: true,
51421
- comment: true,
51422
- headFavicon: true,
51423
- headWhitespace: true,
51424
- headMetaSocial: true,
51425
- headMetaRobots: true,
51426
- headMetaHttpEquiv: true,
51427
- headMetaVerification: true,
51428
- // the following are off for slimDOMOptions === true,
51429
- // as they destroy some (hidden) info:
51430
- headMetaAuthorship: _slimDOMOptions === "all",
51431
- headMetaDescKeywords: _slimDOMOptions === "all",
51432
- headTitleMutations: _slimDOMOptions === "all"
51433
- } : _slimDOMOptions ? _slimDOMOptions : {};
51434
- polyfill$1();
51299
+ const slimDOMOptions = slimDOMDefaults(_slimDOMOptions);
51300
+ polyfill();
51435
51301
  let lastFullSnapshotEvent;
51436
51302
  let incrementalSnapshotCount = 0;
51437
- const eventProcessor = (e2) => {
51303
+ const eventProcessor = (e) => {
51438
51304
  for (const plugin of plugins || []) {
51439
51305
  if (plugin.eventProcessor) {
51440
- e2 = plugin.eventProcessor(e2);
51306
+ e = plugin.eventProcessor(e);
51441
51307
  }
51442
51308
  }
51443
51309
  if (packFn && // Disable packing events which will be emitted to parent frames.
51444
51310
  !passEmitsToParent) {
51445
- e2 = packFn(e2);
51311
+ e = packFn(e);
51446
51312
  }
51447
- return e2;
51313
+ return e;
51448
51314
  };
51449
- wrappedEmit = (r2, isCheckout) => {
51315
+ wrappedEmit = (r, isCheckout) => {
51450
51316
  var _a2;
51451
- const e2 = r2;
51452
- e2.timestamp = nowTimestamp();
51453
- if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
51317
+ const e = r;
51318
+ e.timestamp = nowTimestamp();
51319
+ if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e.type !== EventType.FullSnapshot && !(e.type === EventType.IncrementalSnapshot && e.data.source === IncrementalSource.Mutation)) {
51454
51320
  mutationBuffers.forEach((buf) => buf.unfreeze());
51455
51321
  }
51456
51322
  if (inEmittingFrame) {
51457
- emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
51323
+ emit == null ? void 0 : emit(eventProcessor(e), isCheckout);
51458
51324
  } else if (passEmitsToParent) {
51459
51325
  const message = {
51460
51326
  type: "rrweb",
51461
- event: eventProcessor(e2),
51327
+ event: eventProcessor(e),
51462
51328
  origin: window.location.origin,
51463
51329
  isCheckout
51464
51330
  };
51465
51331
  window.parent.postMessage(message, "*");
51466
51332
  }
51467
- if (e2.type === EventType.FullSnapshot) {
51468
- lastFullSnapshotEvent = e2;
51333
+ if (e.type === EventType.FullSnapshot) {
51334
+ lastFullSnapshotEvent = e;
51469
51335
  incrementalSnapshotCount = 0;
51470
- } else if (e2.type === EventType.IncrementalSnapshot) {
51471
- if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
51336
+ } else if (e.type === EventType.IncrementalSnapshot) {
51337
+ if (e.data.source === IncrementalSource.Mutation && e.data.isAttachIframe) {
51472
51338
  return;
51473
51339
  }
51474
51340
  incrementalSnapshotCount++;
51475
51341
  const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
51476
- const exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
51342
+ const exceedTime = checkoutEveryNms && e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
51477
51343
  if (exceedCount || exceedTime) {
51478
- takeFullSnapshot$1(true);
51344
+ takeFullSnapshot(true);
51479
51345
  }
51480
51346
  }
51481
51347
  };
@@ -51502,11 +51368,11 @@ function record(options = {}) {
51502
51368
  ...p
51503
51369
  }
51504
51370
  });
51505
- const wrappedAdoptedStyleSheetEmit = (a2) => wrappedEmit({
51371
+ const wrappedAdoptedStyleSheetEmit = (a) => wrappedEmit({
51506
51372
  type: EventType.IncrementalSnapshot,
51507
51373
  data: {
51508
51374
  source: IncrementalSource.AdoptedStyleSheet,
51509
- ...a2
51375
+ ...a
51510
51376
  }
51511
51377
  });
51512
51378
  const stylesheetManager = new StylesheetManager({
@@ -51519,7 +51385,7 @@ function record(options = {}) {
51519
51385
  stylesheetManager,
51520
51386
  recordCrossOriginIframes,
51521
51387
  wrappedEmit,
51522
- takeFullSnapshot: takeFullSnapshot$1
51388
+ takeFullSnapshot
51523
51389
  });
51524
51390
  for (const plugin of plugins || []) {
51525
51391
  if (plugin.getMirror)
@@ -51566,7 +51432,7 @@ function record(options = {}) {
51566
51432
  },
51567
51433
  mirror
51568
51434
  });
51569
- takeFullSnapshot$1 = (isCheckout = false) => {
51435
+ takeFullSnapshot = (isCheckout = false) => {
51570
51436
  if (!recordDOM) {
51571
51437
  return;
51572
51438
  }
@@ -51599,15 +51465,15 @@ function record(options = {}) {
51599
51465
  dataURLOptions,
51600
51466
  recordCanvas,
51601
51467
  inlineImages,
51602
- onSerialize: (n2) => {
51603
- if (isSerializedIframe(n2, mirror)) {
51604
- iframeManager.addIframe(n2);
51468
+ onSerialize: (n) => {
51469
+ if (isSerializedIframe(n, mirror)) {
51470
+ iframeManager.addIframe(n);
51605
51471
  }
51606
- if (isSerializedStylesheet(n2, mirror)) {
51607
- stylesheetManager.trackLinkElement(n2);
51472
+ if (isSerializedStylesheet(n, mirror)) {
51473
+ stylesheetManager.trackLinkElement(n);
51608
51474
  }
51609
- if (hasShadowRoot(n2)) {
51610
- shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
51475
+ if (hasShadowRoot(n)) {
51476
+ shadowDomManager.addShadowRoot(index.shadowRoot(n), document);
51611
51477
  }
51612
51478
  },
51613
51479
  onIframeLoad: (iframe, childSn) => {
@@ -51639,7 +51505,7 @@ function record(options = {}) {
51639
51505
  mirror.getId(document)
51640
51506
  );
51641
51507
  };
51642
- iframeManager.setTakeFullSnapshot(takeFullSnapshot$1);
51508
+ iframeManager.setTakeFullSnapshot(takeFullSnapshot);
51643
51509
  try {
51644
51510
  const handlers = [];
51645
51511
  const iframeHandlersMap = /* @__PURE__ */ new Map();
@@ -51670,11 +51536,11 @@ function record(options = {}) {
51670
51536
  ...d
51671
51537
  }
51672
51538
  }),
51673
- inputCb: (v2) => wrappedEmit({
51539
+ inputCb: (v) => wrappedEmit({
51674
51540
  type: EventType.IncrementalSnapshot,
51675
51541
  data: {
51676
51542
  source: IncrementalSource.Input,
51677
- ...v2
51543
+ ...v
51678
51544
  }
51679
51545
  }),
51680
51546
  mediaInteractionCb: (p) => wrappedEmit({
@@ -51684,18 +51550,18 @@ function record(options = {}) {
51684
51550
  ...p
51685
51551
  }
51686
51552
  }),
51687
- styleSheetRuleCb: (r2) => wrappedEmit({
51553
+ styleSheetRuleCb: (r) => wrappedEmit({
51688
51554
  type: EventType.IncrementalSnapshot,
51689
51555
  data: {
51690
51556
  source: IncrementalSource.StyleSheetRule,
51691
- ...r2
51557
+ ...r
51692
51558
  }
51693
51559
  }),
51694
- styleDeclarationCb: (r2) => wrappedEmit({
51560
+ styleDeclarationCb: (r) => wrappedEmit({
51695
51561
  type: EventType.IncrementalSnapshot,
51696
51562
  data: {
51697
51563
  source: IncrementalSource.StyleDeclaration,
51698
- ...r2
51564
+ ...r
51699
51565
  }
51700
51566
  }),
51701
51567
  canvasMutationCb: wrappedCanvasMutationEmit,
@@ -51715,12 +51581,12 @@ function record(options = {}) {
51715
51581
  }
51716
51582
  });
51717
51583
  },
51718
- customElementCb: (c2) => {
51584
+ customElementCb: (c) => {
51719
51585
  wrappedEmit({
51720
51586
  type: EventType.IncrementalSnapshot,
51721
51587
  data: {
51722
51588
  source: IncrementalSource.CustomElement,
51723
- ...c2
51589
+ ...c
51724
51590
  }
51725
51591
  });
51726
51592
  },
@@ -51783,11 +51649,11 @@ function record(options = {}) {
51783
51649
  findAndRemoveIframeBuffer(iframeEl);
51784
51650
  });
51785
51651
  const init = () => {
51786
- takeFullSnapshot$1();
51652
+ takeFullSnapshot();
51787
51653
  handlers.push(observe(document));
51788
51654
  recording = true;
51789
51655
  };
51790
- if (document.readyState === "interactive" || document.readyState === "complete") {
51656
+ if (["interactive", "complete"].includes(document.readyState)) {
51791
51657
  init();
51792
51658
  } else {
51793
51659
  handlers.push(
@@ -51814,7 +51680,16 @@ function record(options = {}) {
51814
51680
  );
51815
51681
  }
51816
51682
  return () => {
51817
- handlers.forEach((h) => h());
51683
+ handlers.forEach((handler) => {
51684
+ try {
51685
+ handler();
51686
+ } catch (error) {
51687
+ const msg = String(error).toLowerCase();
51688
+ if (!msg.includes("cross-origin")) {
51689
+ console.warn(error);
51690
+ }
51691
+ }
51692
+ });
51818
51693
  iframeHandlersMap.forEach((h) => h());
51819
51694
  processedNodeManager.destroy();
51820
51695
  recording = false;
@@ -51843,13 +51718,9 @@ record.takeFullSnapshot = (isCheckout) => {
51843
51718
  if (!recording) {
51844
51719
  throw new Error("please take full snapshot after start recording");
51845
51720
  }
51846
- takeFullSnapshot$1(isCheckout);
51721
+ takeFullSnapshot(isCheckout);
51847
51722
  };
51848
51723
  record.mirror = mirror;
51849
- var n;
51850
- !function(t2) {
51851
- t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
51852
- }(n || (n = {}));
51853
51724
  return record; }
51854
51725
 
51855
51726
  class SessionRecorderBuffer {
@@ -52617,7 +52488,7 @@ class SessionRecorder {
52617
52488
  this.stop();
52618
52489
  }
52619
52490
  if (visitorConfig && visitorConfig.enable && this.isRecording()) {
52620
- this.liveReplayClient.onLiveFlag(visitorConfig.live, this.visitorId, () => this.snapshot());
52491
+ this.liveReplayClient.onLiveFlag(visitorConfig.live, this.visitorId, () => this._snapshotForLiveReplay());
52621
52492
  if (continuationCallback) {
52622
52493
  continuationCallback.call(this);
52623
52494
  }
@@ -52639,6 +52510,11 @@ class SessionRecorder {
52639
52510
  this.send();
52640
52511
  this.record.takeFullSnapshot();
52641
52512
  }
52513
+ _snapshotForLiveReplay() {
52514
+ if (!this._recordsInThisFrame())
52515
+ return;
52516
+ this.snapshot();
52517
+ }
52642
52518
  isRecording() {
52643
52519
  return this.interval != null;
52644
52520
  }
@@ -52675,7 +52551,7 @@ class SessionRecorder {
52675
52551
  blockSelector: blockedSelectors.concat(hiddenSelectors).join(','),
52676
52552
  hideSelector: hiddenSelectors.join(','),
52677
52553
  recordCrossOriginIframes: recordCrossOriginIframes != null ? recordCrossOriginIframes : true,
52678
- emitFromIframe: !!this.api.ConfigReader.get(RECORDING_CONFIG_TREAT_IFRAME_AS_ROOT)
52554
+ emitFromIframe: this._treatIframeAsRoot()
52679
52555
  };
52680
52556
  return config;
52681
52557
  }
@@ -52779,7 +52655,7 @@ class SessionRecorder {
52779
52655
  errorHandler: this.errorHandler
52780
52656
  }, config));
52781
52657
  this._refreshIds();
52782
- this.liveReplayClient.onLiveFlag(visitorConfig.live, this.visitorId, () => this.snapshot());
52658
+ this.liveReplayClient.onLiveFlag(visitorConfig.live, this.visitorId, () => this._snapshotForLiveReplay());
52783
52659
  this.onRecordingStart();
52784
52660
  }
52785
52661
  catch (e) {
@@ -52797,6 +52673,21 @@ class SessionRecorder {
52797
52673
  topId: this.api.store.state.frames.topId
52798
52674
  });
52799
52675
  }
52676
+ _recordsInThisFrame() {
52677
+ if (window == window.top || this._treatIframeAsRoot())
52678
+ return true;
52679
+ if (!this.recordingConfig(this.visitorConfig).recordCrossOriginIframes)
52680
+ return true;
52681
+ try {
52682
+ return !window.parent.document;
52683
+ }
52684
+ catch (e) {
52685
+ return true;
52686
+ }
52687
+ }
52688
+ _treatIframeAsRoot() {
52689
+ return !!this.api.ConfigReader.get(RECORDING_CONFIG_TREAT_IFRAME_AS_ROOT);
52690
+ }
52800
52691
  _refreshIds() {
52801
52692
  if (window == window.top)
52802
52693
  return;
@@ -53049,7 +52940,7 @@ class SessionRecorder {
53049
52940
  // ignore stale responses from a since-changed identity
53050
52941
  if (messageData.visitorId !== this.visitorId)
53051
52942
  break;
53052
- this.liveReplayClient.onLiveFlag(messageData.live, this.visitorId, () => this.snapshot());
52943
+ this.liveReplayClient.onLiveFlag(messageData.live, this.visitorId, () => this._snapshotForLiveReplay());
53053
52944
  break;
53054
52945
  }
53055
52946
  }
@@ -53612,6 +53503,7 @@ function createReplayPlugin() {
53612
53503
  /**
53613
53504
  * limit of number of keys in an object
53614
53505
  * if an object contains more keys than this limit, we would call its toString function directly
53506
+ * arrays longer than this limit are cut down to their first NUM_OF_KEYS_LIMIT elements
53615
53507
  */
53616
53508
  const NUM_OF_KEYS_LIMIT = 50;
53617
53509
  /**
@@ -53683,8 +53575,9 @@ function shouldIgnore(_obj) {
53683
53575
  /**
53684
53576
  * stringify any argument
53685
53577
  * @param arg - the arg to stringify
53578
+ * @param maxLength - stop serializing once this many characters have been visited
53686
53579
  */
53687
- function stringify(arg) {
53580
+ function stringify(arg, maxLength = Infinity) {
53688
53581
  if (arg === undefined)
53689
53582
  return 'undefined';
53690
53583
  // Handle primitives
@@ -53695,11 +53588,19 @@ function stringify(arg) {
53695
53588
  return arg.toString();
53696
53589
  return String(arg);
53697
53590
  }
53591
+ let charsVisited = 0;
53698
53592
  return JSON.stringify(arg, function (key, value) {
53593
+ if (charsVisited > maxLength)
53594
+ return '';
53595
+ const valueLength = typeof value === 'string' ? value.length : 0;
53596
+ charsVisited += key.length + valueLength;
53699
53597
  if (value === null)
53700
53598
  return value;
53701
53599
  if (value === undefined)
53702
53600
  return 'undefined';
53601
+ if (Array.isArray(value) && value.length > NUM_OF_KEYS_LIMIT) {
53602
+ return value.slice(0, NUM_OF_KEYS_LIMIT);
53603
+ }
53703
53604
  // Handle objects
53704
53605
  if (shouldIgnore(value)) {
53705
53606
  return value.toString ? value.toString() : '[object Object]';
@@ -54326,8 +54227,11 @@ function ConsoleCapture() {
54326
54227
  let isRecordingActive = false;
54327
54228
  const CAPTURE_CONSOLE_CONFIG = 'captureConsoleLogs';
54328
54229
  const ALWAYS_CAPTURE_ERRORS_CONFIG = 'alwaysCaptureDevLogErrors';
54230
+ const CONSOLE_LOG_LEVELS_CONFIG = 'consoleLogLevels';
54329
54231
  const CONSOLE_METHODS = ['log', 'warn', 'error', 'info'];
54330
54232
  const DEV_LOG_SUB_TYPE = 'console';
54233
+ const DEFAULT_CONSOLE_LOG_LEVELS = ['error', 'warn', 'info'];
54234
+ let consoleLogLevels = DEFAULT_CONSOLE_LOG_LEVELS;
54331
54235
  // deduplicate logs
54332
54236
  let lastLogKey = '';
54333
54237
  return {
@@ -54346,6 +54250,8 @@ function ConsoleCapture() {
54346
54250
  onPtmPaused,
54347
54251
  onPtmUnpaused,
54348
54252
  securityPolicyViolationFn,
54253
+ uncaughtErrorFn,
54254
+ unhandledRejectionFn,
54349
54255
  get isCapturingConsoleLogs() {
54350
54256
  return isCapturingConsoleLogs;
54351
54257
  },
@@ -54365,10 +54271,12 @@ function ConsoleCapture() {
54365
54271
  const { ConfigReader } = pluginAPI;
54366
54272
  ConfigReader.addOption(CAPTURE_CONSOLE_CONFIG, [ConfigReader.sources.PENDO_CONFIG_SRC], false);
54367
54273
  ConfigReader.addOption(ALWAYS_CAPTURE_ERRORS_CONFIG, [ConfigReader.sources.PENDO_CONFIG_SRC], false);
54274
+ ConfigReader.addOption(CONSOLE_LOG_LEVELS_CONFIG, [ConfigReader.sources.PENDO_CONFIG_SRC], DEFAULT_CONSOLE_LOG_LEVELS);
54368
54275
  const captureConsoleEnabled = ConfigReader.get(CAPTURE_CONSOLE_CONFIG);
54369
54276
  if (!captureConsoleEnabled)
54370
54277
  return;
54371
54278
  alwaysCaptureErrors = !!ConfigReader.get(ALWAYS_CAPTURE_ERRORS_CONFIG);
54279
+ consoleLogLevels = ConfigReader.get(CONSOLE_LOG_LEVELS_CONFIG);
54372
54280
  globalPendo = pendo;
54373
54281
  buffer = new DevlogBuffer(pendo, pluginAPI);
54374
54282
  transport = new DevlogTransport(pendo, pluginAPI);
@@ -54429,6 +54337,8 @@ function ConsoleCapture() {
54429
54337
  try {
54430
54338
  addIntercepts();
54431
54339
  pluginAPI.attachEventInternal(window, 'securitypolicyviolation', securityPolicyViolationFn);
54340
+ pluginAPI.attachEventInternal(window, 'error', uncaughtErrorFn);
54341
+ pluginAPI.attachEventInternal(window, 'unhandledrejection', unhandledRejectionFn);
54432
54342
  }
54433
54343
  catch (error) {
54434
54344
  pluginAPI.log.error('Error setting up console capture intercepts: ', error);
@@ -54469,16 +54379,36 @@ function ConsoleCapture() {
54469
54379
  createConsoleEvent([message], 'error', { skipStackTrace: true, skipScrubPII: true });
54470
54380
  }
54471
54381
  }
54382
+ function uncaughtErrorFn(evt) {
54383
+ if (!evt || typeof evt !== 'object')
54384
+ return;
54385
+ const rawMessage = evt.message || (evt.error && String(evt.error));
54386
+ if (!rawMessage)
54387
+ return;
54388
+ const message = rawMessage.indexOf('Uncaught') === 0 ? rawMessage : `Uncaught ${rawMessage}`;
54389
+ const stackTrace = evt.error && evt.error.stack;
54390
+ createConsoleEvent([stackTrace ? `${message}\n${stackTrace}` : message], 'error', { skipStackTrace: true });
54391
+ }
54392
+ function unhandledRejectionFn(evt) {
54393
+ if (!evt || typeof evt !== 'object')
54394
+ return;
54395
+ const { reason } = evt;
54396
+ const detail = reason && reason.stack ? reason.stack : reason;
54397
+ createConsoleEvent(['Uncaught (in promise)', detail], 'error', { skipStackTrace: true });
54398
+ }
54472
54399
  function createConsoleEvent(args, methodName, { skipStackTrace = false, skipScrubPII = false } = {}) {
54473
54400
  if (!isCapturingConsoleLogs || !args || args.length === 0 || !_.contains(CONSOLE_METHODS, methodName))
54474
54401
  return;
54475
54402
  if (isErrorOnlyCapture() && methodName !== 'error')
54476
54403
  return;
54404
+ const devLogLevel = methodName === 'log' ? 'info' : methodName;
54405
+ if (!_.contains(consoleLogLevels, devLogLevel))
54406
+ return;
54477
54407
  // stringify args
54478
54408
  let message = _.compact(_.map(args, arg => {
54479
54409
  let stringifiedArg;
54480
54410
  try {
54481
- stringifiedArg = stringify(arg);
54411
+ stringifiedArg = stringify(arg, MAX_LENGTH);
54482
54412
  }
54483
54413
  catch (error) {
54484
54414
  pluginAPI.log.error('Error stringifying arg: ', error);
@@ -54502,10 +54432,10 @@ function ConsoleCapture() {
54502
54432
  buffer.lastEvent.devLogCount++;
54503
54433
  return;
54504
54434
  }
54505
- const devLogEnvelope = createDevLogEnvelope(pluginAPI, globalPendo);
54506
- const consoleEvent = Object.assign(Object.assign({}, devLogEnvelope), { subType: DEV_LOG_SUB_TYPE, devLogLevel: methodName === 'log' ? 'info' : methodName, devLogMessage: skipScrubPII ? message : scrubPII({ string: message, _ }), devLogTrace: stackTrace, devLogCount: 1 });
54507
54435
  if (!buffer.hasTokenAvailable())
54508
- return consoleEvent;
54436
+ return;
54437
+ const devLogEnvelope = createDevLogEnvelope(pluginAPI, globalPendo);
54438
+ const consoleEvent = Object.assign(Object.assign({}, devLogEnvelope), { subType: DEV_LOG_SUB_TYPE, devLogLevel, devLogMessage: skipScrubPII ? message : scrubPII({ string: message, _ }), devLogTrace: stackTrace, devLogCount: 1 });
54509
54439
  if (!isPtmPaused) {
54510
54440
  pluginAPI.Events.eventCaptured.trigger(consoleEvent);
54511
54441
  }
@@ -54563,6 +54493,8 @@ function ConsoleCapture() {
54563
54493
  pluginAPI.Events['recording:unpaused'].off(recordingStarted);
54564
54494
  pluginAPI.Events['recording:paused'].off(recordingStopped);
54565
54495
  pluginAPI.detachEventInternal(window, 'securitypolicyviolation', securityPolicyViolationFn);
54496
+ pluginAPI.detachEventInternal(window, 'error', uncaughtErrorFn);
54497
+ pluginAPI.detachEventInternal(window, 'unhandledrejection', unhandledRejectionFn);
54566
54498
  _.each(CONSOLE_METHODS, function (methodName) {
54567
54499
  if (!console[methodName])
54568
54500
  return _.noop;