@leanbase-giangnd/js 0.3.1 → 0.4.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.
@@ -313,9 +313,9 @@ var leanbase = (function () {
313
313
  return '[object Array]' === type_utils_toString.call(obj);
314
314
  };
315
315
  const isFunction = (x)=>'function' == typeof x;
316
- const isObject = (x)=>x === Object(x) && !isArray(x);
316
+ const isObject$1 = (x)=>x === Object(x) && !isArray(x);
317
317
  const isEmptyObject = (x)=>{
318
- if (isObject(x)) {
318
+ if (isObject$1(x)) {
319
319
  for(const key in x)if (type_utils_hasOwnProperty.call(x, key)) return false;
320
320
  return true;
321
321
  }
@@ -329,6 +329,7 @@ var leanbase = (function () {
329
329
  const isNumber = (x)=>'[object Number]' == type_utils_toString.call(x);
330
330
  const isBoolean = (x)=>'[object Boolean]' === type_utils_toString.call(x);
331
331
  const isFormData = (x)=>x instanceof FormData;
332
+ const isFile = (x)=>x instanceof File;
332
333
  const isPlainError = (x)=>x instanceof Error;
333
334
 
334
335
  function clampToRange(value, min, max, logger, fallbackValue) {
@@ -1906,7 +1907,7 @@ var leanbase = (function () {
1906
1907
 
1907
1908
  /* eslint-disable no-console */
1908
1909
  const PREFIX = '[Leanbase]';
1909
- const logger$2 = {
1910
+ const logger$3 = {
1910
1911
  info: (...args) => {
1911
1912
  if (typeof console !== 'undefined') {
1912
1913
  console.log(PREFIX, ...args);
@@ -2204,7 +2205,7 @@ var leanbase = (function () {
2204
2205
  if (!matchedSubDomain) {
2205
2206
  const originalMatch = originalCookieDomainFn(hostname);
2206
2207
  if (originalMatch !== matchedSubDomain) {
2207
- logger$2.info('Warning: cookie subdomain discovery mismatch', originalMatch, matchedSubDomain);
2208
+ logger$3.info('Warning: cookie subdomain discovery mismatch', originalMatch, matchedSubDomain);
2208
2209
  }
2209
2210
  matchedSubDomain = originalMatch;
2210
2211
  }
@@ -2216,7 +2217,7 @@ var leanbase = (function () {
2216
2217
  const cookieStore = {
2217
2218
  _is_supported: () => !!document$1,
2218
2219
  _error: function (msg) {
2219
- logger$2.error('cookieStore error: ' + msg);
2220
+ logger$3.error('cookieStore error: ' + msg);
2220
2221
  },
2221
2222
  _get: function (name) {
2222
2223
  if (!document$1) {
@@ -2265,7 +2266,7 @@ var leanbase = (function () {
2265
2266
  const new_cookie_val = name + '=' + encodeURIComponent(JSON.stringify(value)) + expires + '; SameSite=Lax; path=/' + cdomain + secure;
2266
2267
  // 4096 bytes is the size at which some browsers (e.g. firefox) will not store a cookie, warn slightly before that
2267
2268
  if (new_cookie_val.length > 4096 * 0.9) {
2268
- logger$2.warn('cookieStore warning: large cookie, len=' + new_cookie_val.length);
2269
+ logger$3.warn('cookieStore warning: large cookie, len=' + new_cookie_val.length);
2269
2270
  }
2270
2271
  document$1.cookie = new_cookie_val;
2271
2272
  return new_cookie_val;
@@ -2307,13 +2308,13 @@ var leanbase = (function () {
2307
2308
  supported = false;
2308
2309
  }
2309
2310
  if (!supported) {
2310
- logger$2.error('localStorage unsupported; falling back to cookie store');
2311
+ logger$3.error('localStorage unsupported; falling back to cookie store');
2311
2312
  }
2312
2313
  _localStorage_supported = supported;
2313
2314
  return supported;
2314
2315
  },
2315
2316
  _error: function (msg) {
2316
- logger$2.error('localStorage error: ' + msg);
2317
+ logger$3.error('localStorage error: ' + msg);
2317
2318
  },
2318
2319
  _get: function (name) {
2319
2320
  try {
@@ -2399,7 +2400,7 @@ var leanbase = (function () {
2399
2400
  return true;
2400
2401
  },
2401
2402
  _error: function (msg) {
2402
- logger$2.error('memoryStorage error: ' + msg);
2403
+ logger$3.error('memoryStorage error: ' + msg);
2403
2404
  },
2404
2405
  _get: function (name) {
2405
2406
  return memoryStorage[name] || null;
@@ -2440,7 +2441,7 @@ var leanbase = (function () {
2440
2441
  return sessionStorageSupported;
2441
2442
  },
2442
2443
  _error: function (msg) {
2443
- logger$2.error('sessionStorage error: ', msg);
2444
+ logger$3.error('sessionStorage error: ', msg);
2444
2445
  },
2445
2446
  _get: function (name) {
2446
2447
  try {
@@ -2489,6 +2490,21 @@ var leanbase = (function () {
2489
2490
  location.href = url;
2490
2491
  return location;
2491
2492
  };
2493
+ const formDataToQuery = function (formdata, arg_separator = '&') {
2494
+ let use_val;
2495
+ let use_key;
2496
+ const tph_arr = [];
2497
+ each(formdata, function (val, key) {
2498
+ // the key might be literally the string undefined for e.g. if {undefined: 'something'}
2499
+ if (isUndefined(val) || isUndefined(key) || key === 'undefined') {
2500
+ return;
2501
+ }
2502
+ use_val = encodeURIComponent(isFile(val) ? val.name : val.toString());
2503
+ use_key = encodeURIComponent(key);
2504
+ tph_arr[tph_arr.length] = use_key + '=' + use_val;
2505
+ });
2506
+ return tph_arr.join(arg_separator);
2507
+ };
2492
2508
  // NOTE: Once we get rid of IE11/op_mini we can start using URLSearchParams
2493
2509
  const getQueryParam = function (url, param) {
2494
2510
  const withoutHash = url.split('#')[0] || '';
@@ -2512,7 +2528,7 @@ var leanbase = (function () {
2512
2528
  try {
2513
2529
  result = decodeURIComponent(result);
2514
2530
  } catch {
2515
- logger$2.error('Skipping decoding for malformed query param: ' + result);
2531
+ logger$3.error('Skipping decoding for malformed query param: ' + result);
2516
2532
  }
2517
2533
  return result.replace(/\+/g, ' ');
2518
2534
  }
@@ -2846,7 +2862,7 @@ var leanbase = (function () {
2846
2862
  }
2847
2863
  };
2848
2864
 
2849
- var version = "0.3.1";
2865
+ var version = "0.4.0";
2850
2866
  var packageInfo = {
2851
2867
  version: version};
2852
2868
 
@@ -3111,7 +3127,7 @@ var leanbase = (function () {
3111
3127
  this._storage = this._buildStorage(config);
3112
3128
  this.load();
3113
3129
  if (config.debug) {
3114
- logger$2.info('Persistence loaded', config['persistence'], {
3130
+ logger$3.info('Persistence loaded', config['persistence'], {
3115
3131
  ...this.props
3116
3132
  });
3117
3133
  }
@@ -3127,7 +3143,7 @@ var leanbase = (function () {
3127
3143
  }
3128
3144
  _buildStorage(config) {
3129
3145
  if (CASE_INSENSITIVE_PERSISTENCE_TYPES.indexOf(config['persistence'].toLowerCase()) === -1) {
3130
- logger$2.info('Unknown persistence type ' + config['persistence'] + '; falling back to localStorage+cookie');
3146
+ logger$3.info('Unknown persistence type ' + config['persistence'] + '; falling back to localStorage+cookie');
3131
3147
  config['persistence'] = 'localStorage+cookie';
3132
3148
  }
3133
3149
  let store;
@@ -3153,7 +3169,7 @@ var leanbase = (function () {
3153
3169
  const p = {};
3154
3170
  // Filter out reserved properties
3155
3171
  each(this.props, function (v, k) {
3156
- if (k === ENABLED_FEATURE_FLAGS && isObject(v)) {
3172
+ if (k === ENABLED_FEATURE_FLAGS && isObject$1(v)) {
3157
3173
  const keys = Object.keys(v);
3158
3174
  for (let i = 0; i < keys.length; i++) {
3159
3175
  p[`$feature/${keys[i]}`] = v[keys[i]];
@@ -3198,7 +3214,7 @@ var leanbase = (function () {
3198
3214
  * @param {number=} days
3199
3215
  */
3200
3216
  register_once(props, default_value, days) {
3201
- if (isObject(props)) {
3217
+ if (isObject$1(props)) {
3202
3218
  if (isUndefined(default_value)) {
3203
3219
  default_value = 'None';
3204
3220
  }
@@ -3222,7 +3238,7 @@ var leanbase = (function () {
3222
3238
  * @param {number=} days
3223
3239
  */
3224
3240
  register(props, days) {
3225
- if (isObject(props)) {
3241
+ if (isObject$1(props)) {
3226
3242
  this._expire_days = isUndefined(days) ? this._default_expiry : days;
3227
3243
  let hasChanges = false;
3228
3244
  each(props, (val, prop) => {
@@ -3763,7 +3779,7 @@ var leanbase = (function () {
3763
3779
  text = `${text} ${getNestedSpanText(child)}`.trim();
3764
3780
  }
3765
3781
  } catch (e) {
3766
- logger$2.error('[AutoCapture]', e);
3782
+ logger$3.error('[AutoCapture]', e);
3767
3783
  }
3768
3784
  }
3769
3785
  });
@@ -4057,7 +4073,7 @@ var leanbase = (function () {
4057
4073
  this._elementSelectors = null;
4058
4074
  }
4059
4075
  get _config() {
4060
- const config = isObject(this.instance.config.autocapture) ? this.instance.config.autocapture : {};
4076
+ const config = isObject$1(this.instance.config.autocapture) ? this.instance.config.autocapture : {};
4061
4077
  // precompile the regex
4062
4078
  config.url_allowlist = config.url_allowlist?.map(url => new RegExp(url));
4063
4079
  config.url_ignorelist = config.url_ignorelist?.map(url => new RegExp(url));
@@ -4065,7 +4081,7 @@ var leanbase = (function () {
4065
4081
  }
4066
4082
  _addDomEventHandlers() {
4067
4083
  if (!this.isBrowserSupported()) {
4068
- logger$2.info('Disabling Automatic Event Collection because this browser is not supported');
4084
+ logger$3.info('Disabling Automatic Event Collection because this browser is not supported');
4069
4085
  return;
4070
4086
  }
4071
4087
  if (!win || !document$1) {
@@ -4076,7 +4092,7 @@ var leanbase = (function () {
4076
4092
  try {
4077
4093
  this._captureEvent(e);
4078
4094
  } catch (error) {
4079
- logger$2.error('Failed to capture event', error);
4095
+ logger$3.error('Failed to capture event', error);
4080
4096
  }
4081
4097
  };
4082
4098
  addEventListener(document$1, 'submit', handler, {
@@ -4261,7 +4277,7 @@ var leanbase = (function () {
4261
4277
  this._windowIdGenerator = windowIdGenerator || uuidv7;
4262
4278
  const persistenceName = this._config['persistence_name'] || this._config['token'];
4263
4279
  const desiredTimeout = this._config['session_idle_timeout_seconds'] || DEFAULT_SESSION_IDLE_TIMEOUT_SECONDS;
4264
- this._sessionTimeoutMs = clampToRange(desiredTimeout, MIN_SESSION_IDLE_TIMEOUT_SECONDS, MAX_SESSION_IDLE_TIMEOUT_SECONDS, logger$2, DEFAULT_SESSION_IDLE_TIMEOUT_SECONDS) * 1000;
4280
+ this._sessionTimeoutMs = clampToRange(desiredTimeout, MIN_SESSION_IDLE_TIMEOUT_SECONDS, MAX_SESSION_IDLE_TIMEOUT_SECONDS, logger$3, DEFAULT_SESSION_IDLE_TIMEOUT_SECONDS) * 1000;
4265
4281
  instance.register({
4266
4282
  $configured_session_timeout_ms: this._sessionTimeoutMs
4267
4283
  });
@@ -4288,7 +4304,7 @@ var leanbase = (function () {
4288
4304
  const sessionStartTimestamp = uuid7ToTimestampMs(this._config.bootstrap.sessionID);
4289
4305
  this._setSessionId(this._config.bootstrap.sessionID, new Date().getTime(), sessionStartTimestamp);
4290
4306
  } catch (e) {
4291
- logger$2.error('Invalid sessionID in bootstrap', e);
4307
+ logger$3.error('Invalid sessionID in bootstrap', e);
4292
4308
  }
4293
4309
  }
4294
4310
  this._listenToReloadWindow();
@@ -4429,7 +4445,7 @@ var leanbase = (function () {
4429
4445
  if (noSessionId || activityTimeout || sessionPastMaximumLength) {
4430
4446
  sessionId = this._sessionIdGenerator();
4431
4447
  windowId = this._windowIdGenerator();
4432
- logger$2.info('new session ID generated', {
4448
+ logger$3.info('new session ID generated', {
4433
4449
  sessionId,
4434
4450
  windowId,
4435
4451
  changeReason: {
@@ -4618,10 +4634,10 @@ var leanbase = (function () {
4618
4634
  lastContentY = Math.ceil(lastContentY);
4619
4635
  maxContentY = Math.ceil(maxContentY);
4620
4636
  // if the maximum scroll height is near 0, then the percentage is 1
4621
- const lastScrollPercentage = maxScrollHeight <= 1 ? 1 : clampToRange(lastScrollY / maxScrollHeight, 0, 1, logger$2);
4622
- const maxScrollPercentage = maxScrollHeight <= 1 ? 1 : clampToRange(maxScrollY / maxScrollHeight, 0, 1, logger$2);
4623
- const lastContentPercentage = maxContentHeight <= 1 ? 1 : clampToRange(lastContentY / maxContentHeight, 0, 1, logger$2);
4624
- const maxContentPercentage = maxContentHeight <= 1 ? 1 : clampToRange(maxContentY / maxContentHeight, 0, 1, logger$2);
4637
+ const lastScrollPercentage = maxScrollHeight <= 1 ? 1 : clampToRange(lastScrollY / maxScrollHeight, 0, 1, logger$3);
4638
+ const maxScrollPercentage = maxScrollHeight <= 1 ? 1 : clampToRange(maxScrollY / maxScrollHeight, 0, 1, logger$3);
4639
+ const lastContentPercentage = maxContentHeight <= 1 ? 1 : clampToRange(lastContentY / maxContentHeight, 0, 1, logger$3);
4640
+ const maxContentPercentage = maxContentHeight <= 1 ? 1 : clampToRange(maxContentY / maxContentHeight, 0, 1, logger$3);
4625
4641
  properties = extend(properties, {
4626
4642
  $prev_pageview_last_scroll: lastScrollY,
4627
4643
  $prev_pageview_last_scroll_percentage: lastScrollPercentage,
@@ -4886,17 +4902,17 @@ var leanbase = (function () {
4886
4902
 
4887
4903
  const _createLogger = prefix => {
4888
4904
  return {
4889
- info: (...args) => logger$2.info(prefix, ...args),
4890
- warn: (...args) => logger$2.warn(prefix, ...args),
4891
- error: (...args) => logger$2.error(prefix, ...args),
4892
- critical: (...args) => logger$2.critical(prefix, ...args),
4905
+ info: (...args) => logger$3.info(prefix, ...args),
4906
+ warn: (...args) => logger$3.warn(prefix, ...args),
4907
+ error: (...args) => logger$3.error(prefix, ...args),
4908
+ critical: (...args) => logger$3.critical(prefix, ...args),
4893
4909
  uninitializedWarning: methodName => {
4894
- logger$2.error(prefix, `You must initialize Leanbase before calling ${methodName}`);
4910
+ logger$3.error(prefix, `You must initialize Leanbase before calling ${methodName}`);
4895
4911
  },
4896
4912
  createLogger: additionalPrefix => _createLogger(`${prefix} ${additionalPrefix}`)
4897
4913
  };
4898
4914
  };
4899
- const logger$1 = _createLogger('[Leanbase]');
4915
+ const logger$2 = _createLogger('[Leanbase]');
4900
4916
  const createLogger = _createLogger;
4901
4917
 
4902
4918
  const LOGGER_PREFIX$2 = '[SessionRecording]';
@@ -4970,7 +4986,7 @@ var leanbase = (function () {
4970
4986
  // people can have arbitrarily large payloads on their site, but we don't want to ingest them
4971
4987
  const limitPayloadSize = options => {
4972
4988
  // the smallest of 1MB or the specified limit if there is one
4973
- const limit = Math.min(1000000, options.payloadSizeLimitBytes);
4989
+ const limit = Math.min(1000000, options.payloadSizeLimitBytes ?? 1000000);
4974
4990
  return data => {
4975
4991
  if (data?.requestBody) {
4976
4992
  data.requestBody = enforcePayloadSizeLimit(data.requestBody, data.requestHeaders, limit, 'Request');
@@ -5028,7 +5044,7 @@ var leanbase = (function () {
5028
5044
  const enforcedCleaningFn = d => payloadLimiter(ignorePostHogPaths(removeAuthorizationHeader(d), instanceConfig.host || ''));
5029
5045
  const hasDeprecatedMaskFunction = isFunction(sessionRecordingConfig.maskNetworkRequestFn);
5030
5046
  if (hasDeprecatedMaskFunction && isFunction(sessionRecordingConfig.maskCapturedNetworkRequestFn)) {
5031
- logger$1.warn('Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored.');
5047
+ logger$2.warn('Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored.');
5032
5048
  }
5033
5049
  if (hasDeprecatedMaskFunction) {
5034
5050
  sessionRecordingConfig.maskCapturedNetworkRequestFn = data => {
@@ -5136,8 +5152,8 @@ var leanbase = (function () {
5136
5152
  this.urlBlocked = false;
5137
5153
  }
5138
5154
  onConfig(config) {
5139
- this._urlTriggers = (isEagerLoadedConfig(config) ? isObject(config.sessionRecording) ? config.sessionRecording?.urlTriggers : [] : config?.urlTriggers) || [];
5140
- this._urlBlocklist = (isEagerLoadedConfig(config) ? isObject(config.sessionRecording) ? config.sessionRecording?.urlBlocklist : [] : config?.urlBlocklist) || [];
5155
+ this._urlTriggers = (isEagerLoadedConfig(config) ? isObject$1(config.sessionRecording) ? config.sessionRecording?.urlTriggers : [] : config?.urlTriggers) || [];
5156
+ this._urlBlocklist = (isEagerLoadedConfig(config) ? isObject$1(config.sessionRecording) ? config.sessionRecording?.urlBlocklist : [] : config?.urlBlocklist) || [];
5141
5157
  }
5142
5158
  /**
5143
5159
  * @deprecated Use onConfig instead
@@ -5206,12 +5222,12 @@ var leanbase = (function () {
5206
5222
  return result;
5207
5223
  }
5208
5224
  onConfig(config, onStarted) {
5209
- this.linkedFlag = (isEagerLoadedConfig(config) ? isObject(config.sessionRecording) ? config.sessionRecording?.linkedFlag : null : config?.linkedFlag) || null;
5225
+ this.linkedFlag = (isEagerLoadedConfig(config) ? isObject$1(config.sessionRecording) ? config.sessionRecording?.linkedFlag : null : config?.linkedFlag) || null;
5210
5226
  if (!isNullish(this.linkedFlag) && !this.linkedFlagSeen) {
5211
5227
  const linkedFlag = isString(this.linkedFlag) ? this.linkedFlag : this.linkedFlag.flag;
5212
5228
  const linkedVariant = isString(this.linkedFlag) ? null : this.linkedFlag.variant;
5213
5229
  this._flagListenerCleanup = this._instance.onFeatureFlags(flags => {
5214
- const flagIsPresent = isObject(flags) && linkedFlag in flags;
5230
+ const flagIsPresent = isObject$1(flags) && linkedFlag in flags;
5215
5231
  let linkedFlagMatches = false;
5216
5232
  if (flagIsPresent) {
5217
5233
  const variantForFlagKey = flags[linkedFlag];
@@ -5247,7 +5263,7 @@ var leanbase = (function () {
5247
5263
  this._eventTriggers = [];
5248
5264
  }
5249
5265
  onConfig(config) {
5250
- this._eventTriggers = (isEagerLoadedConfig(config) ? isObject(config.sessionRecording) ? config.sessionRecording?.eventTriggers : [] : config?.eventTriggers) || [];
5266
+ this._eventTriggers = (isEagerLoadedConfig(config) ? isObject$1(config.sessionRecording) ? config.sessionRecording?.eventTriggers : [] : config?.eventTriggers) || [];
5251
5267
  }
5252
5268
  /**
5253
5269
  * @deprecated Use onConfig instead
@@ -5346,7 +5362,7 @@ var leanbase = (function () {
5346
5362
  function circularReferenceReplacer() {
5347
5363
  const ancestors = [];
5348
5364
  return function (_key, value) {
5349
- if (isObject(value)) {
5365
+ if (isObject$1(value)) {
5350
5366
  // `this` is the object that value is contained in,
5351
5367
  // i.e., its direct parent.
5352
5368
  while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) {
@@ -5377,7 +5393,7 @@ var leanbase = (function () {
5377
5393
  const event = _event;
5378
5394
  const MAX_STRING_SIZE = 2000; // Maximum number of characters allowed in a string
5379
5395
  const MAX_STRINGS_PER_LOG = 10; // A log can consist of multiple strings (e.g. consol.log('string1', 'string2'))
5380
- if (event && isObject(event) && event.type === PLUGIN_EVENT_TYPE && isObject(event.data) && event.data.plugin === CONSOLE_LOG_PLUGIN_NAME) {
5396
+ if (event && isObject$1(event) && event.type === PLUGIN_EVENT_TYPE && isObject$1(event.data) && event.data.plugin === CONSOLE_LOG_PLUGIN_NAME) {
5381
5397
  // Note: event.data.payload.payload comes from rr-web, and is an array of strings
5382
5398
  if (event.data.payload.payload.length > MAX_STRINGS_PER_LOG) {
5383
5399
  event.data.payload.payload = event.data.payload.payload.slice(0, MAX_STRINGS_PER_LOG);
@@ -5441,7 +5457,7 @@ var leanbase = (function () {
5441
5457
  }
5442
5458
  return [b, r];
5443
5459
  };
5444
- var _a$1 = freb(fleb, 2), fl = _a$1[0], revfl = _a$1[1];
5460
+ var _a$2 = freb(fleb, 2), fl = _a$2[0], revfl = _a$2[1];
5445
5461
  // we can ignore the fact that the other numbers are wrong; they never happen anyway
5446
5462
  fl[28] = 258, revfl[258] = 28;
5447
5463
  var _b = freb(fdeb, 0), revfd = _b[1];
@@ -6059,7 +6075,7 @@ var leanbase = (function () {
6059
6075
  refillInterval: 1000,
6060
6076
  // one second
6061
6077
  _onBucketRateLimited: this._onNodeRateLimited,
6062
- _logger: logger$1
6078
+ _logger: logger$2
6063
6079
  });
6064
6080
  }
6065
6081
  reset() {
@@ -6083,7 +6099,7 @@ var leanbase = (function () {
6083
6099
  * receives percent as a number between 0 and 1
6084
6100
  */
6085
6101
  function sampleOnProperty(prop, percent) {
6086
- return simpleHash(prop) % 100 < clampToRange(percent * 100, 0, 100, logger$1);
6102
+ return simpleHash(prop) % 100 < clampToRange(percent * 100, 0, 100, logger$2);
6087
6103
  }
6088
6104
 
6089
6105
  /* eslint-disable posthog-js/no-direct-function-check */
@@ -6114,7 +6130,7 @@ var leanbase = (function () {
6114
6130
  const RECORDING_BUFFER_TIMEOUT = 2000; // 2 seconds
6115
6131
  const SESSION_RECORDING_BATCH_KEY = 'recordings';
6116
6132
  const LOGGER_PREFIX$1 = '[SessionRecording]';
6117
- const logger = createLogger(LOGGER_PREFIX$1);
6133
+ const logger$1 = createLogger(LOGGER_PREFIX$1);
6118
6134
  const ACTIVE_SOURCES = [IncrementalSource$1.MouseMove, IncrementalSource$1.MouseInteraction, IncrementalSource$1.Scroll, IncrementalSource$1.ViewportResize, IncrementalSource$1.Input, IncrementalSource$1.TouchMove, IncrementalSource$1.MediaInteraction, IncrementalSource$1.Drag];
6119
6135
  const newQueuedEvent = rrwebMethod => ({
6120
6136
  rrwebMethod,
@@ -6163,7 +6179,7 @@ var leanbase = (function () {
6163
6179
  return rr;
6164
6180
  }
6165
6181
  } catch (e) {
6166
- logger.error('could not dynamically load rrweb', e);
6182
+ logger$1.error('could not dynamically load rrweb', e);
6167
6183
  }
6168
6184
  return null;
6169
6185
  }
@@ -6210,7 +6226,7 @@ var leanbase = (function () {
6210
6226
  };
6211
6227
  }
6212
6228
  } catch (e) {
6213
- logger.error('could not compress event - will use uncompressed event', e);
6229
+ logger$1.error('could not compress event - will use uncompressed event', e);
6214
6230
  }
6215
6231
  return event;
6216
6232
  }
@@ -6247,6 +6263,11 @@ var leanbase = (function () {
6247
6263
  }
6248
6264
  }
6249
6265
  class LazyLoadedSessionRecording {
6266
+ _debug(...args) {
6267
+ if (this._instance?.config?.debug) {
6268
+ logger$1.info(...args);
6269
+ }
6270
+ }
6250
6271
  get sessionId() {
6251
6272
  return this._sessionId;
6252
6273
  }
@@ -6261,9 +6282,9 @@ var leanbase = (function () {
6261
6282
  if (!this._loggedPermanentlyDisabled) {
6262
6283
  this._loggedPermanentlyDisabled = true;
6263
6284
  if (error) {
6264
- logger.error(`replay disabled: ${reason}`, error);
6285
+ logger$1.error(`replay disabled: ${reason}`, error);
6265
6286
  } else {
6266
- logger.error(`replay disabled: ${reason}`);
6287
+ logger$1.error(`replay disabled: ${reason}`);
6267
6288
  }
6268
6289
  }
6269
6290
  }
@@ -6300,6 +6321,7 @@ var leanbase = (function () {
6300
6321
  this._stopRrweb = undefined;
6301
6322
  this._permanentlyDisabled = false;
6302
6323
  this._loggedPermanentlyDisabled = false;
6324
+ this._hasReportedRecordingInitialized = false;
6303
6325
  this._lastActivityTimestamp = Date.now();
6304
6326
  /**
6305
6327
  * and a queue - that contains rrweb events that we want to send to rrweb, but rrweb wasn't able to accept them yet
@@ -6362,7 +6384,7 @@ var leanbase = (function () {
6362
6384
  this._eventTriggerMatching = new EventTriggerMatching(this._instance);
6363
6385
  this._buffer = this._clearBuffer();
6364
6386
  if (this._sessionIdleThresholdMilliseconds >= this._sessionManager.sessionTimeoutMs) {
6365
- logger.warn(`session_idle_threshold_ms (${this._sessionIdleThresholdMilliseconds}) is greater than the session timeout (${this._sessionManager.sessionTimeoutMs}). Session will never be detected as idle`);
6387
+ logger$1.warn(`session_idle_threshold_ms (${this._sessionIdleThresholdMilliseconds}) is greater than the session timeout (${this._sessionManager.sessionTimeoutMs}). Session will never be detected as idle`);
6366
6388
  }
6367
6389
  }
6368
6390
  get _masking() {
@@ -6413,12 +6435,12 @@ var leanbase = (function () {
6413
6435
  const headersOptIn = networkPayloadCapture_client_side?.recordHeaders === true;
6414
6436
  const bodyOptIn = networkPayloadCapture_client_side?.recordBody === true;
6415
6437
  const clientPerformanceConfig = this._instance.config.capture_performance;
6416
- const clientPerformanceOptIn = isObject(clientPerformanceConfig) ? !!clientPerformanceConfig.network_timing : !!clientPerformanceConfig;
6438
+ const clientPerformanceOptIn = isObject$1(clientPerformanceConfig) ? !!clientPerformanceConfig.network_timing : !!clientPerformanceConfig;
6417
6439
  const serverAllowsHeaders = networkPayloadCapture_server_side?.recordHeaders ?? true;
6418
6440
  const serverAllowsBody = networkPayloadCapture_server_side?.recordBody ?? true;
6419
6441
  const capturePerfResponse = networkPayloadCapture_server_side?.capturePerformance;
6420
6442
  const serverAllowsPerformance = (() => {
6421
- if (isObject(capturePerfResponse)) {
6443
+ if (isObject$1(capturePerfResponse)) {
6422
6444
  return !!capturePerfResponse.network_timing;
6423
6445
  }
6424
6446
  return capturePerfResponse ?? true;
@@ -6436,25 +6458,62 @@ var leanbase = (function () {
6436
6458
  payloadHostDenyList: networkPayloadCapture_server_side?.payloadHostDenyList
6437
6459
  };
6438
6460
  }
6439
- _gatherRRWebPlugins() {
6461
+ async _loadConsolePlugin() {
6462
+ try {
6463
+ const mod = await Promise.resolve().then(function () { return rrwebPluginConsoleRecord; });
6464
+ const factory = mod?.getRecordConsolePlugin ?? mod?.default?.getRecordConsolePlugin;
6465
+ if (typeof factory === 'function') {
6466
+ const plugin = factory();
6467
+ this._debug('Console plugin loaded');
6468
+ return plugin;
6469
+ }
6470
+ logger$1.warn('console plugin factory unavailable after import');
6471
+ } catch (e) {
6472
+ logger$1.warn('could not load console plugin', e);
6473
+ }
6474
+ return null;
6475
+ }
6476
+ async _loadNetworkPlugin(networkPayloadCapture) {
6477
+ try {
6478
+ const mod = await Promise.resolve().then(function () { return networkPlugin; });
6479
+ const factory = mod?.getRecordNetworkPlugin ?? mod?.default?.getRecordNetworkPlugin;
6480
+ if (typeof factory === 'function') {
6481
+ const options = buildNetworkRequestOptions(this._instance.config, networkPayloadCapture);
6482
+ const plugin = factory(options);
6483
+ this._debug('Network plugin loaded');
6484
+ return plugin;
6485
+ }
6486
+ logger$1.warn('network plugin factory unavailable after import');
6487
+ } catch (e) {
6488
+ logger$1.warn('could not load network plugin', e);
6489
+ }
6490
+ return null;
6491
+ }
6492
+ async _gatherRRWebPlugins() {
6440
6493
  const plugins = [];
6494
+ if (!win) {
6495
+ return plugins;
6496
+ }
6441
6497
  if (this._isConsoleLogCaptureEnabled) {
6442
- logger.info('Console log capture requested but console plugin is not bundled in this build yet.');
6498
+ const consolePlugin = await this._loadConsolePlugin();
6499
+ if (consolePlugin) {
6500
+ plugins.push(consolePlugin);
6501
+ }
6443
6502
  }
6444
6503
  if (this._networkPayloadCapture) {
6445
6504
  const canRecordNetwork = !isLocalhost() || this._forceAllowLocalhostNetworkCapture;
6446
6505
  if (canRecordNetwork) {
6447
- const assignableWindow = globalThis;
6448
- const networkFactory = assignableWindow.__PosthogExtensions__?.rrwebPlugins?.getRecordNetworkPlugin?.();
6449
- if (typeof networkFactory === 'function') {
6450
- plugins.push(networkFactory(buildNetworkRequestOptions(this._instance.config, this._networkPayloadCapture)));
6451
- } else {
6452
- logger.info('Network plugin factory not available yet; skipping network plugin');
6506
+ const networkPlugin = await this._loadNetworkPlugin(this._networkPayloadCapture);
6507
+ if (networkPlugin) {
6508
+ plugins.push(networkPlugin);
6453
6509
  }
6454
6510
  } else {
6455
- logger.info('NetworkCapture not started because we are on localhost.');
6511
+ this._debug('NetworkCapture not started because we are on localhost.');
6456
6512
  }
6457
6513
  }
6514
+ if (plugins.length > 0) {
6515
+ this._debug('Replay plugins loaded', plugins.map(p => p.name));
6516
+ }
6458
6517
  return plugins;
6459
6518
  }
6460
6519
  _maskUrl(url) {
@@ -6483,7 +6542,7 @@ var leanbase = (function () {
6483
6542
  rrwebMethod: queuedRRWebEvent.rrwebMethod
6484
6543
  });
6485
6544
  } else {
6486
- logger.warn('could not emit queued rrweb event.', e, queuedRRWebEvent);
6545
+ logger$1.warn('could not emit queued rrweb event.', e, queuedRRWebEvent);
6487
6546
  }
6488
6547
  return false;
6489
6548
  }
@@ -6595,7 +6654,7 @@ var leanbase = (function () {
6595
6654
  this._urlTriggerMatching.urlBlocked = true;
6596
6655
  // Clear the snapshot timer since we don't want new snapshots while paused
6597
6656
  clearInterval(this._fullSnapshotTimer);
6598
- logger.info('recording paused due to URL blocker');
6657
+ logger$1.info('recording paused due to URL blocker');
6599
6658
  this._tryAddCustomEvent('recording paused', {
6600
6659
  reason: 'url blocker'
6601
6660
  });
@@ -6614,7 +6673,7 @@ var leanbase = (function () {
6614
6673
  this._tryAddCustomEvent('recording resumed', {
6615
6674
  reason: 'left blocked url'
6616
6675
  });
6617
- logger.info('recording resumed');
6676
+ logger$1.info('recording resumed');
6618
6677
  }
6619
6678
  _activateTrigger(triggerType) {
6620
6679
  if (!this.isStarted || !this._recording || !this._isFullyReady) {
@@ -6637,7 +6696,7 @@ var leanbase = (function () {
6637
6696
  if (!persistedConfig) {
6638
6697
  return undefined;
6639
6698
  }
6640
- const parsedConfig = isObject(persistedConfig) ? persistedConfig : JSON.parse(persistedConfig);
6699
+ const parsedConfig = isObject$1(persistedConfig) ? persistedConfig : JSON.parse(persistedConfig);
6641
6700
  return parsedConfig;
6642
6701
  }
6643
6702
  async start(startReason) {
@@ -6647,7 +6706,7 @@ var leanbase = (function () {
6647
6706
  this._isFullyReady = false;
6648
6707
  const config = this._remoteConfig;
6649
6708
  if (!config) {
6650
- logger.info('remote config must be stored in persistence before recording can start');
6709
+ logger$1.info('remote config must be stored in persistence before recording can start');
6651
6710
  return;
6652
6711
  }
6653
6712
  // We want to ensure the sessionManager is reset if necessary on loading the recorder
@@ -6730,12 +6789,18 @@ var leanbase = (function () {
6730
6789
  });
6731
6790
  }
6732
6791
  } catch (e) {
6733
- logger.error('Could not add $pageview to rrweb session', e);
6792
+ logger$1.error('Could not add $pageview to rrweb session', e);
6734
6793
  }
6735
6794
  });
6736
6795
  }
6737
6796
  if (this.status === ACTIVE) {
6738
- this._reportStarted(startReason || 'recording_initialized');
6797
+ const reason = startReason || 'recording_initialized';
6798
+ if (reason !== 'recording_initialized' || !this._hasReportedRecordingInitialized) {
6799
+ if (reason === 'recording_initialized') {
6800
+ this._hasReportedRecordingInitialized = true;
6801
+ }
6802
+ this._reportStarted(reason);
6803
+ }
6739
6804
  }
6740
6805
  }
6741
6806
  stop() {
@@ -6768,17 +6833,31 @@ var leanbase = (function () {
6768
6833
  this._recording = undefined;
6769
6834
  this._stopRrweb = undefined;
6770
6835
  this._isFullyReady = false;
6771
- logger.info('stopped');
6836
+ this._hasReportedRecordingInitialized = false;
6837
+ logger$1.info('stopped');
6772
6838
  }
6773
6839
  _snapshotIngestionUrl() {
6774
6840
  const endpointFor = this._instance?.requestRouter?.endpointFor;
6775
- if (typeof endpointFor !== 'function') {
6841
+ // Prefer requestRouter (parity with Browser SDK)
6842
+ if (typeof endpointFor === 'function') {
6843
+ try {
6844
+ return endpointFor('api', this._endpoint);
6845
+ } catch {
6846
+ return null;
6847
+ }
6848
+ }
6849
+ // Fallback: construct from host/api_host if requestRouter is unavailable (older IIFE builds)
6850
+ const host = (this._instance.config.api_host || this._instance.config.host || '').trim();
6851
+ if (!host) {
6776
6852
  return null;
6777
6853
  }
6778
6854
  try {
6779
- return endpointFor('api', this._endpoint);
6855
+ // eslint-disable-next-line compat/compat
6856
+ return new URL(this._endpoint, host).href;
6780
6857
  } catch {
6781
- return null;
6858
+ const normalizedHost = host.endsWith('/') ? host.slice(0, -1) : host;
6859
+ const normalizedEndpoint = this._endpoint.startsWith('/') ? this._endpoint : `/${this._endpoint}`;
6860
+ return `${normalizedHost}${normalizedEndpoint}`;
6782
6861
  }
6783
6862
  }
6784
6863
  _canCaptureSnapshots() {
@@ -6795,7 +6874,7 @@ var leanbase = (function () {
6795
6874
  }
6796
6875
  try {
6797
6876
  this._processQueuedEvents();
6798
- if (!rawEvent || !isObject(rawEvent)) {
6877
+ if (!rawEvent || !isObject$1(rawEvent)) {
6799
6878
  return;
6800
6879
  }
6801
6880
  if (rawEvent.type === EventType$1.Meta) {
@@ -6863,7 +6942,7 @@ var leanbase = (function () {
6863
6942
  }
6864
6943
  this._captureSnapshotBuffered(properties);
6865
6944
  } catch (e) {
6866
- logger.error('error processing rrweb event', e);
6945
+ logger$1.error('error processing rrweb event', e);
6867
6946
  }
6868
6947
  }
6869
6948
  get status() {
@@ -6954,7 +7033,7 @@ var leanbase = (function () {
6954
7033
  if (!this._canCaptureSnapshots()) {
6955
7034
  if (!this._loggedMissingEndpointFor) {
6956
7035
  this._loggedMissingEndpointFor = true;
6957
- logger.warn('snapshot capture skipped because requestRouter.endpointFor is unavailable');
7036
+ logger$1.warn('snapshot capture skipped because requestRouter.endpointFor is unavailable');
6958
7037
  }
6959
7038
  this._flushBufferTimer = setTimeout(() => {
6960
7039
  this._flushBuffer();
@@ -6997,7 +7076,7 @@ var leanbase = (function () {
6997
7076
  if (!url) {
6998
7077
  if (!this._loggedMissingEndpointFor) {
6999
7078
  this._loggedMissingEndpointFor = true;
7000
- logger.warn('snapshot capture skipped because requestRouter.endpointFor is unavailable');
7079
+ logger$1.warn('snapshot capture skipped because requestRouter.endpointFor is unavailable');
7001
7080
  }
7002
7081
  return;
7003
7082
  }
@@ -7010,7 +7089,7 @@ var leanbase = (function () {
7010
7089
  skip_client_rate_limiting: true
7011
7090
  });
7012
7091
  } catch (e) {
7013
- logger.error('failed to capture snapshot', e);
7092
+ logger$1.error('failed to capture snapshot', e);
7014
7093
  }
7015
7094
  }
7016
7095
  _snapshotUrl() {
@@ -7067,7 +7146,12 @@ var leanbase = (function () {
7067
7146
  this._instance.registerForSession({
7068
7147
  $session_recording_start_reason: startReason
7069
7148
  });
7070
- logger.info(startReason.replace('_', ' '), tagPayload);
7149
+ const message = startReason.replace('_', ' ');
7150
+ if (typeof tagPayload === 'undefined') {
7151
+ logger$1.info(message);
7152
+ } else {
7153
+ logger$1.info(message, tagPayload);
7154
+ }
7071
7155
  if (!includes(['recording_initialized', 'session_id_changed'], startReason)) {
7072
7156
  this._tryAddCustomEvent(startReason, tagPayload);
7073
7157
  }
@@ -7167,7 +7251,7 @@ var leanbase = (function () {
7167
7251
  if (shouldSample) {
7168
7252
  this._reportStarted(SAMPLED);
7169
7253
  } else {
7170
- logger.warn(`Sample rate (${currentSampleRate}) has determined that this sessionId (${sessionId}) will not be sent to the server.`);
7254
+ logger$1.warn(`Sample rate (${currentSampleRate}) has determined that this sessionId (${sessionId}) will not be sent to the server.`);
7171
7255
  }
7172
7256
  this._tryAddCustomEvent('samplingDecisionMade', {
7173
7257
  sampleRate: currentSampleRate,
@@ -7190,7 +7274,7 @@ var leanbase = (function () {
7190
7274
  this._activateTrigger('event');
7191
7275
  }
7192
7276
  } catch (e) {
7193
- logger.error('Could not activate event trigger', e);
7277
+ logger$1.error('Could not activate event trigger', e);
7194
7278
  }
7195
7279
  });
7196
7280
  }
@@ -7272,7 +7356,7 @@ var leanbase = (function () {
7272
7356
  this._disablePermanently('rrweb record function unavailable');
7273
7357
  return;
7274
7358
  }
7275
- const activePlugins = this._gatherRRWebPlugins();
7359
+ const activePlugins = await this._gatherRRWebPlugins();
7276
7360
  let stopHandler;
7277
7361
  try {
7278
7362
  stopHandler = rrwebRecord({
@@ -7281,7 +7365,7 @@ var leanbase = (function () {
7281
7365
  this.onRRwebEmit(event);
7282
7366
  } catch (e) {
7283
7367
  // never throw from rrweb emit handler
7284
- logger.error('error in rrweb emit handler', e);
7368
+ logger$1.error('error in rrweb emit handler', e);
7285
7369
  }
7286
7370
  },
7287
7371
  plugins: activePlugins,
@@ -7306,7 +7390,7 @@ var leanbase = (function () {
7306
7390
  bucketSize: this._instance.config.session_recording?.__mutationThrottlerBucketSize,
7307
7391
  onBlockedNode: (id, node) => {
7308
7392
  const message = `Too many mutations on node '${id}'. Rate limiting. This could be due to SVG animations or something similar`;
7309
- logger.info(message, {
7393
+ logger$1.info(message, {
7310
7394
  node: node
7311
7395
  });
7312
7396
  this.log(LOGGER_PREFIX$1 + ' ' + message, 'warn');
@@ -7333,11 +7417,16 @@ var leanbase = (function () {
7333
7417
  /* eslint-disable posthog-js/no-direct-function-check */
7334
7418
  const LOGGER_PREFIX = '[SessionRecording]';
7335
7419
  const log = {
7336
- info: (...args) => logger$2.info(LOGGER_PREFIX, ...args),
7337
- warn: (...args) => logger$2.warn(LOGGER_PREFIX, ...args),
7338
- error: (...args) => logger$2.error(LOGGER_PREFIX, ...args)
7420
+ info: (...args) => logger$3.info(LOGGER_PREFIX, ...args),
7421
+ warn: (...args) => logger$3.warn(LOGGER_PREFIX, ...args),
7422
+ error: (...args) => logger$3.error(LOGGER_PREFIX, ...args)
7339
7423
  };
7340
7424
  class SessionRecording {
7425
+ _debug(...args) {
7426
+ if (this._instance?.config?.debug) {
7427
+ log.info(...args);
7428
+ }
7429
+ }
7341
7430
  get started() {
7342
7431
  return !!this._lazyLoadedSessionRecording?.isStarted;
7343
7432
  }
@@ -7375,8 +7464,10 @@ var leanbase = (function () {
7375
7464
  }
7376
7465
  const canRunReplay = !isUndefined(Object.assign) && !isUndefined(Array.from);
7377
7466
  if (this._isRecordingEnabled && canRunReplay) {
7467
+ this._debug('Session replay enabled; starting recorder');
7378
7468
  this._lazyLoadAndStart(startReason);
7379
7469
  } else {
7470
+ this._debug('Session replay disabled; stopping recorder');
7380
7471
  this.stopRecording();
7381
7472
  }
7382
7473
  }
@@ -7448,18 +7539,15 @@ var leanbase = (function () {
7448
7539
  log.info('skipping remote config with no sessionRecording', response);
7449
7540
  return;
7450
7541
  }
7451
- this._receivedFlags = true;
7452
- if (response.sessionRecording === false) {
7453
- return;
7454
- }
7455
7542
  this._persistRemoteConfig(response);
7543
+ this._receivedFlags = true;
7456
7544
  this.startIfEnabledOrStop();
7457
7545
  }
7458
7546
  log(message, level = 'log') {
7459
7547
  if (this._lazyLoadedSessionRecording?.log) {
7460
7548
  this._lazyLoadedSessionRecording.log(message, level);
7461
7549
  } else {
7462
- logger$2.warn('log called before recorder was ready');
7550
+ logger$3.warn('log called before recorder was ready');
7463
7551
  }
7464
7552
  }
7465
7553
  get _scriptName() {
@@ -7482,10 +7570,10 @@ var leanbase = (function () {
7482
7570
  try {
7483
7571
  const maybePromise = this._lazyLoadedSessionRecording.start(startReason);
7484
7572
  if (maybePromise && typeof maybePromise.catch === 'function') {
7485
- maybePromise.catch(e => logger$2.error('error starting session recording', e));
7573
+ maybePromise.catch(e => logger$3.error('error starting session recording', e));
7486
7574
  }
7487
7575
  } catch (e) {
7488
- logger$2.error('error starting session recording', e);
7576
+ logger$3.error('error starting session recording', e);
7489
7577
  }
7490
7578
  return;
7491
7579
  }
@@ -7498,10 +7586,10 @@ var leanbase = (function () {
7498
7586
  try {
7499
7587
  const maybePromise = this._lazyLoadedSessionRecording.start(startReason);
7500
7588
  if (maybePromise && typeof maybePromise.catch === 'function') {
7501
- maybePromise.catch(e => logger$2.error('error starting session recording', e));
7589
+ maybePromise.catch(e => logger$3.error('error starting session recording', e));
7502
7590
  }
7503
7591
  } catch (e) {
7504
- logger$2.error('error starting session recording', e);
7592
+ logger$3.error('error starting session recording', e);
7505
7593
  }
7506
7594
  }
7507
7595
  /**
@@ -7534,6 +7622,39 @@ var leanbase = (function () {
7534
7622
  }
7535
7623
  }
7536
7624
 
7625
+ /**
7626
+ * Leanbase-local version of PostHog's RequestRouter.
7627
+ *
7628
+ * Browser SDK always has a requestRouter instance; Leanbase IIFE needs this too so
7629
+ * features like Session Replay can construct ingestion URLs.
7630
+ */
7631
+ class RequestRouter {
7632
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7633
+ constructor(instance) {
7634
+ this.instance = instance;
7635
+ }
7636
+ get apiHost() {
7637
+ const configured = (this.instance.config.api_host || this.instance.config.host || '').trim();
7638
+ return configured.replace(/\/$/, '');
7639
+ }
7640
+ get uiHost() {
7641
+ const configured = this.instance.config.ui_host?.trim().replace(/\/$/, '');
7642
+ return configured || undefined;
7643
+ }
7644
+ endpointFor(target, path = '') {
7645
+ if (path) {
7646
+ path = path[0] === '/' ? path : `/${path}`;
7647
+ }
7648
+ if (target === 'ui') {
7649
+ const host = this.uiHost || this.apiHost;
7650
+ return host + path;
7651
+ }
7652
+ // Leanbase doesn't currently do region-based routing; default to apiHost.
7653
+ // Browser's router has special handling for assets; we keep parity in interface, not domains.
7654
+ return this.apiHost + path;
7655
+ }
7656
+ }
7657
+
7537
7658
  const defaultConfig = () => ({
7538
7659
  host: 'https://i.leanbase.co',
7539
7660
  token: '',
@@ -7591,6 +7712,8 @@ var leanbase = (function () {
7591
7712
  }));
7592
7713
  this.isLoaded = true;
7593
7714
  this.persistence = new LeanbasePersistence(this.config);
7715
+ // Browser SDK always has a requestRouter; session replay relies on it for $snapshot ingestion URLs.
7716
+ this.requestRouter = new RequestRouter(this);
7594
7717
  if (this.config.cookieless_mode !== 'always') {
7595
7718
  this.sessionManager = new SessionIdManager(this);
7596
7719
  this.sessionPropsManager = new SessionPropsManager(this, this.sessionManager, this.persistence);
@@ -7623,12 +7746,12 @@ var leanbase = (function () {
7623
7746
  }, 1);
7624
7747
  }
7625
7748
  const triggerRemoteConfigLoad = reason => {
7626
- logger$2.info(`remote config load triggered via ${reason}`);
7749
+ logger$3.info(`remote config load triggered via ${reason}`);
7627
7750
  void this.loadRemoteConfig();
7628
7751
  };
7629
7752
  if (document$1) {
7630
7753
  if (document$1.readyState === 'loading') {
7631
- logger$2.info('remote config load deferred until DOMContentLoaded');
7754
+ logger$3.info('remote config load deferred until DOMContentLoaded');
7632
7755
  const onDomReady = () => {
7633
7756
  document$1?.removeEventListener('DOMContentLoaded', onDomReady);
7634
7757
  triggerRemoteConfigLoad('dom');
@@ -7721,7 +7844,7 @@ var leanbase = (function () {
7721
7844
  try {
7722
7845
  this.sessionRecording.startIfEnabledOrStop();
7723
7846
  } catch (e) {
7724
- logger$2.error('Failed to start session recording', e);
7847
+ logger$3.error('Failed to start session recording', e);
7725
7848
  }
7726
7849
  }
7727
7850
  fetch(url, options) {
@@ -7735,7 +7858,7 @@ var leanbase = (function () {
7735
7858
  const oldConfig = {
7736
7859
  ...this.config
7737
7860
  };
7738
- if (isObject(config)) {
7861
+ if (isObject$1(config)) {
7739
7862
  extend(this.config, config);
7740
7863
  if (!this.config.api_host && this.config.host) {
7741
7864
  this.config.api_host = this.config.host;
@@ -7787,7 +7910,7 @@ var leanbase = (function () {
7787
7910
  };
7788
7911
  properties['distinct_id'] = persistenceProps.distinct_id;
7789
7912
  if (!(isString(properties['distinct_id']) || isNumber(properties['distinct_id'])) || isEmptyString(properties['distinct_id'])) {
7790
- logger$2.error('Invalid distinct_id for replay event. This indicates a bug in your implementation');
7913
+ logger$3.error('Invalid distinct_id for replay event. This indicates a bug in your implementation');
7791
7914
  }
7792
7915
  return properties;
7793
7916
  }
@@ -7862,11 +7985,11 @@ var leanbase = (function () {
7862
7985
  return;
7863
7986
  }
7864
7987
  if (isUndefined(event) || !isString(event)) {
7865
- logger$2.error('No event name provided to posthog.capture');
7988
+ logger$3.error('No event name provided to posthog.capture');
7866
7989
  return;
7867
7990
  }
7868
7991
  if (properties?.$current_url && !isString(properties?.$current_url)) {
7869
- logger$2.error('Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value.');
7992
+ logger$3.error('Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value.');
7870
7993
  delete properties?.$current_url;
7871
7994
  }
7872
7995
  this.sessionPersistence.update_search_keyword();
@@ -8004,13 +8127,13 @@ var leanbase = (function () {
8004
8127
  g.Leanbase = g.leanbase;
8005
8128
  })(globalThis);
8006
8129
 
8007
- var __defProp = Object.defineProperty;
8008
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8009
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8010
- var _a;
8011
- var __defProp$1 = Object.defineProperty;
8012
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8013
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
8130
+ var __defProp$2 = Object.defineProperty;
8131
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8132
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
8133
+ var _a$1;
8134
+ var __defProp$1$1 = Object.defineProperty;
8135
+ var __defNormalProp$1$1 = (obj, key, value) => key in obj ? __defProp$1$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8136
+ var __publicField$1$1 = (obj, key, value) => __defNormalProp$1$1(obj, typeof key !== "symbol" ? key + "" : key, value);
8014
8137
  var NodeType$2 = /* @__PURE__ */ ((NodeType2) => {
8015
8138
  NodeType2[NodeType2["Document"] = 0] = "Document";
8016
8139
  NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
@@ -8020,13 +8143,13 @@ var leanbase = (function () {
8020
8143
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
8021
8144
  return NodeType2;
8022
8145
  })(NodeType$2 || {});
8023
- const testableAccessors$1 = {
8146
+ const testableAccessors$1$1 = {
8024
8147
  Node: ["childNodes", "parentNode", "parentElement", "textContent"],
8025
8148
  ShadowRoot: ["host", "styleSheets"],
8026
8149
  Element: ["shadowRoot", "querySelector", "querySelectorAll"],
8027
8150
  MutationObserver: []
8028
8151
  };
8029
- const testableMethods$1 = {
8152
+ const testableMethods$1$1 = {
8030
8153
  Node: ["contains", "getRootNode"],
8031
8154
  ShadowRoot: ["getSelection"],
8032
8155
  Element: [],
@@ -8056,13 +8179,13 @@ var leanbase = (function () {
8056
8179
  }
8057
8180
  }
8058
8181
 
8059
- const untaintedBasePrototype$1 = {};
8060
- function getUntaintedPrototype$1(key) {
8061
- if (untaintedBasePrototype$1[key])
8062
- return untaintedBasePrototype$1[key];
8182
+ const untaintedBasePrototype$1$1 = {};
8183
+ function getUntaintedPrototype$1$1(key) {
8184
+ if (untaintedBasePrototype$1$1[key])
8185
+ return untaintedBasePrototype$1$1[key];
8063
8186
  const defaultObj = angularZoneUnpatchedAlternative(key) || globalThis[key];
8064
8187
  const defaultPrototype = defaultObj.prototype;
8065
- const accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
8188
+ const accessorNames = key in testableAccessors$1$1 ? testableAccessors$1$1[key] : void 0;
8066
8189
  const isUntaintedAccessors = Boolean(
8067
8190
  accessorNames && // @ts-expect-error 2345
8068
8191
  accessorNames.every(
@@ -8074,7 +8197,7 @@ var leanbase = (function () {
8074
8197
  }
8075
8198
  )
8076
8199
  );
8077
- const methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
8200
+ const methodNames = key in testableMethods$1$1 ? testableMethods$1$1[key] : void 0;
8078
8201
  const isUntaintedMethods = Boolean(
8079
8202
  methodNames && methodNames.every(
8080
8203
  // @ts-expect-error 2345
@@ -8085,7 +8208,7 @@ var leanbase = (function () {
8085
8208
  )
8086
8209
  );
8087
8210
  if (isUntaintedAccessors && isUntaintedMethods) {
8088
- untaintedBasePrototype$1[key] = defaultObj.prototype;
8211
+ untaintedBasePrototype$1$1[key] = defaultObj.prototype;
8089
8212
  return defaultObj.prototype;
8090
8213
  }
8091
8214
  try {
@@ -8096,104 +8219,104 @@ var leanbase = (function () {
8096
8219
  const untaintedObject = win[key].prototype;
8097
8220
  document.body.removeChild(iframeEl);
8098
8221
  if (!untaintedObject) return defaultObj.prototype;
8099
- return untaintedBasePrototype$1[key] = untaintedObject;
8222
+ return untaintedBasePrototype$1$1[key] = untaintedObject;
8100
8223
  } catch {
8101
8224
  return defaultObj.prototype;
8102
8225
  }
8103
8226
  }
8104
- const untaintedAccessorCache$1 = {};
8105
- function getUntaintedAccessor$1(key, instance, accessor) {
8227
+ const untaintedAccessorCache$1$1 = {};
8228
+ function getUntaintedAccessor$1$1(key, instance, accessor) {
8106
8229
  var _a2;
8107
8230
  const cacheKey = `${key}.${String(accessor)}`;
8108
- if (untaintedAccessorCache$1[cacheKey])
8109
- return untaintedAccessorCache$1[cacheKey].call(
8231
+ if (untaintedAccessorCache$1$1[cacheKey])
8232
+ return untaintedAccessorCache$1$1[cacheKey].call(
8110
8233
  instance
8111
8234
  );
8112
- const untaintedPrototype = getUntaintedPrototype$1(key);
8235
+ const untaintedPrototype = getUntaintedPrototype$1$1(key);
8113
8236
  const untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(
8114
8237
  untaintedPrototype,
8115
8238
  accessor
8116
8239
  )) == null ? void 0 : _a2.get;
8117
8240
  if (!untaintedAccessor) return instance[accessor];
8118
- untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
8241
+ untaintedAccessorCache$1$1[cacheKey] = untaintedAccessor;
8119
8242
  return untaintedAccessor.call(instance);
8120
8243
  }
8121
- const untaintedMethodCache$1 = {};
8122
- function getUntaintedMethod$1(key, instance, method) {
8244
+ const untaintedMethodCache$1$1 = {};
8245
+ function getUntaintedMethod$1$1(key, instance, method) {
8123
8246
  const cacheKey = `${key}.${String(method)}`;
8124
- if (untaintedMethodCache$1[cacheKey])
8125
- return untaintedMethodCache$1[cacheKey].bind(
8247
+ if (untaintedMethodCache$1$1[cacheKey])
8248
+ return untaintedMethodCache$1$1[cacheKey].bind(
8126
8249
  instance
8127
8250
  );
8128
- const untaintedPrototype = getUntaintedPrototype$1(key);
8251
+ const untaintedPrototype = getUntaintedPrototype$1$1(key);
8129
8252
  const untaintedMethod = untaintedPrototype[method];
8130
8253
  if (typeof untaintedMethod !== "function") return instance[method];
8131
- untaintedMethodCache$1[cacheKey] = untaintedMethod;
8254
+ untaintedMethodCache$1$1[cacheKey] = untaintedMethod;
8132
8255
  return untaintedMethod.bind(instance);
8133
8256
  }
8134
- function childNodes$1(n2) {
8135
- return getUntaintedAccessor$1("Node", n2, "childNodes");
8257
+ function childNodes$1$1(n2) {
8258
+ return getUntaintedAccessor$1$1("Node", n2, "childNodes");
8136
8259
  }
8137
- function parentNode$1(n2) {
8138
- return getUntaintedAccessor$1("Node", n2, "parentNode");
8260
+ function parentNode$1$1(n2) {
8261
+ return getUntaintedAccessor$1$1("Node", n2, "parentNode");
8139
8262
  }
8140
- function parentElement$1(n2) {
8141
- return getUntaintedAccessor$1("Node", n2, "parentElement");
8263
+ function parentElement$1$1(n2) {
8264
+ return getUntaintedAccessor$1$1("Node", n2, "parentElement");
8142
8265
  }
8143
- function textContent$1(n2) {
8144
- return getUntaintedAccessor$1("Node", n2, "textContent");
8266
+ function textContent$1$1(n2) {
8267
+ return getUntaintedAccessor$1$1("Node", n2, "textContent");
8145
8268
  }
8146
- function contains$1(n2, other) {
8147
- return getUntaintedMethod$1("Node", n2, "contains")(other);
8269
+ function contains$1$1(n2, other) {
8270
+ return getUntaintedMethod$1$1("Node", n2, "contains")(other);
8148
8271
  }
8149
- function getRootNode$1(n2) {
8150
- return getUntaintedMethod$1("Node", n2, "getRootNode")();
8272
+ function getRootNode$1$1(n2) {
8273
+ return getUntaintedMethod$1$1("Node", n2, "getRootNode")();
8151
8274
  }
8152
- function host$1(n2) {
8275
+ function host$1$1(n2) {
8153
8276
  if (!n2 || !("host" in n2)) return null;
8154
- return getUntaintedAccessor$1("ShadowRoot", n2, "host");
8277
+ return getUntaintedAccessor$1$1("ShadowRoot", n2, "host");
8155
8278
  }
8156
- function styleSheets$1(n2) {
8279
+ function styleSheets$1$1(n2) {
8157
8280
  return n2.styleSheets;
8158
8281
  }
8159
- function shadowRoot$1(n2) {
8282
+ function shadowRoot$1$1(n2) {
8160
8283
  if (!n2 || !("shadowRoot" in n2)) return null;
8161
- return getUntaintedAccessor$1("Element", n2, "shadowRoot");
8162
- }
8163
- function querySelector$1(n2, selectors) {
8164
- return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
8165
- }
8166
- function querySelectorAll$1(n2, selectors) {
8167
- return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
8168
- }
8169
- function mutationObserverCtor$1() {
8170
- return getUntaintedPrototype$1("MutationObserver").constructor;
8171
- }
8172
- const index$1 = {
8173
- childNodes: childNodes$1,
8174
- parentNode: parentNode$1,
8175
- parentElement: parentElement$1,
8176
- textContent: textContent$1,
8177
- contains: contains$1,
8178
- getRootNode: getRootNode$1,
8179
- host: host$1,
8180
- styleSheets: styleSheets$1,
8181
- shadowRoot: shadowRoot$1,
8182
- querySelector: querySelector$1,
8183
- querySelectorAll: querySelectorAll$1,
8184
- mutationObserver: mutationObserverCtor$1
8284
+ return getUntaintedAccessor$1$1("Element", n2, "shadowRoot");
8285
+ }
8286
+ function querySelector$1$1(n2, selectors) {
8287
+ return getUntaintedAccessor$1$1("Element", n2, "querySelector")(selectors);
8288
+ }
8289
+ function querySelectorAll$1$1(n2, selectors) {
8290
+ return getUntaintedAccessor$1$1("Element", n2, "querySelectorAll")(selectors);
8291
+ }
8292
+ function mutationObserverCtor$1$1() {
8293
+ return getUntaintedPrototype$1$1("MutationObserver").constructor;
8294
+ }
8295
+ const index$1$1 = {
8296
+ childNodes: childNodes$1$1,
8297
+ parentNode: parentNode$1$1,
8298
+ parentElement: parentElement$1$1,
8299
+ textContent: textContent$1$1,
8300
+ contains: contains$1$1,
8301
+ getRootNode: getRootNode$1$1,
8302
+ host: host$1$1,
8303
+ styleSheets: styleSheets$1$1,
8304
+ shadowRoot: shadowRoot$1$1,
8305
+ querySelector: querySelector$1$1,
8306
+ querySelectorAll: querySelectorAll$1$1,
8307
+ mutationObserver: mutationObserverCtor$1$1
8185
8308
  };
8186
8309
  function isElement(n2) {
8187
8310
  return n2.nodeType === n2.ELEMENT_NODE;
8188
8311
  }
8189
- function isShadowRoot(n2) {
8312
+ function isShadowRoot$1(n2) {
8190
8313
  const hostEl = (
8191
8314
  // anchor and textarea elements also have a `host` property
8192
8315
  // but only shadow roots have a `mode` property
8193
- n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null
8316
+ n2 && "host" in n2 && "mode" in n2 && index$1$1.host(n2) || null
8194
8317
  );
8195
8318
  return Boolean(
8196
- hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2
8319
+ hostEl && "shadowRoot" in hostEl && index$1$1.shadowRoot(hostEl) === n2
8197
8320
  );
8198
8321
  }
8199
8322
  function isNativeShadowDom(shadowRoot2) {
@@ -8279,10 +8402,10 @@ var leanbase = (function () {
8279
8402
  function findStylesheet(doc, href) {
8280
8403
  return Array.from(doc.styleSheets).find((s) => s.href === href);
8281
8404
  }
8282
- class Mirror {
8405
+ let Mirror$1 = class Mirror {
8283
8406
  constructor() {
8284
- __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
8285
- __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
8407
+ __publicField$1$1(this, "idNodeMap", /* @__PURE__ */ new Map());
8408
+ __publicField$1$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
8286
8409
  }
8287
8410
  getId(n2) {
8288
8411
  var _a2;
@@ -8333,9 +8456,9 @@ var leanbase = (function () {
8333
8456
  this.idNodeMap = /* @__PURE__ */ new Map();
8334
8457
  this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
8335
8458
  }
8336
- }
8337
- function createMirror$2() {
8338
- return new Mirror();
8459
+ };
8460
+ function createMirror$2$1() {
8461
+ return new Mirror$1();
8339
8462
  }
8340
8463
  function maskInputValue({
8341
8464
  element,
@@ -8451,7 +8574,7 @@ var leanbase = (function () {
8451
8574
  }
8452
8575
  let _id = 1;
8453
8576
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
8454
- const IGNORED_NODE = -2;
8577
+ const IGNORED_NODE$1 = -2;
8455
8578
  function genId() {
8456
8579
  return _id++;
8457
8580
  }
@@ -8590,11 +8713,11 @@ var leanbase = (function () {
8590
8713
  }
8591
8714
  return false;
8592
8715
  }
8593
- function classMatchesRegex(node2, regex, checkAncestors) {
8716
+ function classMatchesRegex$1(node2, regex, checkAncestors) {
8594
8717
  if (!node2) return false;
8595
8718
  if (node2.nodeType !== node2.ELEMENT_NODE) {
8596
8719
  if (!checkAncestors) return false;
8597
- return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
8720
+ return classMatchesRegex$1(index$1$1.parentNode(node2), regex, checkAncestors);
8598
8721
  }
8599
8722
  for (let eIndex = node2.classList.length; eIndex--; ) {
8600
8723
  const className = node2.classList[eIndex];
@@ -8603,19 +8726,19 @@ var leanbase = (function () {
8603
8726
  }
8604
8727
  }
8605
8728
  if (!checkAncestors) return false;
8606
- return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
8729
+ return classMatchesRegex$1(index$1$1.parentNode(node2), regex, checkAncestors);
8607
8730
  }
8608
8731
  function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
8609
8732
  let el;
8610
8733
  if (isElement(node2)) {
8611
8734
  el = node2;
8612
- if (!index$1.childNodes(el).length) {
8735
+ if (!index$1$1.childNodes(el).length) {
8613
8736
  return false;
8614
8737
  }
8615
- } else if (index$1.parentElement(node2) === null) {
8738
+ } else if (index$1$1.parentElement(node2) === null) {
8616
8739
  return false;
8617
8740
  } else {
8618
- el = index$1.parentElement(node2);
8741
+ el = index$1$1.parentElement(node2);
8619
8742
  }
8620
8743
  try {
8621
8744
  if (typeof maskTextClass === "string") {
@@ -8625,7 +8748,7 @@ var leanbase = (function () {
8625
8748
  if (el.classList.contains(maskTextClass)) return true;
8626
8749
  }
8627
8750
  } else {
8628
- if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
8751
+ if (classMatchesRegex$1(el, maskTextClass, checkAncestors)) return true;
8629
8752
  }
8630
8753
  if (maskTextSelector) {
8631
8754
  if (checkAncestors) {
@@ -8764,7 +8887,7 @@ var leanbase = (function () {
8764
8887
  case n2.COMMENT_NODE:
8765
8888
  return {
8766
8889
  type: NodeType$2.Comment,
8767
- textContent: index$1.textContent(n2) || "",
8890
+ textContent: index$1$1.textContent(n2) || "",
8768
8891
  rootId
8769
8892
  };
8770
8893
  default:
@@ -8779,9 +8902,9 @@ var leanbase = (function () {
8779
8902
  function serializeTextNode(n2, options) {
8780
8903
  var _a2;
8781
8904
  const { needsMask, maskTextFn, rootId } = options;
8782
- const parent = index$1.parentNode(n2);
8905
+ const parent = index$1$1.parentNode(n2);
8783
8906
  const parentTagName = parent && parent.tagName;
8784
- let text = index$1.textContent(n2);
8907
+ let text = index$1$1.textContent(n2);
8785
8908
  const isStyle = parentTagName === "STYLE" ? true : void 0;
8786
8909
  const isScript = parentTagName === "SCRIPT" ? true : void 0;
8787
8910
  if (isStyle && text) {
@@ -8802,7 +8925,7 @@ var leanbase = (function () {
8802
8925
  text = "SCRIPT_PLACEHOLDER";
8803
8926
  }
8804
8927
  if (!isStyle && !isScript && text && needsMask) {
8805
- text = maskTextFn ? maskTextFn(text, index$1.parentElement(n2)) : text.replace(/[\S]/g, "*");
8928
+ text = maskTextFn ? maskTextFn(text, index$1$1.parentElement(n2)) : text.replace(/[\S]/g, "*");
8806
8929
  }
8807
8930
  return {
8808
8931
  type: NodeType$2.Text,
@@ -8876,7 +8999,7 @@ var leanbase = (function () {
8876
8999
  }
8877
9000
  }
8878
9001
  if (tagName === "style" && n2.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
8879
- !(n2.innerText || index$1.textContent(n2) || "").trim().length) {
9002
+ !(n2.innerText || index$1$1.textContent(n2) || "").trim().length) {
8880
9003
  const cssText = stringifyStylesheet(
8881
9004
  n2.sheet
8882
9005
  );
@@ -9127,13 +9250,13 @@ var leanbase = (function () {
9127
9250
  if (mirror2.hasNode(n2)) {
9128
9251
  id = mirror2.getId(n2);
9129
9252
  } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$2.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
9130
- id = IGNORED_NODE;
9253
+ id = IGNORED_NODE$1;
9131
9254
  } else {
9132
9255
  id = genId();
9133
9256
  }
9134
9257
  const serializedNode = Object.assign(_serializedNode, { id });
9135
9258
  mirror2.add(n2, serializedNode);
9136
- if (id === IGNORED_NODE) {
9259
+ if (id === IGNORED_NODE$1) {
9137
9260
  return null;
9138
9261
  }
9139
9262
  if (onSerialize) {
@@ -9143,7 +9266,7 @@ var leanbase = (function () {
9143
9266
  if (serializedNode.type === NodeType$2.Element) {
9144
9267
  recordChild = recordChild && !serializedNode.needBlock;
9145
9268
  delete serializedNode.needBlock;
9146
- const shadowRootEl = index$1.shadowRoot(n2);
9269
+ const shadowRootEl = index$1$1.shadowRoot(n2);
9147
9270
  if (shadowRootEl && isNativeShadowDom(shadowRootEl))
9148
9271
  serializedNode.isShadowHost = true;
9149
9272
  }
@@ -9178,7 +9301,7 @@ var leanbase = (function () {
9178
9301
  };
9179
9302
  if (serializedNode.type === NodeType$2.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
9180
9303
  else {
9181
- for (const childN of Array.from(index$1.childNodes(n2))) {
9304
+ for (const childN of Array.from(index$1$1.childNodes(n2))) {
9182
9305
  const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
9183
9306
  if (serializedChildNode) {
9184
9307
  serializedNode.childNodes.push(serializedChildNode);
@@ -9186,8 +9309,8 @@ var leanbase = (function () {
9186
9309
  }
9187
9310
  }
9188
9311
  let shadowRootEl = null;
9189
- if (isElement(n2) && (shadowRootEl = index$1.shadowRoot(n2))) {
9190
- for (const childN of Array.from(index$1.childNodes(shadowRootEl))) {
9312
+ if (isElement(n2) && (shadowRootEl = index$1$1.shadowRoot(n2))) {
9313
+ for (const childN of Array.from(index$1$1.childNodes(shadowRootEl))) {
9191
9314
  const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
9192
9315
  if (serializedChildNode) {
9193
9316
  isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
@@ -9196,8 +9319,8 @@ var leanbase = (function () {
9196
9319
  }
9197
9320
  }
9198
9321
  }
9199
- const parent = index$1.parentNode(n2);
9200
- if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
9322
+ const parent = index$1$1.parentNode(n2);
9323
+ if (parent && isShadowRoot$1(parent) && isNativeShadowDom(parent)) {
9201
9324
  serializedNode.isShadow = true;
9202
9325
  }
9203
9326
  if (serializedNode.type === NodeType$2.Element && serializedNode.tagName === "iframe") {
@@ -9287,7 +9410,7 @@ var leanbase = (function () {
9287
9410
  }
9288
9411
  function snapshot(n2, options) {
9289
9412
  const {
9290
- mirror: mirror2 = new Mirror(),
9413
+ mirror: mirror2 = new Mirror$1(),
9291
9414
  blockClass = "rr-block",
9292
9415
  blockSelector = null,
9293
9416
  maskTextClass = "rr-mask",
@@ -9371,7 +9494,7 @@ var leanbase = (function () {
9371
9494
  });
9372
9495
  }
9373
9496
  // Removed postcss
9374
- class BaseRRNode {
9497
+ let BaseRRNode$1 = class BaseRRNode {
9375
9498
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
9376
9499
  constructor(..._args) {
9377
9500
  __publicField2(this, "parentElement", null);
@@ -9427,14 +9550,14 @@ var leanbase = (function () {
9427
9550
  toString() {
9428
9551
  return "RRNode";
9429
9552
  }
9430
- }
9431
- const testableAccessors = {
9553
+ };
9554
+ const testableAccessors$2 = {
9432
9555
  Node: ["childNodes", "parentNode", "parentElement", "textContent"],
9433
9556
  ShadowRoot: ["host", "styleSheets"],
9434
9557
  Element: ["shadowRoot", "querySelector", "querySelectorAll"],
9435
9558
  MutationObserver: []
9436
9559
  };
9437
- const testableMethods = {
9560
+ const testableMethods$2 = {
9438
9561
  Node: ["contains", "getRootNode"],
9439
9562
  ShadowRoot: ["getSelection"],
9440
9563
  Element: [],
@@ -9463,13 +9586,13 @@ var leanbase = (function () {
9463
9586
  }
9464
9587
  }
9465
9588
 
9466
- const untaintedBasePrototype = {};
9467
- function getUntaintedPrototype(key) {
9468
- if (untaintedBasePrototype[key])
9469
- return untaintedBasePrototype[key];
9589
+ const untaintedBasePrototype$2 = {};
9590
+ function getUntaintedPrototype$2(key) {
9591
+ if (untaintedBasePrototype$2[key])
9592
+ return untaintedBasePrototype$2[key];
9470
9593
  const defaultObj = angularZoneUnpatchedAlternative$1(key) ||globalThis[key];
9471
9594
  const defaultPrototype = defaultObj.prototype;
9472
- const accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
9595
+ const accessorNames = key in testableAccessors$2 ? testableAccessors$2[key] : void 0;
9473
9596
  const isUntaintedAccessors = Boolean(
9474
9597
  accessorNames && // @ts-expect-error 2345
9475
9598
  accessorNames.every(
@@ -9481,7 +9604,7 @@ var leanbase = (function () {
9481
9604
  }
9482
9605
  )
9483
9606
  );
9484
- const methodNames = key in testableMethods ? testableMethods[key] : void 0;
9607
+ const methodNames = key in testableMethods$2 ? testableMethods$2[key] : void 0;
9485
9608
  const isUntaintedMethods = Boolean(
9486
9609
  methodNames && methodNames.every(
9487
9610
  // @ts-expect-error 2345
@@ -9492,7 +9615,7 @@ var leanbase = (function () {
9492
9615
  )
9493
9616
  );
9494
9617
  if (isUntaintedAccessors && isUntaintedMethods) {
9495
- untaintedBasePrototype[key] = defaultObj.prototype;
9618
+ untaintedBasePrototype$2[key] = defaultObj.prototype;
9496
9619
  return defaultObj.prototype;
9497
9620
  }
9498
9621
  try {
@@ -9503,131 +9626,131 @@ var leanbase = (function () {
9503
9626
  const untaintedObject = win[key].prototype;
9504
9627
  document.body.removeChild(iframeEl);
9505
9628
  if (!untaintedObject) return defaultPrototype;
9506
- return untaintedBasePrototype[key] = untaintedObject;
9629
+ return untaintedBasePrototype$2[key] = untaintedObject;
9507
9630
  } catch {
9508
9631
  return defaultPrototype;
9509
9632
  }
9510
9633
  }
9511
- const untaintedAccessorCache = {};
9512
- function getUntaintedAccessor(key, instance, accessor) {
9634
+ const untaintedAccessorCache$2 = {};
9635
+ function getUntaintedAccessor$2(key, instance, accessor) {
9513
9636
  var _a2;
9514
9637
  const cacheKey = `${key}.${String(accessor)}`;
9515
- if (untaintedAccessorCache[cacheKey])
9516
- return untaintedAccessorCache[cacheKey].call(
9638
+ if (untaintedAccessorCache$2[cacheKey])
9639
+ return untaintedAccessorCache$2[cacheKey].call(
9517
9640
  instance
9518
9641
  );
9519
- const untaintedPrototype = getUntaintedPrototype(key);
9642
+ const untaintedPrototype = getUntaintedPrototype$2(key);
9520
9643
  const untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(
9521
9644
  untaintedPrototype,
9522
9645
  accessor
9523
9646
  )) == null ? void 0 : _a2.get;
9524
9647
  if (!untaintedAccessor) return instance[accessor];
9525
- untaintedAccessorCache[cacheKey] = untaintedAccessor;
9648
+ untaintedAccessorCache$2[cacheKey] = untaintedAccessor;
9526
9649
  return untaintedAccessor.call(instance);
9527
9650
  }
9528
- const untaintedMethodCache = {};
9529
- function getUntaintedMethod(key, instance, method) {
9651
+ const untaintedMethodCache$2 = {};
9652
+ function getUntaintedMethod$2(key, instance, method) {
9530
9653
  const cacheKey = `${key}.${String(method)}`;
9531
- if (untaintedMethodCache[cacheKey])
9532
- return untaintedMethodCache[cacheKey].bind(
9654
+ if (untaintedMethodCache$2[cacheKey])
9655
+ return untaintedMethodCache$2[cacheKey].bind(
9533
9656
  instance
9534
9657
  );
9535
- const untaintedPrototype = getUntaintedPrototype(key);
9658
+ const untaintedPrototype = getUntaintedPrototype$2(key);
9536
9659
  const untaintedMethod = untaintedPrototype[method];
9537
9660
  if (typeof untaintedMethod !== "function") return instance[method];
9538
- untaintedMethodCache[cacheKey] = untaintedMethod;
9661
+ untaintedMethodCache$2[cacheKey] = untaintedMethod;
9539
9662
  return untaintedMethod.bind(instance);
9540
9663
  }
9541
- function childNodes(n2) {
9542
- return getUntaintedAccessor("Node", n2, "childNodes");
9664
+ function childNodes$2(n2) {
9665
+ return getUntaintedAccessor$2("Node", n2, "childNodes");
9543
9666
  }
9544
- function parentNode(n2) {
9545
- return getUntaintedAccessor("Node", n2, "parentNode");
9667
+ function parentNode$2(n2) {
9668
+ return getUntaintedAccessor$2("Node", n2, "parentNode");
9546
9669
  }
9547
- function parentElement(n2) {
9548
- return getUntaintedAccessor("Node", n2, "parentElement");
9670
+ function parentElement$2(n2) {
9671
+ return getUntaintedAccessor$2("Node", n2, "parentElement");
9549
9672
  }
9550
- function textContent(n2) {
9551
- return getUntaintedAccessor("Node", n2, "textContent");
9673
+ function textContent$2(n2) {
9674
+ return getUntaintedAccessor$2("Node", n2, "textContent");
9552
9675
  }
9553
- function contains(n2, other) {
9554
- return getUntaintedMethod("Node", n2, "contains")(other);
9676
+ function contains$2(n2, other) {
9677
+ return getUntaintedMethod$2("Node", n2, "contains")(other);
9555
9678
  }
9556
- function getRootNode(n2) {
9557
- return getUntaintedMethod("Node", n2, "getRootNode")();
9679
+ function getRootNode$2(n2) {
9680
+ return getUntaintedMethod$2("Node", n2, "getRootNode")();
9558
9681
  }
9559
- function host(n2) {
9682
+ function host$2(n2) {
9560
9683
  if (!n2 || !("host" in n2)) return null;
9561
- return getUntaintedAccessor("ShadowRoot", n2, "host");
9684
+ return getUntaintedAccessor$2("ShadowRoot", n2, "host");
9562
9685
  }
9563
- function styleSheets(n2) {
9686
+ function styleSheets$2(n2) {
9564
9687
  return n2.styleSheets;
9565
9688
  }
9566
- function shadowRoot(n2) {
9689
+ function shadowRoot$2(n2) {
9567
9690
  if (!n2 || !("shadowRoot" in n2)) return null;
9568
- return getUntaintedAccessor("Element", n2, "shadowRoot");
9569
- }
9570
- function querySelector(n2, selectors) {
9571
- return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
9572
- }
9573
- function querySelectorAll(n2, selectors) {
9574
- return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
9575
- }
9576
- function mutationObserverCtor() {
9577
- return getUntaintedPrototype("MutationObserver").constructor;
9578
- }
9579
- const index = {
9580
- childNodes,
9581
- parentNode,
9582
- parentElement,
9583
- textContent,
9584
- contains,
9585
- getRootNode,
9586
- host,
9587
- styleSheets,
9588
- shadowRoot,
9589
- querySelector,
9590
- querySelectorAll,
9591
- mutationObserver: mutationObserverCtor
9691
+ return getUntaintedAccessor$2("Element", n2, "shadowRoot");
9692
+ }
9693
+ function querySelector$2(n2, selectors) {
9694
+ return getUntaintedAccessor$2("Element", n2, "querySelector")(selectors);
9695
+ }
9696
+ function querySelectorAll$2(n2, selectors) {
9697
+ return getUntaintedAccessor$2("Element", n2, "querySelectorAll")(selectors);
9698
+ }
9699
+ function mutationObserverCtor$2() {
9700
+ return getUntaintedPrototype$2("MutationObserver").constructor;
9701
+ }
9702
+ const index$2 = {
9703
+ childNodes: childNodes$2,
9704
+ parentNode: parentNode$2,
9705
+ parentElement: parentElement$2,
9706
+ textContent: textContent$2,
9707
+ contains: contains$2,
9708
+ getRootNode: getRootNode$2,
9709
+ host: host$2,
9710
+ styleSheets: styleSheets$2,
9711
+ shadowRoot: shadowRoot$2,
9712
+ querySelector: querySelector$2,
9713
+ querySelectorAll: querySelectorAll$2,
9714
+ mutationObserver: mutationObserverCtor$2
9592
9715
  };
9593
- function on(type, fn, target = document) {
9716
+ function on$1(type, fn, target = document) {
9594
9717
  const options = { capture: true, passive: true };
9595
9718
  target.addEventListener(type, fn, options);
9596
9719
  return () => target.removeEventListener(type, fn, options);
9597
9720
  }
9598
- const DEPARTED_MIRROR_ACCESS_WARNING = "Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";
9599
- let _mirror = {
9721
+ const DEPARTED_MIRROR_ACCESS_WARNING$1 = "Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";
9722
+ let _mirror$1 = {
9600
9723
  map: {},
9601
9724
  getId() {
9602
- console.error(DEPARTED_MIRROR_ACCESS_WARNING);
9725
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING$1);
9603
9726
  return -1;
9604
9727
  },
9605
9728
  getNode() {
9606
- console.error(DEPARTED_MIRROR_ACCESS_WARNING);
9729
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING$1);
9607
9730
  return null;
9608
9731
  },
9609
9732
  removeNodeFromMap() {
9610
- console.error(DEPARTED_MIRROR_ACCESS_WARNING);
9733
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING$1);
9611
9734
  },
9612
9735
  has() {
9613
- console.error(DEPARTED_MIRROR_ACCESS_WARNING);
9736
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING$1);
9614
9737
  return false;
9615
9738
  },
9616
9739
  reset() {
9617
- console.error(DEPARTED_MIRROR_ACCESS_WARNING);
9740
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING$1);
9618
9741
  }
9619
9742
  };
9620
9743
  if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
9621
- _mirror = new Proxy(_mirror, {
9744
+ _mirror$1 = new Proxy(_mirror$1, {
9622
9745
  get(target, prop, receiver) {
9623
9746
  if (prop === "map") {
9624
- console.error(DEPARTED_MIRROR_ACCESS_WARNING);
9747
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING$1);
9625
9748
  }
9626
9749
  return Reflect.get(target, prop, receiver);
9627
9750
  }
9628
9751
  });
9629
9752
  }
9630
- function throttle(func, wait, options = {}) {
9753
+ function throttle$1(func, wait, options = {}) {
9631
9754
  let timeout = null;
9632
9755
  let previous = 0;
9633
9756
  return function(...args) {
@@ -9653,7 +9776,7 @@ var leanbase = (function () {
9653
9776
  }
9654
9777
  };
9655
9778
  }
9656
- function hookSetter(target, key, d, isRevoked, win = window) {
9779
+ function hookSetter$1(target, key, d, isRevoked, win = window) {
9657
9780
  const original = win.Object.getOwnPropertyDescriptor(target, key);
9658
9781
  win.Object.defineProperty(
9659
9782
  target,
@@ -9669,9 +9792,9 @@ var leanbase = (function () {
9669
9792
  }
9670
9793
  }
9671
9794
  );
9672
- return () => hookSetter(target, key, original || {}, true);
9795
+ return () => hookSetter$1(target, key, original || {}, true);
9673
9796
  }
9674
- function patch(source, name, replacement) {
9797
+ function patch$2(source, name, replacement) {
9675
9798
  try {
9676
9799
  if (!(name in source)) {
9677
9800
  return () => {
@@ -9697,36 +9820,36 @@ var leanbase = (function () {
9697
9820
  };
9698
9821
  }
9699
9822
  }
9700
- let nowTimestamp = Date.now;
9823
+ let nowTimestamp$1 = Date.now;
9701
9824
  if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
9702
- nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
9825
+ nowTimestamp$1 = () => (/* @__PURE__ */ new Date()).getTime();
9703
9826
  }
9704
- function getWindowScroll(win) {
9827
+ function getWindowScroll$1(win) {
9705
9828
  var _a2, _b, _c, _d;
9706
9829
  const doc = win.document;
9707
9830
  return {
9708
- left: doc.scrollingElement ? doc.scrollingElement.scrollLeft : win.pageXOffset !== void 0 ? win.pageXOffset : doc.documentElement.scrollLeft || (doc == null ? void 0 : doc.body) && ((_a2 = index.parentElement(doc.body)) == null ? void 0 : _a2.scrollLeft) || ((_b = doc == null ? void 0 : doc.body) == null ? void 0 : _b.scrollLeft) || 0,
9709
- top: doc.scrollingElement ? doc.scrollingElement.scrollTop : win.pageYOffset !== void 0 ? win.pageYOffset : (doc == null ? void 0 : doc.documentElement.scrollTop) || (doc == null ? void 0 : doc.body) && ((_c = index.parentElement(doc.body)) == null ? void 0 : _c.scrollTop) || ((_d = doc == null ? void 0 : doc.body) == null ? void 0 : _d.scrollTop) || 0
9831
+ left: doc.scrollingElement ? doc.scrollingElement.scrollLeft : win.pageXOffset !== void 0 ? win.pageXOffset : doc.documentElement.scrollLeft || (doc == null ? void 0 : doc.body) && ((_a2 = index$2.parentElement(doc.body)) == null ? void 0 : _a2.scrollLeft) || ((_b = doc == null ? void 0 : doc.body) == null ? void 0 : _b.scrollLeft) || 0,
9832
+ top: doc.scrollingElement ? doc.scrollingElement.scrollTop : win.pageYOffset !== void 0 ? win.pageYOffset : (doc == null ? void 0 : doc.documentElement.scrollTop) || (doc == null ? void 0 : doc.body) && ((_c = index$2.parentElement(doc.body)) == null ? void 0 : _c.scrollTop) || ((_d = doc == null ? void 0 : doc.body) == null ? void 0 : _d.scrollTop) || 0
9710
9833
  };
9711
9834
  }
9712
- function getWindowHeight() {
9835
+ function getWindowHeight$1() {
9713
9836
  return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
9714
9837
  }
9715
- function getWindowWidth() {
9838
+ function getWindowWidth$1() {
9716
9839
  return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
9717
9840
  }
9718
- function closestElementOfNode(node2) {
9841
+ function closestElementOfNode$1(node2) {
9719
9842
  if (!node2) {
9720
9843
  return null;
9721
9844
  }
9722
- const el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
9845
+ const el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index$2.parentElement(node2);
9723
9846
  return el;
9724
9847
  }
9725
- function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
9848
+ function isBlocked$1(node2, blockClass, blockSelector, checkAncestors) {
9726
9849
  if (!node2) {
9727
9850
  return false;
9728
9851
  }
9729
- const el = closestElementOfNode(node2);
9852
+ const el = closestElementOfNode$1(node2);
9730
9853
  if (!el) {
9731
9854
  return false;
9732
9855
  }
@@ -9735,7 +9858,7 @@ var leanbase = (function () {
9735
9858
  if (el.classList.contains(blockClass)) return true;
9736
9859
  if (checkAncestors && el.closest("." + blockClass) !== null) return true;
9737
9860
  } else {
9738
- if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
9861
+ if (classMatchesRegex$1(el, blockClass, checkAncestors)) return true;
9739
9862
  }
9740
9863
  } catch (e2) {
9741
9864
  }
@@ -9745,36 +9868,36 @@ var leanbase = (function () {
9745
9868
  }
9746
9869
  return false;
9747
9870
  }
9748
- function isSerialized(n2, mirror2) {
9871
+ function isSerialized$1(n2, mirror2) {
9749
9872
  return mirror2.getId(n2) !== -1;
9750
9873
  }
9751
- function isIgnored(n2, mirror2, slimDOMOptions) {
9874
+ function isIgnored$1(n2, mirror2, slimDOMOptions) {
9752
9875
  if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
9753
9876
  return true;
9754
9877
  }
9755
- return mirror2.getId(n2) === IGNORED_NODE;
9878
+ return mirror2.getId(n2) === IGNORED_NODE$1;
9756
9879
  }
9757
- function isAncestorRemoved(target, mirror2) {
9758
- if (isShadowRoot(target)) {
9880
+ function isAncestorRemoved$1(target, mirror2) {
9881
+ if (isShadowRoot$1(target)) {
9759
9882
  return false;
9760
9883
  }
9761
9884
  const id = mirror2.getId(target);
9762
9885
  if (!mirror2.has(id)) {
9763
9886
  return true;
9764
9887
  }
9765
- const parent = index.parentNode(target);
9888
+ const parent = index$2.parentNode(target);
9766
9889
  if (parent && parent.nodeType === target.DOCUMENT_NODE) {
9767
9890
  return false;
9768
9891
  }
9769
9892
  if (!parent) {
9770
9893
  return true;
9771
9894
  }
9772
- return isAncestorRemoved(parent, mirror2);
9895
+ return isAncestorRemoved$1(parent, mirror2);
9773
9896
  }
9774
- function legacy_isTouchEvent(event) {
9897
+ function legacy_isTouchEvent$1(event) {
9775
9898
  return Boolean(event.changedTouches);
9776
9899
  }
9777
- function polyfill$1(win = window) {
9900
+ function polyfill$1$1(win = window) {
9778
9901
  if ("NodeList" in win && !win.NodeList.prototype.forEach) {
9779
9902
  win.NodeList.prototype.forEach = Array.prototype.forEach;
9780
9903
  }
@@ -9782,26 +9905,26 @@ var leanbase = (function () {
9782
9905
  win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
9783
9906
  }
9784
9907
  }
9785
- function isSerializedIframe(n2, mirror2) {
9908
+ function isSerializedIframe$1(n2, mirror2) {
9786
9909
  return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
9787
9910
  }
9788
- function isSerializedStylesheet(n2, mirror2) {
9911
+ function isSerializedStylesheet$1(n2, mirror2) {
9789
9912
  return Boolean(
9790
9913
  n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2)
9791
9914
  );
9792
9915
  }
9793
- function hasShadowRoot(n2) {
9916
+ function hasShadowRoot$1(n2) {
9794
9917
  if (!n2) return false;
9795
- if (n2 instanceof BaseRRNode && "shadowRoot" in n2) {
9918
+ if (n2 instanceof BaseRRNode$1 && "shadowRoot" in n2) {
9796
9919
  return Boolean(n2.shadowRoot);
9797
9920
  }
9798
- return Boolean(index.shadowRoot(n2));
9921
+ return Boolean(index$2.shadowRoot(n2));
9799
9922
  }
9800
- class StyleSheetMirror {
9923
+ let StyleSheetMirror$1 = class StyleSheetMirror {
9801
9924
  constructor() {
9802
- __publicField(this, "id", 1);
9803
- __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
9804
- __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
9925
+ __publicField$2(this, "id", 1);
9926
+ __publicField$2(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
9927
+ __publicField$2(this, "idStyleMap", /* @__PURE__ */ new Map());
9805
9928
  }
9806
9929
  getId(stylesheet) {
9807
9930
  return this.styleIDMap.get(stylesheet) ?? -1;
@@ -9833,31 +9956,31 @@ var leanbase = (function () {
9833
9956
  generateId() {
9834
9957
  return this.id++;
9835
9958
  }
9836
- }
9837
- function getShadowHost(n2) {
9959
+ };
9960
+ function getShadowHost$1(n2) {
9838
9961
  var _a2;
9839
9962
  let shadowHost = null;
9840
- if ("getRootNode" in n2 && ((_a2 = index.getRootNode(n2)) == null ? void 0 : _a2.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && index.host(index.getRootNode(n2)))
9841
- shadowHost = index.host(index.getRootNode(n2));
9963
+ if ("getRootNode" in n2 && ((_a2 = index$2.getRootNode(n2)) == null ? void 0 : _a2.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && index$2.host(index$2.getRootNode(n2)))
9964
+ shadowHost = index$2.host(index$2.getRootNode(n2));
9842
9965
  return shadowHost;
9843
9966
  }
9844
- function getRootShadowHost(n2) {
9967
+ function getRootShadowHost$1(n2) {
9845
9968
  let rootShadowHost = n2;
9846
9969
  let shadowHost;
9847
- while (shadowHost = getShadowHost(rootShadowHost))
9970
+ while (shadowHost = getShadowHost$1(rootShadowHost))
9848
9971
  rootShadowHost = shadowHost;
9849
9972
  return rootShadowHost;
9850
9973
  }
9851
- function shadowHostInDom(n2) {
9974
+ function shadowHostInDom$1(n2) {
9852
9975
  const doc = n2.ownerDocument;
9853
9976
  if (!doc) return false;
9854
- const shadowHost = getRootShadowHost(n2);
9855
- return index.contains(doc, shadowHost);
9977
+ const shadowHost = getRootShadowHost$1(n2);
9978
+ return index$2.contains(doc, shadowHost);
9856
9979
  }
9857
- function inDom(n2) {
9980
+ function inDom$1(n2) {
9858
9981
  const doc = n2.ownerDocument;
9859
9982
  if (!doc) return false;
9860
- return index.contains(doc, n2) || shadowHostInDom(n2);
9983
+ return index$2.contains(doc, n2) || shadowHostInDom$1(n2);
9861
9984
  }
9862
9985
  var EventType = /* @__PURE__ */ ((EventType2) => {
9863
9986
  EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
@@ -9928,9 +10051,9 @@ var leanbase = (function () {
9928
10051
  }
9929
10052
  class DoubleLinkedList {
9930
10053
  constructor() {
9931
- __publicField(this, "length", 0);
9932
- __publicField(this, "head", null);
9933
- __publicField(this, "tail", null);
10054
+ __publicField$2(this, "length", 0);
10055
+ __publicField$2(this, "head", null);
10056
+ __publicField$2(this, "tail", null);
9934
10057
  }
9935
10058
  get(position) {
9936
10059
  if (position >= this.length) {
@@ -10006,44 +10129,44 @@ var leanbase = (function () {
10006
10129
  const moveKey = (id, parentId) => `${id}@${parentId}`;
10007
10130
  class MutationBuffer {
10008
10131
  constructor() {
10009
- __publicField(this, "frozen", false);
10010
- __publicField(this, "locked", false);
10011
- __publicField(this, "texts", []);
10012
- __publicField(this, "attributes", []);
10013
- __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
10014
- __publicField(this, "removes", []);
10015
- __publicField(this, "mapRemoves", []);
10016
- __publicField(this, "movedMap", {});
10017
- __publicField(this, "addedSet", /* @__PURE__ */ new Set());
10018
- __publicField(this, "movedSet", /* @__PURE__ */ new Set());
10019
- __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
10020
- __publicField(this, "mutationCb");
10021
- __publicField(this, "blockClass");
10022
- __publicField(this, "blockSelector");
10023
- __publicField(this, "maskTextClass");
10024
- __publicField(this, "maskTextSelector");
10025
- __publicField(this, "inlineStylesheet");
10026
- __publicField(this, "maskInputOptions");
10027
- __publicField(this, "maskTextFn");
10028
- __publicField(this, "maskInputFn");
10029
- __publicField(this, "keepIframeSrcFn");
10030
- __publicField(this, "recordCanvas");
10031
- __publicField(this, "inlineImages");
10032
- __publicField(this, "slimDOMOptions");
10033
- __publicField(this, "dataURLOptions");
10034
- __publicField(this, "doc");
10035
- __publicField(this, "mirror");
10036
- __publicField(this, "iframeManager");
10037
- __publicField(this, "stylesheetManager");
10038
- __publicField(this, "shadowDomManager");
10039
- __publicField(this, "canvasManager");
10040
- __publicField(this, "processedNodeManager");
10041
- __publicField(this, "unattachedDoc");
10042
- __publicField(this, "processMutations", (mutations) => {
10132
+ __publicField$2(this, "frozen", false);
10133
+ __publicField$2(this, "locked", false);
10134
+ __publicField$2(this, "texts", []);
10135
+ __publicField$2(this, "attributes", []);
10136
+ __publicField$2(this, "attributeMap", /* @__PURE__ */ new WeakMap());
10137
+ __publicField$2(this, "removes", []);
10138
+ __publicField$2(this, "mapRemoves", []);
10139
+ __publicField$2(this, "movedMap", {});
10140
+ __publicField$2(this, "addedSet", /* @__PURE__ */ new Set());
10141
+ __publicField$2(this, "movedSet", /* @__PURE__ */ new Set());
10142
+ __publicField$2(this, "droppedSet", /* @__PURE__ */ new Set());
10143
+ __publicField$2(this, "mutationCb");
10144
+ __publicField$2(this, "blockClass");
10145
+ __publicField$2(this, "blockSelector");
10146
+ __publicField$2(this, "maskTextClass");
10147
+ __publicField$2(this, "maskTextSelector");
10148
+ __publicField$2(this, "inlineStylesheet");
10149
+ __publicField$2(this, "maskInputOptions");
10150
+ __publicField$2(this, "maskTextFn");
10151
+ __publicField$2(this, "maskInputFn");
10152
+ __publicField$2(this, "keepIframeSrcFn");
10153
+ __publicField$2(this, "recordCanvas");
10154
+ __publicField$2(this, "inlineImages");
10155
+ __publicField$2(this, "slimDOMOptions");
10156
+ __publicField$2(this, "dataURLOptions");
10157
+ __publicField$2(this, "doc");
10158
+ __publicField$2(this, "mirror");
10159
+ __publicField$2(this, "iframeManager");
10160
+ __publicField$2(this, "stylesheetManager");
10161
+ __publicField$2(this, "shadowDomManager");
10162
+ __publicField$2(this, "canvasManager");
10163
+ __publicField$2(this, "processedNodeManager");
10164
+ __publicField$2(this, "unattachedDoc");
10165
+ __publicField$2(this, "processMutations", (mutations) => {
10043
10166
  mutations.forEach(this.processMutation);
10044
10167
  this.emit();
10045
10168
  });
10046
- __publicField(this, "emit", () => {
10169
+ __publicField$2(this, "emit", () => {
10047
10170
  if (this.frozen || this.locked) {
10048
10171
  return;
10049
10172
  }
@@ -10052,19 +10175,19 @@ var leanbase = (function () {
10052
10175
  const addList = new DoubleLinkedList();
10053
10176
  const getNextId = (n2) => {
10054
10177
  let ns = n2;
10055
- let nextId = IGNORED_NODE;
10056
- while (nextId === IGNORED_NODE) {
10178
+ let nextId = IGNORED_NODE$1;
10179
+ while (nextId === IGNORED_NODE$1) {
10057
10180
  ns = ns && ns.nextSibling;
10058
10181
  nextId = ns && this.mirror.getId(ns);
10059
10182
  }
10060
10183
  return nextId;
10061
10184
  };
10062
10185
  const pushAdd = (n2) => {
10063
- const parent = index.parentNode(n2);
10064
- if (!parent || !inDom(n2) || parent.tagName === "TEXTAREA") {
10186
+ const parent = index$2.parentNode(n2);
10187
+ if (!parent || !inDom$1(n2) || parent.tagName === "TEXTAREA") {
10065
10188
  return;
10066
10189
  }
10067
- const parentId = isShadowRoot(parent) ? this.mirror.getId(getShadowHost(n2)) : this.mirror.getId(parent);
10190
+ const parentId = isShadowRoot$1(parent) ? this.mirror.getId(getShadowHost$1(n2)) : this.mirror.getId(parent);
10068
10191
  const nextId = getNextId(n2);
10069
10192
  if (parentId === -1 || nextId === -1) {
10070
10193
  return addList.addNode(n2);
@@ -10087,16 +10210,16 @@ var leanbase = (function () {
10087
10210
  recordCanvas: this.recordCanvas,
10088
10211
  inlineImages: this.inlineImages,
10089
10212
  onSerialize: (currentN) => {
10090
- if (isSerializedIframe(currentN, this.mirror)) {
10213
+ if (isSerializedIframe$1(currentN, this.mirror)) {
10091
10214
  this.iframeManager.addIframe(currentN);
10092
10215
  }
10093
- if (isSerializedStylesheet(currentN, this.mirror)) {
10216
+ if (isSerializedStylesheet$1(currentN, this.mirror)) {
10094
10217
  this.stylesheetManager.trackLinkElement(
10095
10218
  currentN
10096
10219
  );
10097
10220
  }
10098
- if (hasShadowRoot(n2)) {
10099
- this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), this.doc);
10221
+ if (hasShadowRoot$1(n2)) {
10222
+ this.shadowDomManager.addShadowRoot(index$2.shadowRoot(n2), this.doc);
10100
10223
  }
10101
10224
  },
10102
10225
  onIframeLoad: (iframe, childSn) => {
@@ -10120,7 +10243,7 @@ var leanbase = (function () {
10120
10243
  this.mirror.removeNodeFromMap(this.mapRemoves.shift());
10121
10244
  }
10122
10245
  for (const n2 of this.movedSet) {
10123
- if (isParentRemoved(this.removes, n2, this.mirror) && !this.movedSet.has(index.parentNode(n2))) {
10246
+ if (isParentRemoved(this.removes, n2, this.mirror) && !this.movedSet.has(index$2.parentNode(n2))) {
10124
10247
  continue;
10125
10248
  }
10126
10249
  pushAdd(n2);
@@ -10138,7 +10261,7 @@ var leanbase = (function () {
10138
10261
  while (addList.length) {
10139
10262
  let node2 = null;
10140
10263
  if (candidate) {
10141
- const parentId = this.mirror.getId(index.parentNode(candidate.value));
10264
+ const parentId = this.mirror.getId(index$2.parentNode(candidate.value));
10142
10265
  const nextId = getNextId(candidate.value);
10143
10266
  if (parentId !== -1 && nextId !== -1) {
10144
10267
  node2 = candidate;
@@ -10150,7 +10273,7 @@ var leanbase = (function () {
10150
10273
  const _node = tailNode;
10151
10274
  tailNode = tailNode.previous;
10152
10275
  if (_node) {
10153
- const parentId = this.mirror.getId(index.parentNode(_node.value));
10276
+ const parentId = this.mirror.getId(index$2.parentNode(_node.value));
10154
10277
  const nextId = getNextId(_node.value);
10155
10278
  if (nextId === -1) continue;
10156
10279
  else if (parentId !== -1) {
@@ -10158,9 +10281,9 @@ var leanbase = (function () {
10158
10281
  break;
10159
10282
  } else {
10160
10283
  const unhandledNode = _node.value;
10161
- const parent = index.parentNode(unhandledNode);
10284
+ const parent = index$2.parentNode(unhandledNode);
10162
10285
  if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
10163
- const shadowHost = index.host(parent);
10286
+ const shadowHost = index$2.host(parent);
10164
10287
  const parentId2 = this.mirror.getId(shadowHost);
10165
10288
  if (parentId2 !== -1) {
10166
10289
  node2 = _node;
@@ -10184,7 +10307,7 @@ var leanbase = (function () {
10184
10307
  const payload = {
10185
10308
  texts: this.texts.map((text) => {
10186
10309
  const n2 = text.node;
10187
- const parent = index.parentNode(n2);
10310
+ const parent = index$2.parentNode(n2);
10188
10311
  if (parent && parent.tagName === "TEXTAREA") {
10189
10312
  this.genTextAreaValueMutation(parent);
10190
10313
  }
@@ -10225,7 +10348,7 @@ var leanbase = (function () {
10225
10348
  this.movedMap = {};
10226
10349
  this.mutationCb(payload);
10227
10350
  });
10228
- __publicField(this, "genTextAreaValueMutation", (textarea) => {
10351
+ __publicField$2(this, "genTextAreaValueMutation", (textarea) => {
10229
10352
  let item = this.attributeMap.get(textarea);
10230
10353
  if (!item) {
10231
10354
  item = {
@@ -10238,18 +10361,18 @@ var leanbase = (function () {
10238
10361
  this.attributeMap.set(textarea, item);
10239
10362
  }
10240
10363
  item.attributes.value = Array.from(
10241
- index.childNodes(textarea),
10242
- (cn) => index.textContent(cn) || ""
10364
+ index$2.childNodes(textarea),
10365
+ (cn) => index$2.textContent(cn) || ""
10243
10366
  ).join("");
10244
10367
  });
10245
- __publicField(this, "processMutation", (m) => {
10246
- if (isIgnored(m.target, this.mirror, this.slimDOMOptions)) {
10368
+ __publicField$2(this, "processMutation", (m) => {
10369
+ if (isIgnored$1(m.target, this.mirror, this.slimDOMOptions)) {
10247
10370
  return;
10248
10371
  }
10249
10372
  switch (m.type) {
10250
10373
  case "characterData": {
10251
- const value = index.textContent(m.target);
10252
- if (!isBlocked(m.target, this.blockClass, this.blockSelector, false) && value !== m.oldValue) {
10374
+ const value = index$2.textContent(m.target);
10375
+ if (!isBlocked$1(m.target, this.blockClass, this.blockSelector, false) && value !== m.oldValue) {
10253
10376
  this.texts.push({
10254
10377
  value: needMaskingText(
10255
10378
  m.target,
@@ -10257,7 +10380,7 @@ var leanbase = (function () {
10257
10380
  this.maskTextSelector,
10258
10381
  true
10259
10382
  // checkAncestors
10260
- ) && value ? this.maskTextFn ? this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
10383
+ ) && value ? this.maskTextFn ? this.maskTextFn(value, closestElementOfNode$1(m.target)) : value.replace(/[\S]/g, "*") : value,
10261
10384
  node: m.target
10262
10385
  });
10263
10386
  }
@@ -10278,7 +10401,7 @@ var leanbase = (function () {
10278
10401
  maskInputFn: this.maskInputFn
10279
10402
  });
10280
10403
  }
10281
- if (isBlocked(m.target, this.blockClass, this.blockSelector, false) || value === m.oldValue) {
10404
+ if (isBlocked$1(m.target, this.blockClass, this.blockSelector, false) || value === m.oldValue) {
10282
10405
  return;
10283
10406
  }
10284
10407
  let item = this.attributeMap.get(m.target);
@@ -10350,7 +10473,7 @@ var leanbase = (function () {
10350
10473
  break;
10351
10474
  }
10352
10475
  case "childList": {
10353
- if (isBlocked(m.target, this.blockClass, this.blockSelector, true))
10476
+ if (isBlocked$1(m.target, this.blockClass, this.blockSelector, true))
10354
10477
  return;
10355
10478
  if (m.target.tagName === "TEXTAREA") {
10356
10479
  this.genTextAreaValueMutation(m.target);
@@ -10359,22 +10482,22 @@ var leanbase = (function () {
10359
10482
  m.addedNodes.forEach((n2) => this.genAdds(n2, m.target));
10360
10483
  m.removedNodes.forEach((n2) => {
10361
10484
  const nodeId = this.mirror.getId(n2);
10362
- const parentId = isShadowRoot(m.target) ? this.mirror.getId(index.host(m.target)) : this.mirror.getId(m.target);
10363
- if (isBlocked(m.target, this.blockClass, this.blockSelector, false) || isIgnored(n2, this.mirror, this.slimDOMOptions) || !isSerialized(n2, this.mirror)) {
10485
+ const parentId = isShadowRoot$1(m.target) ? this.mirror.getId(index$2.host(m.target)) : this.mirror.getId(m.target);
10486
+ if (isBlocked$1(m.target, this.blockClass, this.blockSelector, false) || isIgnored$1(n2, this.mirror, this.slimDOMOptions) || !isSerialized$1(n2, this.mirror)) {
10364
10487
  return;
10365
10488
  }
10366
10489
  if (this.addedSet.has(n2)) {
10367
10490
  deepDelete(this.addedSet, n2);
10368
10491
  this.droppedSet.add(n2);
10369
10492
  } else if (this.addedSet.has(m.target) && nodeId === -1) ;
10370
- else if (isAncestorRemoved(m.target, this.mirror)) ;
10493
+ else if (isAncestorRemoved$1(m.target, this.mirror)) ;
10371
10494
  else if (this.movedSet.has(n2) && this.movedMap[moveKey(nodeId, parentId)]) {
10372
10495
  deepDelete(this.movedSet, n2);
10373
10496
  } else {
10374
10497
  this.removes.push({
10375
10498
  parentId,
10376
10499
  id: nodeId,
10377
- isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
10500
+ isShadow: isShadowRoot$1(m.target) && isNativeShadowDom(m.target) ? true : void 0
10378
10501
  });
10379
10502
  }
10380
10503
  this.mapRemoves.push(n2);
@@ -10383,11 +10506,11 @@ var leanbase = (function () {
10383
10506
  }
10384
10507
  }
10385
10508
  });
10386
- __publicField(this, "genAdds", (n2, target) => {
10509
+ __publicField$2(this, "genAdds", (n2, target) => {
10387
10510
  if (this.processedNodeManager.inOtherBuffer(n2, this)) return;
10388
10511
  if (this.addedSet.has(n2) || this.movedSet.has(n2)) return;
10389
10512
  if (this.mirror.hasNode(n2)) {
10390
- if (isIgnored(n2, this.mirror, this.slimDOMOptions)) {
10513
+ if (isIgnored$1(n2, this.mirror, this.slimDOMOptions)) {
10391
10514
  return;
10392
10515
  }
10393
10516
  this.movedSet.add(n2);
@@ -10402,10 +10525,10 @@ var leanbase = (function () {
10402
10525
  this.addedSet.add(n2);
10403
10526
  this.droppedSet.delete(n2);
10404
10527
  }
10405
- if (!isBlocked(n2, this.blockClass, this.blockSelector, false)) {
10406
- index.childNodes(n2).forEach((childN) => this.genAdds(childN));
10407
- if (hasShadowRoot(n2)) {
10408
- index.childNodes(index.shadowRoot(n2)).forEach((childN) => {
10528
+ if (!isBlocked$1(n2, this.blockClass, this.blockSelector, false)) {
10529
+ index$2.childNodes(n2).forEach((childN) => this.genAdds(childN));
10530
+ if (hasShadowRoot$1(n2)) {
10531
+ index$2.childNodes(index$2.shadowRoot(n2)).forEach((childN) => {
10409
10532
  this.processedNodeManager.add(childN, this);
10410
10533
  this.genAdds(childN, n2);
10411
10534
  });
@@ -10468,20 +10591,20 @@ var leanbase = (function () {
10468
10591
  }
10469
10592
  function deepDelete(addsSet, n2) {
10470
10593
  addsSet.delete(n2);
10471
- index.childNodes(n2).forEach((childN) => deepDelete(addsSet, childN));
10594
+ index$2.childNodes(n2).forEach((childN) => deepDelete(addsSet, childN));
10472
10595
  }
10473
10596
  function isParentRemoved(removes, n2, mirror2) {
10474
10597
  if (removes.length === 0) return false;
10475
10598
  return _isParentRemoved(removes, n2, mirror2);
10476
10599
  }
10477
10600
  function _isParentRemoved(removes, n2, mirror2) {
10478
- let node2 = index.parentNode(n2);
10601
+ let node2 = index$2.parentNode(n2);
10479
10602
  while (node2) {
10480
10603
  const parentId = mirror2.getId(node2);
10481
10604
  if (removes.some((r2) => r2.id === parentId)) {
10482
10605
  return true;
10483
10606
  }
10484
- node2 = index.parentNode(node2);
10607
+ node2 = index$2.parentNode(node2);
10485
10608
  }
10486
10609
  return false;
10487
10610
  }
@@ -10490,7 +10613,7 @@ var leanbase = (function () {
10490
10613
  return _isAncestorInSet(set, n2);
10491
10614
  }
10492
10615
  function _isAncestorInSet(set, n2) {
10493
- const parent = index.parentNode(n2);
10616
+ const parent = index$2.parentNode(n2);
10494
10617
  if (!parent) {
10495
10618
  return false;
10496
10619
  }
@@ -10541,7 +10664,7 @@ var leanbase = (function () {
10541
10664
  const mutationBuffer = new MutationBuffer();
10542
10665
  mutationBuffers.push(mutationBuffer);
10543
10666
  mutationBuffer.init(options);
10544
- const observer = new (mutationObserverCtor())(
10667
+ const observer = new (mutationObserverCtor$2())(
10545
10668
  callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer))
10546
10669
  );
10547
10670
  observer.observe(rootEl, {
@@ -10568,7 +10691,7 @@ var leanbase = (function () {
10568
10691
  const callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
10569
10692
  let positions = [];
10570
10693
  let timeBaseline;
10571
- const wrappedCb = throttle(
10694
+ const wrappedCb = throttle$1(
10572
10695
  callbackWrapper(
10573
10696
  (source) => {
10574
10697
  const totalOffset = Date.now() - timeBaseline;
@@ -10586,18 +10709,18 @@ var leanbase = (function () {
10586
10709
  callbackThreshold
10587
10710
  );
10588
10711
  const updatePosition = callbackWrapper(
10589
- throttle(
10712
+ throttle$1(
10590
10713
  callbackWrapper((evt) => {
10591
10714
  const target = getEventTarget(evt);
10592
- const { clientX, clientY } = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt;
10715
+ const { clientX, clientY } = legacy_isTouchEvent$1(evt) ? evt.changedTouches[0] : evt;
10593
10716
  if (!timeBaseline) {
10594
- timeBaseline = nowTimestamp();
10717
+ timeBaseline = nowTimestamp$1();
10595
10718
  }
10596
10719
  positions.push({
10597
10720
  x: clientX,
10598
10721
  y: clientY,
10599
10722
  id: mirror2.getId(target),
10600
- timeOffset: nowTimestamp() - timeBaseline
10723
+ timeOffset: nowTimestamp$1() - timeBaseline
10601
10724
  });
10602
10725
  wrappedCb(
10603
10726
  typeof DragEvent !== "undefined" && evt instanceof DragEvent ? IncrementalSource.Drag : evt instanceof MouseEvent ? IncrementalSource.MouseMove : IncrementalSource.TouchMove
@@ -10610,9 +10733,9 @@ var leanbase = (function () {
10610
10733
  )
10611
10734
  );
10612
10735
  const handlers = [
10613
- on("mousemove", updatePosition, doc),
10614
- on("touchmove", updatePosition, doc),
10615
- on("drag", updatePosition, doc)
10736
+ on$1("mousemove", updatePosition, doc),
10737
+ on$1("touchmove", updatePosition, doc),
10738
+ on$1("drag", updatePosition, doc)
10616
10739
  ];
10617
10740
  return callbackWrapper(() => {
10618
10741
  handlers.forEach((h) => h());
@@ -10636,7 +10759,7 @@ var leanbase = (function () {
10636
10759
  const getHandler = (eventKey) => {
10637
10760
  return (event) => {
10638
10761
  const target = getEventTarget(event);
10639
- if (isBlocked(target, blockClass, blockSelector, true)) {
10762
+ if (isBlocked$1(target, blockClass, blockSelector, true)) {
10640
10763
  return;
10641
10764
  }
10642
10765
  let pointerType = null;
@@ -10660,7 +10783,7 @@ var leanbase = (function () {
10660
10783
  thisEventKey = "TouchEnd";
10661
10784
  }
10662
10785
  } else if (pointerType === PointerTypes.Pen) ;
10663
- } else if (legacy_isTouchEvent(event)) {
10786
+ } else if (legacy_isTouchEvent$1(event)) {
10664
10787
  pointerType = PointerTypes.Touch;
10665
10788
  }
10666
10789
  if (pointerType !== null) {
@@ -10672,7 +10795,7 @@ var leanbase = (function () {
10672
10795
  pointerType = currentPointerType;
10673
10796
  currentPointerType = null;
10674
10797
  }
10675
- const e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
10798
+ const e2 = legacy_isTouchEvent$1(event) ? event.changedTouches[0] : event;
10676
10799
  if (!e2) {
10677
10800
  return;
10678
10801
  }
@@ -10706,7 +10829,7 @@ var leanbase = (function () {
10706
10829
  return;
10707
10830
  }
10708
10831
  }
10709
- handlers.push(on(eventName, handler, doc));
10832
+ handlers.push(on$1(eventName, handler, doc));
10710
10833
  });
10711
10834
  return callbackWrapper(() => {
10712
10835
  handlers.forEach((h) => h());
@@ -10721,15 +10844,15 @@ var leanbase = (function () {
10721
10844
  sampling
10722
10845
  }) {
10723
10846
  const updatePosition = callbackWrapper(
10724
- throttle(
10847
+ throttle$1(
10725
10848
  callbackWrapper((evt) => {
10726
10849
  const target = getEventTarget(evt);
10727
- if (!target || isBlocked(target, blockClass, blockSelector, true)) {
10850
+ if (!target || isBlocked$1(target, blockClass, blockSelector, true)) {
10728
10851
  return;
10729
10852
  }
10730
10853
  const id = mirror2.getId(target);
10731
10854
  if (target === doc && doc.defaultView) {
10732
- const scrollLeftTop = getWindowScroll(doc.defaultView);
10855
+ const scrollLeftTop = getWindowScroll$1(doc.defaultView);
10733
10856
  scrollCb({
10734
10857
  id,
10735
10858
  x: scrollLeftTop.left,
@@ -10746,16 +10869,16 @@ var leanbase = (function () {
10746
10869
  sampling.scroll || 100
10747
10870
  )
10748
10871
  );
10749
- return on("scroll", updatePosition, doc);
10872
+ return on$1("scroll", updatePosition, doc);
10750
10873
  }
10751
10874
  function initViewportResizeObserver({ viewportResizeCb }, { win }) {
10752
10875
  let lastH = -1;
10753
10876
  let lastW = -1;
10754
10877
  const updateDimension = callbackWrapper(
10755
- throttle(
10878
+ throttle$1(
10756
10879
  callbackWrapper(() => {
10757
- const height = getWindowHeight();
10758
- const width = getWindowWidth();
10880
+ const height = getWindowHeight$1();
10881
+ const width = getWindowWidth$1();
10759
10882
  if (lastH !== height || lastW !== width) {
10760
10883
  viewportResizeCb({
10761
10884
  width: Number(width),
@@ -10768,7 +10891,7 @@ var leanbase = (function () {
10768
10891
  200
10769
10892
  )
10770
10893
  );
10771
- return on("resize", updateDimension, win);
10894
+ return on$1("resize", updateDimension, win);
10772
10895
  }
10773
10896
  const INPUT_TAGS = ["INPUT", "TEXTAREA", "SELECT"];
10774
10897
  const lastInputValueMap = /* @__PURE__ */ new WeakMap();
@@ -10790,9 +10913,9 @@ var leanbase = (function () {
10790
10913
  const userTriggered = event.isTrusted;
10791
10914
  const tagName = target && target.tagName;
10792
10915
  if (target && tagName === "OPTION") {
10793
- target = index.parentElement(target);
10916
+ target = index$2.parentElement(target);
10794
10917
  }
10795
- if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
10918
+ if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked$1(target, blockClass, blockSelector, true)) {
10796
10919
  return;
10797
10920
  }
10798
10921
  if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
@@ -10843,7 +10966,7 @@ var leanbase = (function () {
10843
10966
  }
10844
10967
  const events = sampling.input === "last" ? ["change"] : ["input", "change"];
10845
10968
  const handlers = events.map(
10846
- (eventName) => on(eventName, callbackWrapper(eventHandler), doc)
10969
+ (eventName) => on$1(eventName, callbackWrapper(eventHandler), doc)
10847
10970
  );
10848
10971
  const currentWindow = doc.defaultView;
10849
10972
  if (!currentWindow) {
@@ -10867,7 +10990,7 @@ var leanbase = (function () {
10867
10990
  if (propertyDescriptor && propertyDescriptor.set) {
10868
10991
  handlers.push(
10869
10992
  ...hookProperties.map(
10870
- (p) => hookSetter(
10993
+ (p) => hookSetter$1(
10871
10994
  p[0],
10872
10995
  p[1],
10873
10996
  {
@@ -11117,7 +11240,7 @@ var leanbase = (function () {
11117
11240
  var _a2, _b, _c;
11118
11241
  let hostId = null;
11119
11242
  if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
11120
- else hostId = mirror2.getId(index.host(host2));
11243
+ else hostId = mirror2.getId(index$2.host(host2));
11121
11244
  const patchTarget = host2.nodeName === "#document" ? (_a2 = host2.defaultView) == null ? void 0 : _a2.Document : (_c = (_b = host2.ownerDocument) == null ? void 0 : _b.defaultView) == null ? void 0 : _c.ShadowRoot;
11122
11245
  const originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(
11123
11246
  patchTarget == null ? void 0 : patchTarget.prototype,
@@ -11236,10 +11359,10 @@ var leanbase = (function () {
11236
11359
  doc
11237
11360
  }) {
11238
11361
  const handler = callbackWrapper(
11239
- (type) => throttle(
11362
+ (type) => throttle$1(
11240
11363
  callbackWrapper((event) => {
11241
11364
  const target = getEventTarget(event);
11242
- if (!target || isBlocked(target, blockClass, blockSelector, true)) {
11365
+ if (!target || isBlocked$1(target, blockClass, blockSelector, true)) {
11243
11366
  return;
11244
11367
  }
11245
11368
  const { currentTime, volume, muted, playbackRate, loop } = target;
@@ -11257,11 +11380,11 @@ var leanbase = (function () {
11257
11380
  )
11258
11381
  );
11259
11382
  const handlers = [
11260
- on("play", handler(MediaInteractions.Play), doc),
11261
- on("pause", handler(MediaInteractions.Pause), doc),
11262
- on("seeked", handler(MediaInteractions.Seeked), doc),
11263
- on("volumechange", handler(MediaInteractions.VolumeChange), doc),
11264
- on("ratechange", handler(MediaInteractions.RateChange), doc)
11383
+ on$1("play", handler(MediaInteractions.Play), doc),
11384
+ on$1("pause", handler(MediaInteractions.Pause), doc),
11385
+ on$1("seeked", handler(MediaInteractions.Seeked), doc),
11386
+ on$1("volumechange", handler(MediaInteractions.VolumeChange), doc),
11387
+ on$1("ratechange", handler(MediaInteractions.RateChange), doc)
11265
11388
  ];
11266
11389
  return callbackWrapper(() => {
11267
11390
  handlers.forEach((h) => h());
@@ -11286,7 +11409,7 @@ var leanbase = (function () {
11286
11409
  });
11287
11410
  return fontFace;
11288
11411
  };
11289
- const restoreHandler = patch(
11412
+ const restoreHandler = patch$2(
11290
11413
  doc.fonts,
11291
11414
  "add",
11292
11415
  function(original) {
@@ -11325,7 +11448,7 @@ var leanbase = (function () {
11325
11448
  for (let i2 = 0; i2 < count; i2++) {
11326
11449
  const range = selection.getRangeAt(i2);
11327
11450
  const { startContainer, startOffset, endContainer, endOffset } = range;
11328
- const blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
11451
+ const blocked = isBlocked$1(startContainer, blockClass, blockSelector, true) || isBlocked$1(endContainer, blockClass, blockSelector, true);
11329
11452
  if (blocked) continue;
11330
11453
  ranges.push({
11331
11454
  start: mirror2.getId(startContainer),
@@ -11337,7 +11460,7 @@ var leanbase = (function () {
11337
11460
  selectionCb({ ranges });
11338
11461
  });
11339
11462
  updateSelection();
11340
- return on("selectionchange", updateSelection);
11463
+ return on$1("selectionchange", updateSelection);
11341
11464
  }
11342
11465
  function initCustomElementObserver({
11343
11466
  doc,
@@ -11346,7 +11469,7 @@ var leanbase = (function () {
11346
11469
  const win = doc.defaultView;
11347
11470
  if (!win || !win.customElements) return () => {
11348
11471
  };
11349
- const restoreHandler = patch(
11472
+ const restoreHandler = patch$2(
11350
11473
  win.customElements,
11351
11474
  "define",
11352
11475
  function(original) {
@@ -11536,8 +11659,8 @@ var leanbase = (function () {
11536
11659
  }
11537
11660
  class CrossOriginIframeMirror {
11538
11661
  constructor(generateIdFn) {
11539
- __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
11540
- __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
11662
+ __publicField$2(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
11663
+ __publicField$2(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
11541
11664
  this.generateIdFn = generateIdFn;
11542
11665
  }
11543
11666
  getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
@@ -11597,17 +11720,17 @@ var leanbase = (function () {
11597
11720
  }
11598
11721
  class IframeManager {
11599
11722
  constructor(options) {
11600
- __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
11601
- __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
11602
- __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
11603
- __publicField(this, "crossOriginIframeStyleMirror");
11604
- __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
11605
- __publicField(this, "mirror");
11606
- __publicField(this, "mutationCb");
11607
- __publicField(this, "wrappedEmit");
11608
- __publicField(this, "loadListener");
11609
- __publicField(this, "stylesheetManager");
11610
- __publicField(this, "recordCrossOriginIframes");
11723
+ __publicField$2(this, "iframes", /* @__PURE__ */ new WeakMap());
11724
+ __publicField$2(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
11725
+ __publicField$2(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
11726
+ __publicField$2(this, "crossOriginIframeStyleMirror");
11727
+ __publicField$2(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
11728
+ __publicField$2(this, "mirror");
11729
+ __publicField$2(this, "mutationCb");
11730
+ __publicField$2(this, "wrappedEmit");
11731
+ __publicField$2(this, "loadListener");
11732
+ __publicField$2(this, "stylesheetManager");
11733
+ __publicField$2(this, "recordCrossOriginIframes");
11611
11734
  this.mutationCb = options.mutationCb;
11612
11735
  this.wrappedEmit = options.wrappedEmit;
11613
11736
  this.stylesheetManager = options.stylesheetManager;
@@ -11831,12 +11954,12 @@ var leanbase = (function () {
11831
11954
  }
11832
11955
  class ShadowDomManager {
11833
11956
  constructor(options) {
11834
- __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
11835
- __publicField(this, "mutationCb");
11836
- __publicField(this, "scrollCb");
11837
- __publicField(this, "bypassOptions");
11838
- __publicField(this, "mirror");
11839
- __publicField(this, "restoreHandlers", []);
11957
+ __publicField$2(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
11958
+ __publicField$2(this, "mutationCb");
11959
+ __publicField$2(this, "scrollCb");
11960
+ __publicField$2(this, "bypassOptions");
11961
+ __publicField$2(this, "mirror");
11962
+ __publicField$2(this, "restoreHandlers", []);
11840
11963
  this.mutationCb = options.mutationCb;
11841
11964
  this.scrollCb = options.scrollCb;
11842
11965
  this.bypassOptions = options.bypassOptions;
@@ -11876,7 +11999,7 @@ var leanbase = (function () {
11876
11999
  if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0)
11877
12000
  this.bypassOptions.stylesheetManager.adoptStyleSheets(
11878
12001
  shadowRoot2.adoptedStyleSheets,
11879
- this.mirror.getId(index.host(shadowRoot2))
12002
+ this.mirror.getId(index$2.host(shadowRoot2))
11880
12003
  );
11881
12004
  this.restoreHandlers.push(
11882
12005
  initAdoptedStyleSheetObserver(
@@ -11905,14 +12028,14 @@ var leanbase = (function () {
11905
12028
  patchAttachShadow(element, doc) {
11906
12029
  const manager = this;
11907
12030
  this.restoreHandlers.push(
11908
- patch(
12031
+ patch$2(
11909
12032
  element.prototype,
11910
12033
  "attachShadow",
11911
12034
  function(original) {
11912
12035
  return function(option) {
11913
12036
  const sRoot = original.call(this, option);
11914
- const shadowRootEl = index.shadowRoot(this);
11915
- if (shadowRootEl && inDom(this))
12037
+ const shadowRootEl = index$2.shadowRoot(this);
12038
+ if (shadowRootEl && inDom$1(this))
11916
12039
  manager.addShadowRoot(shadowRootEl, doc);
11917
12040
  return sRoot;
11918
12041
  };
@@ -11931,18 +12054,18 @@ var leanbase = (function () {
11931
12054
  this.shadowDoms = /* @__PURE__ */ new WeakSet();
11932
12055
  }
11933
12056
  }
11934
- var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
11935
- var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
11936
- for (var i$1 = 0; i$1 < chars.length; i$1++) {
11937
- lookup[chars.charCodeAt(i$1)] = i$1;
12057
+ var chars$1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
12058
+ var lookup$1 = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
12059
+ for (var i$1$1 = 0; i$1$1 < chars$1.length; i$1$1++) {
12060
+ lookup$1[chars$1.charCodeAt(i$1$1)] = i$1$1;
11938
12061
  }
11939
12062
  var encode = function(arraybuffer) {
11940
12063
  var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
11941
12064
  for (i2 = 0; i2 < len; i2 += 3) {
11942
- base64 += chars[bytes[i2] >> 2];
11943
- base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
11944
- base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
11945
- base64 += chars[bytes[i2 + 2] & 63];
12065
+ base64 += chars$1[bytes[i2] >> 2];
12066
+ base64 += chars$1[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
12067
+ base64 += chars$1[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
12068
+ base64 += chars$1[bytes[i2 + 2] & 63];
11946
12069
  }
11947
12070
  if (len % 3 === 2) {
11948
12071
  base64 = base64.substring(0, base64.length - 1) + "=";
@@ -12075,12 +12198,12 @@ var leanbase = (function () {
12075
12198
  if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
12076
12199
  continue;
12077
12200
  }
12078
- const restoreHandler = patch(
12201
+ const restoreHandler = patch$2(
12079
12202
  win.CanvasRenderingContext2D.prototype,
12080
12203
  prop,
12081
12204
  function(original) {
12082
12205
  return function(...args) {
12083
- if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
12206
+ if (!isBlocked$1(this.canvas, blockClass, blockSelector, true)) {
12084
12207
  setTimeout(() => {
12085
12208
  const recordArgs = serializeArgs(args, win, this);
12086
12209
  cb(this.canvas, {
@@ -12096,7 +12219,7 @@ var leanbase = (function () {
12096
12219
  );
12097
12220
  handlers.push(restoreHandler);
12098
12221
  } catch {
12099
- const hookHandler = hookSetter(
12222
+ const hookHandler = hookSetter$1(
12100
12223
  win.CanvasRenderingContext2D.prototype,
12101
12224
  prop,
12102
12225
  {
@@ -12123,12 +12246,12 @@ var leanbase = (function () {
12123
12246
  function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
12124
12247
  const handlers = [];
12125
12248
  try {
12126
- const restoreHandler = patch(
12249
+ const restoreHandler = patch$2(
12127
12250
  win.HTMLCanvasElement.prototype,
12128
12251
  "getContext",
12129
12252
  function(original) {
12130
12253
  return function(contextType, ...args) {
12131
- if (!isBlocked(this, blockClass, blockSelector, true)) {
12254
+ if (!isBlocked$1(this, blockClass, blockSelector, true)) {
12132
12255
  const ctxName = getNormalizedContextName(contextType);
12133
12256
  if (!("__context" in this)) this.__context = ctxName;
12134
12257
  if (setPreserveDrawingBufferToTrue && ["webgl", "webgl2"].includes(ctxName)) {
@@ -12175,14 +12298,14 @@ var leanbase = (function () {
12175
12298
  if (typeof prototype[prop] !== "function") {
12176
12299
  continue;
12177
12300
  }
12178
- const restoreHandler = patch(
12301
+ const restoreHandler = patch$2(
12179
12302
  prototype,
12180
12303
  prop,
12181
12304
  function(original) {
12182
12305
  return function(...args) {
12183
12306
  const result2 = original.apply(this, args);
12184
12307
  saveWebGLVar(result2, win, this);
12185
- if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
12308
+ if ("tagName" in this.canvas && !isBlocked$1(this.canvas, blockClass, blockSelector, true)) {
12186
12309
  const recordArgs = serializeArgs(args, win, this);
12187
12310
  const mutation = {
12188
12311
  type,
@@ -12197,7 +12320,7 @@ var leanbase = (function () {
12197
12320
  );
12198
12321
  handlers.push(restoreHandler);
12199
12322
  } catch {
12200
- const hookHandler = hookSetter(prototype, prop, {
12323
+ const hookHandler = hookSetter$1(prototype, prop, {
12201
12324
  set(v2) {
12202
12325
  cb(this.canvas, {
12203
12326
  type,
@@ -12240,9 +12363,9 @@ var leanbase = (function () {
12240
12363
  handlers.forEach((h) => h());
12241
12364
  };
12242
12365
  }
12243
- const encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
12244
- const decodeBase64 = (base64) => Uint8Array.from(atob(base64), (c2) => c2.charCodeAt(0));
12245
- const blob = typeof window !== "undefined" && window.Blob && new Blob([decodeBase64(encodedJs)], { type: "text/javascript;charset=utf-8" });
12366
+ const encodedJs$1 = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
12367
+ const decodeBase64$1 = (base64) => Uint8Array.from(atob(base64), (c2) => c2.charCodeAt(0));
12368
+ const blob = typeof window !== "undefined" && window.Blob && new Blob([decodeBase64$1(encodedJs$1)], { type: "text/javascript;charset=utf-8" });
12246
12369
  function WorkerWrapper(options) {
12247
12370
  let objURL;
12248
12371
  try {
@@ -12257,7 +12380,7 @@ var leanbase = (function () {
12257
12380
  return worker;
12258
12381
  } catch (e2) {
12259
12382
  return new Worker(
12260
- "data:text/javascript;base64," + encodedJs,
12383
+ "data:text/javascript;base64," + encodedJs$1,
12261
12384
  {
12262
12385
  name: options == null ? void 0 : options.name
12263
12386
  }
@@ -12268,14 +12391,14 @@ var leanbase = (function () {
12268
12391
  }
12269
12392
  class CanvasManager {
12270
12393
  constructor(options) {
12271
- __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
12272
- __publicField(this, "rafStamps", { latestId: 0, invokeId: null });
12273
- __publicField(this, "mirror");
12274
- __publicField(this, "mutationCb");
12275
- __publicField(this, "resetObservers");
12276
- __publicField(this, "frozen", false);
12277
- __publicField(this, "locked", false);
12278
- __publicField(this, "processMutation", (target, mutation) => {
12394
+ __publicField$2(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
12395
+ __publicField$2(this, "rafStamps", { latestId: 0, invokeId: null });
12396
+ __publicField$2(this, "mirror");
12397
+ __publicField$2(this, "mutationCb");
12398
+ __publicField$2(this, "resetObservers");
12399
+ __publicField$2(this, "frozen", false);
12400
+ __publicField$2(this, "locked", false);
12401
+ __publicField$2(this, "processMutation", (target, mutation) => {
12279
12402
  const newFrame = this.rafStamps.invokeId && this.rafStamps.latestId !== this.rafStamps.invokeId;
12280
12403
  if (newFrame || !this.rafStamps.invokeId)
12281
12404
  this.rafStamps.invokeId = this.rafStamps.latestId;
@@ -12368,7 +12491,7 @@ var leanbase = (function () {
12368
12491
  const matchedCanvas = [];
12369
12492
  const searchCanvas = (root) => {
12370
12493
  root.querySelectorAll("canvas").forEach((canvas) => {
12371
- if (!isBlocked(canvas, blockClass, blockSelector, true)) {
12494
+ if (!isBlocked$1(canvas, blockClass, blockSelector, true)) {
12372
12495
  matchedCanvas.push(canvas);
12373
12496
  }
12374
12497
  });
@@ -12489,10 +12612,10 @@ var leanbase = (function () {
12489
12612
  }
12490
12613
  class StylesheetManager {
12491
12614
  constructor(options) {
12492
- __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
12493
- __publicField(this, "mutationCb");
12494
- __publicField(this, "adoptedStyleSheetCb");
12495
- __publicField(this, "styleMirror", new StyleSheetMirror());
12615
+ __publicField$2(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
12616
+ __publicField$2(this, "mutationCb");
12617
+ __publicField$2(this, "adoptedStyleSheetCb");
12618
+ __publicField$2(this, "styleMirror", new StyleSheetMirror$1());
12496
12619
  this.mutationCb = options.mutationCb;
12497
12620
  this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
12498
12621
  }
@@ -12550,8 +12673,8 @@ var leanbase = (function () {
12550
12673
  }
12551
12674
  class ProcessedNodeManager {
12552
12675
  constructor() {
12553
- __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
12554
- __publicField(this, "active", false);
12676
+ __publicField$2(this, "nodeMap", /* @__PURE__ */ new WeakMap());
12677
+ __publicField$2(this, "active", false);
12555
12678
  }
12556
12679
  inOtherBuffer(node2, thisBuffer) {
12557
12680
  const buffers = this.nodeMap.get(node2);
@@ -12578,13 +12701,13 @@ var leanbase = (function () {
12578
12701
  if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
12579
12702
  const cleanFrame = document.createElement("iframe");
12580
12703
  document.body.appendChild(cleanFrame);
12581
- Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
12704
+ Array.from = ((_a$1 = cleanFrame.contentWindow) == null ? void 0 : _a$1.Array.from) || Array.from;
12582
12705
  document.body.removeChild(cleanFrame);
12583
12706
  }
12584
12707
  } catch (err) {
12585
12708
  console.debug("Unable to override Array.from", err);
12586
12709
  }
12587
- const mirror = createMirror$2();
12710
+ const mirror = createMirror$2$1();
12588
12711
  function record(options = {}) {
12589
12712
  const {
12590
12713
  emit,
@@ -12675,7 +12798,7 @@ var leanbase = (function () {
12675
12798
  headMetaDescKeywords: _slimDOMOptions === "all",
12676
12799
  headTitleMutations: _slimDOMOptions === "all"
12677
12800
  } : _slimDOMOptions ? _slimDOMOptions : {};
12678
- polyfill$1();
12801
+ polyfill$1$1();
12679
12802
  let lastFullSnapshotEvent;
12680
12803
  let incrementalSnapshotCount = 0;
12681
12804
  const eventProcessor = (e2) => {
@@ -12693,7 +12816,7 @@ var leanbase = (function () {
12693
12816
  wrappedEmit = (r2, isCheckout) => {
12694
12817
  var _a2;
12695
12818
  const e2 = r2;
12696
- e2.timestamp = nowTimestamp();
12819
+ e2.timestamp = nowTimestamp$1();
12697
12820
  if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
12698
12821
  mutationBuffers.forEach((buf) => buf.unfreeze());
12699
12822
  }
@@ -12817,8 +12940,8 @@ var leanbase = (function () {
12817
12940
  type: EventType.Meta,
12818
12941
  data: {
12819
12942
  href: window.location.href,
12820
- width: getWindowWidth(),
12821
- height: getWindowHeight()
12943
+ width: getWindowWidth$1(),
12944
+ height: getWindowHeight$1()
12822
12945
  }
12823
12946
  },
12824
12947
  isCheckout
@@ -12841,14 +12964,14 @@ var leanbase = (function () {
12841
12964
  recordCanvas,
12842
12965
  inlineImages,
12843
12966
  onSerialize: (n2) => {
12844
- if (isSerializedIframe(n2, mirror)) {
12967
+ if (isSerializedIframe$1(n2, mirror)) {
12845
12968
  iframeManager.addIframe(n2);
12846
12969
  }
12847
- if (isSerializedStylesheet(n2, mirror)) {
12970
+ if (isSerializedStylesheet$1(n2, mirror)) {
12848
12971
  stylesheetManager.trackLinkElement(n2);
12849
12972
  }
12850
- if (hasShadowRoot(n2)) {
12851
- shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
12973
+ if (hasShadowRoot$1(n2)) {
12974
+ shadowDomManager.addShadowRoot(index$2.shadowRoot(n2), document);
12852
12975
  }
12853
12976
  },
12854
12977
  onIframeLoad: (iframe, childSn) => {
@@ -12868,7 +12991,7 @@ var leanbase = (function () {
12868
12991
  type: EventType.FullSnapshot,
12869
12992
  data: {
12870
12993
  node: node2,
12871
- initialOffset: getWindowScroll(window)
12994
+ initialOffset: getWindowScroll$1(window)
12872
12995
  }
12873
12996
  },
12874
12997
  isCheckout
@@ -13021,7 +13144,7 @@ var leanbase = (function () {
13021
13144
  init();
13022
13145
  } else {
13023
13146
  handlers.push(
13024
- on("DOMContentLoaded", () => {
13147
+ on$1("DOMContentLoaded", () => {
13025
13148
  wrappedEmit({
13026
13149
  type: EventType.DomContentLoaded,
13027
13150
  data: {}
@@ -13030,7 +13153,7 @@ var leanbase = (function () {
13030
13153
  })
13031
13154
  );
13032
13155
  handlers.push(
13033
- on(
13156
+ on$1(
13034
13157
  "load",
13035
13158
  () => {
13036
13159
  wrappedEmit({
@@ -13075,16 +13198,1960 @@ var leanbase = (function () {
13075
13198
  takeFullSnapshot$1(isCheckout);
13076
13199
  };
13077
13200
  record.mirror = mirror;
13078
- var n;
13201
+ var n$1;
13079
13202
  !function(t2) {
13080
13203
  t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
13081
- }(n || (n = {}));
13204
+ }(n$1 || (n$1 = {}));
13082
13205
 
13083
13206
  var record$1 = /*#__PURE__*/Object.freeze({
13084
13207
  __proto__: null,
13085
13208
  record: record
13086
13209
  });
13087
13210
 
13211
+ var __defProp = Object.defineProperty;
13212
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13213
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
13214
+ var __defProp2 = Object.defineProperty;
13215
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13216
+ var __publicField2$1 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
13217
+ var _a;
13218
+ var __defProp$1 = Object.defineProperty;
13219
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13220
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
13221
+ const testableAccessors$1 = {
13222
+ Node: ["childNodes", "parentNode", "parentElement", "textContent"],
13223
+ ShadowRoot: ["host", "styleSheets"],
13224
+ Element: ["shadowRoot", "querySelector", "querySelectorAll"],
13225
+ MutationObserver: []
13226
+ };
13227
+ const testableMethods$1 = {
13228
+ Node: ["contains", "getRootNode"],
13229
+ ShadowRoot: ["getSelection"],
13230
+ Element: [],
13231
+ MutationObserver: ["constructor"]
13232
+ };
13233
+ const untaintedBasePrototype$1 = {};
13234
+ function getUntaintedPrototype$1(key) {
13235
+ if (untaintedBasePrototype$1[key])
13236
+ return untaintedBasePrototype$1[key];
13237
+ const defaultObj = globalThis[key];
13238
+ const defaultPrototype = defaultObj.prototype;
13239
+ const accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
13240
+ const isUntaintedAccessors = Boolean(
13241
+ accessorNames && // @ts-expect-error 2345
13242
+ accessorNames.every(
13243
+ (accessor) => {
13244
+ var _a2, _b;
13245
+ return Boolean(
13246
+ (_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]")
13247
+ );
13248
+ }
13249
+ )
13250
+ );
13251
+ const methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
13252
+ const isUntaintedMethods = Boolean(
13253
+ methodNames && methodNames.every(
13254
+ // @ts-expect-error 2345
13255
+ (method) => {
13256
+ var _a2;
13257
+ return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
13258
+ }
13259
+ )
13260
+ );
13261
+ if (isUntaintedAccessors && isUntaintedMethods) {
13262
+ untaintedBasePrototype$1[key] = defaultObj.prototype;
13263
+ return defaultObj.prototype;
13264
+ }
13265
+ try {
13266
+ const iframeEl = document.createElement("iframe");
13267
+ document.body.appendChild(iframeEl);
13268
+ const win = iframeEl.contentWindow;
13269
+ if (!win) return defaultObj.prototype;
13270
+ const untaintedObject = win[key].prototype;
13271
+ document.body.removeChild(iframeEl);
13272
+ if (!untaintedObject) return defaultPrototype;
13273
+ return untaintedBasePrototype$1[key] = untaintedObject;
13274
+ } catch {
13275
+ return defaultPrototype;
13276
+ }
13277
+ }
13278
+ const untaintedAccessorCache$1 = {};
13279
+ function getUntaintedAccessor$1(key, instance, accessor) {
13280
+ var _a2;
13281
+ const cacheKey = `${key}.${String(accessor)}`;
13282
+ if (untaintedAccessorCache$1[cacheKey])
13283
+ return untaintedAccessorCache$1[cacheKey].call(
13284
+ instance
13285
+ );
13286
+ const untaintedPrototype = getUntaintedPrototype$1(key);
13287
+ const untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(
13288
+ untaintedPrototype,
13289
+ accessor
13290
+ )) == null ? void 0 : _a2.get;
13291
+ if (!untaintedAccessor) return instance[accessor];
13292
+ untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
13293
+ return untaintedAccessor.call(instance);
13294
+ }
13295
+ const untaintedMethodCache$1 = {};
13296
+ function getUntaintedMethod$1(key, instance, method) {
13297
+ const cacheKey = `${key}.${String(method)}`;
13298
+ if (untaintedMethodCache$1[cacheKey])
13299
+ return untaintedMethodCache$1[cacheKey].bind(
13300
+ instance
13301
+ );
13302
+ const untaintedPrototype = getUntaintedPrototype$1(key);
13303
+ const untaintedMethod = untaintedPrototype[method];
13304
+ if (typeof untaintedMethod !== "function") return instance[method];
13305
+ untaintedMethodCache$1[cacheKey] = untaintedMethod;
13306
+ return untaintedMethod.bind(instance);
13307
+ }
13308
+ function childNodes$1(n2) {
13309
+ return getUntaintedAccessor$1("Node", n2, "childNodes");
13310
+ }
13311
+ function parentNode$1(n2) {
13312
+ return getUntaintedAccessor$1("Node", n2, "parentNode");
13313
+ }
13314
+ function parentElement$1(n2) {
13315
+ return getUntaintedAccessor$1("Node", n2, "parentElement");
13316
+ }
13317
+ function textContent$1(n2) {
13318
+ return getUntaintedAccessor$1("Node", n2, "textContent");
13319
+ }
13320
+ function contains$1(n2, other) {
13321
+ return getUntaintedMethod$1("Node", n2, "contains")(other);
13322
+ }
13323
+ function getRootNode$1(n2) {
13324
+ return getUntaintedMethod$1("Node", n2, "getRootNode")();
13325
+ }
13326
+ function host$1(n2) {
13327
+ if (!n2 || !("host" in n2)) return null;
13328
+ return getUntaintedAccessor$1("ShadowRoot", n2, "host");
13329
+ }
13330
+ function styleSheets$1(n2) {
13331
+ return n2.styleSheets;
13332
+ }
13333
+ function shadowRoot$1(n2) {
13334
+ if (!n2 || !("shadowRoot" in n2)) return null;
13335
+ return getUntaintedAccessor$1("Element", n2, "shadowRoot");
13336
+ }
13337
+ function querySelector$1(n2, selectors) {
13338
+ return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
13339
+ }
13340
+ function querySelectorAll$1(n2, selectors) {
13341
+ return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
13342
+ }
13343
+ function mutationObserverCtor$1() {
13344
+ return getUntaintedPrototype$1("MutationObserver").constructor;
13345
+ }
13346
+ const index$1 = {
13347
+ childNodes: childNodes$1,
13348
+ parentNode: parentNode$1,
13349
+ parentElement: parentElement$1,
13350
+ textContent: textContent$1,
13351
+ contains: contains$1,
13352
+ getRootNode: getRootNode$1,
13353
+ host: host$1,
13354
+ styleSheets: styleSheets$1,
13355
+ shadowRoot: shadowRoot$1,
13356
+ querySelector: querySelector$1,
13357
+ querySelectorAll: querySelectorAll$1,
13358
+ mutationObserver: mutationObserverCtor$1
13359
+ };
13360
+ function isShadowRoot(n2) {
13361
+ const hostEl = (
13362
+ // anchor and textarea elements also have a `host` property
13363
+ // but only shadow roots have a `mode` property
13364
+ n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null
13365
+ );
13366
+ return Boolean(
13367
+ hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2
13368
+ );
13369
+ }
13370
+ class Mirror {
13371
+ constructor() {
13372
+ __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
13373
+ __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
13374
+ }
13375
+ getId(n2) {
13376
+ var _a2;
13377
+ if (!n2) return -1;
13378
+ const id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
13379
+ return id ?? -1;
13380
+ }
13381
+ getNode(id) {
13382
+ return this.idNodeMap.get(id) || null;
13383
+ }
13384
+ getIds() {
13385
+ return Array.from(this.idNodeMap.keys());
13386
+ }
13387
+ getMeta(n2) {
13388
+ return this.nodeMetaMap.get(n2) || null;
13389
+ }
13390
+ // removes the node from idNodeMap
13391
+ // doesn't remove the node from nodeMetaMap
13392
+ removeNodeFromMap(n2) {
13393
+ const id = this.getId(n2);
13394
+ this.idNodeMap.delete(id);
13395
+ if (n2.childNodes) {
13396
+ n2.childNodes.forEach(
13397
+ (childNode) => this.removeNodeFromMap(childNode)
13398
+ );
13399
+ }
13400
+ }
13401
+ has(id) {
13402
+ return this.idNodeMap.has(id);
13403
+ }
13404
+ hasNode(node2) {
13405
+ return this.nodeMetaMap.has(node2);
13406
+ }
13407
+ add(n2, meta) {
13408
+ const id = meta.id;
13409
+ this.idNodeMap.set(id, n2);
13410
+ this.nodeMetaMap.set(n2, meta);
13411
+ }
13412
+ replace(id, n2) {
13413
+ const oldNode = this.getNode(id);
13414
+ if (oldNode) {
13415
+ const meta = this.nodeMetaMap.get(oldNode);
13416
+ if (meta) this.nodeMetaMap.set(n2, meta);
13417
+ }
13418
+ this.idNodeMap.set(id, n2);
13419
+ }
13420
+ reset() {
13421
+ this.idNodeMap = /* @__PURE__ */ new Map();
13422
+ this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
13423
+ }
13424
+ }
13425
+ function createMirror$2() {
13426
+ return new Mirror();
13427
+ }
13428
+ const IGNORED_NODE = -2;
13429
+ function classMatchesRegex(node2, regex, checkAncestors) {
13430
+ if (!node2) return false;
13431
+ if (node2.nodeType !== node2.ELEMENT_NODE) {
13432
+ if (!checkAncestors) return false;
13433
+ return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
13434
+ }
13435
+ for (let eIndex = node2.classList.length; eIndex--; ) {
13436
+ const className = node2.classList[eIndex];
13437
+ if (regex.test(className)) {
13438
+ return true;
13439
+ }
13440
+ }
13441
+ if (!checkAncestors) return false;
13442
+ return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
13443
+ }
13444
+ // Removed postcss here
13445
+ class BaseRRNode {
13446
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
13447
+ constructor(..._args) {
13448
+ __publicField22(this, "parentElement", null);
13449
+ __publicField22(this, "parentNode", null);
13450
+ __publicField22(this, "ownerDocument");
13451
+ __publicField22(this, "firstChild", null);
13452
+ __publicField22(this, "lastChild", null);
13453
+ __publicField22(this, "previousSibling", null);
13454
+ __publicField22(this, "nextSibling", null);
13455
+ __publicField22(this, "ELEMENT_NODE", 1);
13456
+ __publicField22(this, "TEXT_NODE", 3);
13457
+ __publicField22(this, "nodeType");
13458
+ __publicField22(this, "nodeName");
13459
+ __publicField22(this, "RRNodeType");
13460
+ }
13461
+ get childNodes() {
13462
+ const childNodes2 = [];
13463
+ let childIterator = this.firstChild;
13464
+ while (childIterator) {
13465
+ childNodes2.push(childIterator);
13466
+ childIterator = childIterator.nextSibling;
13467
+ }
13468
+ return childNodes2;
13469
+ }
13470
+ contains(node2) {
13471
+ if (!(node2 instanceof BaseRRNode)) return false;
13472
+ else if (node2.ownerDocument !== this.ownerDocument) return false;
13473
+ else if (node2 === this) return true;
13474
+ while (node2.parentNode) {
13475
+ if (node2.parentNode === this) return true;
13476
+ node2 = node2.parentNode;
13477
+ }
13478
+ return false;
13479
+ }
13480
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
13481
+ appendChild(_newChild) {
13482
+ throw new Error(
13483
+ `RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.`
13484
+ );
13485
+ }
13486
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
13487
+ insertBefore(_newChild, _refChild) {
13488
+ throw new Error(
13489
+ `RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.`
13490
+ );
13491
+ }
13492
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
13493
+ removeChild(_node) {
13494
+ throw new Error(
13495
+ `RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.`
13496
+ );
13497
+ }
13498
+ toString() {
13499
+ return "RRNode";
13500
+ }
13501
+ }
13502
+ const testableAccessors = {
13503
+ Node: ["childNodes", "parentNode", "parentElement", "textContent"],
13504
+ ShadowRoot: ["host", "styleSheets"],
13505
+ Element: ["shadowRoot", "querySelector", "querySelectorAll"],
13506
+ MutationObserver: []
13507
+ };
13508
+ const testableMethods = {
13509
+ Node: ["contains", "getRootNode"],
13510
+ ShadowRoot: ["getSelection"],
13511
+ Element: [],
13512
+ MutationObserver: ["constructor"]
13513
+ };
13514
+ const untaintedBasePrototype = {};
13515
+ function getUntaintedPrototype(key) {
13516
+ if (untaintedBasePrototype[key])
13517
+ return untaintedBasePrototype[key];
13518
+ const defaultObj = globalThis[key];
13519
+ const defaultPrototype = defaultObj.prototype;
13520
+ const accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
13521
+ const isUntaintedAccessors = Boolean(
13522
+ accessorNames && // @ts-expect-error 2345
13523
+ accessorNames.every(
13524
+ (accessor) => {
13525
+ var _a2, _b;
13526
+ return Boolean(
13527
+ (_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]")
13528
+ );
13529
+ }
13530
+ )
13531
+ );
13532
+ const methodNames = key in testableMethods ? testableMethods[key] : void 0;
13533
+ const isUntaintedMethods = Boolean(
13534
+ methodNames && methodNames.every(
13535
+ // @ts-expect-error 2345
13536
+ (method) => {
13537
+ var _a2;
13538
+ return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
13539
+ }
13540
+ )
13541
+ );
13542
+ if (isUntaintedAccessors && isUntaintedMethods) {
13543
+ untaintedBasePrototype[key] = defaultObj.prototype;
13544
+ return defaultObj.prototype;
13545
+ }
13546
+ try {
13547
+ const iframeEl = document.createElement("iframe");
13548
+ document.body.appendChild(iframeEl);
13549
+ const win = iframeEl.contentWindow;
13550
+ if (!win) return defaultObj.prototype;
13551
+ const untaintedObject = win[key].prototype;
13552
+ document.body.removeChild(iframeEl);
13553
+ if (!untaintedObject) return defaultPrototype;
13554
+ return untaintedBasePrototype[key] = untaintedObject;
13555
+ } catch {
13556
+ return defaultPrototype;
13557
+ }
13558
+ }
13559
+ const untaintedAccessorCache = {};
13560
+ function getUntaintedAccessor(key, instance, accessor) {
13561
+ var _a2;
13562
+ const cacheKey = `${key}.${String(accessor)}`;
13563
+ if (untaintedAccessorCache[cacheKey])
13564
+ return untaintedAccessorCache[cacheKey].call(
13565
+ instance
13566
+ );
13567
+ const untaintedPrototype = getUntaintedPrototype(key);
13568
+ const untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(
13569
+ untaintedPrototype,
13570
+ accessor
13571
+ )) == null ? void 0 : _a2.get;
13572
+ if (!untaintedAccessor) return instance[accessor];
13573
+ untaintedAccessorCache[cacheKey] = untaintedAccessor;
13574
+ return untaintedAccessor.call(instance);
13575
+ }
13576
+ const untaintedMethodCache = {};
13577
+ function getUntaintedMethod(key, instance, method) {
13578
+ const cacheKey = `${key}.${String(method)}`;
13579
+ if (untaintedMethodCache[cacheKey])
13580
+ return untaintedMethodCache[cacheKey].bind(
13581
+ instance
13582
+ );
13583
+ const untaintedPrototype = getUntaintedPrototype(key);
13584
+ const untaintedMethod = untaintedPrototype[method];
13585
+ if (typeof untaintedMethod !== "function") return instance[method];
13586
+ untaintedMethodCache[cacheKey] = untaintedMethod;
13587
+ return untaintedMethod.bind(instance);
13588
+ }
13589
+ function childNodes(n2) {
13590
+ return getUntaintedAccessor("Node", n2, "childNodes");
13591
+ }
13592
+ function parentNode(n2) {
13593
+ return getUntaintedAccessor("Node", n2, "parentNode");
13594
+ }
13595
+ function parentElement(n2) {
13596
+ return getUntaintedAccessor("Node", n2, "parentElement");
13597
+ }
13598
+ function textContent(n2) {
13599
+ return getUntaintedAccessor("Node", n2, "textContent");
13600
+ }
13601
+ function contains(n2, other) {
13602
+ return getUntaintedMethod("Node", n2, "contains")(other);
13603
+ }
13604
+ function getRootNode(n2) {
13605
+ return getUntaintedMethod("Node", n2, "getRootNode")();
13606
+ }
13607
+ function host(n2) {
13608
+ if (!n2 || !("host" in n2)) return null;
13609
+ return getUntaintedAccessor("ShadowRoot", n2, "host");
13610
+ }
13611
+ function styleSheets(n2) {
13612
+ return n2.styleSheets;
13613
+ }
13614
+ function shadowRoot(n2) {
13615
+ if (!n2 || !("shadowRoot" in n2)) return null;
13616
+ return getUntaintedAccessor("Element", n2, "shadowRoot");
13617
+ }
13618
+ function querySelector(n2, selectors) {
13619
+ return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
13620
+ }
13621
+ function querySelectorAll(n2, selectors) {
13622
+ return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
13623
+ }
13624
+ function mutationObserverCtor() {
13625
+ return getUntaintedPrototype("MutationObserver").constructor;
13626
+ }
13627
+ const index = {
13628
+ childNodes,
13629
+ parentNode,
13630
+ parentElement,
13631
+ textContent,
13632
+ contains,
13633
+ getRootNode,
13634
+ host,
13635
+ styleSheets,
13636
+ shadowRoot,
13637
+ querySelector,
13638
+ querySelectorAll,
13639
+ mutationObserver: mutationObserverCtor
13640
+ };
13641
+ function on(type, fn, target = document) {
13642
+ const options = { capture: true, passive: true };
13643
+ target.addEventListener(type, fn, options);
13644
+ return () => target.removeEventListener(type, fn, options);
13645
+ }
13646
+ const DEPARTED_MIRROR_ACCESS_WARNING = "Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";
13647
+ let _mirror = {
13648
+ map: {},
13649
+ getId() {
13650
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
13651
+ return -1;
13652
+ },
13653
+ getNode() {
13654
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
13655
+ return null;
13656
+ },
13657
+ removeNodeFromMap() {
13658
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
13659
+ },
13660
+ has() {
13661
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
13662
+ return false;
13663
+ },
13664
+ reset() {
13665
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
13666
+ }
13667
+ };
13668
+ if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
13669
+ _mirror = new Proxy(_mirror, {
13670
+ get(target, prop, receiver) {
13671
+ if (prop === "map") {
13672
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
13673
+ }
13674
+ return Reflect.get(target, prop, receiver);
13675
+ }
13676
+ });
13677
+ }
13678
+ function throttle(func, wait, options = {}) {
13679
+ let timeout = null;
13680
+ let previous = 0;
13681
+ return function(...args) {
13682
+ const now = Date.now();
13683
+ if (!previous && options.leading === false) {
13684
+ previous = now;
13685
+ }
13686
+ const remaining = wait - (now - previous);
13687
+ const context = this;
13688
+ if (remaining <= 0 || remaining > wait) {
13689
+ if (timeout) {
13690
+ clearTimeout(timeout);
13691
+ timeout = null;
13692
+ }
13693
+ previous = now;
13694
+ func.apply(context, args);
13695
+ } else if (!timeout && options.trailing !== false) {
13696
+ timeout = setTimeout(() => {
13697
+ previous = options.leading === false ? 0 : Date.now();
13698
+ timeout = null;
13699
+ func.apply(context, args);
13700
+ }, remaining);
13701
+ }
13702
+ };
13703
+ }
13704
+ function hookSetter(target, key, d, isRevoked, win = window) {
13705
+ const original = win.Object.getOwnPropertyDescriptor(target, key);
13706
+ win.Object.defineProperty(
13707
+ target,
13708
+ key,
13709
+ isRevoked ? d : {
13710
+ set(value) {
13711
+ setTimeout(() => {
13712
+ d.set.call(this, value);
13713
+ }, 0);
13714
+ if (original && original.set) {
13715
+ original.set.call(this, value);
13716
+ }
13717
+ }
13718
+ }
13719
+ );
13720
+ return () => hookSetter(target, key, original || {}, true);
13721
+ }
13722
+ function patch$1(source, name, replacement) {
13723
+ try {
13724
+ if (!(name in source)) {
13725
+ return () => {
13726
+ };
13727
+ }
13728
+ const original = source[name];
13729
+ const wrapped = replacement(original);
13730
+ if (typeof wrapped === "function") {
13731
+ wrapped.prototype = wrapped.prototype || {};
13732
+ Object.defineProperties(wrapped, {
13733
+ __rrweb_original__: {
13734
+ enumerable: false,
13735
+ value: original
13736
+ }
13737
+ });
13738
+ }
13739
+ source[name] = wrapped;
13740
+ return () => {
13741
+ source[name] = original;
13742
+ };
13743
+ } catch {
13744
+ return () => {
13745
+ };
13746
+ }
13747
+ }
13748
+ let nowTimestamp = Date.now;
13749
+ if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
13750
+ nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
13751
+ }
13752
+ function getWindowScroll(win) {
13753
+ var _a2, _b, _c, _d;
13754
+ const doc = win.document;
13755
+ return {
13756
+ left: doc.scrollingElement ? doc.scrollingElement.scrollLeft : win.pageXOffset !== void 0 ? win.pageXOffset : doc.documentElement.scrollLeft || (doc == null ? void 0 : doc.body) && ((_a2 = index.parentElement(doc.body)) == null ? void 0 : _a2.scrollLeft) || ((_b = doc == null ? void 0 : doc.body) == null ? void 0 : _b.scrollLeft) || 0,
13757
+ top: doc.scrollingElement ? doc.scrollingElement.scrollTop : win.pageYOffset !== void 0 ? win.pageYOffset : (doc == null ? void 0 : doc.documentElement.scrollTop) || (doc == null ? void 0 : doc.body) && ((_c = index.parentElement(doc.body)) == null ? void 0 : _c.scrollTop) || ((_d = doc == null ? void 0 : doc.body) == null ? void 0 : _d.scrollTop) || 0
13758
+ };
13759
+ }
13760
+ function getWindowHeight() {
13761
+ return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
13762
+ }
13763
+ function getWindowWidth() {
13764
+ return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
13765
+ }
13766
+ function closestElementOfNode(node2) {
13767
+ if (!node2) {
13768
+ return null;
13769
+ }
13770
+ const el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
13771
+ return el;
13772
+ }
13773
+ function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
13774
+ if (!node2) {
13775
+ return false;
13776
+ }
13777
+ const el = closestElementOfNode(node2);
13778
+ if (!el) {
13779
+ return false;
13780
+ }
13781
+ try {
13782
+ if (typeof blockClass === "string") {
13783
+ if (el.classList.contains(blockClass)) return true;
13784
+ if (checkAncestors && el.closest("." + blockClass) !== null) return true;
13785
+ } else {
13786
+ if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
13787
+ }
13788
+ } catch (e2) {
13789
+ }
13790
+ if (blockSelector) {
13791
+ if (el.matches(blockSelector)) return true;
13792
+ if (checkAncestors && el.closest(blockSelector) !== null) return true;
13793
+ }
13794
+ return false;
13795
+ }
13796
+ function isSerialized(n2, mirror2) {
13797
+ return mirror2.getId(n2) !== -1;
13798
+ }
13799
+ function isIgnored(n2, mirror2, slimDOMOptions) {
13800
+ if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
13801
+ return true;
13802
+ }
13803
+ return mirror2.getId(n2) === IGNORED_NODE;
13804
+ }
13805
+ function isAncestorRemoved(target, mirror2) {
13806
+ if (isShadowRoot(target)) {
13807
+ return false;
13808
+ }
13809
+ const id = mirror2.getId(target);
13810
+ if (!mirror2.has(id)) {
13811
+ return true;
13812
+ }
13813
+ const parent = index.parentNode(target);
13814
+ if (parent && parent.nodeType === target.DOCUMENT_NODE) {
13815
+ return false;
13816
+ }
13817
+ if (!parent) {
13818
+ return true;
13819
+ }
13820
+ return isAncestorRemoved(parent, mirror2);
13821
+ }
13822
+ function legacy_isTouchEvent(event) {
13823
+ return Boolean(event.changedTouches);
13824
+ }
13825
+ function polyfill$1(win = window) {
13826
+ if ("NodeList" in win && !win.NodeList.prototype.forEach) {
13827
+ win.NodeList.prototype.forEach = Array.prototype.forEach;
13828
+ }
13829
+ if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
13830
+ win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
13831
+ }
13832
+ }
13833
+ function queueToResolveTrees(queue) {
13834
+ const queueNodeMap = {};
13835
+ const putIntoMap = (m, parent) => {
13836
+ const nodeInTree = {
13837
+ value: m,
13838
+ parent,
13839
+ children: []
13840
+ };
13841
+ queueNodeMap[m.node.id] = nodeInTree;
13842
+ return nodeInTree;
13843
+ };
13844
+ const queueNodeTrees = [];
13845
+ for (const mutation of queue) {
13846
+ const { nextId, parentId } = mutation;
13847
+ if (nextId && nextId in queueNodeMap) {
13848
+ const nextInTree = queueNodeMap[nextId];
13849
+ if (nextInTree.parent) {
13850
+ const idx = nextInTree.parent.children.indexOf(nextInTree);
13851
+ nextInTree.parent.children.splice(
13852
+ idx,
13853
+ 0,
13854
+ putIntoMap(mutation, nextInTree.parent)
13855
+ );
13856
+ } else {
13857
+ const idx = queueNodeTrees.indexOf(nextInTree);
13858
+ queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));
13859
+ }
13860
+ continue;
13861
+ }
13862
+ if (parentId in queueNodeMap) {
13863
+ const parentInTree = queueNodeMap[parentId];
13864
+ parentInTree.children.push(putIntoMap(mutation, parentInTree));
13865
+ continue;
13866
+ }
13867
+ queueNodeTrees.push(putIntoMap(mutation, null));
13868
+ }
13869
+ return queueNodeTrees;
13870
+ }
13871
+ function iterateResolveTree(tree, cb) {
13872
+ cb(tree.value);
13873
+ for (let i2 = tree.children.length - 1; i2 >= 0; i2--) {
13874
+ iterateResolveTree(tree.children[i2], cb);
13875
+ }
13876
+ }
13877
+ function isSerializedIframe(n2, mirror2) {
13878
+ return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
13879
+ }
13880
+ function isSerializedStylesheet(n2, mirror2) {
13881
+ return Boolean(
13882
+ n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2)
13883
+ );
13884
+ }
13885
+ function getBaseDimension(node2, rootIframe) {
13886
+ var _a2, _b;
13887
+ const frameElement = (_b = (_a2 = node2.ownerDocument) == null ? void 0 : _a2.defaultView) == null ? void 0 : _b.frameElement;
13888
+ if (!frameElement || frameElement === rootIframe) {
13889
+ return {
13890
+ x: 0,
13891
+ y: 0,
13892
+ relativeScale: 1,
13893
+ absoluteScale: 1
13894
+ };
13895
+ }
13896
+ const frameDimension = frameElement.getBoundingClientRect();
13897
+ const frameBaseDimension = getBaseDimension(frameElement, rootIframe);
13898
+ const relativeScale = frameDimension.height / frameElement.clientHeight;
13899
+ return {
13900
+ x: frameDimension.x * frameBaseDimension.relativeScale + frameBaseDimension.x,
13901
+ y: frameDimension.y * frameBaseDimension.relativeScale + frameBaseDimension.y,
13902
+ relativeScale,
13903
+ absoluteScale: frameBaseDimension.absoluteScale * relativeScale
13904
+ };
13905
+ }
13906
+ function hasShadowRoot(n2) {
13907
+ if (!n2) return false;
13908
+ if (n2 instanceof BaseRRNode && "shadowRoot" in n2) {
13909
+ return Boolean(n2.shadowRoot);
13910
+ }
13911
+ return Boolean(index.shadowRoot(n2));
13912
+ }
13913
+ function getNestedRule(rules2, position) {
13914
+ const rule2 = rules2[position[0]];
13915
+ if (position.length === 1) {
13916
+ return rule2;
13917
+ } else {
13918
+ return getNestedRule(
13919
+ rule2.cssRules[position[1]].cssRules,
13920
+ position.slice(2)
13921
+ );
13922
+ }
13923
+ }
13924
+ function getPositionsAndIndex(nestedIndex) {
13925
+ const positions = [...nestedIndex];
13926
+ const index2 = positions.pop();
13927
+ return { positions, index: index2 };
13928
+ }
13929
+ function uniqueTextMutations(mutations) {
13930
+ const idSet = /* @__PURE__ */ new Set();
13931
+ const uniqueMutations = [];
13932
+ for (let i2 = mutations.length; i2--; ) {
13933
+ const mutation = mutations[i2];
13934
+ if (!idSet.has(mutation.id)) {
13935
+ uniqueMutations.push(mutation);
13936
+ idSet.add(mutation.id);
13937
+ }
13938
+ }
13939
+ return uniqueMutations;
13940
+ }
13941
+ class StyleSheetMirror {
13942
+ constructor() {
13943
+ __publicField2$1(this, "id", 1);
13944
+ __publicField2$1(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
13945
+ __publicField2$1(this, "idStyleMap", /* @__PURE__ */ new Map());
13946
+ }
13947
+ getId(stylesheet) {
13948
+ return this.styleIDMap.get(stylesheet) ?? -1;
13949
+ }
13950
+ has(stylesheet) {
13951
+ return this.styleIDMap.has(stylesheet);
13952
+ }
13953
+ /**
13954
+ * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
13955
+ */
13956
+ add(stylesheet, id) {
13957
+ if (this.has(stylesheet)) return this.getId(stylesheet);
13958
+ let newId;
13959
+ if (id === void 0) {
13960
+ newId = this.id++;
13961
+ } else newId = id;
13962
+ this.styleIDMap.set(stylesheet, newId);
13963
+ this.idStyleMap.set(newId, stylesheet);
13964
+ return newId;
13965
+ }
13966
+ getStyle(id) {
13967
+ return this.idStyleMap.get(id) || null;
13968
+ }
13969
+ reset() {
13970
+ this.styleIDMap = /* @__PURE__ */ new WeakMap();
13971
+ this.idStyleMap = /* @__PURE__ */ new Map();
13972
+ this.id = 1;
13973
+ }
13974
+ generateId() {
13975
+ return this.id++;
13976
+ }
13977
+ }
13978
+ function getShadowHost(n2) {
13979
+ var _a2;
13980
+ let shadowHost = null;
13981
+ if ("getRootNode" in n2 && ((_a2 = index.getRootNode(n2)) == null ? void 0 : _a2.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && index.host(index.getRootNode(n2)))
13982
+ shadowHost = index.host(index.getRootNode(n2));
13983
+ return shadowHost;
13984
+ }
13985
+ function getRootShadowHost(n2) {
13986
+ let rootShadowHost = n2;
13987
+ let shadowHost;
13988
+ while (shadowHost = getShadowHost(rootShadowHost))
13989
+ rootShadowHost = shadowHost;
13990
+ return rootShadowHost;
13991
+ }
13992
+ function shadowHostInDom(n2) {
13993
+ const doc = n2.ownerDocument;
13994
+ if (!doc) return false;
13995
+ const shadowHost = getRootShadowHost(n2);
13996
+ return index.contains(doc, shadowHost);
13997
+ }
13998
+ function inDom(n2) {
13999
+ const doc = n2.ownerDocument;
14000
+ if (!doc) return false;
14001
+ return index.contains(doc, n2) || shadowHostInDom(n2);
14002
+ }
14003
+ const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14004
+ __proto__: null,
14005
+ StyleSheetMirror,
14006
+ get _mirror() {
14007
+ return _mirror;
14008
+ },
14009
+ closestElementOfNode,
14010
+ getBaseDimension,
14011
+ getNestedRule,
14012
+ getPositionsAndIndex,
14013
+ getRootShadowHost,
14014
+ getShadowHost,
14015
+ getWindowHeight,
14016
+ getWindowScroll,
14017
+ getWindowWidth,
14018
+ hasShadowRoot,
14019
+ hookSetter,
14020
+ inDom,
14021
+ isAncestorRemoved,
14022
+ isBlocked,
14023
+ isIgnored,
14024
+ isSerialized,
14025
+ isSerializedIframe,
14026
+ isSerializedStylesheet,
14027
+ iterateResolveTree,
14028
+ legacy_isTouchEvent,
14029
+ get nowTimestamp() {
14030
+ return nowTimestamp;
14031
+ },
14032
+ on,
14033
+ patch: patch$1,
14034
+ polyfill: polyfill$1,
14035
+ queueToResolveTrees,
14036
+ shadowHostInDom,
14037
+ throttle,
14038
+ uniqueTextMutations
14039
+ }, Symbol.toStringTag, { value: "Module" }));
14040
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
14041
+ var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
14042
+ for (var i$1 = 0; i$1 < chars.length; i$1++) {
14043
+ lookup[chars.charCodeAt(i$1)] = i$1;
14044
+ }
14045
+ const encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
14046
+ const decodeBase64 = (base64) => Uint8Array.from(atob(base64), (c2) => c2.charCodeAt(0));
14047
+ typeof window !== "undefined" && window.Blob && new Blob([decodeBase64(encodedJs)], { type: "text/javascript;charset=utf-8" });
14048
+ try {
14049
+ if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
14050
+ const cleanFrame = document.createElement("iframe");
14051
+ document.body.appendChild(cleanFrame);
14052
+ Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
14053
+ document.body.removeChild(cleanFrame);
14054
+ }
14055
+ } catch (err) {
14056
+ console.debug("Unable to override Array.from", err);
14057
+ }
14058
+ createMirror$2();
14059
+ var n;
14060
+ !function(t2) {
14061
+ t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
14062
+ }(n || (n = {}));
14063
+ class StackFrame {
14064
+ constructor(obj) {
14065
+ __publicField(this, "fileName");
14066
+ __publicField(this, "functionName");
14067
+ __publicField(this, "lineNumber");
14068
+ __publicField(this, "columnNumber");
14069
+ this.fileName = obj.fileName || "";
14070
+ this.functionName = obj.functionName || "";
14071
+ this.lineNumber = obj.lineNumber;
14072
+ this.columnNumber = obj.columnNumber;
14073
+ }
14074
+ toString() {
14075
+ const lineNumber = this.lineNumber || "";
14076
+ const columnNumber = this.columnNumber || "";
14077
+ if (this.functionName)
14078
+ return `${this.functionName} (${this.fileName}:${lineNumber}:${columnNumber})`;
14079
+ return `${this.fileName}:${lineNumber}:${columnNumber}`;
14080
+ }
14081
+ }
14082
+ const FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
14083
+ const CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
14084
+ const SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
14085
+ const ErrorStackParser = {
14086
+ /**
14087
+ * Given an Error object, extract the most information from it.
14088
+ */
14089
+ parse: function(error) {
14090
+ if (!error) {
14091
+ return [];
14092
+ }
14093
+ if (
14094
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14095
+ // @ts-ignore
14096
+ typeof error.stacktrace !== "undefined" || // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14097
+ // @ts-ignore
14098
+ typeof error["opera#sourceloc"] !== "undefined"
14099
+ ) {
14100
+ return this.parseOpera(
14101
+ error
14102
+ );
14103
+ } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
14104
+ return this.parseV8OrIE(error);
14105
+ } else if (error.stack) {
14106
+ return this.parseFFOrSafari(error);
14107
+ } else {
14108
+ console.warn(
14109
+ "[console-record-plugin]: Failed to parse error object:",
14110
+ error
14111
+ );
14112
+ return [];
14113
+ }
14114
+ },
14115
+ // Separate line and column numbers from a string of the form: (URI:Line:Column)
14116
+ extractLocation: function(urlLike) {
14117
+ if (urlLike.indexOf(":") === -1) {
14118
+ return [urlLike];
14119
+ }
14120
+ const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
14121
+ const parts = regExp.exec(urlLike.replace(/[()]/g, ""));
14122
+ if (!parts) throw new Error(`Cannot parse given url: ${urlLike}`);
14123
+ return [parts[1], parts[2] || void 0, parts[3] || void 0];
14124
+ },
14125
+ parseV8OrIE: function(error) {
14126
+ const filtered = error.stack.split("\n").filter(function(line) {
14127
+ return !!line.match(CHROME_IE_STACK_REGEXP);
14128
+ }, this);
14129
+ return filtered.map(function(line) {
14130
+ if (line.indexOf("(eval ") > -1) {
14131
+ line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(\),.*$)/g, "");
14132
+ }
14133
+ let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(");
14134
+ const location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
14135
+ sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
14136
+ const tokens = sanitizedLine.split(/\s+/).slice(1);
14137
+ const locationParts = this.extractLocation(
14138
+ location ? location[1] : tokens.pop()
14139
+ );
14140
+ const functionName = tokens.join(" ") || void 0;
14141
+ const fileName = ["eval", "<anonymous>"].indexOf(locationParts[0]) > -1 ? void 0 : locationParts[0];
14142
+ return new StackFrame({
14143
+ functionName,
14144
+ fileName,
14145
+ lineNumber: locationParts[1],
14146
+ columnNumber: locationParts[2]
14147
+ });
14148
+ }, this);
14149
+ },
14150
+ parseFFOrSafari: function(error) {
14151
+ const filtered = error.stack.split("\n").filter(function(line) {
14152
+ return !line.match(SAFARI_NATIVE_CODE_REGEXP);
14153
+ }, this);
14154
+ return filtered.map(function(line) {
14155
+ if (line.indexOf(" > eval") > -1) {
14156
+ line = line.replace(
14157
+ / line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,
14158
+ ":$1"
14159
+ );
14160
+ }
14161
+ if (line.indexOf("@") === -1 && line.indexOf(":") === -1) {
14162
+ return new StackFrame({
14163
+ functionName: line
14164
+ });
14165
+ } else {
14166
+ const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
14167
+ const matches = line.match(functionNameRegex);
14168
+ const functionName = matches && matches[1] ? matches[1] : void 0;
14169
+ const locationParts = this.extractLocation(
14170
+ line.replace(functionNameRegex, "")
14171
+ );
14172
+ return new StackFrame({
14173
+ functionName,
14174
+ fileName: locationParts[0],
14175
+ lineNumber: locationParts[1],
14176
+ columnNumber: locationParts[2]
14177
+ });
14178
+ }
14179
+ }, this);
14180
+ },
14181
+ parseOpera: function(e) {
14182
+ if (!e.stacktrace || e.message.indexOf("\n") > -1 && e.message.split("\n").length > e.stacktrace.split("\n").length) {
14183
+ return this.parseOpera9(e);
14184
+ } else if (!e.stack) {
14185
+ return this.parseOpera10(e);
14186
+ } else {
14187
+ return this.parseOpera11(e);
14188
+ }
14189
+ },
14190
+ parseOpera9: function(e) {
14191
+ const lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
14192
+ const lines = e.message.split("\n");
14193
+ const result2 = [];
14194
+ for (let i = 2, len = lines.length; i < len; i += 2) {
14195
+ const match = lineRE.exec(lines[i]);
14196
+ if (match) {
14197
+ result2.push(
14198
+ new StackFrame({
14199
+ fileName: match[2],
14200
+ lineNumber: parseFloat(match[1])
14201
+ })
14202
+ );
14203
+ }
14204
+ }
14205
+ return result2;
14206
+ },
14207
+ parseOpera10: function(e) {
14208
+ const lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
14209
+ const lines = e.stacktrace.split("\n");
14210
+ const result2 = [];
14211
+ for (let i = 0, len = lines.length; i < len; i += 2) {
14212
+ const match = lineRE.exec(lines[i]);
14213
+ if (match) {
14214
+ result2.push(
14215
+ new StackFrame({
14216
+ functionName: match[3] || void 0,
14217
+ fileName: match[2],
14218
+ lineNumber: parseFloat(match[1])
14219
+ })
14220
+ );
14221
+ }
14222
+ }
14223
+ return result2;
14224
+ },
14225
+ // Opera 10.65+ Error.stack very similar to FF/Safari
14226
+ parseOpera11: function(error) {
14227
+ const filtered = error.stack.split("\n").filter(function(line) {
14228
+ return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
14229
+ }, this);
14230
+ return filtered.map(function(line) {
14231
+ const tokens = line.split("@");
14232
+ const locationParts = this.extractLocation(tokens.pop());
14233
+ const functionCall = tokens.shift() || "";
14234
+ const functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0;
14235
+ return new StackFrame({
14236
+ functionName,
14237
+ fileName: locationParts[0],
14238
+ lineNumber: locationParts[1],
14239
+ columnNumber: locationParts[2]
14240
+ });
14241
+ }, this);
14242
+ }
14243
+ };
14244
+ function pathToSelector(node2) {
14245
+ if (!node2 || !node2.outerHTML) {
14246
+ return "";
14247
+ }
14248
+ let path = "";
14249
+ while (node2.parentElement) {
14250
+ let name = node2.localName;
14251
+ if (!name) {
14252
+ break;
14253
+ }
14254
+ name = name.toLowerCase();
14255
+ const parent = node2.parentElement;
14256
+ const domSiblings = [];
14257
+ if (parent.children && parent.children.length > 0) {
14258
+ for (let i = 0; i < parent.children.length; i++) {
14259
+ const sibling = parent.children[i];
14260
+ if (sibling.localName && sibling.localName.toLowerCase) {
14261
+ if (sibling.localName.toLowerCase() === name) {
14262
+ domSiblings.push(sibling);
14263
+ }
14264
+ }
14265
+ }
14266
+ }
14267
+ if (domSiblings.length > 1) {
14268
+ name += `:eq(${domSiblings.indexOf(node2)})`;
14269
+ }
14270
+ path = name + (path ? ">" + path : "");
14271
+ node2 = parent;
14272
+ }
14273
+ return path;
14274
+ }
14275
+ function isObject(obj) {
14276
+ return Object.prototype.toString.call(obj) === "[object Object]";
14277
+ }
14278
+ function isObjTooDeep(obj, limit) {
14279
+ if (limit === 0) {
14280
+ return true;
14281
+ }
14282
+ const keys = Object.keys(obj);
14283
+ for (const key of keys) {
14284
+ if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {
14285
+ return true;
14286
+ }
14287
+ }
14288
+ return false;
14289
+ }
14290
+ function stringify(obj, stringifyOptions) {
14291
+ const options = {
14292
+ numOfKeysLimit: 50,
14293
+ depthOfLimit: 4
14294
+ };
14295
+ Object.assign(options, stringifyOptions);
14296
+ const stack = [];
14297
+ const keys = [];
14298
+ return JSON.stringify(
14299
+ obj,
14300
+ function(key, value) {
14301
+ if (stack.length > 0) {
14302
+ const thisPos = stack.indexOf(this);
14303
+ ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
14304
+ ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
14305
+ if (~stack.indexOf(value)) {
14306
+ if (stack[0] === value) {
14307
+ value = "[Circular ~]";
14308
+ } else {
14309
+ value = "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
14310
+ }
14311
+ }
14312
+ } else {
14313
+ stack.push(value);
14314
+ }
14315
+ if (value === null) return value;
14316
+ if (value === void 0) return "undefined";
14317
+ if (shouldIgnore(value)) {
14318
+ return toString(value);
14319
+ }
14320
+ if (typeof value === "bigint") {
14321
+ return value.toString() + "n";
14322
+ }
14323
+ if (value instanceof Event) {
14324
+ const eventResult = {};
14325
+ for (const eventKey in value) {
14326
+ const eventValue = value[eventKey];
14327
+ if (Array.isArray(eventValue)) {
14328
+ eventResult[eventKey] = pathToSelector(
14329
+ eventValue.length ? eventValue[0] : null
14330
+ );
14331
+ } else {
14332
+ eventResult[eventKey] = eventValue;
14333
+ }
14334
+ }
14335
+ return eventResult;
14336
+ } else if (value instanceof Node) {
14337
+ if (value instanceof HTMLElement) {
14338
+ return value ? value.outerHTML : "";
14339
+ }
14340
+ return value.nodeName;
14341
+ } else if (value instanceof Error) {
14342
+ return value.stack ? value.stack + "\nEnd of stack for Error object" : value.name + ": " + value.message;
14343
+ }
14344
+ return value;
14345
+ }
14346
+ );
14347
+ function shouldIgnore(_obj) {
14348
+ if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {
14349
+ return true;
14350
+ }
14351
+ if (typeof _obj === "function") {
14352
+ return true;
14353
+ }
14354
+ if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {
14355
+ return true;
14356
+ }
14357
+ return false;
14358
+ }
14359
+ function toString(_obj) {
14360
+ let str = _obj.toString();
14361
+ if (options.stringLengthLimit && str.length > options.stringLengthLimit) {
14362
+ str = `${str.slice(0, options.stringLengthLimit)}...`;
14363
+ }
14364
+ return str;
14365
+ }
14366
+ }
14367
+ const defaultLogOptions = {
14368
+ level: [
14369
+ "assert",
14370
+ "clear",
14371
+ "count",
14372
+ "countReset",
14373
+ "debug",
14374
+ "dir",
14375
+ "dirxml",
14376
+ "error",
14377
+ "group",
14378
+ "groupCollapsed",
14379
+ "groupEnd",
14380
+ "info",
14381
+ "log",
14382
+ "table",
14383
+ "time",
14384
+ "timeEnd",
14385
+ "timeLog",
14386
+ "trace",
14387
+ "warn"
14388
+ ],
14389
+ lengthThreshold: 1e3,
14390
+ logger: "console"
14391
+ };
14392
+ function initLogObserver(cb, win, options) {
14393
+ const logOptions = options ? Object.assign({}, defaultLogOptions, options) : defaultLogOptions;
14394
+ const loggerType = logOptions.logger;
14395
+ if (!loggerType) {
14396
+ return () => {
14397
+ };
14398
+ }
14399
+ let logger;
14400
+ if (typeof loggerType === "string") {
14401
+ logger = win[loggerType];
14402
+ } else {
14403
+ logger = loggerType;
14404
+ }
14405
+ let logCount = 0;
14406
+ let inStack = false;
14407
+ const cancelHandlers = [];
14408
+ if (logOptions.level.includes("error")) {
14409
+ const errorHandler = (event) => {
14410
+ const message = event.message, error = event.error;
14411
+ const trace = ErrorStackParser.parse(error).map(
14412
+ (stackFrame) => stackFrame.toString()
14413
+ );
14414
+ const payload = [stringify(message, logOptions.stringifyOptions)];
14415
+ cb({
14416
+ level: "error",
14417
+ trace,
14418
+ payload
14419
+ });
14420
+ };
14421
+ win.addEventListener("error", errorHandler);
14422
+ cancelHandlers.push(() => {
14423
+ win.removeEventListener("error", errorHandler);
14424
+ });
14425
+ const unhandledrejectionHandler = (event) => {
14426
+ let error;
14427
+ let payload;
14428
+ if (event.reason instanceof Error) {
14429
+ error = event.reason;
14430
+ payload = [
14431
+ stringify(
14432
+ `Uncaught (in promise) ${error.name}: ${error.message}`,
14433
+ logOptions.stringifyOptions
14434
+ )
14435
+ ];
14436
+ } else {
14437
+ error = new Error();
14438
+ payload = [
14439
+ stringify("Uncaught (in promise)", logOptions.stringifyOptions),
14440
+ stringify(event.reason, logOptions.stringifyOptions)
14441
+ ];
14442
+ }
14443
+ const trace = ErrorStackParser.parse(error).map(
14444
+ (stackFrame) => stackFrame.toString()
14445
+ );
14446
+ cb({
14447
+ level: "error",
14448
+ trace,
14449
+ payload
14450
+ });
14451
+ };
14452
+ win.addEventListener("unhandledrejection", unhandledrejectionHandler);
14453
+ cancelHandlers.push(() => {
14454
+ win.removeEventListener("unhandledrejection", unhandledrejectionHandler);
14455
+ });
14456
+ }
14457
+ for (const levelType of logOptions.level) {
14458
+ cancelHandlers.push(replace(logger, levelType));
14459
+ }
14460
+ return () => {
14461
+ cancelHandlers.forEach((h) => h());
14462
+ };
14463
+ function replace(_logger, level) {
14464
+ if (!_logger[level]) {
14465
+ return () => {
14466
+ };
14467
+ }
14468
+ return utils.patch(
14469
+ _logger,
14470
+ level,
14471
+ (original) => {
14472
+ return (...args) => {
14473
+ original.apply(this, args);
14474
+ if (level === "assert" && !!args[0]) {
14475
+ return;
14476
+ }
14477
+ if (inStack) {
14478
+ return;
14479
+ }
14480
+ inStack = true;
14481
+ try {
14482
+ const trace = ErrorStackParser.parse(new Error()).map((stackFrame) => stackFrame.toString()).splice(1);
14483
+ const argsForPayload = level === "assert" ? args.slice(1) : args;
14484
+ const payload = argsForPayload.map(
14485
+ (s) => stringify(s, logOptions.stringifyOptions)
14486
+ );
14487
+ logCount++;
14488
+ if (logCount < logOptions.lengthThreshold) {
14489
+ cb({
14490
+ level,
14491
+ trace,
14492
+ payload
14493
+ });
14494
+ } else if (logCount === logOptions.lengthThreshold) {
14495
+ cb({
14496
+ level: "warn",
14497
+ trace: [],
14498
+ payload: [
14499
+ stringify("The number of log records reached the threshold.")
14500
+ ]
14501
+ });
14502
+ }
14503
+ } catch (error) {
14504
+ original("rrweb logger error:", error, ...args);
14505
+ } finally {
14506
+ inStack = false;
14507
+ }
14508
+ };
14509
+ }
14510
+ );
14511
+ }
14512
+ }
14513
+ const PLUGIN_NAME = "rrweb/console@1";
14514
+ const getRecordConsolePlugin = (options) => ({
14515
+ name: PLUGIN_NAME,
14516
+ observer: initLogObserver,
14517
+ options
14518
+ });
14519
+
14520
+ var rrwebPluginConsoleRecord = /*#__PURE__*/Object.freeze({
14521
+ __proto__: null,
14522
+ PLUGIN_NAME: PLUGIN_NAME,
14523
+ getRecordConsolePlugin: getRecordConsolePlugin
14524
+ });
14525
+
14526
+ function patch(source, name, replacement) {
14527
+ try {
14528
+ if (!(name in source)) {
14529
+ return () => {
14530
+ //
14531
+ };
14532
+ }
14533
+ const original = source[name];
14534
+ const wrapped = replacement(original);
14535
+ if (isFunction(wrapped)) {
14536
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
14537
+ wrapped.prototype = wrapped.prototype || {};
14538
+ Object.defineProperties(wrapped, {
14539
+ __posthog_wrapped__: {
14540
+ enumerable: false,
14541
+ value: true
14542
+ }
14543
+ });
14544
+ }
14545
+ source[name] = wrapped;
14546
+ return () => {
14547
+ source[name] = original;
14548
+ };
14549
+ } catch {
14550
+ return () => {
14551
+ //
14552
+ };
14553
+ }
14554
+ }
14555
+
14556
+ function hostnameFromURL(url) {
14557
+ try {
14558
+ if (typeof url === 'string') {
14559
+ return new URL(url).hostname;
14560
+ }
14561
+ if ('url' in url) {
14562
+ return new URL(url.url).hostname;
14563
+ }
14564
+ return url.hostname;
14565
+ } catch {
14566
+ return null;
14567
+ }
14568
+ }
14569
+ function isHostOnDenyList(url, options) {
14570
+ const hostname = hostnameFromURL(url);
14571
+ const defaultNotDenied = {
14572
+ hostname,
14573
+ isHostDenied: false
14574
+ };
14575
+ if (!options.payloadHostDenyList?.length || !hostname?.trim().length) {
14576
+ return defaultNotDenied;
14577
+ }
14578
+ for (const deny of options.payloadHostDenyList) {
14579
+ if (hostname.endsWith(deny)) {
14580
+ return {
14581
+ hostname,
14582
+ isHostDenied: true
14583
+ };
14584
+ }
14585
+ }
14586
+ return defaultNotDenied;
14587
+ }
14588
+
14589
+ /// <reference lib="dom" />
14590
+ const logger = createLogger('[Recorder]');
14591
+ const isNavigationTiming = entry => entry.entryType === 'navigation';
14592
+ const isResourceTiming = entry => entry.entryType === 'resource';
14593
+ function findLast(array, predicate) {
14594
+ const length = array.length;
14595
+ for (let i = length - 1; i >= 0; i -= 1) {
14596
+ if (predicate(array[i])) {
14597
+ return array[i];
14598
+ }
14599
+ }
14600
+ return undefined;
14601
+ }
14602
+ function isDocument(value) {
14603
+ return !!value && typeof value === 'object' && 'nodeType' in value && value.nodeType === 9;
14604
+ }
14605
+ function initPerformanceObserver(cb, win, options) {
14606
+ // if we are only observing timings then we could have a single observer for all types, with buffer true,
14607
+ // but we are going to filter by initiatorType _if we are wrapping fetch and xhr as the wrapped functions
14608
+ // will deal with those.
14609
+ // so we have a block which captures requests from before fetch/xhr is wrapped
14610
+ // these are marked `isInitial` so playback can display them differently if needed
14611
+ // they will never have method/status/headers/body because they are pre-wrapping that provides that
14612
+ if (options.recordInitialRequests) {
14613
+ const initialPerformanceEntries = win.performance.getEntries().filter(entry => isNavigationTiming(entry) || isResourceTiming(entry) && options.initiatorTypes.includes(entry.initiatorType));
14614
+ cb({
14615
+ requests: initialPerformanceEntries.flatMap(entry => prepareRequest({
14616
+ entry,
14617
+ method: undefined,
14618
+ status: undefined,
14619
+ networkRequest: {},
14620
+ isInitial: true
14621
+ })),
14622
+ isInitial: true
14623
+ });
14624
+ }
14625
+ const observer = new win.PerformanceObserver(entries => {
14626
+ // if recordBody or recordHeaders is true then we don't want to record fetch or xhr here
14627
+ // as the wrapped functions will do that. Otherwise, this filter becomes a noop
14628
+ // because we do want to record them here
14629
+ const wrappedInitiatorFilter = entry => options.recordBody || options.recordHeaders ? entry.initiatorType !== 'xmlhttprequest' && entry.initiatorType !== 'fetch' : true;
14630
+ const performanceEntries = entries.getEntries().filter(entry => isNavigationTiming(entry) || isResourceTiming(entry) && options.initiatorTypes.includes(entry.initiatorType) &&
14631
+ // TODO if we are _only_ capturing timing we don't want to filter initiator here
14632
+ wrappedInitiatorFilter(entry));
14633
+ cb({
14634
+ requests: performanceEntries.flatMap(entry => prepareRequest({
14635
+ entry,
14636
+ method: undefined,
14637
+ status: undefined,
14638
+ networkRequest: {}
14639
+ }))
14640
+ });
14641
+ });
14642
+ // compat checked earlier
14643
+ // eslint-disable-next-line compat/compat
14644
+ const entryTypes = PerformanceObserver.supportedEntryTypes.filter(x => options.performanceEntryTypeToObserve.includes(x));
14645
+ // initial records are gathered above, so we don't need to observe and buffer each type separately
14646
+ observer.observe({
14647
+ entryTypes
14648
+ });
14649
+ return () => {
14650
+ observer.disconnect();
14651
+ };
14652
+ }
14653
+ function shouldRecordHeaders(type, recordHeaders) {
14654
+ return !!recordHeaders && (isBoolean(recordHeaders) || recordHeaders[type]);
14655
+ }
14656
+ function shouldRecordBody({
14657
+ type,
14658
+ recordBody,
14659
+ headers,
14660
+ url
14661
+ }) {
14662
+ function matchesContentType(contentTypes) {
14663
+ const contentTypeHeader = Object.keys(headers).find(key => key.toLowerCase() === 'content-type');
14664
+ const contentType = contentTypeHeader && headers[contentTypeHeader];
14665
+ return contentTypes.some(ct => contentType?.includes(ct));
14666
+ }
14667
+ /**
14668
+ * particularly in canvas applications we see many requests to blob URLs
14669
+ * e.g. blob:https://video_url
14670
+ * these blob/object URLs are local to the browser, we can never capture that body
14671
+ * so we can just return false here
14672
+ */
14673
+ function isBlobURL(url) {
14674
+ try {
14675
+ if (typeof url === 'string') {
14676
+ return url.startsWith('blob:');
14677
+ }
14678
+ if (url instanceof URL) {
14679
+ return url.protocol === 'blob:';
14680
+ }
14681
+ if (url instanceof Request) {
14682
+ return isBlobURL(url.url);
14683
+ }
14684
+ return false;
14685
+ } catch {
14686
+ return false;
14687
+ }
14688
+ }
14689
+ if (!recordBody) return false;
14690
+ if (isBlobURL(url)) return false;
14691
+ if (isBoolean(recordBody)) return true;
14692
+ if (isArray(recordBody)) return matchesContentType(recordBody);
14693
+ const recordBodyType = recordBody[type];
14694
+ if (isBoolean(recordBodyType)) return recordBodyType;
14695
+ return matchesContentType(recordBodyType);
14696
+ }
14697
+ async function getRequestPerformanceEntry(win, initiatorType, url, start, end, attempt = 0) {
14698
+ if (attempt > 10) {
14699
+ logger.warn('Failed to get performance entry for request', {
14700
+ url,
14701
+ initiatorType
14702
+ });
14703
+ return null;
14704
+ }
14705
+ const urlPerformanceEntries = win.performance.getEntriesByName(url);
14706
+ const performanceEntry = findLast(urlPerformanceEntries, entry => isResourceTiming(entry) && entry.initiatorType === initiatorType && (isUndefined(start) || entry.startTime >= start) && (isUndefined(end) || entry.startTime <= end));
14707
+ if (!performanceEntry) {
14708
+ await new Promise(resolve => setTimeout(resolve, 50 * attempt));
14709
+ return getRequestPerformanceEntry(win, initiatorType, url, start, end, attempt + 1);
14710
+ }
14711
+ return performanceEntry;
14712
+ }
14713
+ /**
14714
+ * According to MDN https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/response
14715
+ * xhr response is typed as any but can be an ArrayBuffer, a Blob, a Document, a JavaScript object,
14716
+ * or a string, depending on the value of XMLHttpRequest.responseType, that contains the response entity body.
14717
+ *
14718
+ * XHR request body is Document | XMLHttpRequestBodyInit | null | undefined
14719
+ */
14720
+ function _tryReadXHRBody({
14721
+ body,
14722
+ options,
14723
+ url
14724
+ }) {
14725
+ if (isNullish(body)) {
14726
+ return null;
14727
+ }
14728
+ const {
14729
+ hostname,
14730
+ isHostDenied
14731
+ } = isHostOnDenyList(url, options);
14732
+ if (isHostDenied) {
14733
+ return hostname + ' is in deny list';
14734
+ }
14735
+ if (isString(body)) {
14736
+ return body;
14737
+ }
14738
+ if (isDocument(body)) {
14739
+ return body.textContent;
14740
+ }
14741
+ if (isFormData(body)) {
14742
+ return formDataToQuery(body);
14743
+ }
14744
+ if (isObject$1(body)) {
14745
+ try {
14746
+ return JSON.stringify(body);
14747
+ } catch {
14748
+ return '[SessionReplay] Failed to stringify response object';
14749
+ }
14750
+ }
14751
+ return '[SessionReplay] Cannot read body of type ' + toString.call(body);
14752
+ }
14753
+ function initXhrObserver(cb, win, options) {
14754
+ if (!options.initiatorTypes.includes('xmlhttprequest')) {
14755
+ return () => {
14756
+ //
14757
+ };
14758
+ }
14759
+ const recordRequestHeaders = shouldRecordHeaders('request', options.recordHeaders);
14760
+ const recordResponseHeaders = shouldRecordHeaders('response', options.recordHeaders);
14761
+ const restorePatch = patch(win.XMLHttpRequest.prototype, 'open',
14762
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14763
+ // @ts-ignore
14764
+ originalOpen => {
14765
+ return function (method, url, async = true, username, password) {
14766
+ // because this function is returned in its actual context `this` _is_ an XMLHttpRequest
14767
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14768
+ // @ts-ignore
14769
+ const xhr = this;
14770
+ // check IE earlier than this, we only initialize if Request is present
14771
+ // eslint-disable-next-line compat/compat
14772
+ const req = new Request(url);
14773
+ const networkRequest = {};
14774
+ let start;
14775
+ let end;
14776
+ const requestHeaders = {};
14777
+ const originalSetRequestHeader = xhr.setRequestHeader.bind(xhr);
14778
+ xhr.setRequestHeader = (header, value) => {
14779
+ requestHeaders[header] = value;
14780
+ return originalSetRequestHeader(header, value);
14781
+ };
14782
+ if (recordRequestHeaders) {
14783
+ networkRequest.requestHeaders = requestHeaders;
14784
+ }
14785
+ const originalSend = xhr.send.bind(xhr);
14786
+ xhr.send = body => {
14787
+ if (shouldRecordBody({
14788
+ type: 'request',
14789
+ headers: requestHeaders,
14790
+ url,
14791
+ recordBody: options.recordBody
14792
+ })) {
14793
+ networkRequest.requestBody = _tryReadXHRBody({
14794
+ body,
14795
+ options,
14796
+ url
14797
+ });
14798
+ }
14799
+ start = win.performance.now();
14800
+ return originalSend(body);
14801
+ };
14802
+ const readyStateListener = () => {
14803
+ if (xhr.readyState !== xhr.DONE) {
14804
+ return;
14805
+ }
14806
+ // Clean up the listener immediately when done to prevent memory leaks
14807
+ xhr.removeEventListener('readystatechange', readyStateListener);
14808
+ end = win.performance.now();
14809
+ const responseHeaders = {};
14810
+ const rawHeaders = xhr.getAllResponseHeaders();
14811
+ const headers = rawHeaders.trim().split(/[\r\n]+/);
14812
+ headers.forEach(line => {
14813
+ const parts = line.split(': ');
14814
+ const header = parts.shift();
14815
+ const value = parts.join(': ');
14816
+ if (header) {
14817
+ responseHeaders[header] = value;
14818
+ }
14819
+ });
14820
+ if (recordResponseHeaders) {
14821
+ networkRequest.responseHeaders = responseHeaders;
14822
+ }
14823
+ if (shouldRecordBody({
14824
+ type: 'response',
14825
+ headers: responseHeaders,
14826
+ url,
14827
+ recordBody: options.recordBody
14828
+ })) {
14829
+ networkRequest.responseBody = _tryReadXHRBody({
14830
+ body: xhr.response,
14831
+ options,
14832
+ url
14833
+ });
14834
+ }
14835
+ getRequestPerformanceEntry(win, 'xmlhttprequest', req.url, start, end).then(entry => {
14836
+ const requests = prepareRequest({
14837
+ entry,
14838
+ method: method,
14839
+ status: xhr?.status,
14840
+ networkRequest,
14841
+ start,
14842
+ end,
14843
+ url: url.toString(),
14844
+ initiatorType: 'xmlhttprequest'
14845
+ });
14846
+ cb({
14847
+ requests
14848
+ });
14849
+ }).catch(() => {
14850
+ //
14851
+ });
14852
+ };
14853
+ // This is very tricky code, and making it passive won't bring many performance benefits,
14854
+ // so let's ignore the rule here.
14855
+ // eslint-disable-next-line posthog-js/no-add-event-listener
14856
+ xhr.addEventListener('readystatechange', readyStateListener);
14857
+ originalOpen.call(xhr, method, url, async, username, password);
14858
+ };
14859
+ });
14860
+ return () => {
14861
+ restorePatch();
14862
+ };
14863
+ }
14864
+ /**
14865
+ * Check if this PerformanceEntry is either a PerformanceResourceTiming or a PerformanceNavigationTiming
14866
+ * NB PerformanceNavigationTiming extends PerformanceResourceTiming
14867
+ * Here we don't care which interface it implements as both expose `serverTimings`
14868
+ */
14869
+ const exposesServerTiming = event => !isNull(event) && (event.entryType === 'navigation' || event.entryType === 'resource');
14870
+ function prepareRequest({
14871
+ entry,
14872
+ method,
14873
+ status,
14874
+ networkRequest,
14875
+ isInitial,
14876
+ start,
14877
+ end,
14878
+ url,
14879
+ initiatorType
14880
+ }) {
14881
+ start = entry ? entry.startTime : start;
14882
+ end = entry ? entry.responseEnd : end;
14883
+ // kudos to sentry javascript sdk for excellent background on why to use Date.now() here
14884
+ // https://github.com/getsentry/sentry-javascript/blob/e856e40b6e71a73252e788cd42b5260f81c9c88e/packages/utils/src/time.ts#L70
14885
+ // can't start observer if performance.now() is not available
14886
+ // eslint-disable-next-line compat/compat
14887
+ const timeOrigin = Math.floor(Date.now() - performance.now());
14888
+ // clickhouse can't ingest timestamps that are floats
14889
+ // (in this case representing fractions of a millisecond we don't care about anyway)
14890
+ // use timeOrigin if we really can't gather a start time
14891
+ const timestamp = Math.floor(timeOrigin + (start || 0));
14892
+ const entryJSON = entry ? entry.toJSON() : {
14893
+ name: url
14894
+ };
14895
+ const requests = [{
14896
+ ...entryJSON,
14897
+ startTime: isUndefined(start) ? undefined : Math.round(start),
14898
+ endTime: isUndefined(end) ? undefined : Math.round(end),
14899
+ timeOrigin,
14900
+ timestamp,
14901
+ method: method,
14902
+ initiatorType: initiatorType ? initiatorType : entry ? entry.initiatorType : undefined,
14903
+ status,
14904
+ requestHeaders: networkRequest.requestHeaders,
14905
+ requestBody: networkRequest.requestBody,
14906
+ responseHeaders: networkRequest.responseHeaders,
14907
+ responseBody: networkRequest.responseBody,
14908
+ isInitial
14909
+ }];
14910
+ if (exposesServerTiming(entry)) {
14911
+ for (const timing of entry.serverTiming || []) {
14912
+ requests.push({
14913
+ timeOrigin,
14914
+ timestamp,
14915
+ startTime: Math.round(entry.startTime),
14916
+ name: timing.name,
14917
+ duration: timing.duration,
14918
+ // the spec has a closed list of possible types
14919
+ // https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry/entryType
14920
+ // but, we need to know this was a server timing so that we know to
14921
+ // match it to the appropriate navigation or resource timing
14922
+ // that matching will have to be on timestamp and $current_url
14923
+ entryType: 'serverTiming'
14924
+ });
14925
+ }
14926
+ }
14927
+ return requests;
14928
+ }
14929
+ const contentTypePrefixDenyList = ['video/', 'audio/'];
14930
+ function _checkForCannotReadResponseBody({
14931
+ r,
14932
+ options,
14933
+ url
14934
+ }) {
14935
+ if (r.headers.get('Transfer-Encoding') === 'chunked') {
14936
+ return 'Chunked Transfer-Encoding is not supported';
14937
+ }
14938
+ // `get` and `has` are case-insensitive
14939
+ // but return the header value with the casing that was supplied
14940
+ const contentType = r.headers.get('Content-Type')?.toLowerCase();
14941
+ const contentTypeIsDenied = contentTypePrefixDenyList.some(prefix => contentType?.startsWith(prefix));
14942
+ if (contentType && contentTypeIsDenied) {
14943
+ return `Content-Type ${contentType} is not supported`;
14944
+ }
14945
+ const {
14946
+ hostname,
14947
+ isHostDenied
14948
+ } = isHostOnDenyList(url, options);
14949
+ if (isHostDenied) {
14950
+ return hostname + ' is in deny list';
14951
+ }
14952
+ return null;
14953
+ }
14954
+ function _tryReadBody(r) {
14955
+ // there are now already multiple places where we're using Promise...
14956
+ // eslint-disable-next-line compat/compat
14957
+ return new Promise((resolve, reject) => {
14958
+ const timeout = setTimeout(() => resolve('[SessionReplay] Timeout while trying to read body'), 500);
14959
+ try {
14960
+ r.clone().text().then(txt => resolve(txt), reason => reject(reason)).finally(() => clearTimeout(timeout));
14961
+ } catch {
14962
+ clearTimeout(timeout);
14963
+ resolve('[SessionReplay] Failed to read body');
14964
+ }
14965
+ });
14966
+ }
14967
+ async function _tryReadRequestBody({
14968
+ r,
14969
+ options,
14970
+ url
14971
+ }) {
14972
+ const {
14973
+ hostname,
14974
+ isHostDenied
14975
+ } = isHostOnDenyList(url, options);
14976
+ if (isHostDenied) {
14977
+ return Promise.resolve(hostname + ' is in deny list');
14978
+ }
14979
+ return _tryReadBody(r);
14980
+ }
14981
+ async function _tryReadResponseBody({
14982
+ r,
14983
+ options,
14984
+ url
14985
+ }) {
14986
+ const cannotReadBodyReason = _checkForCannotReadResponseBody({
14987
+ r,
14988
+ options,
14989
+ url
14990
+ });
14991
+ if (!isNull(cannotReadBodyReason)) {
14992
+ return Promise.resolve(cannotReadBodyReason);
14993
+ }
14994
+ return _tryReadBody(r);
14995
+ }
14996
+ function initFetchObserver(cb, win, options) {
14997
+ if (!options.initiatorTypes.includes('fetch')) {
14998
+ return () => {
14999
+ //
15000
+ };
15001
+ }
15002
+ const recordRequestHeaders = shouldRecordHeaders('request', options.recordHeaders);
15003
+ const recordResponseHeaders = shouldRecordHeaders('response', options.recordHeaders);
15004
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15005
+ // @ts-ignore
15006
+ const restorePatch = patch(win, 'fetch', originalFetch => {
15007
+ return async function (url, init) {
15008
+ // check IE earlier than this, we only initialize if Request is present
15009
+ // eslint-disable-next-line compat/compat
15010
+ const req = new Request(url, init);
15011
+ let res;
15012
+ const networkRequest = {};
15013
+ let start;
15014
+ let end;
15015
+ try {
15016
+ const requestHeaders = {};
15017
+ req.headers.forEach((value, header) => {
15018
+ requestHeaders[header] = value;
15019
+ });
15020
+ if (recordRequestHeaders) {
15021
+ networkRequest.requestHeaders = requestHeaders;
15022
+ }
15023
+ if (shouldRecordBody({
15024
+ type: 'request',
15025
+ headers: requestHeaders,
15026
+ url,
15027
+ recordBody: options.recordBody
15028
+ })) {
15029
+ networkRequest.requestBody = await _tryReadRequestBody({
15030
+ r: req,
15031
+ options,
15032
+ url
15033
+ });
15034
+ }
15035
+ start = win.performance.now();
15036
+ res = await originalFetch(req);
15037
+ end = win.performance.now();
15038
+ const responseHeaders = {};
15039
+ res.headers.forEach((value, header) => {
15040
+ responseHeaders[header] = value;
15041
+ });
15042
+ if (recordResponseHeaders) {
15043
+ networkRequest.responseHeaders = responseHeaders;
15044
+ }
15045
+ if (shouldRecordBody({
15046
+ type: 'response',
15047
+ headers: responseHeaders,
15048
+ url,
15049
+ recordBody: options.recordBody
15050
+ })) {
15051
+ networkRequest.responseBody = await _tryReadResponseBody({
15052
+ r: res,
15053
+ options,
15054
+ url
15055
+ });
15056
+ }
15057
+ return res;
15058
+ } finally {
15059
+ getRequestPerformanceEntry(win, 'fetch', req.url, start, end).then(entry => {
15060
+ const requests = prepareRequest({
15061
+ entry,
15062
+ method: req.method,
15063
+ status: res?.status,
15064
+ networkRequest,
15065
+ start,
15066
+ end,
15067
+ url: req.url,
15068
+ initiatorType: 'fetch'
15069
+ });
15070
+ cb({
15071
+ requests
15072
+ });
15073
+ }).catch(() => {
15074
+ //
15075
+ });
15076
+ }
15077
+ };
15078
+ });
15079
+ return () => {
15080
+ restorePatch();
15081
+ };
15082
+ }
15083
+ let initialisedHandler = null;
15084
+ function initNetworkObserver(callback, win,
15085
+ // top window or in an iframe
15086
+ options) {
15087
+ if (!('performance' in win)) {
15088
+ return () => {
15089
+ //
15090
+ };
15091
+ }
15092
+ if (initialisedHandler) {
15093
+ logger.warn('Network observer already initialised, doing nothing');
15094
+ return () => {
15095
+ // the first caller should already have this handler and will be responsible for teardown
15096
+ };
15097
+ }
15098
+ const networkOptions = options ? Object.assign({}, defaultNetworkOptions, options) : defaultNetworkOptions;
15099
+ const cb = data => {
15100
+ const requests = [];
15101
+ data.requests.forEach(request => {
15102
+ const maskedRequest = networkOptions.maskRequestFn(request);
15103
+ if (maskedRequest) {
15104
+ requests.push(maskedRequest);
15105
+ }
15106
+ });
15107
+ if (requests.length > 0) {
15108
+ callback({
15109
+ ...data,
15110
+ requests
15111
+ });
15112
+ }
15113
+ };
15114
+ const performanceObserver = initPerformanceObserver(cb, win, networkOptions);
15115
+ // only wrap fetch and xhr if headers or body are being recorded
15116
+ let xhrObserver = () => {};
15117
+ let fetchObserver = () => {};
15118
+ if (networkOptions.recordHeaders || networkOptions.recordBody) {
15119
+ xhrObserver = initXhrObserver(cb, win, networkOptions);
15120
+ fetchObserver = initFetchObserver(cb, win, networkOptions);
15121
+ }
15122
+ const teardown = () => {
15123
+ performanceObserver();
15124
+ xhrObserver();
15125
+ fetchObserver();
15126
+ // allow future observers to initialize after cleanup
15127
+ initialisedHandler = null;
15128
+ };
15129
+ initialisedHandler = teardown;
15130
+ return teardown;
15131
+ }
15132
+ // use the plugin name so that when this functionality is adopted into rrweb
15133
+ // we can remove this plugin and use the core functionality with the same data
15134
+ const NETWORK_PLUGIN_NAME = 'rrweb/network@1';
15135
+ // TODO how should this be typed?
15136
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15137
+ // @ts-ignore
15138
+ const getRecordNetworkPlugin = options => {
15139
+ return {
15140
+ name: NETWORK_PLUGIN_NAME,
15141
+ observer: initNetworkObserver,
15142
+ options: options
15143
+ };
15144
+ };
15145
+ // rrweb/networ@1 ends
15146
+
15147
+ var networkPlugin = /*#__PURE__*/Object.freeze({
15148
+ __proto__: null,
15149
+ NETWORK_PLUGIN_NAME: NETWORK_PLUGIN_NAME,
15150
+ findLast: findLast,
15151
+ getRecordNetworkPlugin: getRecordNetworkPlugin,
15152
+ shouldRecordBody: shouldRecordBody
15153
+ });
15154
+
13088
15155
  return api;
13089
15156
 
13090
15157
  })();