mixpanel-browser 2.59.0 → 2.60.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ **2.60.0** (31 Jan 2025)
2
+ - Expanded Autocapture configs
3
+ - Prevent duplicate values in persistence when using people.union (thanks @chrisdeely)
4
+
1
5
  **2.59.0** (21 Jan 2025)
2
6
  - Initial Autocapture support
3
7
  - Block more crawlers (AmazonBot, more Yandex bots)
@@ -7,7 +11,7 @@
7
11
  - Session Replay checkpoint events now include a starting URL
8
12
 
9
13
  **2.57.1** (12 Dec 2024)
10
- - Asynchronous abstractions (primarily Promise support) introduced in internal refactor of batch/queue/retry system.
14
+ - Asynchronous abstractions (primarily Promise support) introduced in internal refactor of batch/queue/retry system
11
15
 
12
16
  **2.57.0** (Dec 2024)
13
17
  REDACTED
package/README.md CHANGED
@@ -78,4 +78,4 @@ Mixpanel production releases are tested against a large matrix of browsers and o
78
78
  - Publish to readme.io via the [rdme](https://www.npmjs.com/package/rdme) util: `RDME_API_KEY=<API_KEY> RDME_DOC_VERSION=<version> npm run dox-publish`
79
79
 
80
80
  ## Thanks
81
- For patches and support: @bohanyang, @dehau, @drubin, @D1plo1d, @feychenie, @mogstad, @pfhayes, @sandorfr, @stefansedich, @gfx, @pkaminski, @austince, @danielbaker, @mkdai, @wolever, @dpraul, @chriszamierowski, @JoaoGomesTW, @@aliyalcinkaya
81
+ For patches and support: @bohanyang, @dehau, @drubin, @D1plo1d, @feychenie, @mogstad, @pfhayes, @sandorfr, @stefansedich, @gfx, @pkaminski, @austince, @danielbaker, @mkdai, @wolever, @dpraul, @chriszamierowski, @JoaoGomesTW, @@aliyalcinkaya, @chrisdeely
@@ -2,7 +2,7 @@
2
2
 
3
3
  var Config = {
4
4
  DEBUG: false,
5
- LIB_VERSION: '2.59.0'
5
+ LIB_VERSION: '2.60.0'
6
6
  };
7
7
 
8
8
  // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
@@ -2196,7 +2196,7 @@ function getPreviousElementSibling(el) {
2196
2196
  }
2197
2197
  }
2198
2198
 
2199
- function getPropertiesFromElement(el) {
2199
+ function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
2200
2200
  var props = {
2201
2201
  '$classes': getClassName(el).split(' '),
2202
2202
  '$tag_name': el.tagName.toLowerCase()
@@ -2206,9 +2206,9 @@ function getPropertiesFromElement(el) {
2206
2206
  props['$id'] = elId;
2207
2207
  }
2208
2208
 
2209
- if (shouldTrackElement(el)) {
2210
- _.each(TRACKED_ATTRS, function(attr) {
2211
- if (el.hasAttribute(attr)) {
2209
+ if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
2210
+ _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
2211
+ if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
2212
2212
  var attrVal = el.getAttribute(attr);
2213
2213
  if (shouldTrackValue(attrVal)) {
2214
2214
  props['$attr-' + attr] = attrVal;
@@ -2232,8 +2232,21 @@ function getPropertiesFromElement(el) {
2232
2232
  return props;
2233
2233
  }
2234
2234
 
2235
- function getPropsForDOMEvent(ev, blockSelectors, captureTextContent) {
2236
- blockSelectors = blockSelectors || [];
2235
+ function getPropsForDOMEvent(ev, config) {
2236
+ var allowElementCallback = config.allowElementCallback;
2237
+ var allowSelectors = config.allowSelectors || [];
2238
+ var blockAttrs = config.blockAttrs || [];
2239
+ var blockElementCallback = config.blockElementCallback;
2240
+ var blockSelectors = config.blockSelectors || [];
2241
+ var captureTextContent = config.captureTextContent || false;
2242
+ var captureExtraAttrs = config.captureExtraAttrs || [];
2243
+
2244
+ // convert array to set every time, as the config may have changed
2245
+ var blockAttrsSet = {};
2246
+ _.each(blockAttrs, function(attr) {
2247
+ blockAttrsSet[attr] = true;
2248
+ });
2249
+
2237
2250
  var props = null;
2238
2251
 
2239
2252
  var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
@@ -2241,7 +2254,11 @@ function getPropsForDOMEvent(ev, blockSelectors, captureTextContent) {
2241
2254
  target = target.parentNode;
2242
2255
  }
2243
2256
 
2244
- if (shouldTrackDomEvent(target, ev)) {
2257
+ if (
2258
+ shouldTrackDomEvent(target, ev) &&
2259
+ isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
2260
+ !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
2261
+ ) {
2245
2262
  var targetElementList = [target];
2246
2263
  var curEl = target;
2247
2264
  while (curEl.parentNode && !isTag(curEl, 'body')) {
@@ -2252,37 +2269,20 @@ function getPropsForDOMEvent(ev, blockSelectors, captureTextContent) {
2252
2269
  var elementsJson = [];
2253
2270
  var href, explicitNoTrack = false;
2254
2271
  _.each(targetElementList, function(el) {
2255
- var shouldTrackEl = shouldTrackElement(el);
2272
+ var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
2256
2273
 
2257
2274
  // if the element or a parent element is an anchor tag
2258
2275
  // include the href as a property
2259
- if (el.tagName.toLowerCase() === 'a') {
2276
+ if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
2260
2277
  href = el.getAttribute('href');
2261
- href = shouldTrackEl && shouldTrackValue(href) && href;
2278
+ href = shouldTrackDetails && shouldTrackValue(href) && href;
2262
2279
  }
2263
2280
 
2264
- // allow users to programmatically prevent tracking of elements by adding classes such as 'mp-no-track'
2265
- var classes = getClasses(el);
2266
- _.each(OPT_OUT_CLASSES, function(cls) {
2267
- if (classes[cls]) {
2268
- explicitNoTrack = true;
2269
- }
2270
- });
2271
-
2272
- if (!explicitNoTrack) {
2273
- // programmatically prevent tracking of elements that match CSS selectors
2274
- _.each(blockSelectors, function(sel) {
2275
- try {
2276
- if (el['matches'](sel)) {
2277
- explicitNoTrack = true;
2278
- }
2279
- } catch (err) {
2280
- logger$3.critical('Error while checking selector: ' + sel, err);
2281
- }
2282
- });
2281
+ if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
2282
+ explicitNoTrack = true;
2283
2283
  }
2284
2284
 
2285
- elementsJson.push(getPropertiesFromElement(el));
2285
+ elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
2286
2286
  }, this);
2287
2287
 
2288
2288
  if (!explicitNoTrack) {
@@ -2296,9 +2296,17 @@ function getPropsForDOMEvent(ev, blockSelectors, captureTextContent) {
2296
2296
  '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
2297
2297
  '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0)
2298
2298
  };
2299
+ _.each(captureExtraAttrs, function(attr) {
2300
+ if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
2301
+ var attrVal = target.getAttribute(attr);
2302
+ if (shouldTrackValue(attrVal)) {
2303
+ props['$el_attr__' + attr] = attrVal;
2304
+ }
2305
+ }
2306
+ });
2299
2307
 
2300
2308
  if (captureTextContent) {
2301
- elementText = getSafeText(target);
2309
+ elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
2302
2310
  if (elementText && elementText.length) {
2303
2311
  props['$el_text'] = elementText;
2304
2312
  }
@@ -2314,14 +2322,22 @@ function getPropsForDOMEvent(ev, blockSelectors, captureTextContent) {
2314
2322
  }
2315
2323
  // prioritize text content from "real" click target if different from original target
2316
2324
  if (captureTextContent) {
2317
- var elementText = getSafeText(target);
2325
+ var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
2318
2326
  if (elementText && elementText.length) {
2319
2327
  props['$el_text'] = elementText;
2320
2328
  }
2321
2329
  }
2322
2330
 
2323
2331
  if (target) {
2324
- var targetProps = getPropertiesFromElement(target);
2332
+ // target may have been recalculated; check allowlists and blocklists again
2333
+ if (
2334
+ !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
2335
+ isElementBlocked(target, ev, blockElementCallback, blockSelectors)
2336
+ ) {
2337
+ return null;
2338
+ }
2339
+
2340
+ var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
2325
2341
  props['$target'] = targetProps;
2326
2342
  // pull up more props onto main event props
2327
2343
  props['$el_classes'] = targetProps['$classes'];
@@ -2337,19 +2353,20 @@ function getPropsForDOMEvent(ev, blockSelectors, captureTextContent) {
2337
2353
  }
2338
2354
 
2339
2355
 
2340
- /*
2356
+ /**
2341
2357
  * Get the direct text content of an element, protecting against sensitive data collection.
2342
2358
  * Concats textContent of each of the element's text node children; this avoids potential
2343
2359
  * collection of sensitive data that could happen if we used element.textContent and the
2344
2360
  * element had sensitive child elements, since element.textContent includes child content.
2345
2361
  * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
2346
2362
  * @param {Element} el - element to get the text of
2363
+ * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
2347
2364
  * @returns {string} the element's direct text content
2348
2365
  */
2349
- function getSafeText(el) {
2366
+ function getSafeText(el, ev, allowElementCallback, allowSelectors) {
2350
2367
  var elText = '';
2351
2368
 
2352
- if (shouldTrackElement(el) && el.childNodes && el.childNodes.length) {
2369
+ if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
2353
2370
  _.each(el.childNodes, function(child) {
2354
2371
  if (isTextNode(child) && child.textContent) {
2355
2372
  elText += _.trim(child.textContent)
@@ -2388,6 +2405,75 @@ function guessRealClickTarget(ev) {
2388
2405
  return target;
2389
2406
  }
2390
2407
 
2408
+ function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
2409
+ if (allowElementCallback) {
2410
+ try {
2411
+ if (!allowElementCallback(el, ev)) {
2412
+ return false;
2413
+ }
2414
+ } catch (err) {
2415
+ logger$3.critical('Error while checking element in allowElementCallback', err);
2416
+ return false;
2417
+ }
2418
+ }
2419
+
2420
+ if (!allowSelectors.length) {
2421
+ // no allowlist; all elements are fair game
2422
+ return true;
2423
+ }
2424
+
2425
+ for (var i = 0; i < allowSelectors.length; i++) {
2426
+ var sel = allowSelectors[i];
2427
+ try {
2428
+ if (el['matches'](sel)) {
2429
+ return true;
2430
+ }
2431
+ } catch (err) {
2432
+ logger$3.critical('Error while checking selector: ' + sel, err);
2433
+ }
2434
+ }
2435
+ return false;
2436
+ }
2437
+
2438
+ function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
2439
+ var i;
2440
+
2441
+ if (blockElementCallback) {
2442
+ try {
2443
+ if (blockElementCallback(el, ev)) {
2444
+ return true;
2445
+ }
2446
+ } catch (err) {
2447
+ logger$3.critical('Error while checking element in blockElementCallback', err);
2448
+ return true;
2449
+ }
2450
+ }
2451
+
2452
+ if (blockSelectors && blockSelectors.length) {
2453
+ // programmatically prevent tracking of elements that match CSS selectors
2454
+ for (i = 0; i < blockSelectors.length; i++) {
2455
+ var sel = blockSelectors[i];
2456
+ try {
2457
+ if (el['matches'](sel)) {
2458
+ return true;
2459
+ }
2460
+ } catch (err) {
2461
+ logger$3.critical('Error while checking selector: ' + sel, err);
2462
+ }
2463
+ }
2464
+ }
2465
+
2466
+ // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
2467
+ var classes = getClasses(el);
2468
+ for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
2469
+ if (classes[OPT_OUT_CLASSES[i]]) {
2470
+ return true;
2471
+ }
2472
+ }
2473
+
2474
+ return false;
2475
+ }
2476
+
2391
2477
  /*
2392
2478
  * Check whether a DOM node has nodeType Node.ELEMENT_NODE
2393
2479
  * @param {Node} node - node to check
@@ -2462,11 +2548,16 @@ function shouldTrackDomEvent(el, ev) {
2462
2548
  * Check whether a DOM element should be "tracked" or if it may contain sensitive data
2463
2549
  * using a variety of heuristics.
2464
2550
  * @param {Element} el - element to check
2551
+ * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
2465
2552
  * @returns {boolean} whether the element should be tracked
2466
2553
  */
2467
- function shouldTrackElement(el) {
2554
+ function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
2468
2555
  var i;
2469
2556
 
2557
+ if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
2558
+ return false;
2559
+ }
2560
+
2470
2561
  for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
2471
2562
  var classes = getClasses(curEl);
2472
2563
  for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
@@ -2556,9 +2647,17 @@ var PAGEVIEW_OPTION_FULL_URL = 'full-url';
2556
2647
  var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
2557
2648
  var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
2558
2649
 
2650
+ var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
2651
+ var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
2652
+ var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
2653
+ var CONFIG_BLOCK_ATTRS = 'block_attrs';
2654
+ var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
2559
2655
  var CONFIG_BLOCK_SELECTORS = 'block_selectors';
2560
2656
  var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
2657
+ var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
2561
2658
  var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
2659
+ var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
2660
+ var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
2562
2661
  var CONFIG_TRACK_CLICK = 'click';
2563
2662
  var CONFIG_TRACK_INPUT = 'input';
2564
2663
  var CONFIG_TRACK_PAGEVIEW = 'pageview';
@@ -2566,7 +2665,16 @@ var CONFIG_TRACK_SCROLL = 'scroll';
2566
2665
  var CONFIG_TRACK_SUBMIT = 'submit';
2567
2666
 
2568
2667
  var CONFIG_DEFAULTS = {};
2668
+ CONFIG_DEFAULTS[CONFIG_ALLOW_SELECTORS] = [];
2669
+ CONFIG_DEFAULTS[CONFIG_ALLOW_URL_REGEXES] = [];
2670
+ CONFIG_DEFAULTS[CONFIG_BLOCK_ATTRS] = [];
2671
+ CONFIG_DEFAULTS[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
2672
+ CONFIG_DEFAULTS[CONFIG_BLOCK_SELECTORS] = [];
2673
+ CONFIG_DEFAULTS[CONFIG_BLOCK_URL_REGEXES] = [];
2674
+ CONFIG_DEFAULTS[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
2569
2675
  CONFIG_DEFAULTS[CONFIG_CAPTURE_TEXT_CONTENT] = false;
2676
+ CONFIG_DEFAULTS[CONFIG_SCROLL_CAPTURE_ALL] = false;
2677
+ CONFIG_DEFAULTS[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
2570
2678
  CONFIG_DEFAULTS[CONFIG_TRACK_CLICK] = true;
2571
2679
  CONFIG_DEFAULTS[CONFIG_TRACK_INPUT] = true;
2572
2680
  CONFIG_DEFAULTS[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
@@ -2621,13 +2729,37 @@ Autocapture.prototype.getConfig = function(key) {
2621
2729
  };
2622
2730
 
2623
2731
  Autocapture.prototype.currentUrlBlocked = function() {
2732
+ var i;
2733
+ var currentUrl = _.info.currentUrl();
2734
+
2735
+ var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
2736
+ if (allowUrlRegexes.length) {
2737
+ // we're using an allowlist, only track if current URL matches
2738
+ var allowed = false;
2739
+ for (i = 0; i < allowUrlRegexes.length; i++) {
2740
+ var allowRegex = allowUrlRegexes[i];
2741
+ try {
2742
+ if (currentUrl.match(allowRegex)) {
2743
+ allowed = true;
2744
+ break;
2745
+ }
2746
+ } catch (err) {
2747
+ logger$3.critical('Error while checking block URL regex: ' + allowRegex, err);
2748
+ return true;
2749
+ }
2750
+ }
2751
+ if (!allowed) {
2752
+ // wasn't allowed by any regex
2753
+ return true;
2754
+ }
2755
+ }
2756
+
2624
2757
  var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
2625
2758
  if (!blockUrlRegexes || !blockUrlRegexes.length) {
2626
2759
  return false;
2627
2760
  }
2628
2761
 
2629
- var currentUrl = _.info.currentUrl();
2630
- for (var i = 0; i < blockUrlRegexes.length; i++) {
2762
+ for (i = 0; i < blockUrlRegexes.length; i++) {
2631
2763
  try {
2632
2764
  if (currentUrl.match(blockUrlRegexes[i])) {
2633
2765
  return true;
@@ -2655,11 +2787,15 @@ Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
2655
2787
  return;
2656
2788
  }
2657
2789
 
2658
- var props = getPropsForDOMEvent(
2659
- ev,
2660
- this.getConfig(CONFIG_BLOCK_SELECTORS),
2661
- this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT)
2662
- );
2790
+ var props = getPropsForDOMEvent(ev, {
2791
+ allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
2792
+ allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
2793
+ blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
2794
+ blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
2795
+ blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
2796
+ captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
2797
+ captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT)
2798
+ });
2663
2799
  if (props) {
2664
2800
  _.extend(props, DEFAULT_PROPS);
2665
2801
  this.mp.track(mpEventName, props);
@@ -2744,13 +2880,14 @@ Autocapture.prototype.initPageviewTracking = function() {
2744
2880
 
2745
2881
  var currentUrl = _.info.currentUrl();
2746
2882
  var shouldTrack = false;
2883
+ var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
2747
2884
  var trackPageviewOption = this.pageviewTrackingConfig();
2748
2885
  if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
2749
2886
  shouldTrack = currentUrl !== previousTrackedUrl;
2750
2887
  } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
2751
2888
  shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
2752
2889
  } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
2753
- shouldTrack = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
2890
+ shouldTrack = didPathChange;
2754
2891
  }
2755
2892
 
2756
2893
  if (shouldTrack) {
@@ -2758,6 +2895,10 @@ Autocapture.prototype.initPageviewTracking = function() {
2758
2895
  if (tracked) {
2759
2896
  previousTrackedUrl = currentUrl;
2760
2897
  }
2898
+ if (didPathChange) {
2899
+ this.lastScrollCheckpoint = 0;
2900
+ logger$3.log('Path change: re-initializing scroll depth checkpoints');
2901
+ }
2761
2902
  }
2762
2903
  }.bind(this)));
2763
2904
  };
@@ -2769,6 +2910,7 @@ Autocapture.prototype.initScrollTracking = function() {
2769
2910
  return;
2770
2911
  }
2771
2912
  logger$3.log('Initializing scroll tracking');
2913
+ this.lastScrollCheckpoint = 0;
2772
2914
 
2773
2915
  this.listenerScroll = win.addEventListener(EV_SCROLLEND, safewrap(function() {
2774
2916
  if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
@@ -2778,6 +2920,11 @@ Autocapture.prototype.initScrollTracking = function() {
2778
2920
  return;
2779
2921
  }
2780
2922
 
2923
+ var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
2924
+ var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
2925
+ .slice()
2926
+ .sort(function(a, b) { return a - b; });
2927
+
2781
2928
  var scrollTop = win.scrollY;
2782
2929
  var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
2783
2930
  try {
@@ -2785,10 +2932,25 @@ Autocapture.prototype.initScrollTracking = function() {
2785
2932
  var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
2786
2933
  props['$scroll_height'] = scrollHeight;
2787
2934
  props['$scroll_percentage'] = scrollPercentage;
2935
+ if (scrollPercentage > this.lastScrollCheckpoint) {
2936
+ for (var i = 0; i < scrollCheckpoints.length; i++) {
2937
+ var checkpoint = scrollCheckpoints[i];
2938
+ if (
2939
+ scrollPercentage >= checkpoint &&
2940
+ this.lastScrollCheckpoint < checkpoint
2941
+ ) {
2942
+ props['$scroll_checkpoint'] = checkpoint;
2943
+ this.lastScrollCheckpoint = checkpoint;
2944
+ shouldTrack = true;
2945
+ }
2946
+ }
2947
+ }
2788
2948
  } catch (err) {
2789
2949
  logger$3.critical('Error while calculating scroll percentage', err);
2790
2950
  }
2791
- this.mp.track(MP_EV_SCROLL, props);
2951
+ if (shouldTrack) {
2952
+ this.mp.track(MP_EV_SCROLL, props);
2953
+ }
2792
2954
  }.bind(this)));
2793
2955
  };
2794
2956
 
@@ -5240,8 +5402,12 @@ MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
5240
5402
  if (!(k in union_q)) {
5241
5403
  union_q[k] = [];
5242
5404
  }
5243
- // We may send duplicates, the server will dedup them.
5244
- union_q[k] = union_q[k].concat(v);
5405
+ // Prevent duplicate values
5406
+ _.each(v, function(item) {
5407
+ if (!_.include(union_q[k], item)) {
5408
+ union_q[k].push(item);
5409
+ }
5410
+ });
5245
5411
  }
5246
5412
  });
5247
5413
  this._pop_from_people_queue(UNSET_ACTION, q_data);
@@ -4510,7 +4510,7 @@
4510
4510
 
4511
4511
  var Config = {
4512
4512
  DEBUG: false,
4513
- LIB_VERSION: '2.59.0'
4513
+ LIB_VERSION: '2.60.0'
4514
4514
  };
4515
4515
 
4516
4516
  // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
@@ -29,7 +29,7 @@ or you can use record.mirror to access the mirror instance during recording.`;le
29
29
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
30
30
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
31
31
  PERFORMANCE OF THIS SOFTWARE.
32
- ***************************************************************************** */function e(d,c,f,p){function h(g){return g instanceof f?g:new f(function(m){m(g)})}return new(f||(f=Promise))(function(g,m){function v(y){try{b(p.next(y))}catch(S){m(S)}}function w(y){try{b(p.throw(y))}catch(S){m(S)}}function b(y){y.done?g(y.value):h(y.value).then(v,w)}b((p=p.apply(d,c||[])).next())})}for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=typeof Uint8Array>"u"?[]:new Uint8Array(256),n=0;n<t.length;n++)r[t.charCodeAt(n)]=n;var i=function(d){var c=new Uint8Array(d),f,p=c.length,h="";for(f=0;f<p;f+=3)h+=t[c[f]>>2],h+=t[(c[f]&3)<<4|c[f+1]>>4],h+=t[(c[f+1]&15)<<2|c[f+2]>>6],h+=t[c[f+2]&63];return p%3===2?h=h.substring(0,h.length-1)+"=":p%3===1&&(h=h.substring(0,h.length-2)+"=="),h};const o=new Map,a=new Map;function u(d,c,f){return e(this,void 0,void 0,function*(){const p=`${d}-${c}`;if("OffscreenCanvas"in globalThis){if(a.has(p))return a.get(p);const h=new OffscreenCanvas(d,c);h.getContext("2d");const m=yield(yield h.convertToBlob(f)).arrayBuffer(),v=i(m);return a.set(p,v),v}else return""})}const s=self;s.onmessage=function(d){return e(this,void 0,void 0,function*(){if("OffscreenCanvas"in globalThis){const{id:c,bitmap:f,width:p,height:h,dataURLOptions:g}=d.data,m=u(p,h,g),v=new OffscreenCanvas(p,h);v.getContext("2d").drawImage(f,0,0),f.close();const b=yield v.convertToBlob(g),y=b.type,S=yield b.arrayBuffer(),I=i(S);if(!o.has(c)&&(yield m)===I)return o.set(c,I),s.postMessage({id:c});if(o.get(c)===I)return s.postMessage({id:c});s.postMessage({id:c,type:y,base64:I,width:p,height:h}),o.set(c,I)}else return s.postMessage({id:d.data.id})})}})()},null);class Kn{reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(s,d)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(s)||this.pendingCanvasMutations.set(s,[]),this.pendingCanvasMutations.get(s).push(d)};const{sampling:r="all",win:n,blockClass:i,blockSelector:o,recordCanvas:a,dataURLOptions:u}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,a&&r==="all"&&this.initCanvasMutationObserver(n,i,o),a&&typeof r=="number"&&this.initCanvasFPSObserver(r,n,i,o,{dataURLOptions:u})}initCanvasFPSObserver(t,r,n,i,o){const a=fr(r,n,i,!0),u=new Map,s=new Xn;s.onmessage=g=>{const{id:m}=g.data;if(u.set(m,!1),!("base64"in g.data))return;const{base64:v,type:w,width:b,height:y}=g.data;this.mutationCb({id:m,type:be["2D"],commands:[{property:"clearRect",args:[0,0,b,y]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:v}],type:w}]},0,0]}]})};const d=1e3/t;let c=0,f;const p=()=>{const g=[];return r.document.querySelectorAll("canvas").forEach(m=>{z(m,n,i,!0)||g.push(m)}),g},h=g=>{if(c&&g-c<d){f=requestAnimationFrame(h);return}c=g,p().forEach(m=>Un(this,void 0,void 0,function*(){var v;const w=this.mirror.getId(m);if(u.get(w)||m.width===0||m.height===0)return;if(u.set(w,!0),["webgl","webgl2"].includes(m.__context)){const y=m.getContext(m.__context);((v=y?.getContextAttributes())===null||v===void 0?void 0:v.preserveDrawingBuffer)===!1&&y.clear(y.COLOR_BUFFER_BIT)}const b=yield createImageBitmap(m);s.postMessage({id:w,bitmap:b,width:m.width,height:m.height,dataURLOptions:o.dataURLOptions},[b])})),f=requestAnimationFrame(h)};f=requestAnimationFrame(h),this.resetObservers=()=>{a(),cancelAnimationFrame(f)}}initCanvasMutationObserver(t,r,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const i=fr(t,r,n,!1),o=$n(this.processMutation.bind(this),t,r,n),a=jn(this.processMutation.bind(this),t,r,n,this.mirror);this.resetObservers=()=>{i(),o(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const n=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||r===-1)return;const i=n.map(a=>Bn(a,["type"])),{type:o}=n[0];this.mutationCb({id:r,type:o,commands:i}),this.pendingCanvasMutations.delete(t)}}class Yn{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new gn,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const n={id:r,styleIds:[]},i=[];for(const o of t){let a;this.styleMirror.has(o)?a=this.styleMirror.getId(o):(a=this.styleMirror.add(o),i.push({styleId:a,rules:Array.from(o.rules||CSSRule,(u,s)=>({rule:Nt(u),index:s}))})),n.styleIds.push(a)}i.length>0&&(n.styles=i),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class Qn{constructor(){this.nodeMap=new WeakMap,this.loop=!0,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame(()=>{this.clear(),this.loop&&this.periodicallyClear()})}inOtherBuffer(t,r){const n=this.nodeMap.get(t);return n&&Array.from(n).some(i=>i!==r)}add(t,r){this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(r))}clear(){this.nodeMap=new WeakMap}destroy(){this.loop=!1}}function F(e){return Object.assign(Object.assign({},e),{timestamp:qe()})}let A,Je,mt,Xe=!1;const J=Hr();function ke(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:i="rr-block",blockSelector:o=null,ignoreClass:a="rr-ignore",ignoreSelector:u=null,maskTextClass:s="rr-mask",maskTextSelector:d=null,inlineStylesheet:c=!0,maskAllInputs:f,maskInputOptions:p,slimDOMOptions:h,maskInputFn:g,maskTextFn:m,hooks:v,packFn:w,sampling:b={},dataURLOptions:y={},mousemoveWait:S,recordDOM:I=!0,recordCanvas:U=!1,recordCrossOriginIframes:B=!1,recordAfter:k=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:T=!1,collectFonts:G=!1,inlineImages:V=!1,plugins:E,keepIframeSrcFn:de=()=>!1,ignoreCSSAttributes:q=new Set([]),errorHandler:se}=e;wn(se);const ee=B?window.parent===window:!0;let ot=!1;if(!ee)try{window.parent.document&&(ot=!1)}catch{ot=!0}if(ee&&!t)throw new Error("emit function is required");S!==void 0&&b.mousemove===void 0&&(b.mousemove=S),J.reset();const Et=f===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:p!==void 0?p:{password:!0},Rt=h===!0||h==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:h==="all",headMetaDescKeywords:h==="all"}:h||{};mn();let Ar,xt=0;const Lr=M=>{for(const Q of E||[])Q.eventProcessor&&(M=Q.eventProcessor(M));return w&&!ot&&(M=w(M)),M};A=(M,Q)=>{var D;if(!((D=ue[0])===null||D===void 0)&&D.isFrozen()&&M.type!==O.FullSnapshot&&!(M.type===O.IncrementalSnapshot&&M.data.source===C.Mutation)&&ue.forEach($=>$.unfreeze()),ee)t?.(Lr(M),Q);else if(ot){const $={type:"rrweb",event:Lr(M),origin:window.location.origin,isCheckout:Q};window.parent.postMessage($,"*")}if(M.type===O.FullSnapshot)Ar=M,xt=0;else if(M.type===O.IncrementalSnapshot){if(M.data.source===C.Mutation&&M.data.isAttachIframe)return;xt++;const $=n&&xt>=n,pe=r&&M.timestamp-Ar.timestamp>r;($||pe)&&Je(!0)}};const st=M=>{A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.Mutation},M)}))},Pr=M=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.Scroll},M)})),Fr=M=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.CanvasMutation},M)})),Mi=M=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.AdoptedStyleSheet},M)})),fe=new Yn({mutationCb:st,adoptedStyleSheetCb:Mi}),he=new Pn({mirror:J,mutationCb:st,stylesheetManager:fe,recordCrossOriginIframes:B,wrappedEmit:A});for(const M of E||[])M.getMirror&&M.getMirror({nodeMirror:J,crossOriginIframeMirror:he.crossOriginIframeMirror,crossOriginIframeStyleMirror:he.crossOriginIframeStyleMirror});const kt=new Qn;mt=new Kn({recordCanvas:U,mutationCb:Fr,win:window,blockClass:i,blockSelector:o,mirror:J,sampling:b.canvas,dataURLOptions:y});const at=new Fn({mutationCb:st,scrollCb:Pr,bypassOptions:{blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:d,inlineStylesheet:c,maskInputOptions:Et,dataURLOptions:y,maskTextFn:m,maskInputFn:g,recordCanvas:U,inlineImages:V,sampling:b,slimDOMOptions:Rt,iframeManager:he,stylesheetManager:fe,canvasManager:mt,keepIframeSrcFn:de,processedNodeManager:kt},mirror:J});Je=(M=!1)=>{if(!I)return;A(F({type:O.Meta,data:{href:window.location.href,width:Ht(),height:$t()}}),M),fe.reset(),at.init(),ue.forEach(D=>D.lock());const Q=hn(document,{mirror:J,blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:d,inlineStylesheet:c,maskAllInputs:Et,maskTextFn:m,slimDOM:Rt,dataURLOptions:y,recordCanvas:U,inlineImages:V,onSerialize:D=>{Vt(D,J)&&he.addIframe(D),Jt(D,J)&&fe.trackLinkElement(D),ht(D)&&at.addShadowRoot(D.shadowRoot,document)},onIframeLoad:(D,$)=>{he.attachIframe(D,$),at.observeAttachShadow(D)},onStylesheetLoad:(D,$)=>{fe.attachLinkElement(D,$)},keepIframeSrcFn:de});if(!Q)return console.warn("Failed to snapshot the document");A(F({type:O.FullSnapshot,data:{node:Q,initialOffset:qt(window)}}),M),ue.forEach(D=>D.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&fe.adoptStyleSheets(document.adoptedStyleSheets,J.getId(document))};try{const M=[],Q=$=>{var pe;return _(Ln)({mutationCb:st,mousemoveCb:(N,Tt)=>A(F({type:O.IncrementalSnapshot,data:{source:Tt,positions:N}})),mouseInteractionCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.MouseInteraction},N)})),scrollCb:Pr,viewportResizeCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.ViewportResize},N)})),inputCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.Input},N)})),mediaInteractionCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.MediaInteraction},N)})),styleSheetRuleCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.StyleSheetRule},N)})),styleDeclarationCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.StyleDeclaration},N)})),canvasMutationCb:Fr,fontCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.Font},N)})),selectionCb:N=>{A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.Selection},N)}))},customElementCb:N=>{A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.CustomElement},N)}))},blockClass:i,ignoreClass:a,ignoreSelector:u,maskTextClass:s,maskTextSelector:d,maskInputOptions:Et,inlineStylesheet:c,sampling:b,recordDOM:I,recordCanvas:U,inlineImages:V,userTriggeredOnInput:T,collectFonts:G,doc:$,maskInputFn:g,maskTextFn:m,keepIframeSrcFn:de,blockSelector:o,slimDOMOptions:Rt,dataURLOptions:y,mirror:J,iframeManager:he,stylesheetManager:fe,shadowDomManager:at,processedNodeManager:kt,canvasManager:mt,ignoreCSSAttributes:q,plugins:((pe=E?.filter(N=>N.observer))===null||pe===void 0?void 0:pe.map(N=>({observer:N.observer,options:N.options,callback:Tt=>A(F({type:O.Plugin,data:{plugin:N.name,payload:Tt}}))})))||[]},v)};he.addLoadListener($=>{try{M.push(Q($.contentDocument))}catch(pe){console.warn(pe)}});const D=()=>{Je(),M.push(Q(document)),Xe=!0};return document.readyState==="interactive"||document.readyState==="complete"?D():(M.push(W("DOMContentLoaded",()=>{A(F({type:O.DomContentLoaded,data:{}})),k==="DOMContentLoaded"&&D()})),M.push(W("load",()=>{A(F({type:O.Load,data:{}})),k==="load"&&D()},window))),()=>{M.forEach($=>$()),kt.destroy(),Xe=!1,In()}}catch(M){console.warn(M)}}ke.addCustomEvent=(e,t)=>{if(!Xe)throw new Error("please add custom event after start recording");A(F({type:O.Custom,data:{tag:e,payload:t}}))},ke.freezePage=()=>{ue.forEach(e=>e.freeze())},ke.takeFullSnapshot=e=>{if(!Xe)throw new Error("please take full snapshot after start recording");Je(e)},ke.mirror=J;var pr=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(pr||{}),Z=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(Z||{}),gt={DEBUG:!1,LIB_VERSION:"2.59.0"},x;if(typeof window>"u"){var mr={hostname:""};x={navigator:{userAgent:"",onLine:!0},document:{createElement:function(){return{}},location:mr,referrer:""},screen:{width:0,height:0},location:mr,addEventListener:function(){},removeEventListener:function(){}}}else x=window;var gr=x.setImmediate,ie,yt,vt,yr=Object.prototype.toString,Zn=typeof gr<"u"?function(t){return gr(t)}:setTimeout;try{Object.defineProperty({},"x",{}),ie=function(t,r,n,i){return Object.defineProperty(t,r,{value:n,writable:!0,configurable:i!==!1})}}catch{ie=function(r,n,i){return r[n]=i,r}}vt=function(){var t,r,n;function i(o,a){this.fn=o,this.self=a,this.next=void 0}return{add:function(a,u){n=new i(a,u),r?r.next=n:t=n,r=n,n=void 0},drain:function(){var a=t;for(t=r=yt=void 0;a;)a.fn.call(a.self),a=a.next}}}();function Ke(e,t){vt.add(e,t),yt||(yt=Zn(vt.drain))}function vr(e){var t,r=typeof e;return e!==null&&(r==="object"||r==="function")&&(t=e.then),typeof t=="function"?t:!1}function St(){for(var e=0;e<this.chain.length;e++)ei(this,this.state===1?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function ei(e,t,r){var n,i;try{t===!1?r.reject(e.msg):(t===!0?n=e.msg:n=t.call(void 0,e.msg),n===r.promise?r.reject(TypeError("Promise-chain cycle")):(i=vr(n))?i.call(n,r.resolve,r.reject):r.resolve(n))}catch(o){r.reject(o)}}function Sr(e){var t,r=this;if(!r.triggered){r.triggered=!0,r.def&&(r=r.def);try{(t=vr(e))?Ke(function(){var n=new wr(r);try{t.call(e,function(){Sr.apply(n,arguments)},function(){Te.apply(n,arguments)})}catch(i){Te.call(n,i)}}):(r.msg=e,r.state=1,r.chain.length>0&&Ke(St,r))}catch(n){Te.call(new wr(r),n)}}}function Te(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&Ke(St,t))}function br(e,t,r,n){for(var i=0;i<t.length;i++)(function(a){e.resolve(t[a]).then(function(s){r(a,s)},n)})(i)}function wr(e){this.def=e,this.triggered=!1}function ti(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function oe(e){if(typeof e!="function")throw TypeError("Not a function");if(this.__NPO__!==0)throw TypeError("Not a promise");this.__NPO__=1;var t=new ti(this);this.then=function(n,i){var o={success:typeof n=="function"?n:!0,failure:typeof i=="function"?i:!1};return o.promise=new this.constructor(function(u,s){if(typeof u!="function"||typeof s!="function")throw TypeError("Not a function");o.resolve=u,o.reject=s}),t.chain.push(o),t.state!==0&&Ke(St,t),o.promise},this.catch=function(n){return this.then(void 0,n)};try{e.call(void 0,function(n){Sr.call(t,n)},function(n){Te.call(t,n)})}catch(r){Te.call(t,r)}}var Ir=ie({},"constructor",oe,!1);oe.prototype=Ir,ie(Ir,"__NPO__",0,!1),ie(oe,"resolve",function(t){var r=this;return t&&typeof t=="object"&&t.__NPO__===1?t:new r(function(i,o){if(typeof i!="function"||typeof o!="function")throw TypeError("Not a function");i(t)})}),ie(oe,"reject",function(t){return new this(function(n,i){if(typeof n!="function"||typeof i!="function")throw TypeError("Not a function");i(t)})}),ie(oe,"all",function(t){var r=this;return yr.call(t)!=="[object Array]"?r.reject(TypeError("Not an array")):t.length===0?r.resolve([]):new r(function(i,o){if(typeof i!="function"||typeof o!="function")throw TypeError("Not a function");var a=t.length,u=Array(a),s=0;br(r,t,function(c,f){u[c]=f,++s===a&&i(u)},o)})}),ie(oe,"race",function(t){var r=this;return yr.call(t)!=="[object Array]"?r.reject(TypeError("Not an array")):new r(function(i,o){if(typeof i!="function"||typeof o!="function")throw TypeError("Not a function");br(r,t,function(u,s){i(s)},o)})});var L;typeof Promise<"u"&&Promise.toString().indexOf("[native code]")!==-1?L=Promise:L=oe;var Ye=24*60*60*1e3,bt=8*1e3,Qe=Array.prototype,ri=Function.prototype,Mr=Object.prototype,le=Qe.slice,Ne=Mr.toString,Ze=Mr.hasOwnProperty,De=x.console,Ae=x.navigator,j=x.document,et=x.opera,tt=x.screen,ce=Ae.userAgent,wt=ri.bind,Cr=Qe.forEach,_r=Qe.indexOf,Or=Qe.map,ni=Array.isArray,It={},l={trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},X={log:function(){},warn:function(){},error:function(){},critical:function(){if(!l.isUndefined(De)&&De){var e=["Mixpanel error:"].concat(l.toArray(arguments));try{De.error.apply(De,e)}catch{l.each(e,function(r){De.error(r)})}}}},Mt=function(e,t){return function(){return arguments[0]="["+t+"] "+arguments[0],e.apply(X,arguments)}},Le=function(e){return{log:Mt(X.log,e),error:Mt(X.error,e),critical:Mt(X.critical,e)}};l.bind=function(e,t){var r,n;if(wt&&e.bind===wt)return wt.apply(e,le.call(arguments,1));if(!l.isFunction(e))throw new TypeError;return r=le.call(arguments,2),n=function(){if(!(this instanceof n))return e.apply(t,r.concat(le.call(arguments)));var i={};i.prototype=e.prototype;var o=new i;i.prototype=null;var a=e.apply(o,r.concat(le.call(arguments)));return Object(a)===a?a:o},n},l.each=function(e,t,r){if(e!=null){if(Cr&&e.forEach===Cr)e.forEach(t,r);else if(e.length===+e.length){for(var n=0,i=e.length;n<i;n++)if(n in e&&t.call(r,e[n],n,e)===It)return}else for(var o in e)if(Ze.call(e,o)&&t.call(r,e[o],o,e)===It)return}},l.extend=function(e){return l.each(le.call(arguments,1),function(t){for(var r in t)t[r]!==void 0&&(e[r]=t[r])}),e},l.isArray=ni||function(e){return Ne.call(e)==="[object Array]"},l.isFunction=function(e){try{return/^\s*\bfunction\b/.test(e)}catch{return!1}},l.isArguments=function(e){return!!(e&&Ze.call(e,"callee"))},l.toArray=function(e){return e?e.toArray?e.toArray():l.isArray(e)||l.isArguments(e)?le.call(e):l.values(e):[]},l.map=function(e,t,r){if(Or&&e.map===Or)return e.map(t,r);var n=[];return l.each(e,function(i){n.push(t.call(r,i))}),n},l.keys=function(e){var t=[];return e===null||l.each(e,function(r,n){t[t.length]=n}),t},l.values=function(e){var t=[];return e===null||l.each(e,function(r){t[t.length]=r}),t},l.include=function(e,t){var r=!1;return e===null?r:_r&&e.indexOf===_r?e.indexOf(t)!=-1:(l.each(e,function(n){if(r||(r=n===t))return It}),r)},l.includes=function(e,t){return e.indexOf(t)!==-1},l.inherit=function(e,t){return e.prototype=new t,e.prototype.constructor=e,e.superclass=t.prototype,e},l.isObject=function(e){return e===Object(e)&&!l.isArray(e)},l.isEmptyObject=function(e){if(l.isObject(e)){for(var t in e)if(Ze.call(e,t))return!1;return!0}return!1},l.isUndefined=function(e){return e===void 0},l.isString=function(e){return Ne.call(e)=="[object String]"},l.isDate=function(e){return Ne.call(e)=="[object Date]"},l.isNumber=function(e){return Ne.call(e)=="[object Number]"},l.isElement=function(e){return!!(e&&e.nodeType===1)},l.encodeDates=function(e){return l.each(e,function(t,r){l.isDate(t)?e[r]=l.formatDate(t):l.isObject(t)&&(e[r]=l.encodeDates(t))}),e},l.timestamp=function(){return Date.now=Date.now||function(){return+new Date},Date.now()},l.formatDate=function(e){function t(r){return r<10?"0"+r:r}return e.getUTCFullYear()+"-"+t(e.getUTCMonth()+1)+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())},l.strip_empty_properties=function(e){var t={};return l.each(e,function(r,n){l.isString(r)&&r.length>0&&(t[n]=r)}),t},l.truncate=function(e,t){var r;return typeof e=="string"?r=e.slice(0,t):l.isArray(e)?(r=[],l.each(e,function(n){r.push(l.truncate(n,t))})):l.isObject(e)?(r={},l.each(e,function(n,i){r[i]=l.truncate(n,t)})):r=e,r},l.JSONEncode=function(){return function(e){var t=e,r=function(i){var o=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,a={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return o.lastIndex=0,o.test(i)?'"'+i.replace(o,function(u){var s=a[u];return typeof s=="string"?s:"\\u"+("0000"+u.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+i+'"'},n=function(i,o){var a="",u=" ",s=0,d="",c="",f=0,p=a,h=[],g=o[i];switch(g&&typeof g=="object"&&typeof g.toJSON=="function"&&(g=g.toJSON(i)),typeof g){case"string":return r(g);case"number":return isFinite(g)?String(g):"null";case"boolean":case"null":return String(g);case"object":if(!g)return"null";if(a+=u,h=[],Ne.apply(g)==="[object Array]"){for(f=g.length,s=0;s<f;s+=1)h[s]=n(s,g)||"null";return c=h.length===0?"[]":a?`[
32
+ ***************************************************************************** */function e(d,c,f,p){function h(g){return g instanceof f?g:new f(function(m){m(g)})}return new(f||(f=Promise))(function(g,m){function v(y){try{b(p.next(y))}catch(S){m(S)}}function w(y){try{b(p.throw(y))}catch(S){m(S)}}function b(y){y.done?g(y.value):h(y.value).then(v,w)}b((p=p.apply(d,c||[])).next())})}for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=typeof Uint8Array>"u"?[]:new Uint8Array(256),n=0;n<t.length;n++)r[t.charCodeAt(n)]=n;var i=function(d){var c=new Uint8Array(d),f,p=c.length,h="";for(f=0;f<p;f+=3)h+=t[c[f]>>2],h+=t[(c[f]&3)<<4|c[f+1]>>4],h+=t[(c[f+1]&15)<<2|c[f+2]>>6],h+=t[c[f+2]&63];return p%3===2?h=h.substring(0,h.length-1)+"=":p%3===1&&(h=h.substring(0,h.length-2)+"=="),h};const o=new Map,a=new Map;function u(d,c,f){return e(this,void 0,void 0,function*(){const p=`${d}-${c}`;if("OffscreenCanvas"in globalThis){if(a.has(p))return a.get(p);const h=new OffscreenCanvas(d,c);h.getContext("2d");const m=yield(yield h.convertToBlob(f)).arrayBuffer(),v=i(m);return a.set(p,v),v}else return""})}const s=self;s.onmessage=function(d){return e(this,void 0,void 0,function*(){if("OffscreenCanvas"in globalThis){const{id:c,bitmap:f,width:p,height:h,dataURLOptions:g}=d.data,m=u(p,h,g),v=new OffscreenCanvas(p,h);v.getContext("2d").drawImage(f,0,0),f.close();const b=yield v.convertToBlob(g),y=b.type,S=yield b.arrayBuffer(),I=i(S);if(!o.has(c)&&(yield m)===I)return o.set(c,I),s.postMessage({id:c});if(o.get(c)===I)return s.postMessage({id:c});s.postMessage({id:c,type:y,base64:I,width:p,height:h}),o.set(c,I)}else return s.postMessage({id:d.data.id})})}})()},null);class Kn{reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(s,d)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(s)||this.pendingCanvasMutations.set(s,[]),this.pendingCanvasMutations.get(s).push(d)};const{sampling:r="all",win:n,blockClass:i,blockSelector:o,recordCanvas:a,dataURLOptions:u}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,a&&r==="all"&&this.initCanvasMutationObserver(n,i,o),a&&typeof r=="number"&&this.initCanvasFPSObserver(r,n,i,o,{dataURLOptions:u})}initCanvasFPSObserver(t,r,n,i,o){const a=fr(r,n,i,!0),u=new Map,s=new Xn;s.onmessage=g=>{const{id:m}=g.data;if(u.set(m,!1),!("base64"in g.data))return;const{base64:v,type:w,width:b,height:y}=g.data;this.mutationCb({id:m,type:be["2D"],commands:[{property:"clearRect",args:[0,0,b,y]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:v}],type:w}]},0,0]}]})};const d=1e3/t;let c=0,f;const p=()=>{const g=[];return r.document.querySelectorAll("canvas").forEach(m=>{z(m,n,i,!0)||g.push(m)}),g},h=g=>{if(c&&g-c<d){f=requestAnimationFrame(h);return}c=g,p().forEach(m=>Un(this,void 0,void 0,function*(){var v;const w=this.mirror.getId(m);if(u.get(w)||m.width===0||m.height===0)return;if(u.set(w,!0),["webgl","webgl2"].includes(m.__context)){const y=m.getContext(m.__context);((v=y?.getContextAttributes())===null||v===void 0?void 0:v.preserveDrawingBuffer)===!1&&y.clear(y.COLOR_BUFFER_BIT)}const b=yield createImageBitmap(m);s.postMessage({id:w,bitmap:b,width:m.width,height:m.height,dataURLOptions:o.dataURLOptions},[b])})),f=requestAnimationFrame(h)};f=requestAnimationFrame(h),this.resetObservers=()=>{a(),cancelAnimationFrame(f)}}initCanvasMutationObserver(t,r,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const i=fr(t,r,n,!1),o=$n(this.processMutation.bind(this),t,r,n),a=jn(this.processMutation.bind(this),t,r,n,this.mirror);this.resetObservers=()=>{i(),o(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const n=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||r===-1)return;const i=n.map(a=>Bn(a,["type"])),{type:o}=n[0];this.mutationCb({id:r,type:o,commands:i}),this.pendingCanvasMutations.delete(t)}}class Yn{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new gn,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const n={id:r,styleIds:[]},i=[];for(const o of t){let a;this.styleMirror.has(o)?a=this.styleMirror.getId(o):(a=this.styleMirror.add(o),i.push({styleId:a,rules:Array.from(o.rules||CSSRule,(u,s)=>({rule:Nt(u),index:s}))})),n.styleIds.push(a)}i.length>0&&(n.styles=i),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class Qn{constructor(){this.nodeMap=new WeakMap,this.loop=!0,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame(()=>{this.clear(),this.loop&&this.periodicallyClear()})}inOtherBuffer(t,r){const n=this.nodeMap.get(t);return n&&Array.from(n).some(i=>i!==r)}add(t,r){this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(r))}clear(){this.nodeMap=new WeakMap}destroy(){this.loop=!1}}function F(e){return Object.assign(Object.assign({},e),{timestamp:qe()})}let A,Je,mt,Xe=!1;const J=Hr();function ke(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:i="rr-block",blockSelector:o=null,ignoreClass:a="rr-ignore",ignoreSelector:u=null,maskTextClass:s="rr-mask",maskTextSelector:d=null,inlineStylesheet:c=!0,maskAllInputs:f,maskInputOptions:p,slimDOMOptions:h,maskInputFn:g,maskTextFn:m,hooks:v,packFn:w,sampling:b={},dataURLOptions:y={},mousemoveWait:S,recordDOM:I=!0,recordCanvas:U=!1,recordCrossOriginIframes:B=!1,recordAfter:k=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:T=!1,collectFonts:G=!1,inlineImages:V=!1,plugins:E,keepIframeSrcFn:de=()=>!1,ignoreCSSAttributes:q=new Set([]),errorHandler:se}=e;wn(se);const ee=B?window.parent===window:!0;let ot=!1;if(!ee)try{window.parent.document&&(ot=!1)}catch{ot=!0}if(ee&&!t)throw new Error("emit function is required");S!==void 0&&b.mousemove===void 0&&(b.mousemove=S),J.reset();const Et=f===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:p!==void 0?p:{password:!0},Rt=h===!0||h==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:h==="all",headMetaDescKeywords:h==="all"}:h||{};mn();let Ar,xt=0;const Lr=M=>{for(const Q of E||[])Q.eventProcessor&&(M=Q.eventProcessor(M));return w&&!ot&&(M=w(M)),M};A=(M,Q)=>{var D;if(!((D=ue[0])===null||D===void 0)&&D.isFrozen()&&M.type!==O.FullSnapshot&&!(M.type===O.IncrementalSnapshot&&M.data.source===C.Mutation)&&ue.forEach($=>$.unfreeze()),ee)t?.(Lr(M),Q);else if(ot){const $={type:"rrweb",event:Lr(M),origin:window.location.origin,isCheckout:Q};window.parent.postMessage($,"*")}if(M.type===O.FullSnapshot)Ar=M,xt=0;else if(M.type===O.IncrementalSnapshot){if(M.data.source===C.Mutation&&M.data.isAttachIframe)return;xt++;const $=n&&xt>=n,pe=r&&M.timestamp-Ar.timestamp>r;($||pe)&&Je(!0)}};const st=M=>{A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.Mutation},M)}))},Pr=M=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.Scroll},M)})),Fr=M=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.CanvasMutation},M)})),Mi=M=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.AdoptedStyleSheet},M)})),fe=new Yn({mutationCb:st,adoptedStyleSheetCb:Mi}),he=new Pn({mirror:J,mutationCb:st,stylesheetManager:fe,recordCrossOriginIframes:B,wrappedEmit:A});for(const M of E||[])M.getMirror&&M.getMirror({nodeMirror:J,crossOriginIframeMirror:he.crossOriginIframeMirror,crossOriginIframeStyleMirror:he.crossOriginIframeStyleMirror});const kt=new Qn;mt=new Kn({recordCanvas:U,mutationCb:Fr,win:window,blockClass:i,blockSelector:o,mirror:J,sampling:b.canvas,dataURLOptions:y});const at=new Fn({mutationCb:st,scrollCb:Pr,bypassOptions:{blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:d,inlineStylesheet:c,maskInputOptions:Et,dataURLOptions:y,maskTextFn:m,maskInputFn:g,recordCanvas:U,inlineImages:V,sampling:b,slimDOMOptions:Rt,iframeManager:he,stylesheetManager:fe,canvasManager:mt,keepIframeSrcFn:de,processedNodeManager:kt},mirror:J});Je=(M=!1)=>{if(!I)return;A(F({type:O.Meta,data:{href:window.location.href,width:Ht(),height:$t()}}),M),fe.reset(),at.init(),ue.forEach(D=>D.lock());const Q=hn(document,{mirror:J,blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:d,inlineStylesheet:c,maskAllInputs:Et,maskTextFn:m,slimDOM:Rt,dataURLOptions:y,recordCanvas:U,inlineImages:V,onSerialize:D=>{Vt(D,J)&&he.addIframe(D),Jt(D,J)&&fe.trackLinkElement(D),ht(D)&&at.addShadowRoot(D.shadowRoot,document)},onIframeLoad:(D,$)=>{he.attachIframe(D,$),at.observeAttachShadow(D)},onStylesheetLoad:(D,$)=>{fe.attachLinkElement(D,$)},keepIframeSrcFn:de});if(!Q)return console.warn("Failed to snapshot the document");A(F({type:O.FullSnapshot,data:{node:Q,initialOffset:qt(window)}}),M),ue.forEach(D=>D.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&fe.adoptStyleSheets(document.adoptedStyleSheets,J.getId(document))};try{const M=[],Q=$=>{var pe;return _(Ln)({mutationCb:st,mousemoveCb:(N,Tt)=>A(F({type:O.IncrementalSnapshot,data:{source:Tt,positions:N}})),mouseInteractionCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.MouseInteraction},N)})),scrollCb:Pr,viewportResizeCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.ViewportResize},N)})),inputCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.Input},N)})),mediaInteractionCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.MediaInteraction},N)})),styleSheetRuleCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.StyleSheetRule},N)})),styleDeclarationCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.StyleDeclaration},N)})),canvasMutationCb:Fr,fontCb:N=>A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.Font},N)})),selectionCb:N=>{A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.Selection},N)}))},customElementCb:N=>{A(F({type:O.IncrementalSnapshot,data:Object.assign({source:C.CustomElement},N)}))},blockClass:i,ignoreClass:a,ignoreSelector:u,maskTextClass:s,maskTextSelector:d,maskInputOptions:Et,inlineStylesheet:c,sampling:b,recordDOM:I,recordCanvas:U,inlineImages:V,userTriggeredOnInput:T,collectFonts:G,doc:$,maskInputFn:g,maskTextFn:m,keepIframeSrcFn:de,blockSelector:o,slimDOMOptions:Rt,dataURLOptions:y,mirror:J,iframeManager:he,stylesheetManager:fe,shadowDomManager:at,processedNodeManager:kt,canvasManager:mt,ignoreCSSAttributes:q,plugins:((pe=E?.filter(N=>N.observer))===null||pe===void 0?void 0:pe.map(N=>({observer:N.observer,options:N.options,callback:Tt=>A(F({type:O.Plugin,data:{plugin:N.name,payload:Tt}}))})))||[]},v)};he.addLoadListener($=>{try{M.push(Q($.contentDocument))}catch(pe){console.warn(pe)}});const D=()=>{Je(),M.push(Q(document)),Xe=!0};return document.readyState==="interactive"||document.readyState==="complete"?D():(M.push(W("DOMContentLoaded",()=>{A(F({type:O.DomContentLoaded,data:{}})),k==="DOMContentLoaded"&&D()})),M.push(W("load",()=>{A(F({type:O.Load,data:{}})),k==="load"&&D()},window))),()=>{M.forEach($=>$()),kt.destroy(),Xe=!1,In()}}catch(M){console.warn(M)}}ke.addCustomEvent=(e,t)=>{if(!Xe)throw new Error("please add custom event after start recording");A(F({type:O.Custom,data:{tag:e,payload:t}}))},ke.freezePage=()=>{ue.forEach(e=>e.freeze())},ke.takeFullSnapshot=e=>{if(!Xe)throw new Error("please take full snapshot after start recording");Je(e)},ke.mirror=J;var pr=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(pr||{}),Z=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(Z||{}),gt={DEBUG:!1,LIB_VERSION:"2.60.0"},x;if(typeof window>"u"){var mr={hostname:""};x={navigator:{userAgent:"",onLine:!0},document:{createElement:function(){return{}},location:mr,referrer:""},screen:{width:0,height:0},location:mr,addEventListener:function(){},removeEventListener:function(){}}}else x=window;var gr=x.setImmediate,ie,yt,vt,yr=Object.prototype.toString,Zn=typeof gr<"u"?function(t){return gr(t)}:setTimeout;try{Object.defineProperty({},"x",{}),ie=function(t,r,n,i){return Object.defineProperty(t,r,{value:n,writable:!0,configurable:i!==!1})}}catch{ie=function(r,n,i){return r[n]=i,r}}vt=function(){var t,r,n;function i(o,a){this.fn=o,this.self=a,this.next=void 0}return{add:function(a,u){n=new i(a,u),r?r.next=n:t=n,r=n,n=void 0},drain:function(){var a=t;for(t=r=yt=void 0;a;)a.fn.call(a.self),a=a.next}}}();function Ke(e,t){vt.add(e,t),yt||(yt=Zn(vt.drain))}function vr(e){var t,r=typeof e;return e!==null&&(r==="object"||r==="function")&&(t=e.then),typeof t=="function"?t:!1}function St(){for(var e=0;e<this.chain.length;e++)ei(this,this.state===1?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function ei(e,t,r){var n,i;try{t===!1?r.reject(e.msg):(t===!0?n=e.msg:n=t.call(void 0,e.msg),n===r.promise?r.reject(TypeError("Promise-chain cycle")):(i=vr(n))?i.call(n,r.resolve,r.reject):r.resolve(n))}catch(o){r.reject(o)}}function Sr(e){var t,r=this;if(!r.triggered){r.triggered=!0,r.def&&(r=r.def);try{(t=vr(e))?Ke(function(){var n=new wr(r);try{t.call(e,function(){Sr.apply(n,arguments)},function(){Te.apply(n,arguments)})}catch(i){Te.call(n,i)}}):(r.msg=e,r.state=1,r.chain.length>0&&Ke(St,r))}catch(n){Te.call(new wr(r),n)}}}function Te(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&Ke(St,t))}function br(e,t,r,n){for(var i=0;i<t.length;i++)(function(a){e.resolve(t[a]).then(function(s){r(a,s)},n)})(i)}function wr(e){this.def=e,this.triggered=!1}function ti(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function oe(e){if(typeof e!="function")throw TypeError("Not a function");if(this.__NPO__!==0)throw TypeError("Not a promise");this.__NPO__=1;var t=new ti(this);this.then=function(n,i){var o={success:typeof n=="function"?n:!0,failure:typeof i=="function"?i:!1};return o.promise=new this.constructor(function(u,s){if(typeof u!="function"||typeof s!="function")throw TypeError("Not a function");o.resolve=u,o.reject=s}),t.chain.push(o),t.state!==0&&Ke(St,t),o.promise},this.catch=function(n){return this.then(void 0,n)};try{e.call(void 0,function(n){Sr.call(t,n)},function(n){Te.call(t,n)})}catch(r){Te.call(t,r)}}var Ir=ie({},"constructor",oe,!1);oe.prototype=Ir,ie(Ir,"__NPO__",0,!1),ie(oe,"resolve",function(t){var r=this;return t&&typeof t=="object"&&t.__NPO__===1?t:new r(function(i,o){if(typeof i!="function"||typeof o!="function")throw TypeError("Not a function");i(t)})}),ie(oe,"reject",function(t){return new this(function(n,i){if(typeof n!="function"||typeof i!="function")throw TypeError("Not a function");i(t)})}),ie(oe,"all",function(t){var r=this;return yr.call(t)!=="[object Array]"?r.reject(TypeError("Not an array")):t.length===0?r.resolve([]):new r(function(i,o){if(typeof i!="function"||typeof o!="function")throw TypeError("Not a function");var a=t.length,u=Array(a),s=0;br(r,t,function(c,f){u[c]=f,++s===a&&i(u)},o)})}),ie(oe,"race",function(t){var r=this;return yr.call(t)!=="[object Array]"?r.reject(TypeError("Not an array")):new r(function(i,o){if(typeof i!="function"||typeof o!="function")throw TypeError("Not a function");br(r,t,function(u,s){i(s)},o)})});var L;typeof Promise<"u"&&Promise.toString().indexOf("[native code]")!==-1?L=Promise:L=oe;var Ye=24*60*60*1e3,bt=8*1e3,Qe=Array.prototype,ri=Function.prototype,Mr=Object.prototype,le=Qe.slice,Ne=Mr.toString,Ze=Mr.hasOwnProperty,De=x.console,Ae=x.navigator,j=x.document,et=x.opera,tt=x.screen,ce=Ae.userAgent,wt=ri.bind,Cr=Qe.forEach,_r=Qe.indexOf,Or=Qe.map,ni=Array.isArray,It={},l={trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},X={log:function(){},warn:function(){},error:function(){},critical:function(){if(!l.isUndefined(De)&&De){var e=["Mixpanel error:"].concat(l.toArray(arguments));try{De.error.apply(De,e)}catch{l.each(e,function(r){De.error(r)})}}}},Mt=function(e,t){return function(){return arguments[0]="["+t+"] "+arguments[0],e.apply(X,arguments)}},Le=function(e){return{log:Mt(X.log,e),error:Mt(X.error,e),critical:Mt(X.critical,e)}};l.bind=function(e,t){var r,n;if(wt&&e.bind===wt)return wt.apply(e,le.call(arguments,1));if(!l.isFunction(e))throw new TypeError;return r=le.call(arguments,2),n=function(){if(!(this instanceof n))return e.apply(t,r.concat(le.call(arguments)));var i={};i.prototype=e.prototype;var o=new i;i.prototype=null;var a=e.apply(o,r.concat(le.call(arguments)));return Object(a)===a?a:o},n},l.each=function(e,t,r){if(e!=null){if(Cr&&e.forEach===Cr)e.forEach(t,r);else if(e.length===+e.length){for(var n=0,i=e.length;n<i;n++)if(n in e&&t.call(r,e[n],n,e)===It)return}else for(var o in e)if(Ze.call(e,o)&&t.call(r,e[o],o,e)===It)return}},l.extend=function(e){return l.each(le.call(arguments,1),function(t){for(var r in t)t[r]!==void 0&&(e[r]=t[r])}),e},l.isArray=ni||function(e){return Ne.call(e)==="[object Array]"},l.isFunction=function(e){try{return/^\s*\bfunction\b/.test(e)}catch{return!1}},l.isArguments=function(e){return!!(e&&Ze.call(e,"callee"))},l.toArray=function(e){return e?e.toArray?e.toArray():l.isArray(e)||l.isArguments(e)?le.call(e):l.values(e):[]},l.map=function(e,t,r){if(Or&&e.map===Or)return e.map(t,r);var n=[];return l.each(e,function(i){n.push(t.call(r,i))}),n},l.keys=function(e){var t=[];return e===null||l.each(e,function(r,n){t[t.length]=n}),t},l.values=function(e){var t=[];return e===null||l.each(e,function(r){t[t.length]=r}),t},l.include=function(e,t){var r=!1;return e===null?r:_r&&e.indexOf===_r?e.indexOf(t)!=-1:(l.each(e,function(n){if(r||(r=n===t))return It}),r)},l.includes=function(e,t){return e.indexOf(t)!==-1},l.inherit=function(e,t){return e.prototype=new t,e.prototype.constructor=e,e.superclass=t.prototype,e},l.isObject=function(e){return e===Object(e)&&!l.isArray(e)},l.isEmptyObject=function(e){if(l.isObject(e)){for(var t in e)if(Ze.call(e,t))return!1;return!0}return!1},l.isUndefined=function(e){return e===void 0},l.isString=function(e){return Ne.call(e)=="[object String]"},l.isDate=function(e){return Ne.call(e)=="[object Date]"},l.isNumber=function(e){return Ne.call(e)=="[object Number]"},l.isElement=function(e){return!!(e&&e.nodeType===1)},l.encodeDates=function(e){return l.each(e,function(t,r){l.isDate(t)?e[r]=l.formatDate(t):l.isObject(t)&&(e[r]=l.encodeDates(t))}),e},l.timestamp=function(){return Date.now=Date.now||function(){return+new Date},Date.now()},l.formatDate=function(e){function t(r){return r<10?"0"+r:r}return e.getUTCFullYear()+"-"+t(e.getUTCMonth()+1)+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())},l.strip_empty_properties=function(e){var t={};return l.each(e,function(r,n){l.isString(r)&&r.length>0&&(t[n]=r)}),t},l.truncate=function(e,t){var r;return typeof e=="string"?r=e.slice(0,t):l.isArray(e)?(r=[],l.each(e,function(n){r.push(l.truncate(n,t))})):l.isObject(e)?(r={},l.each(e,function(n,i){r[i]=l.truncate(n,t)})):r=e,r},l.JSONEncode=function(){return function(e){var t=e,r=function(i){var o=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,a={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return o.lastIndex=0,o.test(i)?'"'+i.replace(o,function(u){var s=a[u];return typeof s=="string"?s:"\\u"+("0000"+u.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+i+'"'},n=function(i,o){var a="",u=" ",s=0,d="",c="",f=0,p=a,h=[],g=o[i];switch(g&&typeof g=="object"&&typeof g.toJSON=="function"&&(g=g.toJSON(i)),typeof g){case"string":return r(g);case"number":return isFinite(g)?String(g):"null";case"boolean":case"null":return String(g);case"object":if(!g)return"null";if(a+=u,h=[],Ne.apply(g)==="[object Array]"){for(f=g.length,s=0;s<f;s+=1)h[s]=n(s,g)||"null";return c=h.length===0?"[]":a?`[
33
33
  `+a+h.join(`,
34
34
  `+a)+`
35
35
  `+p+"]":"["+h.join(",")+"]",a=p,c}for(d in g)Ze.call(g,d)&&(c=n(d,g),c&&h.push(r(d)+(a?": ":":")+c));return c=h.length===0?"{}":a?"{"+h.join(",")+p+"}":"{"+h.join(",")+"}",a=p,c}};return n("",{"":t})}}(),l.JSONDecode=function(){var e,t,r={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`