@reservamos/browser-analytics 1.1.6 → 1.1.7-alpha.1

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.
@@ -190,10 +190,10 @@ class ZodError extends Error {
190
190
  fieldErrors._errors.push(mapper(issue));
191
191
  } else {
192
192
  let curr = fieldErrors;
193
- let i = 0;
194
- while (i < issue.path.length) {
195
- const el = issue.path[i];
196
- const terminal = i === issue.path.length - 1;
193
+ let i2 = 0;
194
+ while (i2 < issue.path.length) {
195
+ const el = issue.path[i2];
196
+ const terminal = i2 === issue.path.length - 1;
197
197
  if (!terminal) {
198
198
  curr[el] = curr[el] || { _errors: [] };
199
199
  } else {
@@ -201,7 +201,7 @@ class ZodError extends Error {
201
201
  curr[el]._errors.push(mapper(issue));
202
202
  }
203
203
  curr = curr[el];
204
- i++;
204
+ i2++;
205
205
  }
206
206
  }
207
207
  }
@@ -2047,14 +2047,14 @@ class ZodArray extends ZodType {
2047
2047
  }
2048
2048
  }
2049
2049
  if (ctx.common.async) {
2050
- return Promise.all([...ctx.data].map((item, i) => {
2051
- return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2050
+ return Promise.all([...ctx.data].map((item, i2) => {
2051
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i2));
2052
2052
  })).then((result2) => {
2053
2053
  return ParseStatus.mergeArray(status, result2);
2054
2054
  });
2055
2055
  }
2056
- const result = [...ctx.data].map((item, i) => {
2057
- return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2056
+ const result = [...ctx.data].map((item, i2) => {
2057
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i2));
2058
2058
  });
2059
2059
  return ParseStatus.mergeArray(status, result);
2060
2060
  }
@@ -2982,7 +2982,7 @@ class ZodSet extends ZodType {
2982
2982
  }
2983
2983
  return { status: status.value, value: parsedSet };
2984
2984
  }
2985
- const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
2985
+ const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i2)));
2986
2986
  if (ctx.common.async) {
2987
2987
  return Promise.all(elements).then((elements2) => finalizeSet(elements2));
2988
2988
  } else {
@@ -3921,6 +3921,89 @@ const customEventSchema = z.record(
3921
3921
  z.union([allowedPrimitiveSchema, z.array(allowedPrimitiveSchema)])
3922
3922
  );
3923
3923
  const eventNameSchema = z.string().min(1, "Event name is required");
3924
+ let environment;
3925
+ let appName;
3926
+ const origin = window.location.origin;
3927
+ const coreAPIConfig = {
3928
+ sandbox: {
3929
+ baseUrl: "https://datalake-api-dev.reservamossaas.com/api",
3930
+ defaultHeaders: {
3931
+ Origin: origin,
3932
+ Authorization: "Bearer 753bf0710dc920a84236d42241d4f487"
3933
+ }
3934
+ },
3935
+ prod: {
3936
+ baseUrl: "https://data-lake.reservamossaas.com/api",
3937
+ defaultHeaders: {
3938
+ Origin: origin,
3939
+ Authorization: "Bearer 753bf0710dc920a84236d42241d4f487"
3940
+ }
3941
+ }
3942
+ };
3943
+ function setEnvironment(env) {
3944
+ environment = env;
3945
+ }
3946
+ function setAppName(name) {
3947
+ appName = name;
3948
+ }
3949
+ function getCoreAPIConfig() {
3950
+ if (!environment) {
3951
+ throw new Error(
3952
+ "Unable to get core API config, environment not set. Use configService.setEnvironment(environment) to set the environment."
3953
+ );
3954
+ }
3955
+ const config = coreAPIConfig[environment];
3956
+ return {
3957
+ ...config,
3958
+ defaultHeaders: {
3959
+ ...config.defaultHeaders,
3960
+ ...appName ? { "x-app-name": appName } : {}
3961
+ }
3962
+ };
3963
+ }
3964
+ const configService = {
3965
+ setEnvironment,
3966
+ setAppName,
3967
+ getCoreAPIConfig
3968
+ };
3969
+ const BOT_DETECTION_RELAY_PATH = "/v1/fingerprint/bot-detection";
3970
+ const BOT_DETECTION_EVENTS = [
3971
+ "Search",
3972
+ "Payment Attempt",
3973
+ "Purchase Attempt"
3974
+ ];
3975
+ function isEnabledFor(eventName) {
3976
+ return BOT_DETECTION_EVENTS.includes(eventName);
3977
+ }
3978
+ async function relay(payload) {
3979
+ var _a;
3980
+ try {
3981
+ const coreApiConfig = configService.getCoreAPIConfig();
3982
+ const response = await fetch(
3983
+ `${coreApiConfig.baseUrl}${BOT_DETECTION_RELAY_PATH}`,
3984
+ {
3985
+ method: "POST",
3986
+ headers: {
3987
+ "Content-Type": "application/json",
3988
+ ...((_a = coreApiConfig.defaultHeaders) == null ? void 0 : _a["x-app-name"]) ? { "x-app-name": coreApiConfig.defaultHeaders["x-app-name"] } : {}
3989
+ },
3990
+ body: JSON.stringify(payload),
3991
+ keepalive: true
3992
+ }
3993
+ );
3994
+ if (!response.ok) {
3995
+ throw new Error(
3996
+ `Bot Detection relay failed with status ${response.status}`
3997
+ );
3998
+ }
3999
+ } catch (error) {
4000
+ console.error("Error relaying Fingerprint identification:", error);
4001
+ }
4002
+ }
4003
+ const botDetectionRelayService = {
4004
+ isEnabledFor,
4005
+ relay
4006
+ };
3924
4007
  function __awaiter$1(thisArg, _arguments, P2, generator) {
3925
4008
  function adopt(value) {
3926
4009
  return value instanceof P2 ? value : new P2(function(resolve) {
@@ -3958,14 +4041,14 @@ function e(e2, t2) {
3958
4041
  }(e2, t2) ? e2[t2] : void 0;
3959
4042
  }
3960
4043
  function t$3(e2, t2, n2, r2) {
3961
- const o2 = document, i = "securitypolicyviolation";
4044
+ const o2 = document, i2 = "securitypolicyviolation";
3962
4045
  let R2;
3963
4046
  const s2 = (t3) => {
3964
4047
  const n3 = new URL(e2, location.href), { blockedURI: r3 } = t3;
3965
4048
  r3 !== n3.href && r3 !== n3.protocol.slice(0, -1) && r3 !== n3.origin || (R2 = t3, a2());
3966
4049
  };
3967
- o2.addEventListener(i, s2);
3968
- const a2 = () => o2.removeEventListener(i, s2);
4050
+ o2.addEventListener(i2, s2);
4051
+ const a2 = () => o2.removeEventListener(i2, s2);
3969
4052
  return Promise.resolve().then(t2).then((e3) => (a2(), e3), (e3) => new Promise((e4) => {
3970
4053
  const t3 = new MessageChannel();
3971
4054
  t3.port1.onmessage = () => e4(), t3.port2.postMessage(null);
@@ -4001,26 +4084,26 @@ function V(e2, t2) {
4001
4084
  return () => Math.random() * Math.min(t4, e4 * Math.pow(2, n4++));
4002
4085
  }(100, 3e3), r3 = /* @__PURE__ */ new Set();
4003
4086
  return [t3.current(), (e4, o3) => {
4004
- let i2;
4087
+ let i3;
4005
4088
  const R3 = o3 instanceof Error ? o3.message : "";
4006
- if (R3 === c$3 || R3 === E$1) t3.exclude(), i2 = 0;
4089
+ if (R3 === c$3 || R3 === E$1) t3.exclude(), i3 = 0;
4007
4090
  else if (R3 === K) t3.exclude();
4008
4091
  else if (R3 === M) {
4009
4092
  const n4 = Date.now() - e4.getTime() < 50, o4 = t3.current();
4010
- o4 && n4 && !r3.has(o4) && (r3.add(o4), i2 = 0), t3.postpone();
4093
+ o4 && n4 && !r3.has(o4) && (r3.add(o4), i3 = 0), t3.postpone();
4011
4094
  } else t3.postpone();
4012
4095
  const s2 = t3.current();
4013
- return void 0 === s2 ? void 0 : [s2, null != i2 ? i2 : e4.getTime() + n3() - Date.now()];
4096
+ return void 0 === s2 ? void 0 : [s2, null != i3 ? i3 : e4.getTime() + n3() - Date.now()];
4014
4097
  }];
4015
4098
  }(e2);
4016
- let i;
4099
+ let i2;
4017
4100
  if (void 0 === r2) return Promise.reject(new TypeError("The list of script URL patterns is empty"));
4018
4101
  const R2 = (e3) => {
4019
4102
  const r3 = /* @__PURE__ */ new Date(), s2 = (t3) => n2.push({ url: e3, startedAt: r3, finishedAt: /* @__PURE__ */ new Date(), error: t3 }), a2 = t2(e3);
4020
4103
  return a2.then(() => s2(), s2), a2.catch((e4) => {
4021
- if (null != i || (i = e4), n2.length >= 5) throw i;
4104
+ if (null != i2 || (i2 = e4), n2.length >= 5) throw i2;
4022
4105
  const t3 = o2(r3, e4);
4023
- if (!t3) throw i;
4106
+ if (!t3) throw i2;
4024
4107
  const [s3, a3] = t3;
4025
4108
  return (c2 = a3, new Promise((e5) => setTimeout(e5, c2))).then(() => R2(s3));
4026
4109
  var c2;
@@ -4031,9 +4114,9 @@ function V(e2, t2) {
4031
4114
  const k = "https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js", G = k;
4032
4115
  function B(t2) {
4033
4116
  var n2, r2;
4034
- const { picked: o2, rest: i } = function(e2, t3) {
4117
+ const { picked: o2, rest: i2 } = function(e2, t3) {
4035
4118
  const n3 = {}, r3 = {};
4036
- for (const [o3, i2] of Object.entries(e2)) t3.includes(o3) ? n3[o3] = i2 : r3[o3] = i2;
4119
+ for (const [o3, i3] of Object.entries(e2)) t3.includes(o3) ? n3[o3] = i3 : r3[o3] = i3;
4037
4120
  return { picked: n3, rest: r3 };
4038
4121
  }(t2, ["scriptUrlPattern", "token", "apiKey"]), R2 = o2.token, s2 = null !== (n2 = o2.apiKey) && void 0 !== n2 ? n2 : R2, a2 = null !== (r2 = e(t2, "scriptUrlPattern")) && void 0 !== r2 ? r2 : k, [c2, E2] = function() {
4039
4122
  const e2 = [], t3 = () => {
@@ -4057,7 +4140,7 @@ function B(t2) {
4057
4140
  if (e3 instanceof Error && e3.message === K) return new Error(M);
4058
4141
  return e3;
4059
4142
  }(e2);
4060
- }).then(([e2, t3]) => (E2(), e2.load({ ...i, ldi: { attempts: t3, visibilityStates: c2 } })));
4143
+ }).then(([e2, t3]) => (E2(), e2.load({ ...i2, ldi: { attempts: t3, visibilityStates: c2 } })));
4061
4144
  }
4062
4145
  function F(e2) {
4063
4146
  return t$3(e2, () => function(e3) {
@@ -4073,12 +4156,12 @@ function F(e2) {
4073
4156
  const r2 = document.createElement("script"), o2 = () => {
4074
4157
  var e4;
4075
4158
  return null === (e4 = r2.parentNode) || void 0 === e4 ? void 0 : e4.removeChild(r2);
4076
- }, i = document.head || document.getElementsByTagName("head")[0];
4159
+ }, i2 = document.head || document.getElementsByTagName("head")[0];
4077
4160
  r2.onload = () => {
4078
4161
  o2(), t2();
4079
4162
  }, r2.onerror = () => {
4080
4163
  o2(), n2(new Error(M));
4081
- }, r2.async = true, r2.src = e3, i.appendChild(r2);
4164
+ }, r2.async = true, r2.src = e3, i2.appendChild(r2);
4082
4165
  });
4083
4166
  }(e2), () => {
4084
4167
  throw new Error(c$3);
@@ -4494,1897 +4577,1384 @@ class FpjsClient {
4494
4577
  });
4495
4578
  }
4496
4579
  }
4497
- const DEFAULT_CACHE_NAME = "default_fingerprint_cache";
4498
- const DEFAULT_CACHE_TIME_IN_DAYS = 7;
4499
- const PROXY_QUERY_PARAM = "apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>";
4500
- const getExpirationDate = (cacheTimeInDays) => {
4501
- const currentDate = /* @__PURE__ */ new Date();
4502
- const futureDate = new Date(
4503
- currentDate.getTime() + cacheTimeInDays * 24 * 60 * 60 * 1e3
4504
- );
4505
- return futureDate.getTime();
4506
- };
4507
- const getCachedFingerprint = () => {
4508
- const { cacheName = DEFAULT_CACHE_NAME } = window.fingerprintConfig;
4509
- try {
4510
- const cachedData = JSON.parse(localStorage.getItem(cacheName) || "null");
4511
- if (cachedData && cachedData.expiresAt > Date.now()) {
4512
- return cachedData.fingerprint;
4513
- }
4514
- localStorage.removeItem(cacheName);
4515
- return null;
4516
- } catch {
4517
- return null;
4580
+ var NodeType;
4581
+ (function(NodeType2) {
4582
+ NodeType2[NodeType2["Document"] = 0] = "Document";
4583
+ NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
4584
+ NodeType2[NodeType2["Element"] = 2] = "Element";
4585
+ NodeType2[NodeType2["Text"] = 3] = "Text";
4586
+ NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
4587
+ NodeType2[NodeType2["Comment"] = 5] = "Comment";
4588
+ })(NodeType || (NodeType = {}));
4589
+ function isElement(n2) {
4590
+ return n2.nodeType === n2.ELEMENT_NODE;
4591
+ }
4592
+ function isShadowRoot(n2) {
4593
+ const host = n2 === null || n2 === void 0 ? void 0 : n2.host;
4594
+ return Boolean((host === null || host === void 0 ? void 0 : host.shadowRoot) === n2);
4595
+ }
4596
+ function isNativeShadowDom(shadowRoot) {
4597
+ return Object.prototype.toString.call(shadowRoot) === "[object ShadowRoot]";
4598
+ }
4599
+ function fixBrowserCompatibilityIssuesInCSS(cssText) {
4600
+ if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
4601
+ cssText = cssText.replace(" background-clip: text;", " -webkit-background-clip: text; background-clip: text;");
4518
4602
  }
4519
- };
4520
- const setCachedFingerprint = (fingerprint) => {
4521
- const {
4522
- cacheName = DEFAULT_CACHE_NAME,
4523
- cacheTimeInDays = DEFAULT_CACHE_TIME_IN_DAYS
4524
- } = window.fingerprintConfig;
4525
- const cacheData = {
4526
- fingerprint,
4527
- expiresAt: getExpirationDate(cacheTimeInDays)
4528
- };
4529
- localStorage.setItem(cacheName, JSON.stringify(cacheData));
4530
- };
4531
- function buildProxyUrl(url) {
4532
- return `${url}?${PROXY_QUERY_PARAM}`;
4603
+ return cssText;
4533
4604
  }
4534
- async function initFingerprint(apiKey, proxyUrl) {
4535
- const customEndpointArray = [r$2];
4536
- const customScriptEndpointArray = [G];
4537
- if (proxyUrl) {
4538
- customEndpointArray.unshift(proxyUrl);
4539
- customScriptEndpointArray.unshift(buildProxyUrl(proxyUrl));
4605
+ function escapeImportStatement(rule) {
4606
+ const { cssText } = rule;
4607
+ if (cssText.split('"').length < 3)
4608
+ return cssText;
4609
+ const statement = ["@import", `url(${JSON.stringify(rule.href)})`];
4610
+ if (rule.layerName === "") {
4611
+ statement.push(`layer`);
4612
+ } else if (rule.layerName) {
4613
+ statement.push(`layer(${rule.layerName})`);
4540
4614
  }
4541
- window.fingerprintConfig = {};
4542
- window.fpClient = new FpjsClient({
4543
- loadOptions: {
4544
- apiKey,
4545
- endpoint: customEndpointArray,
4546
- scriptUrlPattern: customScriptEndpointArray
4547
- }
4548
- });
4615
+ if (rule.supportsText) {
4616
+ statement.push(`supports(${rule.supportsText})`);
4617
+ }
4618
+ if (rule.media.length) {
4619
+ statement.push(rule.media.mediaText);
4620
+ }
4621
+ return statement.join(" ") + ";";
4622
+ }
4623
+ function stringifyStylesheet(s2) {
4549
4624
  try {
4550
- await window.fpClient.init();
4625
+ const rules = s2.rules || s2.cssRules;
4626
+ return rules ? fixBrowserCompatibilityIssuesInCSS(Array.from(rules, stringifyRule).join("")) : null;
4551
4627
  } catch (error) {
4552
- console.error("Error initializing identification service:", error);
4553
- throw error;
4628
+ return null;
4554
4629
  }
4555
4630
  }
4556
- async function getFingerprint(cacheOnly = false) {
4557
- if (!window.fingerprintConfig) {
4558
- if (cacheOnly) {
4559
- return "";
4631
+ function stringifyRule(rule) {
4632
+ let importStringified;
4633
+ if (isCSSImportRule(rule)) {
4634
+ try {
4635
+ importStringified = stringifyStylesheet(rule.styleSheet) || escapeImportStatement(rule);
4636
+ } catch (error) {
4560
4637
  }
4561
- throw new Error("Fingerprint configuration is not initialized.");
4562
- }
4563
- const cachedFingerprint = getCachedFingerprint();
4564
- if (cachedFingerprint) {
4565
- return cachedFingerprint;
4638
+ } else if (isCSSStyleRule(rule) && rule.selectorText.includes(":")) {
4639
+ return fixSafariColons(rule.cssText);
4566
4640
  }
4567
- if (cacheOnly) {
4568
- return "";
4641
+ return importStringified || rule.cssText;
4642
+ }
4643
+ function fixSafariColons(cssStringified) {
4644
+ const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
4645
+ return cssStringified.replace(regex, "$1\\$2");
4646
+ }
4647
+ function isCSSImportRule(rule) {
4648
+ return "styleSheet" in rule;
4649
+ }
4650
+ function isCSSStyleRule(rule) {
4651
+ return "selectorText" in rule;
4652
+ }
4653
+ class Mirror {
4654
+ constructor() {
4655
+ this.idNodeMap = /* @__PURE__ */ new Map();
4656
+ this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
4569
4657
  }
4570
- if (!isFingerprintReady()) {
4571
- throw new Error("Identification service is not initialized.");
4658
+ getId(n2) {
4659
+ var _a;
4660
+ if (!n2)
4661
+ return -1;
4662
+ const id = (_a = this.getMeta(n2)) === null || _a === void 0 ? void 0 : _a.id;
4663
+ return id !== null && id !== void 0 ? id : -1;
4572
4664
  }
4573
- try {
4574
- const fpClient = window.fpClient;
4575
- const { visitorId: fingerprint } = await fpClient.getVisitorData();
4576
- setCachedFingerprint(fingerprint);
4577
- return fingerprint;
4578
- } catch (error) {
4579
- console.error("Error retrieving fingerprint:", error);
4580
- throw error;
4665
+ getNode(id) {
4666
+ return this.idNodeMap.get(id) || null;
4581
4667
  }
4582
- }
4583
- function isFingerprintReady() {
4584
- return window.fpClient !== void 0;
4585
- }
4586
- const fingerprintService = {
4587
- initFingerprint,
4588
- getFingerprint,
4589
- isFingerprintReady,
4590
- getCachedFingerprint
4591
- };
4592
- const r$1 = {
4593
- sandbox: {
4594
- search: "https://search.resertravel.com/api",
4595
- purchase: "https://purchases.resertravel.com/api",
4596
- core: ""
4597
- },
4598
- production: {
4599
- search: "https://search.reservamos.mx/api",
4600
- purchase: "https://compras.reservamos.mx/api",
4601
- core: ""
4668
+ getIds() {
4669
+ return Array.from(this.idNodeMap.keys());
4602
4670
  }
4603
- }, s$2 = "sandbox", a$1 = "v2", t$2 = "v1", n$1 = {
4604
- env: s$2,
4605
- headers: {},
4606
- searchUrl: r$1[s$2].search,
4607
- purchaseUrl: r$1[s$2].purchase,
4608
- coreUrl: r$1[s$2].core,
4609
- version: a$1,
4610
- coreVersion: t$2,
4611
- apiKey: void 0,
4612
- userAuthToken: void 0,
4613
- withCredentials: false
4614
- };
4615
- let c$2 = Object.assign({}, n$1);
4616
- const o$1 = {
4617
- // UNAUTHORIZED
4618
- 1: {
4619
- code: 200,
4620
- message: "Operación no autorizada"
4671
+ getMeta(n2) {
4672
+ return this.nodeMetaMap.get(n2) || null;
4621
4673
  }
4622
- }, s$1 = {
4623
- // INCORRECT_PARAMS
4624
- 3: {
4625
- code: 300,
4626
- message: "Parámetros incorrectos"
4627
- },
4628
- // INCORRECT_DATE
4629
- 7: {
4630
- code: 301,
4631
- message: "Fecha inválida"
4674
+ removeNodeFromMap(n2) {
4675
+ const id = this.getId(n2);
4676
+ this.idNodeMap.delete(id);
4677
+ if (n2.childNodes) {
4678
+ n2.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));
4679
+ }
4632
4680
  }
4633
- }, r = {
4634
- // NONEXISTENT_TRIP
4635
- 10: {
4636
- code: 400,
4637
- message: "No existe el viaje"
4638
- },
4639
- // journey_key_not_found
4640
- 20: {
4641
- code: 60,
4642
- message: "No se encontró el viaje"
4643
- },
4644
- // sold_out_fare_code
4645
- 21: {
4646
- code: 60,
4647
- message: "Tarifa no disponible"
4648
- },
4649
- // unavailable_fare_code
4650
- 22: {
4651
- code: 60,
4652
- message: "Tarifa no disponible"
4653
- }
4654
- }, n = (e2) => ({
4655
- // INVALID_DISCOUNT
4656
- 11: {
4657
- code: 500,
4658
- message: e2
4659
- },
4660
- //EXPIRED_DISCOUNT
4661
- 12: {
4662
- code: 501,
4663
- message: e2
4681
+ has(id) {
4682
+ return this.idNodeMap.has(id);
4664
4683
  }
4665
- }), a = {
4666
- // unavailable_student
4667
- 23: {
4668
- code: 60,
4669
- message: "Estudiante no disponible"
4670
- },
4671
- // unavailable_teacher
4672
- 24: {
4673
- code: 60,
4674
- message: "Profesor no disponible"
4675
- },
4676
- // unavailable_minor
4677
- 25: {
4678
- code: 60,
4679
- message: "Menor no disponible"
4680
- },
4681
- // unavailable_special
4682
- 26: {
4683
- code: 60,
4684
- message: "Capacidades diferentes no disponible"
4685
- },
4686
- // unavailable_older
4687
- 27: {
4688
- code: 60,
4689
- message: "INSEN no disponible"
4690
- },
4691
- // unavailable_general
4692
- 28: {
4693
- code: 60,
4694
- message: "General no disponible"
4695
- },
4696
- // unavailable_unknown
4697
- 29: {
4698
- code: 60,
4699
- message: "Error desconocido"
4684
+ hasNode(node) {
4685
+ return this.nodeMetaMap.has(node);
4700
4686
  }
4701
- }, c$1 = (e2) => ({
4702
- 30: {
4703
- code: 30,
4704
- message: e2
4687
+ add(n2, meta) {
4688
+ const id = meta.id;
4689
+ this.idNodeMap.set(id, n2);
4690
+ this.nodeMetaMap.set(n2, meta);
4705
4691
  }
4706
- }), d$1 = {
4707
- 50: {
4708
- code: 50,
4709
- message: "Unknow Error"
4692
+ replace(id, n2) {
4693
+ const oldNode = this.getNode(id);
4694
+ if (oldNode) {
4695
+ const meta = this.nodeMetaMap.get(oldNode);
4696
+ if (meta)
4697
+ this.nodeMetaMap.set(n2, meta);
4698
+ }
4699
+ this.idNodeMap.set(id, n2);
4710
4700
  }
4711
- }, i$2 = (e2) => ({
4712
- ...o$1,
4713
- ...s$1,
4714
- ...r,
4715
- ...n(e2),
4716
- ...a,
4717
- ...d$1,
4718
- ...c$1(e2)
4719
- });
4720
- class o extends Error {
4721
- constructor(r2 = -100, s2 = "Unknown error", t2 = null) {
4722
- super(s2), this.code = r2, this.details = t2, this.stack = new Error().stack;
4701
+ reset() {
4702
+ this.idNodeMap = /* @__PURE__ */ new Map();
4703
+ this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
4723
4704
  }
4724
4705
  }
4725
- async function w(t2) {
4726
- const e2 = [404, 422, 500], r2 = await t2.json();
4727
- if (t2.ok)
4728
- return r2;
4729
- if (e2.includes(t2.status))
4730
- switch (t2.status) {
4731
- case 404:
4732
- throw new o(100, "Not found");
4733
- case 422:
4734
- return r2;
4735
- case 500:
4736
- throw new o(101, "Server error");
4737
- default:
4738
- throw new o();
4739
- }
4740
- else
4741
- throw new o(t2.status, r2.message || t2.statusText, r2);
4706
+ function createMirror() {
4707
+ return new Mirror();
4742
4708
  }
4743
- function l$1(t2) {
4744
- if (t2.errors instanceof Array) {
4745
- const { code: e2 = -100, message: r2 = "Unknown error" } = t2.errors[0] || {}, n2 = i$2(r2)[e2];
4746
- throw n2 ? new o(n2.code, n2.message, t2.errors[0]) : new o(e2, r2, t2.errors[0]);
4747
- } else
4748
- return t2;
4709
+ function maskInputValue({ element, maskInputOptions, tagName, type, value, maskInputFn }) {
4710
+ let text = value || "";
4711
+ const actualType = type && toLowerCase(type);
4712
+ if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
4713
+ if (maskInputFn) {
4714
+ text = maskInputFn(text, element);
4715
+ } else {
4716
+ text = "*".repeat(text.length);
4717
+ }
4718
+ }
4719
+ return text;
4749
4720
  }
4750
- function y(...t2) {
4751
- const r2 = Object.keys(Object.assign({}, ...t2)).reduce(
4752
- (n2, o2) => ({
4753
- ...n2,
4754
- [o2]: t2.map((a2) => o2 in a2 && a2[o2]).filter(Boolean)
4755
- }),
4756
- {}
4757
- );
4758
- return new Headers(r2);
4721
+ function toLowerCase(str) {
4722
+ return str.toLowerCase();
4759
4723
  }
4760
- function c(t2, e2 = {}, r2 = {}, n2) {
4761
- const {
4762
- apiKey: o2,
4763
- withCredentials: a2,
4764
- userAuthToken: s2,
4765
- headers: d2
4766
- } = c$2, u3 = {
4767
- Accept: "application/json",
4768
- Authorization: `Token token=${r2.apiKey || o2}`,
4769
- "Content-Type": "application/json"
4770
- };
4771
- return s2 && (u3.Authorization = `Token ${r2.apiKey || o2}, Bearer ${s2}`), e2.headers = y(d2, u3), e2.credentials = a2 ? "include" : "omit", typeof e2.body != "string" && (e2.body = JSON.stringify(e2.body)), fetch(t2, e2).then(w).then(l$1).catch(n2);
4724
+ const ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
4725
+ function is2DCanvasBlank(canvas) {
4726
+ const ctx = canvas.getContext("2d");
4727
+ if (!ctx)
4728
+ return true;
4729
+ const chunkSize = 50;
4730
+ for (let x2 = 0; x2 < canvas.width; x2 += chunkSize) {
4731
+ for (let y2 = 0; y2 < canvas.height; y2 += chunkSize) {
4732
+ const getImageData = ctx.getImageData;
4733
+ const originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
4734
+ const pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x2, y2, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y2)).data.buffer);
4735
+ if (pixelBuffer.some((pixel) => pixel !== 0))
4736
+ return false;
4737
+ }
4738
+ }
4739
+ return true;
4772
4740
  }
4773
- function E(t2, e2 = {}, r2) {
4774
- return c(t2, e2, {}, r2);
4741
+ function getInputType(element) {
4742
+ const type = element.type;
4743
+ return element.hasAttribute("data-rr-is-password") ? "password" : type ? toLowerCase(type) : null;
4775
4744
  }
4776
- let u$1 = class u {
4777
- constructor({
4778
- url: e2,
4779
- watch: i,
4780
- expect: h2,
4781
- maxRetries: t2 = 30,
4782
- interval: s2 = 2e3,
4783
- eachCall: c2 = null
4784
- }) {
4785
- this.url = e2, this.watch = i, this.expect = h2 instanceof Array ? h2 : [h2], this.interval = s2, this.maxRetries = t2, this.eachCall = c2 && c2.bind(this), this.aborted = false, this.timers = [], this.execute = this.execute.bind(this), this.executeEachCall = this.executeEachCall.bind(this);
4786
- }
4787
- start() {
4788
- return this.execute(this.maxRetries);
4789
- }
4790
- abort() {
4791
- this.aborted = true;
4745
+ function extractFileExtension(path, baseURL) {
4746
+ var _a;
4747
+ let url;
4748
+ try {
4749
+ url = new URL(path, baseURL !== null && baseURL !== void 0 ? baseURL : window.location.href);
4750
+ } catch (err) {
4751
+ return null;
4792
4752
  }
4793
- execute(e2) {
4794
- const i = (t2) => {
4795
- if (this.expect.includes(t2[this.watch]) || e2 === 1 || this.aborted) {
4796
- let s2 = t2[this.watch];
4797
- e2 === 1 ? s2 = "retries_exceeded" : this.aborted && (s2 = "aborted"), this.timers.forEach(clearInterval), this.executeEachCall(s2, t2);
4798
- } else if (t2[this.watch] === "failed")
4799
- this.timers.forEach(clearInterval), this.executeEachCall("failed", t2);
4800
- else {
4801
- this.executeEachCall("pending", t2);
4802
- const s2 = window.setTimeout(
4803
- this.execute,
4804
- this.interval,
4805
- e2 - 1
4806
- );
4807
- this.timers.push(s2);
4808
- }
4809
- }, h2 = (t2) => this.executeEachCall("error", t2);
4810
- return E(this.url, {}, h2).then(i);
4753
+ const regex = /\.([0-9a-z]+)(?:$)/i;
4754
+ const match = url.pathname.match(regex);
4755
+ return (_a = match === null || match === void 0 ? void 0 : match[1]) !== null && _a !== void 0 ? _a : null;
4756
+ }
4757
+ let _id = 1;
4758
+ const tagNameRegex = new RegExp("[^a-z0-9-_:]");
4759
+ const IGNORED_NODE = -2;
4760
+ function genId() {
4761
+ return _id++;
4762
+ }
4763
+ function getValidTagName(element) {
4764
+ if (element instanceof HTMLFormElement) {
4765
+ return "form";
4811
4766
  }
4812
- executeEachCall(e2, i) {
4813
- this.eachCall instanceof Function && this.eachCall({ status: e2, payload: i }) && this.abort();
4767
+ const processedTagName = toLowerCase(element.tagName);
4768
+ if (tagNameRegex.test(processedTagName)) {
4769
+ return "div";
4814
4770
  }
4815
- };
4816
- function j({
4817
- apiName: h2,
4818
- defaultApiVersion: c2
4819
- }) {
4820
- let n2, i = {
4821
- "Content-Type": "application/json"
4822
- }, r2;
4823
- function f2(e2) {
4824
- n2 = e2.baseUrl, i = {
4825
- ...i,
4826
- ...e2.defaultHeaders || {}
4827
- };
4771
+ return processedTagName;
4772
+ }
4773
+ function extractOrigin(url) {
4774
+ let origin2 = "";
4775
+ if (url.indexOf("//") > -1) {
4776
+ origin2 = url.split("/").slice(0, 3).join("/");
4777
+ } else {
4778
+ origin2 = url.split("/")[0];
4828
4779
  }
4829
- function p2(e2) {
4830
- r2 = e2;
4831
- }
4832
- function d2() {
4833
- if (!n2)
4834
- throw new Error(`Base URL is not set for ${h2} API.`);
4835
- }
4836
- const $ = { body: {} };
4837
- async function y2(e2, t2 = $) {
4838
- d2();
4839
- const { body: s2, headers: o2 = {}, apiVersion: a2 = c2 } = t2, u3 = `${n2}/${a2}/${e2}`, l2 = {
4840
- ...i,
4841
- ...o2,
4842
- ...r2 ? { Authorization: r2 } : {}
4843
- };
4844
- return (await fetch(u3, {
4845
- method: "POST",
4846
- body: JSON.stringify(s2),
4847
- headers: l2
4848
- })).json();
4780
+ origin2 = origin2.split("?")[0];
4781
+ return origin2;
4782
+ }
4783
+ let canvasService;
4784
+ let canvasCtx;
4785
+ const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
4786
+ const URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
4787
+ const URL_WWW_MATCH = /^www\..*/i;
4788
+ const DATA_URI = /^(data:)([^,]*),(.*)/i;
4789
+ function absoluteToStylesheet(cssText, href) {
4790
+ return (cssText || "").replace(URL_IN_CSS_REF, (origin2, quote1, path1, quote2, path2, path3) => {
4791
+ const filePath = path1 || path2 || path3;
4792
+ const maybeQuote = quote1 || quote2 || "";
4793
+ if (!filePath) {
4794
+ return origin2;
4795
+ }
4796
+ if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
4797
+ return `url(${maybeQuote}${filePath}${maybeQuote})`;
4798
+ }
4799
+ if (DATA_URI.test(filePath)) {
4800
+ return `url(${maybeQuote}${filePath}${maybeQuote})`;
4801
+ }
4802
+ if (filePath[0] === "/") {
4803
+ return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
4804
+ }
4805
+ const stack = href.split("/");
4806
+ const parts = filePath.split("/");
4807
+ stack.pop();
4808
+ for (const part of parts) {
4809
+ if (part === ".") {
4810
+ continue;
4811
+ } else if (part === "..") {
4812
+ stack.pop();
4813
+ } else {
4814
+ stack.push(part);
4815
+ }
4816
+ }
4817
+ return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
4818
+ });
4819
+ }
4820
+ const SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
4821
+ const SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
4822
+ function getAbsoluteSrcsetString(doc, attributeValue) {
4823
+ if (attributeValue.trim() === "") {
4824
+ return attributeValue;
4849
4825
  }
4850
- async function w2(e2, t2 = {}) {
4851
- d2();
4852
- const { headers: s2 = {}, apiVersion: o2 = c2 } = t2, a2 = `${n2}/${o2}/${e2}`;
4853
- return (await fetch(a2, { headers: s2 })).json();
4826
+ let pos = 0;
4827
+ function collectCharacters(regEx) {
4828
+ let chars2;
4829
+ const match = regEx.exec(attributeValue.substring(pos));
4830
+ if (match) {
4831
+ chars2 = match[0];
4832
+ pos += chars2.length;
4833
+ return chars2;
4834
+ }
4835
+ return "";
4854
4836
  }
4855
- function H2(e2, t2) {
4856
- const o2 = {
4857
- url: `${n2}/${c2}/${e2}`,
4858
- watch: t2.watch,
4859
- expect: t2.expect,
4860
- eachCall: t2.onEachResponse
4861
- };
4862
- return new u$1(o2);
4837
+ const output = [];
4838
+ while (true) {
4839
+ collectCharacters(SRCSET_COMMAS_OR_SPACES);
4840
+ if (pos >= attributeValue.length) {
4841
+ break;
4842
+ }
4843
+ let url = collectCharacters(SRCSET_NOT_SPACES);
4844
+ if (url.slice(-1) === ",") {
4845
+ url = absoluteToDoc(doc, url.substring(0, url.length - 1));
4846
+ output.push(url);
4847
+ } else {
4848
+ let descriptorsStr = "";
4849
+ url = absoluteToDoc(doc, url);
4850
+ let inParens = false;
4851
+ while (true) {
4852
+ const c2 = attributeValue.charAt(pos);
4853
+ if (c2 === "") {
4854
+ output.push((url + descriptorsStr).trim());
4855
+ break;
4856
+ } else if (!inParens) {
4857
+ if (c2 === ",") {
4858
+ pos += 1;
4859
+ output.push((url + descriptorsStr).trim());
4860
+ break;
4861
+ } else if (c2 === "(") {
4862
+ inParens = true;
4863
+ }
4864
+ } else {
4865
+ if (c2 === ")") {
4866
+ inParens = false;
4867
+ }
4868
+ }
4869
+ descriptorsStr += c2;
4870
+ pos += 1;
4871
+ }
4872
+ }
4863
4873
  }
4864
- async function b2(e2, t2 = {}) {
4865
- d2();
4866
- const { headers: s2 = {}, apiVersion: o2 = c2 } = t2, a2 = `${n2}/${o2}/${e2}`, u3 = {
4867
- ...i,
4868
- ...s2,
4869
- ...r2 ? { Authorization: r2 } : {}
4870
- };
4871
- return (await fetch(a2, {
4872
- method: "DELETE",
4873
- headers: u3
4874
- })).json();
4874
+ return output.join(", ");
4875
+ }
4876
+ function absoluteToDoc(doc, attributeValue) {
4877
+ if (!attributeValue || attributeValue.trim() === "") {
4878
+ return attributeValue;
4875
4879
  }
4876
- return {
4877
- get: w2,
4878
- post: y2,
4879
- delete: b2,
4880
- setAuthorizationHeader: p2,
4881
- setConfig: f2,
4882
- poll: H2
4883
- };
4880
+ const a2 = doc.createElement("a");
4881
+ a2.href = attributeValue;
4882
+ return a2.href;
4884
4883
  }
4885
- const t$1 = j({
4886
- apiName: "Core",
4887
- defaultApiVersion: "v1"
4888
- });
4889
- async function t(o2) {
4890
- const { data: e2 } = await t$1.post(
4891
- "anonymous_profiles/identify",
4892
- {
4893
- body: o2
4894
- }
4895
- );
4896
- return e2;
4884
+ function isSVGElement(el) {
4885
+ return Boolean(el.tagName === "svg" || el.ownerSVGElement);
4897
4886
  }
4898
- const s = {
4899
- createAnonymousProfile: t
4900
- };
4901
- function d({
4902
- searchId: e2,
4903
- userIdentifier: t2
4904
- }) {
4905
- return t$1.get(
4906
- `trip_recommendations/${e2}/${t2}`
4907
- );
4887
+ function getHref() {
4888
+ const a2 = document.createElement("a");
4889
+ a2.href = "";
4890
+ return a2.href;
4908
4891
  }
4909
- function i$1(e2) {
4910
- return t$1.post("seat_recommendations", {
4911
- body: e2
4912
- });
4892
+ function transformAttribute(doc, tagName, name, value) {
4893
+ if (!value) {
4894
+ return value;
4895
+ }
4896
+ if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
4897
+ return absoluteToDoc(doc, value);
4898
+ } else if (name === "xlink:href" && value[0] !== "#") {
4899
+ return absoluteToDoc(doc, value);
4900
+ } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
4901
+ return absoluteToDoc(doc, value);
4902
+ } else if (name === "srcset") {
4903
+ return getAbsoluteSrcsetString(doc, value);
4904
+ } else if (name === "style") {
4905
+ return absoluteToStylesheet(value, getHref());
4906
+ } else if (tagName === "object" && name === "data") {
4907
+ return absoluteToDoc(doc, value);
4908
+ }
4909
+ return value;
4913
4910
  }
4914
- function p({
4915
- distinct_id: e2,
4916
- ...t2
4917
- }) {
4918
- return t$1.post(`seat_recommendations/${e2}`, {
4919
- body: t2
4920
- });
4911
+ function ignoreAttribute(tagName, name, _value) {
4912
+ return (tagName === "video" || tagName === "audio") && name === "autoplay";
4921
4913
  }
4922
- function u2(e2, t2) {
4923
- const { start: o2, onEachResponse: r2 } = t2, c2 = `profiles/${e2}`, a2 = {
4924
- watch: "state",
4925
- expect: "finished",
4926
- onEachResponse: r2
4927
- }, s2 = t$1.poll(c2, a2);
4928
- return o2 && s2.start(), s2;
4914
+ function _isBlockedElement(element, blockClass, blockSelector) {
4915
+ try {
4916
+ if (typeof blockClass === "string") {
4917
+ if (element.classList.contains(blockClass)) {
4918
+ return true;
4919
+ }
4920
+ } else {
4921
+ for (let eIndex = element.classList.length; eIndex--; ) {
4922
+ const className = element.classList[eIndex];
4923
+ if (blockClass.test(className)) {
4924
+ return true;
4925
+ }
4926
+ }
4927
+ }
4928
+ if (blockSelector) {
4929
+ return element.matches(blockSelector);
4930
+ }
4931
+ } catch (e2) {
4932
+ }
4933
+ return false;
4929
4934
  }
4930
- async function m(e2) {
4931
- return t$1.post("profiles", {
4932
- body: e2
4933
- });
4935
+ function classMatchesRegex(node, regex, checkAncestors) {
4936
+ if (!node)
4937
+ return false;
4938
+ if (node.nodeType !== node.ELEMENT_NODE) {
4939
+ if (!checkAncestors)
4940
+ return false;
4941
+ return classMatchesRegex(node.parentNode, regex, checkAncestors);
4942
+ }
4943
+ for (let eIndex = node.classList.length; eIndex--; ) {
4944
+ const className = node.classList[eIndex];
4945
+ if (regex.test(className)) {
4946
+ return true;
4947
+ }
4948
+ }
4949
+ if (!checkAncestors)
4950
+ return false;
4951
+ return classMatchesRegex(node.parentNode, regex, checkAncestors);
4934
4952
  }
4935
- async function l(e2) {
4936
- return t$1.post("passengers", {
4937
- body: e2
4938
- });
4939
- }
4940
- async function f$1(e2) {
4941
- return t$1.get(
4942
- `passengers/${e2}`
4943
- );
4944
- }
4945
- async function g(e2, t2) {
4946
- return t$1.delete(
4947
- `passengers/${e2}/${t2}`
4948
- );
4949
- }
4950
- const R = {
4951
- getRecommendedTrips: d,
4952
- createRecommendedPlaces: m,
4953
- pollRecommendedPlaces: u2,
4954
- createRecommendedSeats: i$1,
4955
- getRecommendedSeats: p,
4956
- getFrequentPassengers: f$1,
4957
- createFrequentPassengers: l,
4958
- deleteFrequentPassenger: g
4959
- };
4960
- const f = {
4961
- setConfig: t$1.setConfig,
4962
- recommendations: R,
4963
- profiles: s
4964
- };
4965
- let environment;
4966
- let appName;
4967
- const origin = window.location.origin;
4968
- const coreAPIConfig = {
4969
- sandbox: {
4970
- baseUrl: "https://datalake-api-dev.reservamossaas.com/api",
4971
- defaultHeaders: {
4972
- Origin: origin,
4973
- Authorization: "Bearer 753bf0710dc920a84236d42241d4f487"
4953
+ function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) {
4954
+ try {
4955
+ const el = node.nodeType === node.ELEMENT_NODE ? node : node.parentElement;
4956
+ if (el === null)
4957
+ return false;
4958
+ if (typeof maskTextClass === "string") {
4959
+ if (checkAncestors) {
4960
+ if (el.closest(`.${maskTextClass}`))
4961
+ return true;
4962
+ } else {
4963
+ if (el.classList.contains(maskTextClass))
4964
+ return true;
4965
+ }
4966
+ } else {
4967
+ if (classMatchesRegex(el, maskTextClass, checkAncestors))
4968
+ return true;
4974
4969
  }
4975
- },
4976
- prod: {
4977
- baseUrl: "https://data-lake.reservamossaas.com/api",
4978
- defaultHeaders: {
4979
- Origin: origin,
4980
- Authorization: "Bearer 753bf0710dc920a84236d42241d4f487"
4970
+ if (maskTextSelector) {
4971
+ if (checkAncestors) {
4972
+ if (el.closest(maskTextSelector))
4973
+ return true;
4974
+ } else {
4975
+ if (el.matches(maskTextSelector))
4976
+ return true;
4977
+ }
4981
4978
  }
4979
+ } catch (e2) {
4982
4980
  }
4983
- };
4984
- function setEnvironment(env) {
4985
- environment = env;
4986
- }
4987
- function setAppName(name) {
4988
- appName = name;
4989
- }
4990
- function getCoreAPIConfig() {
4991
- if (!environment) {
4992
- throw new Error(
4993
- "Unable to get core API config, environment not set. Use configService.setEnvironment(environment) to set the environment."
4994
- );
4995
- }
4996
- const config = coreAPIConfig[environment];
4997
- return {
4998
- ...config,
4999
- defaultHeaders: {
5000
- ...config.defaultHeaders,
5001
- ...appName ? { "x-app-name": appName } : {}
5002
- }
5003
- };
5004
- }
5005
- const configService = {
5006
- setEnvironment,
5007
- setAppName,
5008
- getCoreAPIConfig
5009
- };
5010
- var NodeType;
5011
- (function(NodeType2) {
5012
- NodeType2[NodeType2["Document"] = 0] = "Document";
5013
- NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
5014
- NodeType2[NodeType2["Element"] = 2] = "Element";
5015
- NodeType2[NodeType2["Text"] = 3] = "Text";
5016
- NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
5017
- NodeType2[NodeType2["Comment"] = 5] = "Comment";
5018
- })(NodeType || (NodeType = {}));
5019
- function isElement(n2) {
5020
- return n2.nodeType === n2.ELEMENT_NODE;
5021
- }
5022
- function isShadowRoot(n2) {
5023
- const host = n2 === null || n2 === void 0 ? void 0 : n2.host;
5024
- return Boolean((host === null || host === void 0 ? void 0 : host.shadowRoot) === n2);
5025
- }
5026
- function isNativeShadowDom(shadowRoot) {
5027
- return Object.prototype.toString.call(shadowRoot) === "[object ShadowRoot]";
4981
+ return false;
5028
4982
  }
5029
- function fixBrowserCompatibilityIssuesInCSS(cssText) {
5030
- if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
5031
- cssText = cssText.replace(" background-clip: text;", " -webkit-background-clip: text; background-clip: text;");
4983
+ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
4984
+ const win2 = iframeEl.contentWindow;
4985
+ if (!win2) {
4986
+ return;
5032
4987
  }
5033
- return cssText;
5034
- }
5035
- function escapeImportStatement(rule) {
5036
- const { cssText } = rule;
5037
- if (cssText.split('"').length < 3)
5038
- return cssText;
5039
- const statement = ["@import", `url(${JSON.stringify(rule.href)})`];
5040
- if (rule.layerName === "") {
5041
- statement.push(`layer`);
5042
- } else if (rule.layerName) {
5043
- statement.push(`layer(${rule.layerName})`);
4988
+ let fired = false;
4989
+ let readyState;
4990
+ try {
4991
+ readyState = win2.document.readyState;
4992
+ } catch (error) {
4993
+ return;
5044
4994
  }
5045
- if (rule.supportsText) {
5046
- statement.push(`supports(${rule.supportsText})`);
4995
+ if (readyState !== "complete") {
4996
+ const timer = setTimeout(() => {
4997
+ if (!fired) {
4998
+ listener();
4999
+ fired = true;
5000
+ }
5001
+ }, iframeLoadTimeout);
5002
+ iframeEl.addEventListener("load", () => {
5003
+ clearTimeout(timer);
5004
+ fired = true;
5005
+ listener();
5006
+ });
5007
+ return;
5047
5008
  }
5048
- if (rule.media.length) {
5049
- statement.push(rule.media.mediaText);
5009
+ const blankUrl = "about:blank";
5010
+ if (win2.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
5011
+ setTimeout(listener, 0);
5012
+ return iframeEl.addEventListener("load", listener);
5050
5013
  }
5051
- return statement.join(" ") + ";";
5014
+ iframeEl.addEventListener("load", listener);
5052
5015
  }
5053
- function stringifyStylesheet(s2) {
5016
+ function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
5017
+ let fired = false;
5018
+ let styleSheetLoaded;
5054
5019
  try {
5055
- const rules = s2.rules || s2.cssRules;
5056
- return rules ? fixBrowserCompatibilityIssuesInCSS(Array.from(rules, stringifyRule).join("")) : null;
5020
+ styleSheetLoaded = link.sheet;
5057
5021
  } catch (error) {
5058
- return null;
5022
+ return;
5059
5023
  }
5060
- }
5061
- function stringifyRule(rule) {
5062
- let importStringified;
5063
- if (isCSSImportRule(rule)) {
5064
- try {
5065
- importStringified = stringifyStylesheet(rule.styleSheet) || escapeImportStatement(rule);
5066
- } catch (error) {
5024
+ if (styleSheetLoaded)
5025
+ return;
5026
+ const timer = setTimeout(() => {
5027
+ if (!fired) {
5028
+ listener();
5029
+ fired = true;
5067
5030
  }
5068
- } else if (isCSSStyleRule(rule) && rule.selectorText.includes(":")) {
5069
- return fixSafariColons(rule.cssText);
5070
- }
5071
- return importStringified || rule.cssText;
5031
+ }, styleSheetLoadTimeout);
5032
+ link.addEventListener("load", () => {
5033
+ clearTimeout(timer);
5034
+ fired = true;
5035
+ listener();
5036
+ });
5072
5037
  }
5073
- function fixSafariColons(cssStringified) {
5074
- const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
5075
- return cssStringified.replace(regex, "$1\\$2");
5038
+ function serializeNode(n2, options) {
5039
+ const { doc, mirror: mirror2, blockClass, blockSelector, needsMask, inlineStylesheet, maskInputOptions = {}, maskTextFn, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, newlyAddedElement = false } = options;
5040
+ const rootId = getRootId(doc, mirror2);
5041
+ switch (n2.nodeType) {
5042
+ case n2.DOCUMENT_NODE:
5043
+ if (n2.compatMode !== "CSS1Compat") {
5044
+ return {
5045
+ type: NodeType.Document,
5046
+ childNodes: [],
5047
+ compatMode: n2.compatMode
5048
+ };
5049
+ } else {
5050
+ return {
5051
+ type: NodeType.Document,
5052
+ childNodes: []
5053
+ };
5054
+ }
5055
+ case n2.DOCUMENT_TYPE_NODE:
5056
+ return {
5057
+ type: NodeType.DocumentType,
5058
+ name: n2.name,
5059
+ publicId: n2.publicId,
5060
+ systemId: n2.systemId,
5061
+ rootId
5062
+ };
5063
+ case n2.ELEMENT_NODE:
5064
+ return serializeElementNode(n2, {
5065
+ doc,
5066
+ blockClass,
5067
+ blockSelector,
5068
+ inlineStylesheet,
5069
+ maskInputOptions,
5070
+ maskInputFn,
5071
+ dataURLOptions,
5072
+ inlineImages,
5073
+ recordCanvas,
5074
+ keepIframeSrcFn,
5075
+ newlyAddedElement,
5076
+ rootId
5077
+ });
5078
+ case n2.TEXT_NODE:
5079
+ return serializeTextNode(n2, {
5080
+ needsMask,
5081
+ maskTextFn,
5082
+ rootId
5083
+ });
5084
+ case n2.CDATA_SECTION_NODE:
5085
+ return {
5086
+ type: NodeType.CDATA,
5087
+ textContent: "",
5088
+ rootId
5089
+ };
5090
+ case n2.COMMENT_NODE:
5091
+ return {
5092
+ type: NodeType.Comment,
5093
+ textContent: n2.textContent || "",
5094
+ rootId
5095
+ };
5096
+ default:
5097
+ return false;
5098
+ }
5076
5099
  }
5077
- function isCSSImportRule(rule) {
5078
- return "styleSheet" in rule;
5079
- }
5080
- function isCSSStyleRule(rule) {
5081
- return "selectorText" in rule;
5100
+ function getRootId(doc, mirror2) {
5101
+ if (!mirror2.hasNode(doc))
5102
+ return void 0;
5103
+ const docId = mirror2.getId(doc);
5104
+ return docId === 1 ? void 0 : docId;
5082
5105
  }
5083
- class Mirror {
5084
- constructor() {
5085
- this.idNodeMap = /* @__PURE__ */ new Map();
5086
- this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
5106
+ function serializeTextNode(n2, options) {
5107
+ var _a;
5108
+ const { needsMask, maskTextFn, rootId } = options;
5109
+ const parentTagName = n2.parentNode && n2.parentNode.tagName;
5110
+ let textContent = n2.textContent;
5111
+ const isStyle = parentTagName === "STYLE" ? true : void 0;
5112
+ const isScript = parentTagName === "SCRIPT" ? true : void 0;
5113
+ if (isStyle && textContent) {
5114
+ try {
5115
+ if (n2.nextSibling || n2.previousSibling) {
5116
+ } else if ((_a = n2.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
5117
+ textContent = stringifyStylesheet(n2.parentNode.sheet);
5118
+ }
5119
+ } catch (err) {
5120
+ console.warn(`Cannot get CSS styles from text's parentNode. Error: ${err}`, n2);
5121
+ }
5122
+ textContent = absoluteToStylesheet(textContent, getHref());
5087
5123
  }
5088
- getId(n2) {
5089
- var _a;
5090
- if (!n2)
5091
- return -1;
5092
- const id = (_a = this.getMeta(n2)) === null || _a === void 0 ? void 0 : _a.id;
5093
- return id !== null && id !== void 0 ? id : -1;
5124
+ if (isScript) {
5125
+ textContent = "SCRIPT_PLACEHOLDER";
5094
5126
  }
5095
- getNode(id) {
5096
- return this.idNodeMap.get(id) || null;
5127
+ if (!isStyle && !isScript && textContent && needsMask) {
5128
+ textContent = maskTextFn ? maskTextFn(textContent, n2.parentElement) : textContent.replace(/[\S]/g, "*");
5097
5129
  }
5098
- getIds() {
5099
- return Array.from(this.idNodeMap.keys());
5130
+ return {
5131
+ type: NodeType.Text,
5132
+ textContent: textContent || "",
5133
+ isStyle,
5134
+ rootId
5135
+ };
5136
+ }
5137
+ function serializeElementNode(n2, options) {
5138
+ const { doc, blockClass, blockSelector, inlineStylesheet, maskInputOptions = {}, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, newlyAddedElement = false, rootId } = options;
5139
+ const needBlock = _isBlockedElement(n2, blockClass, blockSelector);
5140
+ const tagName = getValidTagName(n2);
5141
+ let attributes = {};
5142
+ const len = n2.attributes.length;
5143
+ for (let i2 = 0; i2 < len; i2++) {
5144
+ const attr = n2.attributes[i2];
5145
+ if (!ignoreAttribute(tagName, attr.name, attr.value)) {
5146
+ attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
5147
+ }
5100
5148
  }
5101
- getMeta(n2) {
5102
- return this.nodeMetaMap.get(n2) || null;
5149
+ if (tagName === "link" && inlineStylesheet) {
5150
+ const stylesheet = Array.from(doc.styleSheets).find((s2) => {
5151
+ return s2.href === n2.href;
5152
+ });
5153
+ let cssText = null;
5154
+ if (stylesheet) {
5155
+ cssText = stringifyStylesheet(stylesheet);
5156
+ }
5157
+ if (cssText) {
5158
+ delete attributes.rel;
5159
+ delete attributes.href;
5160
+ attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href);
5161
+ }
5103
5162
  }
5104
- removeNodeFromMap(n2) {
5105
- const id = this.getId(n2);
5106
- this.idNodeMap.delete(id);
5107
- if (n2.childNodes) {
5108
- n2.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));
5163
+ if (tagName === "style" && n2.sheet && !(n2.innerText || n2.textContent || "").trim().length) {
5164
+ const cssText = stringifyStylesheet(n2.sheet);
5165
+ if (cssText) {
5166
+ attributes._cssText = absoluteToStylesheet(cssText, getHref());
5109
5167
  }
5110
5168
  }
5111
- has(id) {
5112
- return this.idNodeMap.has(id);
5169
+ if (tagName === "input" || tagName === "textarea" || tagName === "select") {
5170
+ const value = n2.value;
5171
+ const checked = n2.checked;
5172
+ if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
5173
+ attributes.value = maskInputValue({
5174
+ element: n2,
5175
+ type: getInputType(n2),
5176
+ tagName,
5177
+ value,
5178
+ maskInputOptions,
5179
+ maskInputFn
5180
+ });
5181
+ } else if (checked) {
5182
+ attributes.checked = checked;
5183
+ }
5113
5184
  }
5114
- hasNode(node) {
5115
- return this.nodeMetaMap.has(node);
5185
+ if (tagName === "option") {
5186
+ if (n2.selected && !maskInputOptions["select"]) {
5187
+ attributes.selected = true;
5188
+ } else {
5189
+ delete attributes.selected;
5190
+ }
5116
5191
  }
5117
- add(n2, meta) {
5118
- const id = meta.id;
5119
- this.idNodeMap.set(id, n2);
5120
- this.nodeMetaMap.set(n2, meta);
5192
+ if (tagName === "canvas" && recordCanvas) {
5193
+ if (n2.__context === "2d") {
5194
+ if (!is2DCanvasBlank(n2)) {
5195
+ attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
5196
+ }
5197
+ } else if (!("__context" in n2)) {
5198
+ const canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
5199
+ const blankCanvas = document.createElement("canvas");
5200
+ blankCanvas.width = n2.width;
5201
+ blankCanvas.height = n2.height;
5202
+ const blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
5203
+ if (canvasDataURL !== blankCanvasDataURL) {
5204
+ attributes.rr_dataURL = canvasDataURL;
5205
+ }
5206
+ }
5121
5207
  }
5122
- replace(id, n2) {
5123
- const oldNode = this.getNode(id);
5124
- if (oldNode) {
5125
- const meta = this.nodeMetaMap.get(oldNode);
5126
- if (meta)
5127
- this.nodeMetaMap.set(n2, meta);
5208
+ if (tagName === "img" && inlineImages) {
5209
+ if (!canvasService) {
5210
+ canvasService = doc.createElement("canvas");
5211
+ canvasCtx = canvasService.getContext("2d");
5128
5212
  }
5129
- this.idNodeMap.set(id, n2);
5213
+ const image = n2;
5214
+ const oldValue = image.crossOrigin;
5215
+ image.crossOrigin = "anonymous";
5216
+ const recordInlineImage = () => {
5217
+ image.removeEventListener("load", recordInlineImage);
5218
+ try {
5219
+ canvasService.width = image.naturalWidth;
5220
+ canvasService.height = image.naturalHeight;
5221
+ canvasCtx.drawImage(image, 0, 0);
5222
+ attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
5223
+ } catch (err) {
5224
+ console.warn(`Cannot inline img src=${image.currentSrc}! Error: ${err}`);
5225
+ }
5226
+ oldValue ? attributes.crossOrigin = oldValue : image.removeAttribute("crossorigin");
5227
+ };
5228
+ if (image.complete && image.naturalWidth !== 0)
5229
+ recordInlineImage();
5230
+ else
5231
+ image.addEventListener("load", recordInlineImage);
5130
5232
  }
5131
- reset() {
5132
- this.idNodeMap = /* @__PURE__ */ new Map();
5133
- this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
5233
+ if (tagName === "audio" || tagName === "video") {
5234
+ const mediaAttributes = attributes;
5235
+ mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
5236
+ mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
5237
+ mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
5238
+ mediaAttributes.rr_mediaMuted = n2.muted;
5239
+ mediaAttributes.rr_mediaLoop = n2.loop;
5240
+ mediaAttributes.rr_mediaVolume = n2.volume;
5134
5241
  }
5135
- }
5136
- function createMirror() {
5137
- return new Mirror();
5138
- }
5139
- function maskInputValue({ element, maskInputOptions, tagName, type, value, maskInputFn }) {
5140
- let text = value || "";
5141
- const actualType = type && toLowerCase(type);
5142
- if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
5143
- if (maskInputFn) {
5144
- text = maskInputFn(text, element);
5145
- } else {
5146
- text = "*".repeat(text.length);
5242
+ if (!newlyAddedElement) {
5243
+ if (n2.scrollLeft) {
5244
+ attributes.rr_scrollLeft = n2.scrollLeft;
5245
+ }
5246
+ if (n2.scrollTop) {
5247
+ attributes.rr_scrollTop = n2.scrollTop;
5147
5248
  }
5148
5249
  }
5149
- return text;
5150
- }
5151
- function toLowerCase(str) {
5152
- return str.toLowerCase();
5153
- }
5154
- const ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
5155
- function is2DCanvasBlank(canvas) {
5156
- const ctx = canvas.getContext("2d");
5157
- if (!ctx)
5158
- return true;
5159
- const chunkSize = 50;
5160
- for (let x2 = 0; x2 < canvas.width; x2 += chunkSize) {
5161
- for (let y2 = 0; y2 < canvas.height; y2 += chunkSize) {
5162
- const getImageData = ctx.getImageData;
5163
- const originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
5164
- const pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x2, y2, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y2)).data.buffer);
5165
- if (pixelBuffer.some((pixel) => pixel !== 0))
5166
- return false;
5250
+ if (needBlock) {
5251
+ const { width, height } = n2.getBoundingClientRect();
5252
+ attributes = {
5253
+ class: attributes.class,
5254
+ rr_width: `${width}px`,
5255
+ rr_height: `${height}px`
5256
+ };
5257
+ }
5258
+ if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
5259
+ if (!n2.contentDocument) {
5260
+ attributes.rr_src = attributes.src;
5167
5261
  }
5262
+ delete attributes.src;
5168
5263
  }
5169
- return true;
5170
- }
5171
- function getInputType(element) {
5172
- const type = element.type;
5173
- return element.hasAttribute("data-rr-is-password") ? "password" : type ? toLowerCase(type) : null;
5174
- }
5175
- function extractFileExtension(path, baseURL) {
5176
- var _a;
5177
- let url;
5264
+ let isCustomElement;
5178
5265
  try {
5179
- url = new URL(path, baseURL !== null && baseURL !== void 0 ? baseURL : window.location.href);
5180
- } catch (err) {
5181
- return null;
5266
+ if (customElements.get(tagName))
5267
+ isCustomElement = true;
5268
+ } catch (e2) {
5182
5269
  }
5183
- const regex = /\.([0-9a-z]+)(?:$)/i;
5184
- const match = url.pathname.match(regex);
5185
- return (_a = match === null || match === void 0 ? void 0 : match[1]) !== null && _a !== void 0 ? _a : null;
5270
+ return {
5271
+ type: NodeType.Element,
5272
+ tagName,
5273
+ attributes,
5274
+ childNodes: [],
5275
+ isSVG: isSVGElement(n2) || void 0,
5276
+ needBlock,
5277
+ rootId,
5278
+ isCustom: isCustomElement
5279
+ };
5186
5280
  }
5187
- let _id = 1;
5188
- const tagNameRegex = new RegExp("[^a-z0-9-_:]");
5189
- const IGNORED_NODE = -2;
5190
- function genId() {
5191
- return _id++;
5281
+ function lowerIfExists(maybeAttr) {
5282
+ if (maybeAttr === void 0 || maybeAttr === null) {
5283
+ return "";
5284
+ } else {
5285
+ return maybeAttr.toLowerCase();
5286
+ }
5192
5287
  }
5193
- function getValidTagName(element) {
5194
- if (element instanceof HTMLFormElement) {
5195
- return "form";
5196
- }
5197
- const processedTagName = toLowerCase(element.tagName);
5198
- if (tagNameRegex.test(processedTagName)) {
5199
- return "div";
5288
+ function slimDOMExcluded(sn, slimDOMOptions) {
5289
+ if (slimDOMOptions.comment && sn.type === NodeType.Comment) {
5290
+ return true;
5291
+ } else if (sn.type === NodeType.Element) {
5292
+ if (slimDOMOptions.script && (sn.tagName === "script" || sn.tagName === "link" && (sn.attributes.rel === "preload" || sn.attributes.rel === "modulepreload") && sn.attributes.as === "script" || sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
5293
+ return true;
5294
+ } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) {
5295
+ return true;
5296
+ } else if (sn.tagName === "meta") {
5297
+ if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
5298
+ return true;
5299
+ } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
5300
+ return true;
5301
+ } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
5302
+ return true;
5303
+ } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
5304
+ return true;
5305
+ } else if (slimDOMOptions.headMetaAuthorship && (lowerIfExists(sn.attributes.name) === "author" || lowerIfExists(sn.attributes.name) === "generator" || lowerIfExists(sn.attributes.name) === "framework" || lowerIfExists(sn.attributes.name) === "publisher" || lowerIfExists(sn.attributes.name) === "progid" || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
5306
+ return true;
5307
+ } else if (slimDOMOptions.headMetaVerification && (lowerIfExists(sn.attributes.name) === "google-site-verification" || lowerIfExists(sn.attributes.name) === "yandex-verification" || lowerIfExists(sn.attributes.name) === "csrf-token" || lowerIfExists(sn.attributes.name) === "p:domain_verify" || lowerIfExists(sn.attributes.name) === "verify-v1" || lowerIfExists(sn.attributes.name) === "verification" || lowerIfExists(sn.attributes.name) === "shopify-checkout-api-token")) {
5308
+ return true;
5309
+ }
5310
+ }
5200
5311
  }
5201
- return processedTagName;
5312
+ return false;
5202
5313
  }
5203
- function extractOrigin(url) {
5204
- let origin2 = "";
5205
- if (url.indexOf("//") > -1) {
5206
- origin2 = url.split("/").slice(0, 3).join("/");
5314
+ function serializeNodeWithId(n2, options) {
5315
+ const { doc, mirror: mirror2, blockClass, blockSelector, maskTextClass, maskTextSelector, skipChild = false, inlineStylesheet = true, maskInputOptions = {}, maskTextFn, maskInputFn, slimDOMOptions, dataURLOptions = {}, inlineImages = false, recordCanvas = false, onSerialize, onIframeLoad, iframeLoadTimeout = 5e3, onStylesheetLoad, stylesheetLoadTimeout = 5e3, keepIframeSrcFn = () => false, newlyAddedElement = false } = options;
5316
+ let { needsMask } = options;
5317
+ let { preserveWhiteSpace = true } = options;
5318
+ if (!needsMask && n2.childNodes) {
5319
+ const checkAncestors = needsMask === void 0;
5320
+ needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
5321
+ }
5322
+ const _serializedNode = serializeNode(n2, {
5323
+ doc,
5324
+ mirror: mirror2,
5325
+ blockClass,
5326
+ blockSelector,
5327
+ needsMask,
5328
+ inlineStylesheet,
5329
+ maskInputOptions,
5330
+ maskTextFn,
5331
+ maskInputFn,
5332
+ dataURLOptions,
5333
+ inlineImages,
5334
+ recordCanvas,
5335
+ keepIframeSrcFn,
5336
+ newlyAddedElement
5337
+ });
5338
+ if (!_serializedNode) {
5339
+ console.warn(n2, "not serialized");
5340
+ return null;
5341
+ }
5342
+ let id;
5343
+ if (mirror2.hasNode(n2)) {
5344
+ id = mirror2.getId(n2);
5345
+ } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
5346
+ id = IGNORED_NODE;
5207
5347
  } else {
5208
- origin2 = url.split("/")[0];
5348
+ id = genId();
5209
5349
  }
5210
- origin2 = origin2.split("?")[0];
5211
- return origin2;
5212
- }
5213
- let canvasService;
5214
- let canvasCtx;
5215
- const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
5216
- const URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
5217
- const URL_WWW_MATCH = /^www\..*/i;
5218
- const DATA_URI = /^(data:)([^,]*),(.*)/i;
5219
- function absoluteToStylesheet(cssText, href) {
5220
- return (cssText || "").replace(URL_IN_CSS_REF, (origin2, quote1, path1, quote2, path2, path3) => {
5221
- const filePath = path1 || path2 || path3;
5222
- const maybeQuote = quote1 || quote2 || "";
5223
- if (!filePath) {
5224
- return origin2;
5225
- }
5226
- if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
5227
- return `url(${maybeQuote}${filePath}${maybeQuote})`;
5228
- }
5229
- if (DATA_URI.test(filePath)) {
5230
- return `url(${maybeQuote}${filePath}${maybeQuote})`;
5350
+ const serializedNode = Object.assign(_serializedNode, { id });
5351
+ mirror2.add(n2, serializedNode);
5352
+ if (id === IGNORED_NODE) {
5353
+ return null;
5354
+ }
5355
+ if (onSerialize) {
5356
+ onSerialize(n2);
5357
+ }
5358
+ let recordChild = !skipChild;
5359
+ if (serializedNode.type === NodeType.Element) {
5360
+ recordChild = recordChild && !serializedNode.needBlock;
5361
+ delete serializedNode.needBlock;
5362
+ const shadowRoot = n2.shadowRoot;
5363
+ if (shadowRoot && isNativeShadowDom(shadowRoot))
5364
+ serializedNode.isShadowHost = true;
5365
+ }
5366
+ if ((serializedNode.type === NodeType.Document || serializedNode.type === NodeType.Element) && recordChild) {
5367
+ if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType.Element && serializedNode.tagName === "head") {
5368
+ preserveWhiteSpace = false;
5231
5369
  }
5232
- if (filePath[0] === "/") {
5233
- return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
5370
+ const bypassOptions = {
5371
+ doc,
5372
+ mirror: mirror2,
5373
+ blockClass,
5374
+ blockSelector,
5375
+ needsMask,
5376
+ maskTextClass,
5377
+ maskTextSelector,
5378
+ skipChild,
5379
+ inlineStylesheet,
5380
+ maskInputOptions,
5381
+ maskTextFn,
5382
+ maskInputFn,
5383
+ slimDOMOptions,
5384
+ dataURLOptions,
5385
+ inlineImages,
5386
+ recordCanvas,
5387
+ preserveWhiteSpace,
5388
+ onSerialize,
5389
+ onIframeLoad,
5390
+ iframeLoadTimeout,
5391
+ onStylesheetLoad,
5392
+ stylesheetLoadTimeout,
5393
+ keepIframeSrcFn
5394
+ };
5395
+ if (serializedNode.type === NodeType.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
5396
+ else {
5397
+ for (const childN of Array.from(n2.childNodes)) {
5398
+ const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
5399
+ if (serializedChildNode) {
5400
+ serializedNode.childNodes.push(serializedChildNode);
5401
+ }
5402
+ }
5234
5403
  }
5235
- const stack = href.split("/");
5236
- const parts = filePath.split("/");
5237
- stack.pop();
5238
- for (const part of parts) {
5239
- if (part === ".") {
5240
- continue;
5241
- } else if (part === "..") {
5242
- stack.pop();
5243
- } else {
5244
- stack.push(part);
5404
+ if (isElement(n2) && n2.shadowRoot) {
5405
+ for (const childN of Array.from(n2.shadowRoot.childNodes)) {
5406
+ const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
5407
+ if (serializedChildNode) {
5408
+ isNativeShadowDom(n2.shadowRoot) && (serializedChildNode.isShadow = true);
5409
+ serializedNode.childNodes.push(serializedChildNode);
5410
+ }
5245
5411
  }
5246
5412
  }
5247
- return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
5248
- });
5249
- }
5250
- const SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
5251
- const SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
5252
- function getAbsoluteSrcsetString(doc, attributeValue) {
5253
- if (attributeValue.trim() === "") {
5254
- return attributeValue;
5255
5413
  }
5256
- let pos = 0;
5257
- function collectCharacters(regEx) {
5258
- let chars2;
5259
- const match = regEx.exec(attributeValue.substring(pos));
5260
- if (match) {
5261
- chars2 = match[0];
5262
- pos += chars2.length;
5263
- return chars2;
5264
- }
5265
- return "";
5414
+ if (n2.parentNode && isShadowRoot(n2.parentNode) && isNativeShadowDom(n2.parentNode)) {
5415
+ serializedNode.isShadow = true;
5266
5416
  }
5267
- const output = [];
5268
- while (true) {
5269
- collectCharacters(SRCSET_COMMAS_OR_SPACES);
5270
- if (pos >= attributeValue.length) {
5271
- break;
5272
- }
5273
- let url = collectCharacters(SRCSET_NOT_SPACES);
5274
- if (url.slice(-1) === ",") {
5275
- url = absoluteToDoc(doc, url.substring(0, url.length - 1));
5276
- output.push(url);
5277
- } else {
5278
- let descriptorsStr = "";
5279
- url = absoluteToDoc(doc, url);
5280
- let inParens = false;
5281
- while (true) {
5282
- const c2 = attributeValue.charAt(pos);
5283
- if (c2 === "") {
5284
- output.push((url + descriptorsStr).trim());
5285
- break;
5286
- } else if (!inParens) {
5287
- if (c2 === ",") {
5288
- pos += 1;
5289
- output.push((url + descriptorsStr).trim());
5290
- break;
5291
- } else if (c2 === "(") {
5292
- inParens = true;
5293
- }
5294
- } else {
5295
- if (c2 === ")") {
5296
- inParens = false;
5297
- }
5417
+ if (serializedNode.type === NodeType.Element && serializedNode.tagName === "iframe") {
5418
+ onceIframeLoaded(n2, () => {
5419
+ const iframeDoc = n2.contentDocument;
5420
+ if (iframeDoc && onIframeLoad) {
5421
+ const serializedIframeNode = serializeNodeWithId(iframeDoc, {
5422
+ doc: iframeDoc,
5423
+ mirror: mirror2,
5424
+ blockClass,
5425
+ blockSelector,
5426
+ needsMask,
5427
+ maskTextClass,
5428
+ maskTextSelector,
5429
+ skipChild: false,
5430
+ inlineStylesheet,
5431
+ maskInputOptions,
5432
+ maskTextFn,
5433
+ maskInputFn,
5434
+ slimDOMOptions,
5435
+ dataURLOptions,
5436
+ inlineImages,
5437
+ recordCanvas,
5438
+ preserveWhiteSpace,
5439
+ onSerialize,
5440
+ onIframeLoad,
5441
+ iframeLoadTimeout,
5442
+ onStylesheetLoad,
5443
+ stylesheetLoadTimeout,
5444
+ keepIframeSrcFn
5445
+ });
5446
+ if (serializedIframeNode) {
5447
+ onIframeLoad(n2, serializedIframeNode);
5298
5448
  }
5299
- descriptorsStr += c2;
5300
- pos += 1;
5301
5449
  }
5302
- }
5303
- }
5304
- return output.join(", ");
5305
- }
5306
- function absoluteToDoc(doc, attributeValue) {
5307
- if (!attributeValue || attributeValue.trim() === "") {
5308
- return attributeValue;
5450
+ }, iframeLoadTimeout);
5309
5451
  }
5310
- const a2 = doc.createElement("a");
5311
- a2.href = attributeValue;
5312
- return a2.href;
5313
- }
5314
- function isSVGElement(el) {
5315
- return Boolean(el.tagName === "svg" || el.ownerSVGElement);
5316
- }
5317
- function getHref() {
5318
- const a2 = document.createElement("a");
5319
- a2.href = "";
5320
- return a2.href;
5321
- }
5322
- function transformAttribute(doc, tagName, name, value) {
5323
- if (!value) {
5324
- return value;
5325
- }
5326
- if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
5327
- return absoluteToDoc(doc, value);
5328
- } else if (name === "xlink:href" && value[0] !== "#") {
5329
- return absoluteToDoc(doc, value);
5330
- } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
5331
- return absoluteToDoc(doc, value);
5332
- } else if (name === "srcset") {
5333
- return getAbsoluteSrcsetString(doc, value);
5334
- } else if (name === "style") {
5335
- return absoluteToStylesheet(value, getHref());
5336
- } else if (tagName === "object" && name === "data") {
5337
- return absoluteToDoc(doc, value);
5338
- }
5339
- return value;
5340
- }
5341
- function ignoreAttribute(tagName, name, _value) {
5342
- return (tagName === "video" || tagName === "audio") && name === "autoplay";
5343
- }
5344
- function _isBlockedElement(element, blockClass, blockSelector) {
5345
- try {
5346
- if (typeof blockClass === "string") {
5347
- if (element.classList.contains(blockClass)) {
5348
- return true;
5349
- }
5350
- } else {
5351
- for (let eIndex = element.classList.length; eIndex--; ) {
5352
- const className = element.classList[eIndex];
5353
- if (blockClass.test(className)) {
5354
- return true;
5452
+ if (serializedNode.type === NodeType.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
5453
+ onceStylesheetLoaded(n2, () => {
5454
+ if (onStylesheetLoad) {
5455
+ const serializedLinkNode = serializeNodeWithId(n2, {
5456
+ doc,
5457
+ mirror: mirror2,
5458
+ blockClass,
5459
+ blockSelector,
5460
+ needsMask,
5461
+ maskTextClass,
5462
+ maskTextSelector,
5463
+ skipChild: false,
5464
+ inlineStylesheet,
5465
+ maskInputOptions,
5466
+ maskTextFn,
5467
+ maskInputFn,
5468
+ slimDOMOptions,
5469
+ dataURLOptions,
5470
+ inlineImages,
5471
+ recordCanvas,
5472
+ preserveWhiteSpace,
5473
+ onSerialize,
5474
+ onIframeLoad,
5475
+ iframeLoadTimeout,
5476
+ onStylesheetLoad,
5477
+ stylesheetLoadTimeout,
5478
+ keepIframeSrcFn
5479
+ });
5480
+ if (serializedLinkNode) {
5481
+ onStylesheetLoad(n2, serializedLinkNode);
5355
5482
  }
5356
5483
  }
5357
- }
5358
- if (blockSelector) {
5359
- return element.matches(blockSelector);
5360
- }
5361
- } catch (e2) {
5484
+ }, stylesheetLoadTimeout);
5362
5485
  }
5363
- return false;
5486
+ return serializedNode;
5364
5487
  }
5365
- function classMatchesRegex(node, regex, checkAncestors) {
5366
- if (!node)
5488
+ function snapshot(n2, options) {
5489
+ const { mirror: mirror2 = new Mirror(), blockClass = "rr-block", blockSelector = null, maskTextClass = "rr-mask", maskTextSelector = null, inlineStylesheet = true, inlineImages = false, recordCanvas = false, maskAllInputs = false, maskTextFn, maskInputFn, slimDOM = false, dataURLOptions, preserveWhiteSpace, onSerialize, onIframeLoad, iframeLoadTimeout, onStylesheetLoad, stylesheetLoadTimeout, keepIframeSrcFn = () => false } = options || {};
5490
+ const maskInputOptions = maskAllInputs === true ? {
5491
+ color: true,
5492
+ date: true,
5493
+ "datetime-local": true,
5494
+ email: true,
5495
+ month: true,
5496
+ number: true,
5497
+ range: true,
5498
+ search: true,
5499
+ tel: true,
5500
+ text: true,
5501
+ time: true,
5502
+ url: true,
5503
+ week: true,
5504
+ textarea: true,
5505
+ select: true,
5506
+ password: true
5507
+ } : maskAllInputs === false ? {
5508
+ password: true
5509
+ } : maskAllInputs;
5510
+ const slimDOMOptions = slimDOM === true || slimDOM === "all" ? {
5511
+ script: true,
5512
+ comment: true,
5513
+ headFavicon: true,
5514
+ headWhitespace: true,
5515
+ headMetaDescKeywords: slimDOM === "all",
5516
+ headMetaSocial: true,
5517
+ headMetaRobots: true,
5518
+ headMetaHttpEquiv: true,
5519
+ headMetaAuthorship: true,
5520
+ headMetaVerification: true
5521
+ } : slimDOM === false ? {} : slimDOM;
5522
+ return serializeNodeWithId(n2, {
5523
+ doc: n2,
5524
+ mirror: mirror2,
5525
+ blockClass,
5526
+ blockSelector,
5527
+ maskTextClass,
5528
+ maskTextSelector,
5529
+ skipChild: false,
5530
+ inlineStylesheet,
5531
+ maskInputOptions,
5532
+ maskTextFn,
5533
+ maskInputFn,
5534
+ slimDOMOptions,
5535
+ dataURLOptions,
5536
+ inlineImages,
5537
+ recordCanvas,
5538
+ preserveWhiteSpace,
5539
+ onSerialize,
5540
+ onIframeLoad,
5541
+ iframeLoadTimeout,
5542
+ onStylesheetLoad,
5543
+ stylesheetLoadTimeout,
5544
+ keepIframeSrcFn,
5545
+ newlyAddedElement: false
5546
+ });
5547
+ }
5548
+ function on(type, fn, target = document) {
5549
+ const options = { capture: true, passive: true };
5550
+ target.addEventListener(type, fn, options);
5551
+ return () => target.removeEventListener(type, fn, options);
5552
+ }
5553
+ 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.";
5554
+ let _mirror = {
5555
+ map: {},
5556
+ getId() {
5557
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
5558
+ return -1;
5559
+ },
5560
+ getNode() {
5561
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
5562
+ return null;
5563
+ },
5564
+ removeNodeFromMap() {
5565
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
5566
+ },
5567
+ has() {
5568
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
5367
5569
  return false;
5368
- if (node.nodeType !== node.ELEMENT_NODE) {
5369
- if (!checkAncestors)
5370
- return false;
5371
- return classMatchesRegex(node.parentNode, regex, checkAncestors);
5570
+ },
5571
+ reset() {
5572
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
5372
5573
  }
5373
- for (let eIndex = node.classList.length; eIndex--; ) {
5374
- const className = node.classList[eIndex];
5375
- if (regex.test(className)) {
5376
- return true;
5574
+ };
5575
+ if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
5576
+ _mirror = new Proxy(_mirror, {
5577
+ get(target, prop, receiver) {
5578
+ if (prop === "map") {
5579
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
5580
+ }
5581
+ return Reflect.get(target, prop, receiver);
5377
5582
  }
5378
- }
5379
- if (!checkAncestors)
5380
- return false;
5381
- return classMatchesRegex(node.parentNode, regex, checkAncestors);
5583
+ });
5382
5584
  }
5383
- function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) {
5384
- try {
5385
- const el = node.nodeType === node.ELEMENT_NODE ? node : node.parentElement;
5386
- if (el === null)
5387
- return false;
5388
- if (typeof maskTextClass === "string") {
5389
- if (checkAncestors) {
5390
- if (el.closest(`.${maskTextClass}`))
5391
- return true;
5392
- } else {
5393
- if (el.classList.contains(maskTextClass))
5394
- return true;
5585
+ function throttle(func, wait, options = {}) {
5586
+ let timeout = null;
5587
+ let previous = 0;
5588
+ return function(...args) {
5589
+ const now = Date.now();
5590
+ if (!previous && options.leading === false) {
5591
+ previous = now;
5592
+ }
5593
+ const remaining = wait - (now - previous);
5594
+ const context = this;
5595
+ if (remaining <= 0 || remaining > wait) {
5596
+ if (timeout) {
5597
+ clearTimeout(timeout);
5598
+ timeout = null;
5395
5599
  }
5396
- } else {
5397
- if (classMatchesRegex(el, maskTextClass, checkAncestors))
5398
- return true;
5600
+ previous = now;
5601
+ func.apply(context, args);
5602
+ } else if (!timeout && options.trailing !== false) {
5603
+ timeout = setTimeout(() => {
5604
+ previous = options.leading === false ? 0 : Date.now();
5605
+ timeout = null;
5606
+ func.apply(context, args);
5607
+ }, remaining);
5399
5608
  }
5400
- if (maskTextSelector) {
5401
- if (checkAncestors) {
5402
- if (el.closest(maskTextSelector))
5403
- return true;
5404
- } else {
5405
- if (el.matches(maskTextSelector))
5406
- return true;
5609
+ };
5610
+ }
5611
+ function hookSetter(target, key, d2, isRevoked, win2 = window) {
5612
+ const original = win2.Object.getOwnPropertyDescriptor(target, key);
5613
+ win2.Object.defineProperty(target, key, isRevoked ? d2 : {
5614
+ set(value) {
5615
+ setTimeout(() => {
5616
+ d2.set.call(this, value);
5617
+ }, 0);
5618
+ if (original && original.set) {
5619
+ original.set.call(this, value);
5407
5620
  }
5408
5621
  }
5409
- } catch (e2) {
5410
- }
5411
- return false;
5622
+ });
5623
+ return () => hookSetter(target, key, original || {}, true);
5412
5624
  }
5413
- function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
5414
- const win2 = iframeEl.contentWindow;
5415
- if (!win2) {
5416
- return;
5417
- }
5418
- let fired = false;
5419
- let readyState;
5420
- try {
5421
- readyState = win2.document.readyState;
5422
- } catch (error) {
5423
- return;
5424
- }
5425
- if (readyState !== "complete") {
5426
- const timer = setTimeout(() => {
5427
- if (!fired) {
5428
- listener();
5429
- fired = true;
5430
- }
5431
- }, iframeLoadTimeout);
5432
- iframeEl.addEventListener("load", () => {
5433
- clearTimeout(timer);
5434
- fired = true;
5435
- listener();
5436
- });
5437
- return;
5438
- }
5439
- const blankUrl = "about:blank";
5440
- if (win2.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
5441
- setTimeout(listener, 0);
5442
- return iframeEl.addEventListener("load", listener);
5443
- }
5444
- iframeEl.addEventListener("load", listener);
5445
- }
5446
- function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
5447
- let fired = false;
5448
- let styleSheetLoaded;
5625
+ function patch(source, name, replacement) {
5449
5626
  try {
5450
- styleSheetLoaded = link.sheet;
5451
- } catch (error) {
5452
- return;
5453
- }
5454
- if (styleSheetLoaded)
5455
- return;
5456
- const timer = setTimeout(() => {
5457
- if (!fired) {
5458
- listener();
5459
- fired = true;
5460
- }
5461
- }, styleSheetLoadTimeout);
5462
- link.addEventListener("load", () => {
5463
- clearTimeout(timer);
5464
- fired = true;
5465
- listener();
5466
- });
5467
- }
5468
- function serializeNode(n2, options) {
5469
- const { doc, mirror: mirror2, blockClass, blockSelector, needsMask, inlineStylesheet, maskInputOptions = {}, maskTextFn, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, newlyAddedElement = false } = options;
5470
- const rootId = getRootId(doc, mirror2);
5471
- switch (n2.nodeType) {
5472
- case n2.DOCUMENT_NODE:
5473
- if (n2.compatMode !== "CSS1Compat") {
5474
- return {
5475
- type: NodeType.Document,
5476
- childNodes: [],
5477
- compatMode: n2.compatMode
5478
- };
5479
- } else {
5480
- return {
5481
- type: NodeType.Document,
5482
- childNodes: []
5483
- };
5484
- }
5485
- case n2.DOCUMENT_TYPE_NODE:
5486
- return {
5487
- type: NodeType.DocumentType,
5488
- name: n2.name,
5489
- publicId: n2.publicId,
5490
- systemId: n2.systemId,
5491
- rootId
5627
+ if (!(name in source)) {
5628
+ return () => {
5492
5629
  };
5493
- case n2.ELEMENT_NODE:
5494
- return serializeElementNode(n2, {
5495
- doc,
5496
- blockClass,
5497
- blockSelector,
5498
- inlineStylesheet,
5499
- maskInputOptions,
5500
- maskInputFn,
5501
- dataURLOptions,
5502
- inlineImages,
5503
- recordCanvas,
5504
- keepIframeSrcFn,
5505
- newlyAddedElement,
5506
- rootId
5507
- });
5508
- case n2.TEXT_NODE:
5509
- return serializeTextNode(n2, {
5510
- needsMask,
5511
- maskTextFn,
5512
- rootId
5630
+ }
5631
+ const original = source[name];
5632
+ const wrapped = replacement(original);
5633
+ if (typeof wrapped === "function") {
5634
+ wrapped.prototype = wrapped.prototype || {};
5635
+ Object.defineProperties(wrapped, {
5636
+ __rrweb_original__: {
5637
+ enumerable: false,
5638
+ value: original
5639
+ }
5513
5640
  });
5514
- case n2.CDATA_SECTION_NODE:
5515
- return {
5516
- type: NodeType.CDATA,
5517
- textContent: "",
5518
- rootId
5519
- };
5520
- case n2.COMMENT_NODE:
5521
- return {
5522
- type: NodeType.Comment,
5523
- textContent: n2.textContent || "",
5524
- rootId
5525
- };
5526
- default:
5527
- return false;
5641
+ }
5642
+ source[name] = wrapped;
5643
+ return () => {
5644
+ source[name] = original;
5645
+ };
5646
+ } catch (_a) {
5647
+ return () => {
5648
+ };
5528
5649
  }
5529
5650
  }
5530
- function getRootId(doc, mirror2) {
5531
- if (!mirror2.hasNode(doc))
5532
- return void 0;
5533
- const docId = mirror2.getId(doc);
5534
- return docId === 1 ? void 0 : docId;
5651
+ let nowTimestamp = Date.now;
5652
+ if (!/[1-9][0-9]{12}/.test(Date.now().toString())) {
5653
+ nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
5535
5654
  }
5536
- function serializeTextNode(n2, options) {
5537
- var _a;
5538
- const { needsMask, maskTextFn, rootId } = options;
5539
- const parentTagName = n2.parentNode && n2.parentNode.tagName;
5540
- let textContent = n2.textContent;
5541
- const isStyle = parentTagName === "STYLE" ? true : void 0;
5542
- const isScript = parentTagName === "SCRIPT" ? true : void 0;
5543
- if (isStyle && textContent) {
5544
- try {
5545
- if (n2.nextSibling || n2.previousSibling) {
5546
- } else if ((_a = n2.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
5547
- textContent = stringifyStylesheet(n2.parentNode.sheet);
5548
- }
5549
- } catch (err) {
5550
- console.warn(`Cannot get CSS styles from text's parentNode. Error: ${err}`, n2);
5551
- }
5552
- textContent = absoluteToStylesheet(textContent, getHref());
5553
- }
5554
- if (isScript) {
5555
- textContent = "SCRIPT_PLACEHOLDER";
5556
- }
5557
- if (!isStyle && !isScript && textContent && needsMask) {
5558
- textContent = maskTextFn ? maskTextFn(textContent, n2.parentElement) : textContent.replace(/[\S]/g, "*");
5559
- }
5655
+ function getWindowScroll(win2) {
5656
+ var _a, _b, _c, _d, _e, _f;
5657
+ const doc = win2.document;
5560
5658
  return {
5561
- type: NodeType.Text,
5562
- textContent: textContent || "",
5563
- isStyle,
5564
- rootId
5659
+ left: doc.scrollingElement ? doc.scrollingElement.scrollLeft : win2.pageXOffset !== void 0 ? win2.pageXOffset : (doc === null || doc === void 0 ? void 0 : doc.documentElement.scrollLeft) || ((_b = (_a = doc === null || doc === void 0 ? void 0 : doc.body) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.scrollLeft) || ((_c = doc === null || doc === void 0 ? void 0 : doc.body) === null || _c === void 0 ? void 0 : _c.scrollLeft) || 0,
5660
+ top: doc.scrollingElement ? doc.scrollingElement.scrollTop : win2.pageYOffset !== void 0 ? win2.pageYOffset : (doc === null || doc === void 0 ? void 0 : doc.documentElement.scrollTop) || ((_e = (_d = doc === null || doc === void 0 ? void 0 : doc.body) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.scrollTop) || ((_f = doc === null || doc === void 0 ? void 0 : doc.body) === null || _f === void 0 ? void 0 : _f.scrollTop) || 0
5565
5661
  };
5566
5662
  }
5567
- function serializeElementNode(n2, options) {
5568
- const { doc, blockClass, blockSelector, inlineStylesheet, maskInputOptions = {}, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, newlyAddedElement = false, rootId } = options;
5569
- const needBlock = _isBlockedElement(n2, blockClass, blockSelector);
5570
- const tagName = getValidTagName(n2);
5571
- let attributes = {};
5572
- const len = n2.attributes.length;
5573
- for (let i = 0; i < len; i++) {
5574
- const attr = n2.attributes[i];
5575
- if (!ignoreAttribute(tagName, attr.name, attr.value)) {
5576
- attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
5577
- }
5578
- }
5579
- if (tagName === "link" && inlineStylesheet) {
5580
- const stylesheet = Array.from(doc.styleSheets).find((s2) => {
5581
- return s2.href === n2.href;
5582
- });
5583
- let cssText = null;
5584
- if (stylesheet) {
5585
- cssText = stringifyStylesheet(stylesheet);
5586
- }
5587
- if (cssText) {
5588
- delete attributes.rel;
5589
- delete attributes.href;
5590
- attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href);
5591
- }
5663
+ function getWindowHeight() {
5664
+ return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
5665
+ }
5666
+ function getWindowWidth() {
5667
+ return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
5668
+ }
5669
+ function closestElementOfNode(node) {
5670
+ if (!node) {
5671
+ return null;
5592
5672
  }
5593
- if (tagName === "style" && n2.sheet && !(n2.innerText || n2.textContent || "").trim().length) {
5594
- const cssText = stringifyStylesheet(n2.sheet);
5595
- if (cssText) {
5596
- attributes._cssText = absoluteToStylesheet(cssText, getHref());
5597
- }
5673
+ const el = node.nodeType === node.ELEMENT_NODE ? node : node.parentElement;
5674
+ return el;
5675
+ }
5676
+ function isBlocked(node, blockClass, blockSelector, checkAncestors) {
5677
+ if (!node) {
5678
+ return false;
5598
5679
  }
5599
- if (tagName === "input" || tagName === "textarea" || tagName === "select") {
5600
- const value = n2.value;
5601
- const checked = n2.checked;
5602
- if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
5603
- attributes.value = maskInputValue({
5604
- element: n2,
5605
- type: getInputType(n2),
5606
- tagName,
5607
- value,
5608
- maskInputOptions,
5609
- maskInputFn
5610
- });
5611
- } else if (checked) {
5612
- attributes.checked = checked;
5613
- }
5680
+ const el = closestElementOfNode(node);
5681
+ if (!el) {
5682
+ return false;
5614
5683
  }
5615
- if (tagName === "option") {
5616
- if (n2.selected && !maskInputOptions["select"]) {
5617
- attributes.selected = true;
5684
+ try {
5685
+ if (typeof blockClass === "string") {
5686
+ if (el.classList.contains(blockClass))
5687
+ return true;
5688
+ if (checkAncestors && el.closest("." + blockClass) !== null)
5689
+ return true;
5618
5690
  } else {
5619
- delete attributes.selected;
5691
+ if (classMatchesRegex(el, blockClass, checkAncestors))
5692
+ return true;
5620
5693
  }
5694
+ } catch (e2) {
5621
5695
  }
5622
- if (tagName === "canvas" && recordCanvas) {
5623
- if (n2.__context === "2d") {
5624
- if (!is2DCanvasBlank(n2)) {
5625
- attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
5626
- }
5627
- } else if (!("__context" in n2)) {
5628
- const canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
5629
- const blankCanvas = document.createElement("canvas");
5630
- blankCanvas.width = n2.width;
5631
- blankCanvas.height = n2.height;
5632
- const blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
5633
- if (canvasDataURL !== blankCanvasDataURL) {
5634
- attributes.rr_dataURL = canvasDataURL;
5635
- }
5636
- }
5637
- }
5638
- if (tagName === "img" && inlineImages) {
5639
- if (!canvasService) {
5640
- canvasService = doc.createElement("canvas");
5641
- canvasCtx = canvasService.getContext("2d");
5642
- }
5643
- const image = n2;
5644
- const oldValue = image.crossOrigin;
5645
- image.crossOrigin = "anonymous";
5646
- const recordInlineImage = () => {
5647
- image.removeEventListener("load", recordInlineImage);
5648
- try {
5649
- canvasService.width = image.naturalWidth;
5650
- canvasService.height = image.naturalHeight;
5651
- canvasCtx.drawImage(image, 0, 0);
5652
- attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
5653
- } catch (err) {
5654
- console.warn(`Cannot inline img src=${image.currentSrc}! Error: ${err}`);
5655
- }
5656
- oldValue ? attributes.crossOrigin = oldValue : image.removeAttribute("crossorigin");
5657
- };
5658
- if (image.complete && image.naturalWidth !== 0)
5659
- recordInlineImage();
5660
- else
5661
- image.addEventListener("load", recordInlineImage);
5662
- }
5663
- if (tagName === "audio" || tagName === "video") {
5664
- const mediaAttributes = attributes;
5665
- mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
5666
- mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
5667
- mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
5668
- mediaAttributes.rr_mediaMuted = n2.muted;
5669
- mediaAttributes.rr_mediaLoop = n2.loop;
5670
- mediaAttributes.rr_mediaVolume = n2.volume;
5696
+ if (blockSelector) {
5697
+ if (el.matches(blockSelector))
5698
+ return true;
5699
+ if (checkAncestors && el.closest(blockSelector) !== null)
5700
+ return true;
5671
5701
  }
5672
- if (!newlyAddedElement) {
5673
- if (n2.scrollLeft) {
5674
- attributes.rr_scrollLeft = n2.scrollLeft;
5675
- }
5676
- if (n2.scrollTop) {
5677
- attributes.rr_scrollTop = n2.scrollTop;
5678
- }
5702
+ return false;
5703
+ }
5704
+ function isSerialized(n2, mirror2) {
5705
+ return mirror2.getId(n2) !== -1;
5706
+ }
5707
+ function isIgnored(n2, mirror2) {
5708
+ return mirror2.getId(n2) === IGNORED_NODE;
5709
+ }
5710
+ function isAncestorRemoved(target, mirror2) {
5711
+ if (isShadowRoot(target)) {
5712
+ return false;
5679
5713
  }
5680
- if (needBlock) {
5681
- const { width, height } = n2.getBoundingClientRect();
5682
- attributes = {
5683
- class: attributes.class,
5684
- rr_width: `${width}px`,
5685
- rr_height: `${height}px`
5686
- };
5714
+ const id = mirror2.getId(target);
5715
+ if (!mirror2.has(id)) {
5716
+ return true;
5687
5717
  }
5688
- if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
5689
- if (!n2.contentDocument) {
5690
- attributes.rr_src = attributes.src;
5691
- }
5692
- delete attributes.src;
5718
+ if (target.parentNode && target.parentNode.nodeType === target.DOCUMENT_NODE) {
5719
+ return false;
5693
5720
  }
5694
- let isCustomElement;
5695
- try {
5696
- if (customElements.get(tagName))
5697
- isCustomElement = true;
5698
- } catch (e2) {
5721
+ if (!target.parentNode) {
5722
+ return true;
5699
5723
  }
5700
- return {
5701
- type: NodeType.Element,
5702
- tagName,
5703
- attributes,
5704
- childNodes: [],
5705
- isSVG: isSVGElement(n2) || void 0,
5706
- needBlock,
5707
- rootId,
5708
- isCustom: isCustomElement
5709
- };
5724
+ return isAncestorRemoved(target.parentNode, mirror2);
5710
5725
  }
5711
- function lowerIfExists(maybeAttr) {
5712
- if (maybeAttr === void 0 || maybeAttr === null) {
5713
- return "";
5714
- } else {
5715
- return maybeAttr.toLowerCase();
5716
- }
5726
+ function legacy_isTouchEvent(event) {
5727
+ return Boolean(event.changedTouches);
5717
5728
  }
5718
- function slimDOMExcluded(sn, slimDOMOptions) {
5719
- if (slimDOMOptions.comment && sn.type === NodeType.Comment) {
5720
- return true;
5721
- } else if (sn.type === NodeType.Element) {
5722
- if (slimDOMOptions.script && (sn.tagName === "script" || sn.tagName === "link" && (sn.attributes.rel === "preload" || sn.attributes.rel === "modulepreload") && sn.attributes.as === "script" || sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
5723
- return true;
5724
- } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) {
5725
- return true;
5726
- } else if (sn.tagName === "meta") {
5727
- if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
5728
- return true;
5729
- } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
5730
- return true;
5731
- } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
5732
- return true;
5733
- } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
5734
- return true;
5735
- } else if (slimDOMOptions.headMetaAuthorship && (lowerIfExists(sn.attributes.name) === "author" || lowerIfExists(sn.attributes.name) === "generator" || lowerIfExists(sn.attributes.name) === "framework" || lowerIfExists(sn.attributes.name) === "publisher" || lowerIfExists(sn.attributes.name) === "progid" || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
5736
- return true;
5737
- } else if (slimDOMOptions.headMetaVerification && (lowerIfExists(sn.attributes.name) === "google-site-verification" || lowerIfExists(sn.attributes.name) === "yandex-verification" || lowerIfExists(sn.attributes.name) === "csrf-token" || lowerIfExists(sn.attributes.name) === "p:domain_verify" || lowerIfExists(sn.attributes.name) === "verify-v1" || lowerIfExists(sn.attributes.name) === "verification" || lowerIfExists(sn.attributes.name) === "shopify-checkout-api-token")) {
5738
- return true;
5729
+ function polyfill(win2 = window) {
5730
+ if ("NodeList" in win2 && !win2.NodeList.prototype.forEach) {
5731
+ win2.NodeList.prototype.forEach = Array.prototype.forEach;
5732
+ }
5733
+ if ("DOMTokenList" in win2 && !win2.DOMTokenList.prototype.forEach) {
5734
+ win2.DOMTokenList.prototype.forEach = Array.prototype.forEach;
5735
+ }
5736
+ if (!Node.prototype.contains) {
5737
+ Node.prototype.contains = (...args) => {
5738
+ let node = args[0];
5739
+ if (!(0 in args)) {
5740
+ throw new TypeError("1 argument is required");
5739
5741
  }
5740
- }
5742
+ do {
5743
+ if (this === node) {
5744
+ return true;
5745
+ }
5746
+ } while (node = node && node.parentNode);
5747
+ return false;
5748
+ };
5741
5749
  }
5742
- return false;
5743
5750
  }
5744
- function serializeNodeWithId(n2, options) {
5745
- const { doc, mirror: mirror2, blockClass, blockSelector, maskTextClass, maskTextSelector, skipChild = false, inlineStylesheet = true, maskInputOptions = {}, maskTextFn, maskInputFn, slimDOMOptions, dataURLOptions = {}, inlineImages = false, recordCanvas = false, onSerialize, onIframeLoad, iframeLoadTimeout = 5e3, onStylesheetLoad, stylesheetLoadTimeout = 5e3, keepIframeSrcFn = () => false, newlyAddedElement = false } = options;
5746
- let { needsMask } = options;
5747
- let { preserveWhiteSpace = true } = options;
5748
- if (!needsMask && n2.childNodes) {
5749
- const checkAncestors = needsMask === void 0;
5750
- needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
5751
+ function isSerializedIframe(n2, mirror2) {
5752
+ return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
5753
+ }
5754
+ function isSerializedStylesheet(n2, mirror2) {
5755
+ return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
5756
+ }
5757
+ function hasShadowRoot(n2) {
5758
+ return Boolean(n2 === null || n2 === void 0 ? void 0 : n2.shadowRoot);
5759
+ }
5760
+ class StyleSheetMirror {
5761
+ constructor() {
5762
+ this.id = 1;
5763
+ this.styleIDMap = /* @__PURE__ */ new WeakMap();
5764
+ this.idStyleMap = /* @__PURE__ */ new Map();
5751
5765
  }
5752
- const _serializedNode = serializeNode(n2, {
5753
- doc,
5754
- mirror: mirror2,
5755
- blockClass,
5756
- blockSelector,
5757
- needsMask,
5758
- inlineStylesheet,
5759
- maskInputOptions,
5760
- maskTextFn,
5761
- maskInputFn,
5762
- dataURLOptions,
5763
- inlineImages,
5764
- recordCanvas,
5765
- keepIframeSrcFn,
5766
- newlyAddedElement
5767
- });
5768
- if (!_serializedNode) {
5769
- console.warn(n2, "not serialized");
5770
- return null;
5766
+ getId(stylesheet) {
5767
+ var _a;
5768
+ return (_a = this.styleIDMap.get(stylesheet)) !== null && _a !== void 0 ? _a : -1;
5771
5769
  }
5772
- let id;
5773
- if (mirror2.hasNode(n2)) {
5774
- id = mirror2.getId(n2);
5775
- } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
5776
- id = IGNORED_NODE;
5777
- } else {
5778
- id = genId();
5770
+ has(stylesheet) {
5771
+ return this.styleIDMap.has(stylesheet);
5779
5772
  }
5780
- const serializedNode = Object.assign(_serializedNode, { id });
5781
- mirror2.add(n2, serializedNode);
5782
- if (id === IGNORED_NODE) {
5783
- return null;
5773
+ add(stylesheet, id) {
5774
+ if (this.has(stylesheet))
5775
+ return this.getId(stylesheet);
5776
+ let newId;
5777
+ if (id === void 0) {
5778
+ newId = this.id++;
5779
+ } else
5780
+ newId = id;
5781
+ this.styleIDMap.set(stylesheet, newId);
5782
+ this.idStyleMap.set(newId, stylesheet);
5783
+ return newId;
5784
5784
  }
5785
- if (onSerialize) {
5786
- onSerialize(n2);
5785
+ getStyle(id) {
5786
+ return this.idStyleMap.get(id) || null;
5787
5787
  }
5788
- let recordChild = !skipChild;
5789
- if (serializedNode.type === NodeType.Element) {
5790
- recordChild = recordChild && !serializedNode.needBlock;
5791
- delete serializedNode.needBlock;
5792
- const shadowRoot = n2.shadowRoot;
5793
- if (shadowRoot && isNativeShadowDom(shadowRoot))
5794
- serializedNode.isShadowHost = true;
5788
+ reset() {
5789
+ this.styleIDMap = /* @__PURE__ */ new WeakMap();
5790
+ this.idStyleMap = /* @__PURE__ */ new Map();
5791
+ this.id = 1;
5795
5792
  }
5796
- if ((serializedNode.type === NodeType.Document || serializedNode.type === NodeType.Element) && recordChild) {
5797
- if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType.Element && serializedNode.tagName === "head") {
5798
- preserveWhiteSpace = false;
5799
- }
5800
- const bypassOptions = {
5801
- doc,
5802
- mirror: mirror2,
5803
- blockClass,
5804
- blockSelector,
5805
- needsMask,
5806
- maskTextClass,
5807
- maskTextSelector,
5808
- skipChild,
5809
- inlineStylesheet,
5810
- maskInputOptions,
5811
- maskTextFn,
5812
- maskInputFn,
5813
- slimDOMOptions,
5814
- dataURLOptions,
5815
- inlineImages,
5816
- recordCanvas,
5817
- preserveWhiteSpace,
5818
- onSerialize,
5819
- onIframeLoad,
5820
- iframeLoadTimeout,
5821
- onStylesheetLoad,
5822
- stylesheetLoadTimeout,
5823
- keepIframeSrcFn
5824
- };
5825
- if (serializedNode.type === NodeType.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
5826
- else {
5827
- for (const childN of Array.from(n2.childNodes)) {
5828
- const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
5829
- if (serializedChildNode) {
5830
- serializedNode.childNodes.push(serializedChildNode);
5831
- }
5832
- }
5793
+ generateId() {
5794
+ return this.id++;
5795
+ }
5796
+ }
5797
+ function getShadowHost(n2) {
5798
+ var _a, _b;
5799
+ let shadowHost = null;
5800
+ if (((_b = (_a = n2.getRootNode) === null || _a === void 0 ? void 0 : _a.call(n2)) === null || _b === void 0 ? void 0 : _b.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && n2.getRootNode().host)
5801
+ shadowHost = n2.getRootNode().host;
5802
+ return shadowHost;
5803
+ }
5804
+ function getRootShadowHost(n2) {
5805
+ let rootShadowHost = n2;
5806
+ let shadowHost;
5807
+ while (shadowHost = getShadowHost(rootShadowHost))
5808
+ rootShadowHost = shadowHost;
5809
+ return rootShadowHost;
5810
+ }
5811
+ function shadowHostInDom(n2) {
5812
+ const doc = n2.ownerDocument;
5813
+ if (!doc)
5814
+ return false;
5815
+ const shadowHost = getRootShadowHost(n2);
5816
+ return doc.contains(shadowHost);
5817
+ }
5818
+ function inDom(n2) {
5819
+ const doc = n2.ownerDocument;
5820
+ if (!doc)
5821
+ return false;
5822
+ return doc.contains(n2) || shadowHostInDom(n2);
5823
+ }
5824
+ var EventType$1 = /* @__PURE__ */ ((EventType2) => {
5825
+ EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
5826
+ EventType2[EventType2["Load"] = 1] = "Load";
5827
+ EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
5828
+ EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
5829
+ EventType2[EventType2["Meta"] = 4] = "Meta";
5830
+ EventType2[EventType2["Custom"] = 5] = "Custom";
5831
+ EventType2[EventType2["Plugin"] = 6] = "Plugin";
5832
+ return EventType2;
5833
+ })(EventType$1 || {});
5834
+ var IncrementalSource$1 = /* @__PURE__ */ ((IncrementalSource2) => {
5835
+ IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
5836
+ IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
5837
+ IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
5838
+ IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
5839
+ IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
5840
+ IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
5841
+ IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
5842
+ IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
5843
+ IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
5844
+ IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
5845
+ IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
5846
+ IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
5847
+ IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
5848
+ IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
5849
+ IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
5850
+ IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
5851
+ IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
5852
+ return IncrementalSource2;
5853
+ })(IncrementalSource$1 || {});
5854
+ var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
5855
+ MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
5856
+ MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
5857
+ MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
5858
+ MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
5859
+ MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
5860
+ MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
5861
+ MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
5862
+ MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
5863
+ MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
5864
+ MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
5865
+ MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
5866
+ return MouseInteractions2;
5867
+ })(MouseInteractions || {});
5868
+ var PointerTypes = /* @__PURE__ */ ((PointerTypes2) => {
5869
+ PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
5870
+ PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
5871
+ PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
5872
+ return PointerTypes2;
5873
+ })(PointerTypes || {});
5874
+ var CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {
5875
+ CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
5876
+ CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
5877
+ CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
5878
+ return CanvasContext2;
5879
+ })(CanvasContext || {});
5880
+ function isNodeInLinkedList(n2) {
5881
+ return "__ln" in n2;
5882
+ }
5883
+ class DoubleLinkedList {
5884
+ constructor() {
5885
+ this.length = 0;
5886
+ this.head = null;
5887
+ this.tail = null;
5888
+ }
5889
+ get(position) {
5890
+ if (position >= this.length) {
5891
+ throw new Error("Position outside of list range");
5833
5892
  }
5834
- if (isElement(n2) && n2.shadowRoot) {
5835
- for (const childN of Array.from(n2.shadowRoot.childNodes)) {
5836
- const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
5837
- if (serializedChildNode) {
5838
- isNativeShadowDom(n2.shadowRoot) && (serializedChildNode.isShadow = true);
5839
- serializedNode.childNodes.push(serializedChildNode);
5840
- }
5841
- }
5893
+ let current = this.head;
5894
+ for (let index = 0; index < position; index++) {
5895
+ current = (current === null || current === void 0 ? void 0 : current.next) || null;
5842
5896
  }
5897
+ return current;
5843
5898
  }
5844
- if (n2.parentNode && isShadowRoot(n2.parentNode) && isNativeShadowDom(n2.parentNode)) {
5845
- serializedNode.isShadow = true;
5846
- }
5847
- if (serializedNode.type === NodeType.Element && serializedNode.tagName === "iframe") {
5848
- onceIframeLoaded(n2, () => {
5849
- const iframeDoc = n2.contentDocument;
5850
- if (iframeDoc && onIframeLoad) {
5851
- const serializedIframeNode = serializeNodeWithId(iframeDoc, {
5852
- doc: iframeDoc,
5853
- mirror: mirror2,
5854
- blockClass,
5855
- blockSelector,
5856
- needsMask,
5857
- maskTextClass,
5858
- maskTextSelector,
5859
- skipChild: false,
5860
- inlineStylesheet,
5861
- maskInputOptions,
5862
- maskTextFn,
5863
- maskInputFn,
5864
- slimDOMOptions,
5865
- dataURLOptions,
5866
- inlineImages,
5867
- recordCanvas,
5868
- preserveWhiteSpace,
5869
- onSerialize,
5870
- onIframeLoad,
5871
- iframeLoadTimeout,
5872
- onStylesheetLoad,
5873
- stylesheetLoadTimeout,
5874
- keepIframeSrcFn
5875
- });
5876
- if (serializedIframeNode) {
5877
- onIframeLoad(n2, serializedIframeNode);
5878
- }
5899
+ addNode(n2) {
5900
+ const node = {
5901
+ value: n2,
5902
+ previous: null,
5903
+ next: null
5904
+ };
5905
+ n2.__ln = node;
5906
+ if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
5907
+ const current = n2.previousSibling.__ln.next;
5908
+ node.next = current;
5909
+ node.previous = n2.previousSibling.__ln;
5910
+ n2.previousSibling.__ln.next = node;
5911
+ if (current) {
5912
+ current.previous = node;
5879
5913
  }
5880
- }, iframeLoadTimeout);
5914
+ } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
5915
+ const current = n2.nextSibling.__ln.previous;
5916
+ node.previous = current;
5917
+ node.next = n2.nextSibling.__ln;
5918
+ n2.nextSibling.__ln.previous = node;
5919
+ if (current) {
5920
+ current.next = node;
5921
+ }
5922
+ } else {
5923
+ if (this.head) {
5924
+ this.head.previous = node;
5925
+ }
5926
+ node.next = this.head;
5927
+ this.head = node;
5928
+ }
5929
+ if (node.next === null) {
5930
+ this.tail = node;
5931
+ }
5932
+ this.length++;
5881
5933
  }
5882
- if (serializedNode.type === NodeType.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
5883
- onceStylesheetLoaded(n2, () => {
5884
- if (onStylesheetLoad) {
5885
- const serializedLinkNode = serializeNodeWithId(n2, {
5886
- doc,
5887
- mirror: mirror2,
5888
- blockClass,
5889
- blockSelector,
5890
- needsMask,
5891
- maskTextClass,
5892
- maskTextSelector,
5893
- skipChild: false,
5894
- inlineStylesheet,
5895
- maskInputOptions,
5896
- maskTextFn,
5897
- maskInputFn,
5898
- slimDOMOptions,
5899
- dataURLOptions,
5900
- inlineImages,
5901
- recordCanvas,
5902
- preserveWhiteSpace,
5903
- onSerialize,
5904
- onIframeLoad,
5905
- iframeLoadTimeout,
5906
- onStylesheetLoad,
5907
- stylesheetLoadTimeout,
5908
- keepIframeSrcFn
5909
- });
5910
- if (serializedLinkNode) {
5911
- onStylesheetLoad(n2, serializedLinkNode);
5912
- }
5934
+ removeNode(n2) {
5935
+ const current = n2.__ln;
5936
+ if (!this.head) {
5937
+ return;
5938
+ }
5939
+ if (!current.previous) {
5940
+ this.head = current.next;
5941
+ if (this.head) {
5942
+ this.head.previous = null;
5943
+ } else {
5944
+ this.tail = null;
5913
5945
  }
5914
- }, stylesheetLoadTimeout);
5915
- }
5916
- return serializedNode;
5917
- }
5918
- function snapshot(n2, options) {
5919
- const { mirror: mirror2 = new Mirror(), blockClass = "rr-block", blockSelector = null, maskTextClass = "rr-mask", maskTextSelector = null, inlineStylesheet = true, inlineImages = false, recordCanvas = false, maskAllInputs = false, maskTextFn, maskInputFn, slimDOM = false, dataURLOptions, preserveWhiteSpace, onSerialize, onIframeLoad, iframeLoadTimeout, onStylesheetLoad, stylesheetLoadTimeout, keepIframeSrcFn = () => false } = options || {};
5920
- const maskInputOptions = maskAllInputs === true ? {
5921
- color: true,
5922
- date: true,
5923
- "datetime-local": true,
5924
- email: true,
5925
- month: true,
5926
- number: true,
5927
- range: true,
5928
- search: true,
5929
- tel: true,
5930
- text: true,
5931
- time: true,
5932
- url: true,
5933
- week: true,
5934
- textarea: true,
5935
- select: true,
5936
- password: true
5937
- } : maskAllInputs === false ? {
5938
- password: true
5939
- } : maskAllInputs;
5940
- const slimDOMOptions = slimDOM === true || slimDOM === "all" ? {
5941
- script: true,
5942
- comment: true,
5943
- headFavicon: true,
5944
- headWhitespace: true,
5945
- headMetaDescKeywords: slimDOM === "all",
5946
- headMetaSocial: true,
5947
- headMetaRobots: true,
5948
- headMetaHttpEquiv: true,
5949
- headMetaAuthorship: true,
5950
- headMetaVerification: true
5951
- } : slimDOM === false ? {} : slimDOM;
5952
- return serializeNodeWithId(n2, {
5953
- doc: n2,
5954
- mirror: mirror2,
5955
- blockClass,
5956
- blockSelector,
5957
- maskTextClass,
5958
- maskTextSelector,
5959
- skipChild: false,
5960
- inlineStylesheet,
5961
- maskInputOptions,
5962
- maskTextFn,
5963
- maskInputFn,
5964
- slimDOMOptions,
5965
- dataURLOptions,
5966
- inlineImages,
5967
- recordCanvas,
5968
- preserveWhiteSpace,
5969
- onSerialize,
5970
- onIframeLoad,
5971
- iframeLoadTimeout,
5972
- onStylesheetLoad,
5973
- stylesheetLoadTimeout,
5974
- keepIframeSrcFn,
5975
- newlyAddedElement: false
5976
- });
5977
- }
5978
- function on(type, fn, target = document) {
5979
- const options = { capture: true, passive: true };
5980
- target.addEventListener(type, fn, options);
5981
- return () => target.removeEventListener(type, fn, options);
5982
- }
5983
- 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.";
5984
- let _mirror = {
5985
- map: {},
5986
- getId() {
5987
- console.error(DEPARTED_MIRROR_ACCESS_WARNING);
5988
- return -1;
5989
- },
5990
- getNode() {
5991
- console.error(DEPARTED_MIRROR_ACCESS_WARNING);
5992
- return null;
5993
- },
5994
- removeNodeFromMap() {
5995
- console.error(DEPARTED_MIRROR_ACCESS_WARNING);
5996
- },
5997
- has() {
5998
- console.error(DEPARTED_MIRROR_ACCESS_WARNING);
5999
- return false;
6000
- },
6001
- reset() {
6002
- console.error(DEPARTED_MIRROR_ACCESS_WARNING);
6003
- }
6004
- };
6005
- if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
6006
- _mirror = new Proxy(_mirror, {
6007
- get(target, prop, receiver) {
6008
- if (prop === "map") {
6009
- console.error(DEPARTED_MIRROR_ACCESS_WARNING);
6010
- }
6011
- return Reflect.get(target, prop, receiver);
6012
- }
6013
- });
6014
- }
6015
- function throttle(func, wait, options = {}) {
6016
- let timeout = null;
6017
- let previous = 0;
6018
- return function(...args) {
6019
- const now = Date.now();
6020
- if (!previous && options.leading === false) {
6021
- previous = now;
6022
- }
6023
- const remaining = wait - (now - previous);
6024
- const context = this;
6025
- if (remaining <= 0 || remaining > wait) {
6026
- if (timeout) {
6027
- clearTimeout(timeout);
6028
- timeout = null;
6029
- }
6030
- previous = now;
6031
- func.apply(context, args);
6032
- } else if (!timeout && options.trailing !== false) {
6033
- timeout = setTimeout(() => {
6034
- previous = options.leading === false ? 0 : Date.now();
6035
- timeout = null;
6036
- func.apply(context, args);
6037
- }, remaining);
6038
- }
6039
- };
6040
- }
6041
- function hookSetter(target, key, d2, isRevoked, win2 = window) {
6042
- const original = win2.Object.getOwnPropertyDescriptor(target, key);
6043
- win2.Object.defineProperty(target, key, isRevoked ? d2 : {
6044
- set(value) {
6045
- setTimeout(() => {
6046
- d2.set.call(this, value);
6047
- }, 0);
6048
- if (original && original.set) {
6049
- original.set.call(this, value);
6050
- }
6051
- }
6052
- });
6053
- return () => hookSetter(target, key, original || {}, true);
6054
- }
6055
- function patch(source, name, replacement) {
6056
- try {
6057
- if (!(name in source)) {
6058
- return () => {
6059
- };
6060
- }
6061
- const original = source[name];
6062
- const wrapped = replacement(original);
6063
- if (typeof wrapped === "function") {
6064
- wrapped.prototype = wrapped.prototype || {};
6065
- Object.defineProperties(wrapped, {
6066
- __rrweb_original__: {
6067
- enumerable: false,
6068
- value: original
6069
- }
6070
- });
6071
- }
6072
- source[name] = wrapped;
6073
- return () => {
6074
- source[name] = original;
6075
- };
6076
- } catch (_a) {
6077
- return () => {
6078
- };
6079
- }
6080
- }
6081
- let nowTimestamp = Date.now;
6082
- if (!/[1-9][0-9]{12}/.test(Date.now().toString())) {
6083
- nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
6084
- }
6085
- function getWindowScroll(win2) {
6086
- var _a, _b, _c, _d, _e, _f;
6087
- const doc = win2.document;
6088
- return {
6089
- left: doc.scrollingElement ? doc.scrollingElement.scrollLeft : win2.pageXOffset !== void 0 ? win2.pageXOffset : (doc === null || doc === void 0 ? void 0 : doc.documentElement.scrollLeft) || ((_b = (_a = doc === null || doc === void 0 ? void 0 : doc.body) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.scrollLeft) || ((_c = doc === null || doc === void 0 ? void 0 : doc.body) === null || _c === void 0 ? void 0 : _c.scrollLeft) || 0,
6090
- top: doc.scrollingElement ? doc.scrollingElement.scrollTop : win2.pageYOffset !== void 0 ? win2.pageYOffset : (doc === null || doc === void 0 ? void 0 : doc.documentElement.scrollTop) || ((_e = (_d = doc === null || doc === void 0 ? void 0 : doc.body) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.scrollTop) || ((_f = doc === null || doc === void 0 ? void 0 : doc.body) === null || _f === void 0 ? void 0 : _f.scrollTop) || 0
6091
- };
6092
- }
6093
- function getWindowHeight() {
6094
- return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
6095
- }
6096
- function getWindowWidth() {
6097
- return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
6098
- }
6099
- function closestElementOfNode(node) {
6100
- if (!node) {
6101
- return null;
6102
- }
6103
- const el = node.nodeType === node.ELEMENT_NODE ? node : node.parentElement;
6104
- return el;
6105
- }
6106
- function isBlocked(node, blockClass, blockSelector, checkAncestors) {
6107
- if (!node) {
6108
- return false;
6109
- }
6110
- const el = closestElementOfNode(node);
6111
- if (!el) {
6112
- return false;
6113
- }
6114
- try {
6115
- if (typeof blockClass === "string") {
6116
- if (el.classList.contains(blockClass))
6117
- return true;
6118
- if (checkAncestors && el.closest("." + blockClass) !== null)
6119
- return true;
6120
- } else {
6121
- if (classMatchesRegex(el, blockClass, checkAncestors))
6122
- return true;
6123
- }
6124
- } catch (e2) {
6125
- }
6126
- if (blockSelector) {
6127
- if (el.matches(blockSelector))
6128
- return true;
6129
- if (checkAncestors && el.closest(blockSelector) !== null)
6130
- return true;
6131
- }
6132
- return false;
6133
- }
6134
- function isSerialized(n2, mirror2) {
6135
- return mirror2.getId(n2) !== -1;
6136
- }
6137
- function isIgnored(n2, mirror2) {
6138
- return mirror2.getId(n2) === IGNORED_NODE;
6139
- }
6140
- function isAncestorRemoved(target, mirror2) {
6141
- if (isShadowRoot(target)) {
6142
- return false;
6143
- }
6144
- const id = mirror2.getId(target);
6145
- if (!mirror2.has(id)) {
6146
- return true;
6147
- }
6148
- if (target.parentNode && target.parentNode.nodeType === target.DOCUMENT_NODE) {
6149
- return false;
6150
- }
6151
- if (!target.parentNode) {
6152
- return true;
6153
- }
6154
- return isAncestorRemoved(target.parentNode, mirror2);
6155
- }
6156
- function legacy_isTouchEvent(event) {
6157
- return Boolean(event.changedTouches);
6158
- }
6159
- function polyfill(win2 = window) {
6160
- if ("NodeList" in win2 && !win2.NodeList.prototype.forEach) {
6161
- win2.NodeList.prototype.forEach = Array.prototype.forEach;
6162
- }
6163
- if ("DOMTokenList" in win2 && !win2.DOMTokenList.prototype.forEach) {
6164
- win2.DOMTokenList.prototype.forEach = Array.prototype.forEach;
6165
- }
6166
- if (!Node.prototype.contains) {
6167
- Node.prototype.contains = (...args) => {
6168
- let node = args[0];
6169
- if (!(0 in args)) {
6170
- throw new TypeError("1 argument is required");
6171
- }
6172
- do {
6173
- if (this === node) {
6174
- return true;
6175
- }
6176
- } while (node = node && node.parentNode);
6177
- return false;
6178
- };
6179
- }
6180
- }
6181
- function isSerializedIframe(n2, mirror2) {
6182
- return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
6183
- }
6184
- function isSerializedStylesheet(n2, mirror2) {
6185
- return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
6186
- }
6187
- function hasShadowRoot(n2) {
6188
- return Boolean(n2 === null || n2 === void 0 ? void 0 : n2.shadowRoot);
6189
- }
6190
- class StyleSheetMirror {
6191
- constructor() {
6192
- this.id = 1;
6193
- this.styleIDMap = /* @__PURE__ */ new WeakMap();
6194
- this.idStyleMap = /* @__PURE__ */ new Map();
6195
- }
6196
- getId(stylesheet) {
6197
- var _a;
6198
- return (_a = this.styleIDMap.get(stylesheet)) !== null && _a !== void 0 ? _a : -1;
6199
- }
6200
- has(stylesheet) {
6201
- return this.styleIDMap.has(stylesheet);
6202
- }
6203
- add(stylesheet, id) {
6204
- if (this.has(stylesheet))
6205
- return this.getId(stylesheet);
6206
- let newId;
6207
- if (id === void 0) {
6208
- newId = this.id++;
6209
- } else
6210
- newId = id;
6211
- this.styleIDMap.set(stylesheet, newId);
6212
- this.idStyleMap.set(newId, stylesheet);
6213
- return newId;
6214
- }
6215
- getStyle(id) {
6216
- return this.idStyleMap.get(id) || null;
6217
- }
6218
- reset() {
6219
- this.styleIDMap = /* @__PURE__ */ new WeakMap();
6220
- this.idStyleMap = /* @__PURE__ */ new Map();
6221
- this.id = 1;
6222
- }
6223
- generateId() {
6224
- return this.id++;
6225
- }
6226
- }
6227
- function getShadowHost(n2) {
6228
- var _a, _b;
6229
- let shadowHost = null;
6230
- if (((_b = (_a = n2.getRootNode) === null || _a === void 0 ? void 0 : _a.call(n2)) === null || _b === void 0 ? void 0 : _b.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && n2.getRootNode().host)
6231
- shadowHost = n2.getRootNode().host;
6232
- return shadowHost;
6233
- }
6234
- function getRootShadowHost(n2) {
6235
- let rootShadowHost = n2;
6236
- let shadowHost;
6237
- while (shadowHost = getShadowHost(rootShadowHost))
6238
- rootShadowHost = shadowHost;
6239
- return rootShadowHost;
6240
- }
6241
- function shadowHostInDom(n2) {
6242
- const doc = n2.ownerDocument;
6243
- if (!doc)
6244
- return false;
6245
- const shadowHost = getRootShadowHost(n2);
6246
- return doc.contains(shadowHost);
6247
- }
6248
- function inDom(n2) {
6249
- const doc = n2.ownerDocument;
6250
- if (!doc)
6251
- return false;
6252
- return doc.contains(n2) || shadowHostInDom(n2);
6253
- }
6254
- var EventType$1 = /* @__PURE__ */ ((EventType2) => {
6255
- EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
6256
- EventType2[EventType2["Load"] = 1] = "Load";
6257
- EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
6258
- EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
6259
- EventType2[EventType2["Meta"] = 4] = "Meta";
6260
- EventType2[EventType2["Custom"] = 5] = "Custom";
6261
- EventType2[EventType2["Plugin"] = 6] = "Plugin";
6262
- return EventType2;
6263
- })(EventType$1 || {});
6264
- var IncrementalSource$1 = /* @__PURE__ */ ((IncrementalSource2) => {
6265
- IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
6266
- IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
6267
- IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
6268
- IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
6269
- IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
6270
- IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
6271
- IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
6272
- IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
6273
- IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
6274
- IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
6275
- IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
6276
- IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
6277
- IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
6278
- IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
6279
- IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
6280
- IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
6281
- IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
6282
- return IncrementalSource2;
6283
- })(IncrementalSource$1 || {});
6284
- var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
6285
- MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
6286
- MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
6287
- MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
6288
- MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
6289
- MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
6290
- MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
6291
- MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
6292
- MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
6293
- MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
6294
- MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
6295
- MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
6296
- return MouseInteractions2;
6297
- })(MouseInteractions || {});
6298
- var PointerTypes = /* @__PURE__ */ ((PointerTypes2) => {
6299
- PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
6300
- PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
6301
- PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
6302
- return PointerTypes2;
6303
- })(PointerTypes || {});
6304
- var CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {
6305
- CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
6306
- CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
6307
- CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
6308
- return CanvasContext2;
6309
- })(CanvasContext || {});
6310
- function isNodeInLinkedList(n2) {
6311
- return "__ln" in n2;
6312
- }
6313
- class DoubleLinkedList {
6314
- constructor() {
6315
- this.length = 0;
6316
- this.head = null;
6317
- this.tail = null;
6318
- }
6319
- get(position) {
6320
- if (position >= this.length) {
6321
- throw new Error("Position outside of list range");
6322
- }
6323
- let current = this.head;
6324
- for (let index = 0; index < position; index++) {
6325
- current = (current === null || current === void 0 ? void 0 : current.next) || null;
6326
- }
6327
- return current;
6328
- }
6329
- addNode(n2) {
6330
- const node = {
6331
- value: n2,
6332
- previous: null,
6333
- next: null
6334
- };
6335
- n2.__ln = node;
6336
- if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
6337
- const current = n2.previousSibling.__ln.next;
6338
- node.next = current;
6339
- node.previous = n2.previousSibling.__ln;
6340
- n2.previousSibling.__ln.next = node;
6341
- if (current) {
6342
- current.previous = node;
6343
- }
6344
- } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
6345
- const current = n2.nextSibling.__ln.previous;
6346
- node.previous = current;
6347
- node.next = n2.nextSibling.__ln;
6348
- n2.nextSibling.__ln.previous = node;
6349
- if (current) {
6350
- current.next = node;
6351
- }
6352
- } else {
6353
- if (this.head) {
6354
- this.head.previous = node;
6355
- }
6356
- node.next = this.head;
6357
- this.head = node;
6358
- }
6359
- if (node.next === null) {
6360
- this.tail = node;
6361
- }
6362
- this.length++;
6363
- }
6364
- removeNode(n2) {
6365
- const current = n2.__ln;
6366
- if (!this.head) {
6367
- return;
6368
- }
6369
- if (!current.previous) {
6370
- this.head = current.next;
6371
- if (this.head) {
6372
- this.head.previous = null;
6373
- } else {
6374
- this.tail = null;
6375
- }
6376
- } else {
6377
- current.previous.next = current.next;
6378
- if (current.next) {
6379
- current.next.previous = current.previous;
6380
- } else {
6381
- this.tail = current.previous;
6382
- }
6383
- }
6384
- if (n2.__ln) {
6385
- delete n2.__ln;
6386
- }
6387
- this.length--;
5946
+ } else {
5947
+ current.previous.next = current.next;
5948
+ if (current.next) {
5949
+ current.next.previous = current.previous;
5950
+ } else {
5951
+ this.tail = current.previous;
5952
+ }
5953
+ }
5954
+ if (n2.__ln) {
5955
+ delete n2.__ln;
5956
+ }
5957
+ this.length--;
6388
5958
  }
6389
5959
  }
6390
5960
  const moveKey = (id, parentId) => `${id}@${parentId}`;
@@ -7480,8 +7050,8 @@ function initSelectionObserver(param) {
7480
7050
  collapsed = selection.isCollapsed || false;
7481
7051
  const ranges = [];
7482
7052
  const count = selection.rangeCount || 0;
7483
- for (let i = 0; i < count; i++) {
7484
- const range = selection.getRangeAt(i);
7053
+ for (let i2 = 0; i2 < count; i2++) {
7054
+ const range = selection.getRangeAt(i2);
7485
7055
  const { startContainer, startOffset, endContainer, endOffset } = range;
7486
7056
  const blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
7487
7057
  if (blocked)
@@ -8011,9 +7581,9 @@ function __rest(s2, e2) {
8011
7581
  for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2) && e2.indexOf(p2) < 0)
8012
7582
  t2[p2] = s2[p2];
8013
7583
  if (s2 != null && typeof Object.getOwnPropertySymbols === "function")
8014
- for (var i = 0, p2 = Object.getOwnPropertySymbols(s2); i < p2.length; i++) {
8015
- if (e2.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i]))
8016
- t2[p2[i]] = s2[p2[i]];
7584
+ for (var i2 = 0, p2 = Object.getOwnPropertySymbols(s2); i2 < p2.length; i2++) {
7585
+ if (e2.indexOf(p2[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i2]))
7586
+ t2[p2[i2]] = s2[p2[i2]];
8017
7587
  }
8018
7588
  return t2;
8019
7589
  }
@@ -8046,16 +7616,16 @@ function __awaiter(thisArg, _arguments, P2, generator) {
8046
7616
  }
8047
7617
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
8048
7618
  var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
8049
- for (var i = 0; i < chars.length; i++) {
8050
- lookup[chars.charCodeAt(i)] = i;
7619
+ for (var i$2 = 0; i$2 < chars.length; i$2++) {
7620
+ lookup[chars.charCodeAt(i$2)] = i$2;
8051
7621
  }
8052
7622
  var encode = function(arraybuffer) {
8053
- var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = "";
8054
- for (i = 0; i < len; i += 3) {
8055
- base64 += chars[bytes[i] >> 2];
8056
- base64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
8057
- base64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
8058
- base64 += chars[bytes[i + 2] & 63];
7623
+ var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
7624
+ for (i2 = 0; i2 < len; i2 += 3) {
7625
+ base64 += chars[bytes[i2] >> 2];
7626
+ base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
7627
+ base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
7628
+ base64 += chars[bytes[i2 + 2] & 63];
8059
7629
  }
8060
7630
  if (len % 3 === 2) {
8061
7631
  base64 = base64.substring(0, base64.length - 1) + "=";
@@ -8310,8 +7880,8 @@ function funcToSource(fn, sourcemapArg) {
8310
7880
  lines.shift();
8311
7881
  var blankPrefixLength = lines[0].search(/\S/);
8312
7882
  var regex = /(['"])__worker_loader_strict__(['"])/g;
8313
- for (var i = 0, n2 = lines.length; i < n2; ++i) {
8314
- lines[i] = lines[i].substring(blankPrefixLength).replace(regex, "$1use strict$2") + "\n";
7883
+ for (var i2 = 0, n2 = lines.length; i2 < n2; ++i2) {
7884
+ lines[i2] = lines[i2].substring(blankPrefixLength).replace(regex, "$1use strict$2") + "\n";
8315
7885
  }
8316
7886
  return lines;
8317
7887
  }
@@ -8375,16 +7945,16 @@ var WorkerFactory = createInlineWorkerFactory(
8375
7945
  }
8376
7946
  var chars2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
8377
7947
  var lookup2 = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
8378
- for (var i = 0; i < chars2.length; i++) {
8379
- lookup2[chars2.charCodeAt(i)] = i;
7948
+ for (var i2 = 0; i2 < chars2.length; i2++) {
7949
+ lookup2[chars2.charCodeAt(i2)] = i2;
8380
7950
  }
8381
7951
  var encode2 = function(arraybuffer) {
8382
- var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
8383
- for (i2 = 0; i2 < len; i2 += 3) {
8384
- base64 += chars2[bytes[i2] >> 2];
8385
- base64 += chars2[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
8386
- base64 += chars2[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
8387
- base64 += chars2[bytes[i2 + 2] & 63];
7952
+ var bytes = new Uint8Array(arraybuffer), i3, len = bytes.length, base64 = "";
7953
+ for (i3 = 0; i3 < len; i3 += 3) {
7954
+ base64 += chars2[bytes[i3] >> 2];
7955
+ base64 += chars2[(bytes[i3] & 3) << 4 | bytes[i3 + 1] >> 4];
7956
+ base64 += chars2[(bytes[i3 + 1] & 15) << 2 | bytes[i3 + 2] >> 6];
7957
+ base64 += chars2[bytes[i3 + 2] & 63];
8388
7958
  }
8389
7959
  if (len % 3 === 2) {
8390
7960
  base64 = base64.substring(0, base64.length - 1) + "=";
@@ -9267,8 +8837,8 @@ _.each = function(obj, iterator, context) {
9267
8837
  if (nativeForEach && obj.forEach === nativeForEach) {
9268
8838
  obj.forEach(iterator, context);
9269
8839
  } else if (obj.length === +obj.length) {
9270
- for (var i = 0, l2 = obj.length; i < l2; i++) {
9271
- if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
8840
+ for (var i2 = 0, l2 = obj.length; i2 < l2; i2++) {
8841
+ if (i2 in obj && iterator.call(context, obj[i2], i2, obj) === breaker) {
9272
8842
  return;
9273
8843
  }
9274
8844
  }
@@ -9478,7 +9048,7 @@ _.JSONEncode = /* @__PURE__ */ function() {
9478
9048
  var str = function(key, holder) {
9479
9049
  var gap = "";
9480
9050
  var indent = " ";
9481
- var i = 0;
9051
+ var i2 = 0;
9482
9052
  var k2 = "";
9483
9053
  var v2 = "";
9484
9054
  var length = 0;
@@ -9504,8 +9074,8 @@ _.JSONEncode = /* @__PURE__ */ function() {
9504
9074
  partial = [];
9505
9075
  if (toString.apply(value2) === "[object Array]") {
9506
9076
  length = value2.length;
9507
- for (i = 0; i < length; i += 1) {
9508
- partial[i] = str(i, value2) || "null";
9077
+ for (i2 = 0; i2 < length; i2 += 1) {
9078
+ partial[i2] = str(i2, value2) || "null";
9509
9079
  }
9510
9080
  v2 = partial.length === 0 ? "[]" : gap ? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]" : "[" + partial.join(",") + "]";
9511
9081
  gap = mind;
@@ -9586,7 +9156,7 @@ _.JSONDecode = function() {
9586
9156
  return number2;
9587
9157
  }
9588
9158
  }, string = function() {
9589
- var hex, i, string2 = "", uffff;
9159
+ var hex, i2, string2 = "", uffff;
9590
9160
  if (ch === '"') {
9591
9161
  while (next()) {
9592
9162
  if (ch === '"') {
@@ -9597,7 +9167,7 @@ _.JSONDecode = function() {
9597
9167
  next();
9598
9168
  if (ch === "u") {
9599
9169
  uffff = 0;
9600
- for (i = 0; i < 4; i += 1) {
9170
+ for (i2 = 0; i2 < 4; i2 += 1) {
9601
9171
  hex = parseInt(next(), 16);
9602
9172
  if (!isFinite(hex)) {
9603
9173
  break;
@@ -9722,22 +9292,22 @@ _.JSONDecode = function() {
9722
9292
  }();
9723
9293
  _.base64Encode = function(data) {
9724
9294
  var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
9725
- var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, enc = "", tmp_arr = [];
9295
+ var o1, o2, o3, h1, h2, h3, h4, bits, i2 = 0, ac = 0, enc = "", tmp_arr = [];
9726
9296
  if (!data) {
9727
9297
  return data;
9728
9298
  }
9729
9299
  data = _.utf8Encode(data);
9730
9300
  do {
9731
- o1 = data.charCodeAt(i++);
9732
- o2 = data.charCodeAt(i++);
9733
- o3 = data.charCodeAt(i++);
9301
+ o1 = data.charCodeAt(i2++);
9302
+ o2 = data.charCodeAt(i2++);
9303
+ o3 = data.charCodeAt(i2++);
9734
9304
  bits = o1 << 16 | o2 << 8 | o3;
9735
9305
  h1 = bits >> 18 & 63;
9736
9306
  h2 = bits >> 12 & 63;
9737
9307
  h3 = bits >> 6 & 63;
9738
9308
  h4 = bits & 63;
9739
9309
  tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
9740
- } while (i < data.length);
9310
+ } while (i2 < data.length);
9741
9311
  enc = tmp_arr.join("");
9742
9312
  switch (data.length % 3) {
9743
9313
  case 1:
@@ -9796,7 +9366,7 @@ _.UUID = /* @__PURE__ */ function() {
9796
9366
  return Math.random().toString(16).replace(".", "");
9797
9367
  };
9798
9368
  var UA = function() {
9799
- var ua = userAgent, i, ch, buffer = [], ret = 0;
9369
+ var ua = userAgent, i2, ch, buffer = [], ret = 0;
9800
9370
  function xor(result, byte_array) {
9801
9371
  var j2, tmp = 0;
9802
9372
  for (j2 = 0; j2 < byte_array.length; j2++) {
@@ -9804,8 +9374,8 @@ _.UUID = /* @__PURE__ */ function() {
9804
9374
  }
9805
9375
  return result ^ tmp;
9806
9376
  }
9807
- for (i = 0; i < ua.length; i++) {
9808
- ch = ua.charCodeAt(i);
9377
+ for (i2 = 0; i2 < ua.length; i2++) {
9378
+ ch = ua.charCodeAt(i2);
9809
9379
  buffer.unshift(ch & 255);
9810
9380
  if (buffer.length >= 4) {
9811
9381
  ret = xor(ret, buffer);
@@ -9850,10 +9420,10 @@ var BLOCKED_UA_STRS = [
9850
9420
  "storebot-google"
9851
9421
  ];
9852
9422
  _.isBlockedUA = function(ua) {
9853
- var i;
9423
+ var i2;
9854
9424
  ua = ua.toLowerCase();
9855
- for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
9856
- if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
9425
+ for (i2 = 0; i2 < BLOCKED_UA_STRS.length; i2++) {
9426
+ if (ua.indexOf(BLOCKED_UA_STRS[i2]) !== -1) {
9857
9427
  return true;
9858
9428
  }
9859
9429
  }
@@ -9890,8 +9460,8 @@ _.cookie = {
9890
9460
  get: function(name) {
9891
9461
  var nameEQ = name + "=";
9892
9462
  var ca = document$1.cookie.split(";");
9893
- for (var i = 0; i < ca.length; i++) {
9894
- var c2 = ca[i];
9463
+ for (var i2 = 0; i2 < ca.length; i2++) {
9464
+ var c2 = ca[i2];
9895
9465
  while (c2.charAt(0) == " ") {
9896
9466
  c2 = c2.substring(1, c2.length);
9897
9467
  }
@@ -10083,10 +9653,10 @@ _.dom_query = /* @__PURE__ */ function() {
10083
9653
  return [];
10084
9654
  }
10085
9655
  var tokens = selector.split(" ");
10086
- var token, bits, tagName, found, foundCount, i, j2, k2, elements, currentContextIndex;
9656
+ var token, bits, tagName, found, foundCount, i2, j2, k2, elements, currentContextIndex;
10087
9657
  var currentContext = [document$1];
10088
- for (i = 0; i < tokens.length; i++) {
10089
- token = tokens[i].replace(/^\s+/, "").replace(/\s+$/, "");
9658
+ for (i2 = 0; i2 < tokens.length; i2++) {
9659
+ token = tokens[i2].replace(/^\s+/, "").replace(/\s+$/, "");
10090
9660
  if (token.indexOf("#") > -1) {
10091
9661
  bits = token.split("#");
10092
9662
  tagName = bits[0];
@@ -10621,7 +10191,7 @@ SharedLock.prototype.withLock = function(lockedCB, errorCB, pid) {
10621
10191
  pid = errorCB;
10622
10192
  errorCB = null;
10623
10193
  }
10624
- var i = pid || (/* @__PURE__ */ new Date()).getTime() + "|" + Math.random();
10194
+ var i2 = pid || (/* @__PURE__ */ new Date()).getTime() + "|" + Math.random();
10625
10195
  var startTime = (/* @__PURE__ */ new Date()).getTime();
10626
10196
  var key = this.storageKey;
10627
10197
  var pollIntervalMS = this.pollIntervalMS;
@@ -10635,7 +10205,7 @@ SharedLock.prototype.withLock = function(lockedCB, errorCB, pid) {
10635
10205
  };
10636
10206
  var delay = function(cb) {
10637
10207
  if ((/* @__PURE__ */ new Date()).getTime() - startTime > timeoutMS) {
10638
- logger$3.error("Timeout waiting for mutex on " + key + "; clearing lock. [" + i + "]");
10208
+ logger$3.error("Timeout waiting for mutex on " + key + "; clearing lock. [" + i2 + "]");
10639
10209
  storage.removeItem(keyZ);
10640
10210
  storage.removeItem(keyY);
10641
10211
  loop();
@@ -10660,11 +10230,11 @@ SharedLock.prototype.withLock = function(lockedCB, errorCB, pid) {
10660
10230
  };
10661
10231
  var getSetY = function() {
10662
10232
  var valY = storage.getItem(keyY);
10663
- if (valY && valY !== i) {
10233
+ if (valY && valY !== i2) {
10664
10234
  return false;
10665
10235
  } else {
10666
- storage.setItem(keyY, i);
10667
- if (storage.getItem(keyY) === i) {
10236
+ storage.setItem(keyY, i2);
10237
+ if (storage.getItem(keyY) === i2) {
10668
10238
  return true;
10669
10239
  } else {
10670
10240
  if (!localStorageSupported(storage, true)) {
@@ -10675,14 +10245,14 @@ SharedLock.prototype.withLock = function(lockedCB, errorCB, pid) {
10675
10245
  }
10676
10246
  };
10677
10247
  var loop = function() {
10678
- storage.setItem(keyX, i);
10248
+ storage.setItem(keyX, i2);
10679
10249
  waitFor(getSetY, function() {
10680
- if (storage.getItem(keyX) === i) {
10250
+ if (storage.getItem(keyX) === i2) {
10681
10251
  criticalSection();
10682
10252
  return;
10683
10253
  }
10684
10254
  delay(function() {
10685
- if (storage.getItem(keyY) !== i) {
10255
+ if (storage.getItem(keyY) !== i2) {
10686
10256
  loop();
10687
10257
  return;
10688
10258
  }
@@ -10698,10 +10268,10 @@ SharedLock.prototype.withLock = function(lockedCB, errorCB, pid) {
10698
10268
  lockedCB();
10699
10269
  } finally {
10700
10270
  storage.removeItem(keyZ);
10701
- if (storage.getItem(keyY) === i) {
10271
+ if (storage.getItem(keyY) === i2) {
10702
10272
  storage.removeItem(keyY);
10703
10273
  }
10704
- if (storage.getItem(keyX) === i) {
10274
+ if (storage.getItem(keyX) === i2) {
10705
10275
  storage.removeItem(keyX);
10706
10276
  }
10707
10277
  }
@@ -10772,8 +10342,8 @@ RequestQueue.prototype.fillBatch = function(batchSize) {
10772
10342
  _.each(batch, function(item2) {
10773
10343
  idsInBatch[item2["id"]] = true;
10774
10344
  });
10775
- for (var i = 0; i < storedQueue.length; i++) {
10776
- var item = storedQueue[i];
10345
+ for (var i2 = 0; i2 < storedQueue.length; i2++) {
10346
+ var item = storedQueue[i2];
10777
10347
  if ((/* @__PURE__ */ new Date()).getTime() > item["flushAfter"] && !idsInBatch[item["id"]]) {
10778
10348
  item.orphaned = true;
10779
10349
  batch.push(item);
@@ -10814,8 +10384,8 @@ RequestQueue.prototype.removeItemsByID = function(ids, cb) {
10814
10384
  succeeded = this.saveToStorage(storedQueue);
10815
10385
  if (succeeded) {
10816
10386
  storedQueue = this.readFromStorage();
10817
- for (var i = 0; i < storedQueue.length; i++) {
10818
- var item = storedQueue[i];
10387
+ for (var i2 = 0; i2 < storedQueue.length; i2++) {
10388
+ var item = storedQueue[i2];
10819
10389
  if (item["id"] && !!idSet[item["id"]]) {
10820
10390
  this.reportError("Item not removed from storage");
10821
10391
  return false;
@@ -11824,7 +11394,7 @@ MixpanelPeople.prototype._flush = function(_set_callback, _add_callback, _append
11824
11394
  _append_callback(response, data);
11825
11395
  }
11826
11396
  };
11827
- for (var i = $append_queue.length - 1; i >= 0; i--) {
11397
+ for (var i2 = $append_queue.length - 1; i2 >= 0; i2--) {
11828
11398
  $append_queue = this._mixpanel["persistence"].load_queue(APPEND_ACTION);
11829
11399
  $append_item = $append_queue.pop();
11830
11400
  _this._mixpanel["persistence"].save();
@@ -13346,133 +12916,757 @@ var override_mp_init_func = function() {
13346
12916
  instance._loaded();
13347
12917
  instances[PRIMARY_INSTANCE_NAME] = instance;
13348
12918
  }
13349
- mixpanel_master = instance;
13350
- if (init_type === INIT_SNIPPET) {
13351
- win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
12919
+ mixpanel_master = instance;
12920
+ if (init_type === INIT_SNIPPET) {
12921
+ win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
12922
+ }
12923
+ extend_mp();
12924
+ }
12925
+ };
12926
+ };
12927
+ var add_dom_loaded_handler = function() {
12928
+ function dom_loaded_handler() {
12929
+ if (dom_loaded_handler.done) {
12930
+ return;
12931
+ }
12932
+ dom_loaded_handler.done = true;
12933
+ DOM_LOADED = true;
12934
+ ENQUEUE_REQUESTS = false;
12935
+ _.each(instances, function(inst) {
12936
+ inst._dom_loaded();
12937
+ });
12938
+ }
12939
+ function do_scroll_check() {
12940
+ try {
12941
+ document$1.documentElement.doScroll("left");
12942
+ } catch (e2) {
12943
+ setTimeout(do_scroll_check, 1);
12944
+ return;
12945
+ }
12946
+ dom_loaded_handler();
12947
+ }
12948
+ if (document$1.addEventListener) {
12949
+ if (document$1.readyState === "complete") {
12950
+ dom_loaded_handler();
12951
+ } else {
12952
+ document$1.addEventListener("DOMContentLoaded", dom_loaded_handler, false);
12953
+ }
12954
+ } else if (document$1.attachEvent) {
12955
+ document$1.attachEvent("onreadystatechange", dom_loaded_handler);
12956
+ var toplevel = false;
12957
+ try {
12958
+ toplevel = win.frameElement === null;
12959
+ } catch (e2) {
12960
+ }
12961
+ if (document$1.documentElement.doScroll && toplevel) {
12962
+ do_scroll_check();
12963
+ }
12964
+ }
12965
+ _.register_event(win, "load", dom_loaded_handler, true);
12966
+ };
12967
+ function init_as_module(bundle_loader) {
12968
+ load_extra_bundle = bundle_loader;
12969
+ init_type = INIT_MODULE;
12970
+ mixpanel_master = new MixpanelLib();
12971
+ override_mp_init_func();
12972
+ mixpanel_master["init"]();
12973
+ add_dom_loaded_handler();
12974
+ return mixpanel_master;
12975
+ }
12976
+ function loadNoop(_src, onload) {
12977
+ onload();
12978
+ }
12979
+ var mixpanel = init_as_module(loadNoop);
12980
+ function createIdentifyReporter() {
12981
+ const reported = /* @__PURE__ */ new Set();
12982
+ return (stage, reason, httpStatus) => {
12983
+ const key = `${stage}:${reason}`;
12984
+ if (reported.has(key)) return;
12985
+ reported.add(key);
12986
+ const payload = {
12987
+ stage,
12988
+ reason,
12989
+ ...httpStatus !== void 0 ? { httpStatus } : {}
12990
+ };
12991
+ try {
12992
+ if (mixpanelService.isReady()) {
12993
+ trackEventError(
12994
+ "Identify",
12995
+ new Error(`Identify ${stage}: ${reason}`),
12996
+ payload
12997
+ );
12998
+ } else {
12999
+ console.error("Identify diagnostic", payload);
13000
+ }
13001
+ } catch {
13002
+ console.error("Identify diagnostic", payload);
13003
+ }
13004
+ };
13005
+ }
13006
+ function waitForIdentifyReady(report) {
13007
+ if (mixpanelService.isReady()) return Promise.resolve(true);
13008
+ return new Promise((resolve) => {
13009
+ let active = true;
13010
+ const finish = (ready) => {
13011
+ if (!active) return;
13012
+ active = false;
13013
+ clearTimeout(timer);
13014
+ window.removeEventListener("Tracker Ready", onReady);
13015
+ if (!ready) report("readiness", "timeout");
13016
+ resolve(ready);
13017
+ };
13018
+ const onReady = () => {
13019
+ if (mixpanelService.isReady()) finish(true);
13020
+ };
13021
+ const timer = setTimeout(() => finish(false), 5e3);
13022
+ window.addEventListener("Tracker Ready", onReady);
13023
+ onReady();
13024
+ });
13025
+ }
13026
+ function waitForIdentifyStage(stage, timeout, run, report) {
13027
+ return new Promise((resolve) => {
13028
+ let active = true;
13029
+ const finish = (value) => {
13030
+ if (!active) return;
13031
+ active = false;
13032
+ clearTimeout(timer);
13033
+ resolve(value);
13034
+ };
13035
+ const timer = setTimeout(() => {
13036
+ report(stage, "timeout");
13037
+ finish();
13038
+ }, timeout);
13039
+ const context = {
13040
+ isActive: () => active,
13041
+ report: (...args) => {
13042
+ if (active) report(...args);
13043
+ }
13044
+ };
13045
+ void Promise.resolve().then(() => run(context)).then(
13046
+ (value) => finish(value),
13047
+ () => {
13048
+ if (active) report(stage, "failed");
13049
+ finish();
13050
+ }
13051
+ );
13052
+ });
13053
+ }
13054
+ function observeIdentifyResult(stage, report, onTimeout) {
13055
+ let active = true;
13056
+ const complete = (reason, httpStatus) => {
13057
+ if (!active) return;
13058
+ active = false;
13059
+ clearTimeout(timer);
13060
+ if (reason) report(stage, reason, httpStatus);
13061
+ };
13062
+ const timer = setTimeout(() => {
13063
+ complete(stage === "people" ? "unobserved" : "timeout");
13064
+ onTimeout == null ? void 0 : onTimeout();
13065
+ }, 5e3);
13066
+ return { complete };
13067
+ }
13068
+ const version = "1.1.7-alpha.1";
13069
+ const MIXPANEL_DISTINCT_ID_CACHE_KEY = "mp_distinct_id";
13070
+ const SDK_SUPER_PROPERTIES = {
13071
+ "Event Source": "sdk",
13072
+ "Reservamos Version": version
13073
+ };
13074
+ function init$2(mixpanelToken, debug = false, proxyUrl) {
13075
+ return new Promise((resolve) => {
13076
+ mixpanel.init(mixpanelToken, {
13077
+ debug,
13078
+ loaded: () => {
13079
+ window.mixpanel = mixpanel;
13080
+ mixpanel.register({ ...SDK_SUPER_PROPERTIES });
13081
+ resolve();
13082
+ },
13083
+ ...proxyUrl && { api_host: proxyUrl }
13084
+ });
13085
+ });
13086
+ }
13087
+ function identify$1(userId, properties, report) {
13088
+ mixpanel.identify(userId);
13089
+ try {
13090
+ updateCachedDistinctId(userId);
13091
+ } catch {
13092
+ report == null ? void 0 : report("cache", "unavailable");
13093
+ }
13094
+ if (!report) {
13095
+ mixpanel.people.set(properties);
13096
+ return;
13097
+ }
13098
+ const observer = observeIdentifyResult("people", report);
13099
+ try {
13100
+ mixpanel.people.set(properties, (response) => {
13101
+ const status = typeof response === "number" ? response : response == null ? void 0 : response.status;
13102
+ observer.complete(
13103
+ status === 1 ? void 0 : status === 0 ? "failed" : "unconfirmed"
13104
+ );
13105
+ });
13106
+ } catch {
13107
+ observer.complete("failed");
13108
+ }
13109
+ }
13110
+ function attachProperty(key, value) {
13111
+ if (!isReady()) {
13112
+ return;
13113
+ }
13114
+ mixpanel.people.union(key, [value]);
13115
+ }
13116
+ function setPeopleProperties(properties) {
13117
+ if (!isReady()) {
13118
+ return;
13119
+ }
13120
+ mixpanel.people.set(properties);
13121
+ }
13122
+ function isReady() {
13123
+ return window.mixpanel !== void 0;
13124
+ }
13125
+ function track(eventName, properties) {
13126
+ if (!isReady()) {
13127
+ return;
13128
+ }
13129
+ mixpanel.track(eventName, { ...properties, "Reservamos Version": version });
13130
+ }
13131
+ const getMixpanelDistinctId = () => {
13132
+ const cachedId = localStorage.getItem(MIXPANEL_DISTINCT_ID_CACHE_KEY);
13133
+ if (mixpanel && mixpanel.get_distinct_id) {
13134
+ const distinctId = mixpanel.get_distinct_id();
13135
+ updateCachedDistinctId(distinctId);
13136
+ return distinctId;
13137
+ } else if (cachedId) {
13138
+ return cachedId;
13139
+ }
13140
+ return null;
13141
+ };
13142
+ function updateCachedDistinctId(distinctId) {
13143
+ localStorage.setItem(MIXPANEL_DISTINCT_ID_CACHE_KEY, distinctId);
13144
+ }
13145
+ const mixpanelService = {
13146
+ init: init$2,
13147
+ isReady,
13148
+ track,
13149
+ identify: identify$1,
13150
+ attachProperty,
13151
+ setPeopleProperties,
13152
+ getMixpanelDistinctId
13153
+ };
13154
+ const DEFAULT_CACHE_NAME = "default_fingerprint_cache";
13155
+ const DEFAULT_CACHE_TIME_IN_DAYS = 7;
13156
+ const PROXY_QUERY_PARAM = "apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>";
13157
+ let fingerprintAgentReady = false;
13158
+ const getExpirationDate = (cacheTimeInDays) => {
13159
+ const currentDate = /* @__PURE__ */ new Date();
13160
+ const futureDate = new Date(
13161
+ currentDate.getTime() + cacheTimeInDays * 24 * 60 * 60 * 1e3
13162
+ );
13163
+ return futureDate.getTime();
13164
+ };
13165
+ const getCachedFingerprint = () => {
13166
+ return readCachedFingerprint();
13167
+ };
13168
+ function readCachedFingerprint(context) {
13169
+ const { cacheName = DEFAULT_CACHE_NAME } = window.fingerprintConfig;
13170
+ try {
13171
+ const cachedData = JSON.parse(localStorage.getItem(cacheName) || "null");
13172
+ if (cachedData && cachedData.expiresAt > Date.now()) {
13173
+ return cachedData.fingerprint;
13174
+ }
13175
+ localStorage.removeItem(cacheName);
13176
+ return null;
13177
+ } catch {
13178
+ context == null ? void 0 : context.report("cache", "unavailable");
13179
+ return null;
13180
+ }
13181
+ }
13182
+ const setCachedFingerprint = (fingerprint) => {
13183
+ const {
13184
+ cacheName = DEFAULT_CACHE_NAME,
13185
+ cacheTimeInDays = DEFAULT_CACHE_TIME_IN_DAYS
13186
+ } = window.fingerprintConfig;
13187
+ const cacheData = {
13188
+ fingerprint,
13189
+ expiresAt: getExpirationDate(cacheTimeInDays)
13190
+ };
13191
+ localStorage.setItem(cacheName, JSON.stringify(cacheData));
13192
+ };
13193
+ function buildProxyUrl(url) {
13194
+ return `${url}?${PROXY_QUERY_PARAM}`;
13195
+ }
13196
+ async function initFingerprint(apiKey, proxyUrl) {
13197
+ const customEndpointArray = [r$2];
13198
+ const customScriptEndpointArray = [G];
13199
+ if (proxyUrl) {
13200
+ customEndpointArray.unshift(proxyUrl);
13201
+ customScriptEndpointArray.unshift(buildProxyUrl(proxyUrl));
13202
+ }
13203
+ fingerprintAgentReady = false;
13204
+ window.fingerprintConfig = {};
13205
+ const client = new FpjsClient({
13206
+ loadOptions: {
13207
+ apiKey,
13208
+ endpoint: customEndpointArray,
13209
+ scriptUrlPattern: customScriptEndpointArray
13210
+ }
13211
+ });
13212
+ window.fpClient = client;
13213
+ try {
13214
+ await client.init();
13215
+ if (window.fpClient === client) {
13216
+ fingerprintAgentReady = true;
13217
+ }
13218
+ } catch (error) {
13219
+ if (window.fpClient === client) {
13220
+ fingerprintAgentReady = false;
13221
+ }
13222
+ console.error("Error initializing identification service:", error);
13223
+ throw error;
13224
+ }
13225
+ }
13226
+ async function getFingerprint(cacheOnly = false) {
13227
+ return readFingerprint(cacheOnly);
13228
+ }
13229
+ function getFingerprintForIdentify(context) {
13230
+ return readFingerprint(false, context);
13231
+ }
13232
+ async function readFingerprint(cacheOnly, context) {
13233
+ if (!window.fingerprintConfig) {
13234
+ if (cacheOnly) {
13235
+ return "";
13236
+ }
13237
+ throw new Error("Fingerprint configuration is not initialized.");
13238
+ }
13239
+ const cachedFingerprint = readCachedFingerprint(context);
13240
+ if (cachedFingerprint) {
13241
+ return cachedFingerprint;
13242
+ }
13243
+ if (cacheOnly || !isFingerprintReady()) {
13244
+ return "";
13245
+ }
13246
+ const { visitorId } = await requestIdentification(false, context);
13247
+ return visitorId;
13248
+ }
13249
+ async function identifyVisitor(ignoreCache = false) {
13250
+ return requestIdentification(ignoreCache);
13251
+ }
13252
+ async function requestIdentification(ignoreCache, context) {
13253
+ if (!isFingerprintReady()) {
13254
+ throw new Error("Identification service is not initialized.");
13255
+ }
13256
+ try {
13257
+ const result = await window.fpClient.getVisitorData({}, ignoreCache);
13258
+ if (!context || context.isActive()) {
13259
+ try {
13260
+ setCachedFingerprint(result.visitorId);
13261
+ } catch (error) {
13262
+ if (!context) throw error;
13263
+ context.report("cache", "unavailable");
13264
+ }
13265
+ if (typeof result.visitorFound === "boolean") {
13266
+ try {
13267
+ mixpanelService.setPeopleProperties({
13268
+ "Visitor Found": result.visitorFound
13269
+ });
13270
+ } catch (error) {
13271
+ if (context) context.report("fingerprint", "failed");
13272
+ else console.error("Error updating Mixpanel visitor profile:", error);
13273
+ }
13352
13274
  }
13353
- extend_mp();
13354
13275
  }
13355
- };
13276
+ return {
13277
+ visitorId: result.visitorId,
13278
+ requestId: result.requestId,
13279
+ ...typeof result.visitorFound === "boolean" ? { visitorFound: result.visitorFound } : {},
13280
+ confidenceScore: result.confidence.score,
13281
+ cacheHit: result.cacheHit
13282
+ };
13283
+ } catch (error) {
13284
+ if (!context) console.error("Error retrieving fingerprint:", error);
13285
+ throw error;
13286
+ }
13287
+ }
13288
+ function isFingerprintReady() {
13289
+ return window.fpClient !== void 0 && fingerprintAgentReady;
13290
+ }
13291
+ const fingerprintService = {
13292
+ initFingerprint,
13293
+ getFingerprint,
13294
+ identifyVisitor,
13295
+ isFingerprintReady,
13296
+ getCachedFingerprint
13356
13297
  };
13357
- var add_dom_loaded_handler = function() {
13358
- function dom_loaded_handler() {
13359
- if (dom_loaded_handler.done) {
13360
- return;
13361
- }
13362
- dom_loaded_handler.done = true;
13363
- DOM_LOADED = true;
13364
- ENQUEUE_REQUESTS = false;
13365
- _.each(instances, function(inst) {
13366
- inst._dom_loaded();
13367
- });
13298
+ const r$1 = {
13299
+ sandbox: {
13300
+ search: "https://search.resertravel.com/api",
13301
+ purchase: "https://purchases.resertravel.com/api",
13302
+ core: ""
13303
+ },
13304
+ production: {
13305
+ search: "https://search.reservamos.mx/api",
13306
+ purchase: "https://compras.reservamos.mx/api",
13307
+ core: ""
13368
13308
  }
13369
- function do_scroll_check() {
13370
- try {
13371
- document$1.documentElement.doScroll("left");
13372
- } catch (e2) {
13373
- setTimeout(do_scroll_check, 1);
13374
- return;
13309
+ }, s$2 = "sandbox", a$1 = "v2", t$2 = "v1", n$1 = {
13310
+ env: s$2,
13311
+ headers: {},
13312
+ searchUrl: r$1[s$2].search,
13313
+ purchaseUrl: r$1[s$2].purchase,
13314
+ coreUrl: r$1[s$2].core,
13315
+ version: a$1,
13316
+ coreVersion: t$2,
13317
+ apiKey: void 0,
13318
+ userAuthToken: void 0,
13319
+ withCredentials: false
13320
+ };
13321
+ let c$2 = Object.assign({}, n$1);
13322
+ const o$1 = {
13323
+ // UNAUTHORIZED
13324
+ 1: {
13325
+ code: 200,
13326
+ message: "Operación no autorizada"
13327
+ }
13328
+ }, s$1 = {
13329
+ // INCORRECT_PARAMS
13330
+ 3: {
13331
+ code: 300,
13332
+ message: "Parámetros incorrectos"
13333
+ },
13334
+ // INCORRECT_DATE
13335
+ 7: {
13336
+ code: 301,
13337
+ message: "Fecha inválida"
13338
+ }
13339
+ }, r = {
13340
+ // NONEXISTENT_TRIP
13341
+ 10: {
13342
+ code: 400,
13343
+ message: "No existe el viaje"
13344
+ },
13345
+ // journey_key_not_found
13346
+ 20: {
13347
+ code: 60,
13348
+ message: "No se encontró el viaje"
13349
+ },
13350
+ // sold_out_fare_code
13351
+ 21: {
13352
+ code: 60,
13353
+ message: "Tarifa no disponible"
13354
+ },
13355
+ // unavailable_fare_code
13356
+ 22: {
13357
+ code: 60,
13358
+ message: "Tarifa no disponible"
13359
+ }
13360
+ }, n = (e2) => ({
13361
+ // INVALID_DISCOUNT
13362
+ 11: {
13363
+ code: 500,
13364
+ message: e2
13365
+ },
13366
+ //EXPIRED_DISCOUNT
13367
+ 12: {
13368
+ code: 501,
13369
+ message: e2
13370
+ }
13371
+ }), a = {
13372
+ // unavailable_student
13373
+ 23: {
13374
+ code: 60,
13375
+ message: "Estudiante no disponible"
13376
+ },
13377
+ // unavailable_teacher
13378
+ 24: {
13379
+ code: 60,
13380
+ message: "Profesor no disponible"
13381
+ },
13382
+ // unavailable_minor
13383
+ 25: {
13384
+ code: 60,
13385
+ message: "Menor no disponible"
13386
+ },
13387
+ // unavailable_special
13388
+ 26: {
13389
+ code: 60,
13390
+ message: "Capacidades diferentes no disponible"
13391
+ },
13392
+ // unavailable_older
13393
+ 27: {
13394
+ code: 60,
13395
+ message: "INSEN no disponible"
13396
+ },
13397
+ // unavailable_general
13398
+ 28: {
13399
+ code: 60,
13400
+ message: "General no disponible"
13401
+ },
13402
+ // unavailable_unknown
13403
+ 29: {
13404
+ code: 60,
13405
+ message: "Error desconocido"
13406
+ }
13407
+ }, c$1 = (e2) => ({
13408
+ 30: {
13409
+ code: 30,
13410
+ message: e2
13411
+ }
13412
+ }), d$1 = {
13413
+ 50: {
13414
+ code: 50,
13415
+ message: "Unknow Error"
13416
+ }
13417
+ }, i$1 = (e2) => ({
13418
+ ...o$1,
13419
+ ...s$1,
13420
+ ...r,
13421
+ ...n(e2),
13422
+ ...a,
13423
+ ...d$1,
13424
+ ...c$1(e2)
13425
+ });
13426
+ class o extends Error {
13427
+ constructor(r2 = -100, s2 = "Unknown error", t2 = null) {
13428
+ super(s2), this.code = r2, this.details = t2, this.stack = new Error().stack;
13429
+ }
13430
+ }
13431
+ async function w(t2) {
13432
+ const e2 = [404, 422, 500], r2 = await t2.json();
13433
+ if (t2.ok)
13434
+ return r2;
13435
+ if (e2.includes(t2.status))
13436
+ switch (t2.status) {
13437
+ case 404:
13438
+ throw new o(100, "Not found");
13439
+ case 422:
13440
+ return r2;
13441
+ case 500:
13442
+ throw new o(101, "Server error");
13443
+ default:
13444
+ throw new o();
13375
13445
  }
13376
- dom_loaded_handler();
13446
+ else
13447
+ throw new o(t2.status, r2.message || t2.statusText, r2);
13448
+ }
13449
+ function l$1(t2) {
13450
+ if (t2.errors instanceof Array) {
13451
+ const { code: e2 = -100, message: r2 = "Unknown error" } = t2.errors[0] || {}, n2 = i$1(r2)[e2];
13452
+ throw n2 ? new o(n2.code, n2.message, t2.errors[0]) : new o(e2, r2, t2.errors[0]);
13453
+ } else
13454
+ return t2;
13455
+ }
13456
+ function y(...t2) {
13457
+ const r2 = Object.keys(Object.assign({}, ...t2)).reduce(
13458
+ (n2, o2) => ({
13459
+ ...n2,
13460
+ [o2]: t2.map((a2) => o2 in a2 && a2[o2]).filter(Boolean)
13461
+ }),
13462
+ {}
13463
+ );
13464
+ return new Headers(r2);
13465
+ }
13466
+ function c(t2, e2 = {}, r2 = {}, n2) {
13467
+ const {
13468
+ apiKey: o2,
13469
+ withCredentials: a2,
13470
+ userAuthToken: s2,
13471
+ headers: d2
13472
+ } = c$2, u3 = {
13473
+ Accept: "application/json",
13474
+ Authorization: `Token token=${r2.apiKey || o2}`,
13475
+ "Content-Type": "application/json"
13476
+ };
13477
+ return s2 && (u3.Authorization = `Token ${r2.apiKey || o2}, Bearer ${s2}`), e2.headers = y(d2, u3), e2.credentials = a2 ? "include" : "omit", typeof e2.body != "string" && (e2.body = JSON.stringify(e2.body)), fetch(t2, e2).then(w).then(l$1).catch(n2);
13478
+ }
13479
+ function E(t2, e2 = {}, r2) {
13480
+ return c(t2, e2, {}, r2);
13481
+ }
13482
+ let u$1 = class u {
13483
+ constructor({
13484
+ url: e2,
13485
+ watch: i2,
13486
+ expect: h2,
13487
+ maxRetries: t2 = 30,
13488
+ interval: s2 = 2e3,
13489
+ eachCall: c2 = null
13490
+ }) {
13491
+ this.url = e2, this.watch = i2, this.expect = h2 instanceof Array ? h2 : [h2], this.interval = s2, this.maxRetries = t2, this.eachCall = c2 && c2.bind(this), this.aborted = false, this.timers = [], this.execute = this.execute.bind(this), this.executeEachCall = this.executeEachCall.bind(this);
13492
+ }
13493
+ start() {
13494
+ return this.execute(this.maxRetries);
13495
+ }
13496
+ abort() {
13497
+ this.aborted = true;
13498
+ }
13499
+ execute(e2) {
13500
+ const i2 = (t2) => {
13501
+ if (this.expect.includes(t2[this.watch]) || e2 === 1 || this.aborted) {
13502
+ let s2 = t2[this.watch];
13503
+ e2 === 1 ? s2 = "retries_exceeded" : this.aborted && (s2 = "aborted"), this.timers.forEach(clearInterval), this.executeEachCall(s2, t2);
13504
+ } else if (t2[this.watch] === "failed")
13505
+ this.timers.forEach(clearInterval), this.executeEachCall("failed", t2);
13506
+ else {
13507
+ this.executeEachCall("pending", t2);
13508
+ const s2 = window.setTimeout(
13509
+ this.execute,
13510
+ this.interval,
13511
+ e2 - 1
13512
+ );
13513
+ this.timers.push(s2);
13514
+ }
13515
+ }, h2 = (t2) => this.executeEachCall("error", t2);
13516
+ return E(this.url, {}, h2).then(i2);
13377
13517
  }
13378
- if (document$1.addEventListener) {
13379
- if (document$1.readyState === "complete") {
13380
- dom_loaded_handler();
13381
- } else {
13382
- document$1.addEventListener("DOMContentLoaded", dom_loaded_handler, false);
13383
- }
13384
- } else if (document$1.attachEvent) {
13385
- document$1.attachEvent("onreadystatechange", dom_loaded_handler);
13386
- var toplevel = false;
13387
- try {
13388
- toplevel = win.frameElement === null;
13389
- } catch (e2) {
13390
- }
13391
- if (document$1.documentElement.doScroll && toplevel) {
13392
- do_scroll_check();
13393
- }
13518
+ executeEachCall(e2, i2) {
13519
+ this.eachCall instanceof Function && this.eachCall({ status: e2, payload: i2 }) && this.abort();
13394
13520
  }
13395
- _.register_event(win, "load", dom_loaded_handler, true);
13396
13521
  };
13397
- function init_as_module(bundle_loader) {
13398
- load_extra_bundle = bundle_loader;
13399
- init_type = INIT_MODULE;
13400
- mixpanel_master = new MixpanelLib();
13401
- override_mp_init_func();
13402
- mixpanel_master["init"]();
13403
- add_dom_loaded_handler();
13404
- return mixpanel_master;
13522
+ function j({
13523
+ apiName: h2,
13524
+ defaultApiVersion: c2
13525
+ }) {
13526
+ let n2, i2 = {
13527
+ "Content-Type": "application/json"
13528
+ }, r2;
13529
+ function f2(e2) {
13530
+ n2 = e2.baseUrl, i2 = {
13531
+ ...i2,
13532
+ ...e2.defaultHeaders || {}
13533
+ };
13534
+ }
13535
+ function p2(e2) {
13536
+ r2 = e2;
13537
+ }
13538
+ function d2() {
13539
+ if (!n2)
13540
+ throw new Error(`Base URL is not set for ${h2} API.`);
13541
+ }
13542
+ const $ = { body: {} };
13543
+ async function y2(e2, t2 = $) {
13544
+ d2();
13545
+ const { body: s2, headers: o2 = {}, apiVersion: a2 = c2 } = t2, u3 = `${n2}/${a2}/${e2}`, l2 = {
13546
+ ...i2,
13547
+ ...o2,
13548
+ ...r2 ? { Authorization: r2 } : {}
13549
+ };
13550
+ return (await fetch(u3, {
13551
+ method: "POST",
13552
+ body: JSON.stringify(s2),
13553
+ headers: l2
13554
+ })).json();
13555
+ }
13556
+ async function w2(e2, t2 = {}) {
13557
+ d2();
13558
+ const { headers: s2 = {}, apiVersion: o2 = c2 } = t2, a2 = `${n2}/${o2}/${e2}`;
13559
+ return (await fetch(a2, { headers: s2 })).json();
13560
+ }
13561
+ function H2(e2, t2) {
13562
+ const o2 = {
13563
+ url: `${n2}/${c2}/${e2}`,
13564
+ watch: t2.watch,
13565
+ expect: t2.expect,
13566
+ eachCall: t2.onEachResponse
13567
+ };
13568
+ return new u$1(o2);
13569
+ }
13570
+ async function b2(e2, t2 = {}) {
13571
+ d2();
13572
+ const { headers: s2 = {}, apiVersion: o2 = c2 } = t2, a2 = `${n2}/${o2}/${e2}`, u3 = {
13573
+ ...i2,
13574
+ ...s2,
13575
+ ...r2 ? { Authorization: r2 } : {}
13576
+ };
13577
+ return (await fetch(a2, {
13578
+ method: "DELETE",
13579
+ headers: u3
13580
+ })).json();
13581
+ }
13582
+ return {
13583
+ get: w2,
13584
+ post: y2,
13585
+ delete: b2,
13586
+ setAuthorizationHeader: p2,
13587
+ setConfig: f2,
13588
+ poll: H2
13589
+ };
13405
13590
  }
13406
- function loadNoop(_src, onload) {
13407
- onload();
13591
+ const t$1 = j({
13592
+ apiName: "Core",
13593
+ defaultApiVersion: "v1"
13594
+ });
13595
+ async function t(o2) {
13596
+ const { data: e2 } = await t$1.post(
13597
+ "anonymous_profiles/identify",
13598
+ {
13599
+ body: o2
13600
+ }
13601
+ );
13602
+ return e2;
13408
13603
  }
13409
- var mixpanel = init_as_module(loadNoop);
13410
- const version = "1.1.6";
13411
- const MIXPANEL_DISTINCT_ID_CACHE_KEY = "mp_distinct_id";
13412
- const EVENT_SOURCE_SUPER_PROPERTY = {
13413
- "Event Source": "sdk"
13604
+ const s = {
13605
+ createAnonymousProfile: t
13414
13606
  };
13415
- function init$2(mixpanelToken, debug = false, proxyUrl) {
13416
- return new Promise((resolve) => {
13417
- mixpanel.init(mixpanelToken, {
13418
- debug,
13419
- loaded: () => {
13420
- window.mixpanel = mixpanel;
13421
- mixpanel.register({ ...EVENT_SOURCE_SUPER_PROPERTY });
13422
- resolve();
13423
- },
13424
- ...proxyUrl && { api_host: proxyUrl }
13425
- });
13607
+ function d({
13608
+ searchId: e2,
13609
+ userIdentifier: t2
13610
+ }) {
13611
+ return t$1.get(
13612
+ `trip_recommendations/${e2}/${t2}`
13613
+ );
13614
+ }
13615
+ function i(e2) {
13616
+ return t$1.post("seat_recommendations", {
13617
+ body: e2
13426
13618
  });
13427
13619
  }
13428
- function identify$1(userId, properties) {
13429
- mixpanel.identify(userId);
13430
- updateCachedDistinctId(userId);
13431
- mixpanel.people.set(properties);
13620
+ function p({
13621
+ distinct_id: e2,
13622
+ ...t2
13623
+ }) {
13624
+ return t$1.post(`seat_recommendations/${e2}`, {
13625
+ body: t2
13626
+ });
13432
13627
  }
13433
- function attachProperty(key, value) {
13434
- if (!isReady()) {
13435
- return;
13436
- }
13437
- mixpanel.people.union(key, [value]);
13628
+ function u2(e2, t2) {
13629
+ const { start: o2, onEachResponse: r2 } = t2, c2 = `profiles/${e2}`, a2 = {
13630
+ watch: "state",
13631
+ expect: "finished",
13632
+ onEachResponse: r2
13633
+ }, s2 = t$1.poll(c2, a2);
13634
+ return o2 && s2.start(), s2;
13438
13635
  }
13439
- function setPeopleProperties(properties) {
13440
- if (!isReady()) {
13441
- return;
13442
- }
13443
- mixpanel.people.set(properties);
13636
+ async function m(e2) {
13637
+ return t$1.post("profiles", {
13638
+ body: e2
13639
+ });
13444
13640
  }
13445
- function isReady() {
13446
- return window.mixpanel !== void 0;
13641
+ async function l(e2) {
13642
+ return t$1.post("passengers", {
13643
+ body: e2
13644
+ });
13447
13645
  }
13448
- function track(eventName, properties) {
13449
- if (!isReady()) {
13450
- return;
13451
- }
13452
- mixpanel.track(eventName, { ...properties, "Reservamos Version": version });
13646
+ async function f$1(e2) {
13647
+ return t$1.get(
13648
+ `passengers/${e2}`
13649
+ );
13453
13650
  }
13454
- const getMixpanelDistinctId = () => {
13455
- const cachedId = localStorage.getItem(MIXPANEL_DISTINCT_ID_CACHE_KEY);
13456
- if (mixpanel && mixpanel.get_distinct_id) {
13457
- const distinctId = mixpanel.get_distinct_id();
13458
- updateCachedDistinctId(distinctId);
13459
- return distinctId;
13460
- } else if (cachedId) {
13461
- return cachedId;
13462
- }
13463
- return null;
13464
- };
13465
- function updateCachedDistinctId(distinctId) {
13466
- localStorage.setItem(MIXPANEL_DISTINCT_ID_CACHE_KEY, distinctId);
13651
+ async function g(e2, t2) {
13652
+ return t$1.delete(
13653
+ `passengers/${e2}/${t2}`
13654
+ );
13467
13655
  }
13468
- const mixpanelService = {
13469
- init: init$2,
13470
- isReady,
13471
- track,
13472
- identify: identify$1,
13473
- attachProperty,
13474
- setPeopleProperties,
13475
- getMixpanelDistinctId
13656
+ const R = {
13657
+ getRecommendedTrips: d,
13658
+ createRecommendedPlaces: m,
13659
+ pollRecommendedPlaces: u2,
13660
+ createRecommendedSeats: i,
13661
+ getRecommendedSeats: p,
13662
+ getFrequentPassengers: f$1,
13663
+ createFrequentPassengers: l,
13664
+ deleteFrequentPassenger: g
13665
+ };
13666
+ const f = {
13667
+ setConfig: t$1.setConfig,
13668
+ recommendations: R,
13669
+ profiles: s
13476
13670
  };
13477
13671
  const geolocationSelectedSchema = z.object({
13478
13672
  "Selected City": z.string().min(1, "Selected city is required"),
@@ -14146,9 +14340,18 @@ async function trackEvent(eventName, eventProperties, meta = {}) {
14146
14340
  }
14147
14341
  try {
14148
14342
  validatorService.parseEventProps(eventName, eventProperties);
14149
- const cacheOnly = !FP_TRIGGER_EVENTS.includes(eventName);
14150
- mixpanelService.getMixpanelDistinctId();
14151
- const fingerprint = await fingerprintService.getFingerprint(cacheOnly);
14343
+ const distinctId = mixpanelService.getMixpanelDistinctId();
14344
+ const botDetectionEnabled = botDetectionRelayService.isEnabledFor(eventName);
14345
+ let fingerprint;
14346
+ let fingerprintRequestId;
14347
+ if (botDetectionEnabled && fingerprintService.isFingerprintReady()) {
14348
+ const identification = await fingerprintService.identifyVisitor(true);
14349
+ fingerprint = identification.visitorId;
14350
+ fingerprintRequestId = identification.requestId;
14351
+ } else {
14352
+ const cacheOnly = !FP_TRIGGER_EVENTS.includes(eventName);
14353
+ fingerprint = await fingerprintService.getFingerprint(cacheOnly);
14354
+ }
14152
14355
  const defaultCoordinates = {};
14153
14356
  const coordinates = geolocationService.getCoordinates();
14154
14357
  const geolocationSource = geolocationService.getGeolocationSource();
@@ -14172,6 +14375,14 @@ async function trackEvent(eventName, eventProperties, meta = {}) {
14172
14375
  ...meta
14173
14376
  };
14174
14377
  mixpanelService.track(eventName, properties);
14378
+ if (fingerprintRequestId) {
14379
+ void botDetectionRelayService.relay({
14380
+ requestId: fingerprintRequestId,
14381
+ visitorId: fingerprint,
14382
+ ...distinctId && { distinctId },
14383
+ eventName
14384
+ });
14385
+ }
14175
14386
  } catch (error) {
14176
14387
  console.error(`Error tracking event '${eventName}':`, error);
14177
14388
  trackEventError(eventName, error, eventProperties);
@@ -14260,20 +14471,37 @@ function getAnonymousProfilePayload(values, identifiersProps) {
14260
14471
  }
14261
14472
  async function createAnonymousProfile(payload) {
14262
14473
  try {
14263
- validatorService.validateProps(payload, CreateAnonymousProfileSchema);
14264
- const identifiers = [];
14265
- const userFingerprintId = fingerprintService.getCachedFingerprint();
14266
- const distinctId = mixpanelService.getMixpanelDistinctId();
14267
- if (userFingerprintId)
14268
- identifiers.push({ key: "fingerprint", value: userFingerprintId });
14269
- if (distinctId) identifiers.push({ key: "distinct_id", value: distinctId });
14270
- const dataPayload = getAnonymousProfilePayload(payload, identifiers);
14271
- return await f.profiles.createAnonymousProfile(dataPayload);
14474
+ return await requestAnonymousProfile(payload);
14272
14475
  } catch (error) {
14273
14476
  console.error("Could not create anonymous profile:", error);
14274
14477
  return void 0;
14275
14478
  }
14276
14479
  }
14480
+ function createAnonymousProfileForIdentify(payload, report) {
14481
+ return requestAnonymousProfile(payload, report);
14482
+ }
14483
+ async function requestAnonymousProfile(payload, report) {
14484
+ validatorService.validateProps(payload, CreateAnonymousProfileSchema);
14485
+ const identifiers = [];
14486
+ const readIdentifier = (read) => {
14487
+ if (!report) return read();
14488
+ try {
14489
+ return read();
14490
+ } catch {
14491
+ report("cache", "unavailable");
14492
+ return null;
14493
+ }
14494
+ };
14495
+ const userFingerprintId = readIdentifier(
14496
+ fingerprintService.getCachedFingerprint
14497
+ );
14498
+ const distinctId = readIdentifier(mixpanelService.getMixpanelDistinctId);
14499
+ if (userFingerprintId)
14500
+ identifiers.push({ key: "fingerprint", value: userFingerprintId });
14501
+ if (distinctId) identifiers.push({ key: "distinct_id", value: distinctId });
14502
+ const dataPayload = getAnonymousProfilePayload(payload, identifiers);
14503
+ return await f.profiles.createAnonymousProfile(dataPayload);
14504
+ }
14277
14505
  const KNOWN_PROPERTIES = ["firstName", "lastName", "email", "phone"];
14278
14506
  const FINGERPRINT_PROPERTY = "Known Fingerprints";
14279
14507
  function mapProperties(properties) {
@@ -14294,8 +14522,9 @@ function mapProperties(properties) {
14294
14522
  );
14295
14523
  return { ...parsedProperties, ...additionalProperties };
14296
14524
  }
14297
- const identifyWithLocation = async (userId, properties) => {
14525
+ const identifyWithLocation = async (userId, properties, report) => {
14298
14526
  var _a, _b, _c;
14527
+ let observer;
14299
14528
  try {
14300
14529
  const coordinates = geolocationService.getCoordinates();
14301
14530
  if (!coordinates) {
@@ -14310,50 +14539,87 @@ const identifyWithLocation = async (userId, properties) => {
14310
14539
  delete properties.firstName;
14311
14540
  delete properties.lastName;
14312
14541
  const coreApiConfig = configService.getCoreAPIConfig();
14313
- fetch(`${coreApiConfig.baseUrl}/v1/datalake/identify`, {
14314
- method: "POST",
14315
- headers: {
14316
- "Content-Type": "application/json",
14317
- "Authorization": ((_a = coreApiConfig.defaultHeaders) == null ? void 0 : _a.Authorization) || "",
14318
- "Origin": ((_b = coreApiConfig.defaultHeaders) == null ? void 0 : _b.Origin) || "",
14319
- ...((_c = coreApiConfig.defaultHeaders) == null ? void 0 : _c["x-app-name"]) ? { "x-app-name": coreApiConfig.defaultHeaders["x-app-name"] } : {}
14320
- },
14321
- body: JSON.stringify({
14322
- profile_params: {
14323
- ...properties,
14324
- distinct_id: userId
14325
- }
14326
- })
14327
- });
14328
- } catch (error) {
14329
- console.error("Error identifying user-service", error);
14542
+ const controller = new AbortController();
14543
+ observer = observeIdentifyResult(
14544
+ "datalake",
14545
+ report,
14546
+ () => controller.abort()
14547
+ );
14548
+ const response = await fetch(
14549
+ `${coreApiConfig.baseUrl}/v1/datalake/identify`,
14550
+ {
14551
+ method: "POST",
14552
+ signal: controller.signal,
14553
+ headers: {
14554
+ "Content-Type": "application/json",
14555
+ "Authorization": ((_a = coreApiConfig.defaultHeaders) == null ? void 0 : _a.Authorization) || "",
14556
+ "Origin": ((_b = coreApiConfig.defaultHeaders) == null ? void 0 : _b.Origin) || "",
14557
+ ...((_c = coreApiConfig.defaultHeaders) == null ? void 0 : _c["x-app-name"]) ? { "x-app-name": coreApiConfig.defaultHeaders["x-app-name"] } : {}
14558
+ },
14559
+ body: JSON.stringify({
14560
+ profile_params: {
14561
+ ...properties,
14562
+ distinct_id: userId
14563
+ }
14564
+ })
14565
+ }
14566
+ );
14567
+ observer.complete(
14568
+ response.ok ? void 0 : "http_error",
14569
+ response.ok ? void 0 : response.status
14570
+ );
14571
+ } catch {
14572
+ if (observer) observer.complete("failed");
14573
+ else report("datalake", "failed");
14330
14574
  }
14331
14575
  };
14332
14576
  async function identify(userId, properties = {}) {
14333
- tryTrackEvent(async () => {
14577
+ const report = createIdentifyReporter();
14578
+ if (!await waitForIdentifyReady(report)) return;
14579
+ try {
14334
14580
  try {
14335
14581
  validatorService.parseIdentifyProps(properties);
14336
14582
  if (!userId) {
14337
- console.error("User ID is required for identification.");
14338
- throw new Error("User ID is required for identification.");
14339
- }
14340
- const anonymousProfile = await createAnonymousProfile(properties);
14341
- if (anonymousProfile) {
14342
- properties.reservamos_one_id = anonymousProfile.id;
14583
+ report("validation", "invalid_input");
14584
+ return;
14343
14585
  }
14344
- const mappedProps = mapProperties(properties);
14345
- mixpanelService.identify(userId, mappedProps);
14346
- const fingerprint = await fingerprintService.getFingerprint();
14347
- if (fingerprint) {
14586
+ } catch {
14587
+ report("validation", "invalid_input");
14588
+ return;
14589
+ }
14590
+ const anonymousProfile = await waitForIdentifyStage(
14591
+ "profile",
14592
+ 3e3,
14593
+ (context) => createAnonymousProfileForIdentify({ ...properties }, context.report),
14594
+ report
14595
+ );
14596
+ if (anonymousProfile) {
14597
+ properties.reservamos_one_id = anonymousProfile.id;
14598
+ }
14599
+ const mappedProps = mapProperties(properties);
14600
+ try {
14601
+ mixpanelService.identify(userId, mappedProps, report);
14602
+ } catch {
14603
+ report("mixpanel", "failed");
14604
+ }
14605
+ const fingerprint = await waitForIdentifyStage(
14606
+ "fingerprint",
14607
+ 2e3,
14608
+ getFingerprintForIdentify,
14609
+ report
14610
+ );
14611
+ if (fingerprint) {
14612
+ try {
14348
14613
  mixpanelService.attachProperty(FINGERPRINT_PROPERTY, fingerprint);
14614
+ } catch {
14615
+ report("fingerprint", "failed");
14349
14616
  }
14350
- } catch (error) {
14351
- console.error("Error identifying user", error);
14352
- trackEventError("Identify", error, { userId, properties });
14353
- } finally {
14354
- identifyWithLocation(userId, properties);
14355
14617
  }
14356
- });
14618
+ } catch {
14619
+ report("mixpanel", "failed");
14620
+ } finally {
14621
+ void identifyWithLocation(userId, properties, report);
14622
+ }
14357
14623
  }
14358
14624
  z.object({
14359
14625
  "Operation Id": stringField("Operation Id"),