makethisbetter 1.1.1 → 1.1.2

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.
@@ -410,12 +410,12 @@ class wt {
410
410
  <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
411
411
  </svg>
412
412
  </div>
413
- <button class="mtb-clarify-skip">${L(t.clarify.skip)}</button>
413
+ <button class="mtb-clarify-skip">${T(t.clarify.skip)}</button>
414
414
  </div>
415
415
  <div class="mtb-clarify-messages"></div>
416
416
  <div class="mtb-clarify-footer">
417
- <input class="mtb-clarify-input" type="text" placeholder="${L(t.clarify.placeholder)}" />
418
- <button class="mtb-clarify-send" disabled>${L(t.clarify.send)}</button>
417
+ <input class="mtb-clarify-input" type="text" placeholder="${T(t.clarify.placeholder)}" />
418
+ <button class="mtb-clarify-send" disabled>${T(t.clarify.send)}</button>
419
419
  </div>
420
420
  `;
421
421
  }
@@ -495,7 +495,7 @@ class wt {
495
495
  this.destroyed = !0, this.stopPolling(), this.doneTimer !== null && (clearTimeout(this.doneTimer), this.doneTimer = null), this.el.remove();
496
496
  }
497
497
  }
498
- function L(i) {
498
+ function T(i) {
499
499
  return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
500
500
  }
501
501
  const kt = 5e3;
@@ -563,7 +563,7 @@ function Y(i, t = {}) {
563
563
  const e = t.width || Ct(i), s = t.height || Mt(i);
564
564
  return { width: e, height: s };
565
565
  }
566
- function Tt() {
566
+ function Lt() {
567
567
  let i, t;
568
568
  try {
569
569
  t = process;
@@ -573,7 +573,7 @@ function Tt() {
573
573
  return e && (i = parseInt(e, 10), Number.isNaN(i) && (i = 1)), i || window.devicePixelRatio || 1;
574
574
  }
575
575
  const d = 16384;
576
- function Lt(i) {
576
+ function Tt(i) {
577
577
  (i.width > d || i.height > d) && (i.width > d && i.height > d ? i.width > i.height ? (i.height *= d / i.width, i.width = d) : (i.width *= d / i.height, i.height = d) : i.width > d ? (i.height *= d / i.width, i.width = d) : (i.width *= d / i.height, i.height = d));
578
578
  }
579
579
  function C(i) {
@@ -589,7 +589,7 @@ function C(i) {
589
589
  async function At(i) {
590
590
  return Promise.resolve().then(() => new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then((t) => `data:image/svg+xml;charset=utf-8,${t}`);
591
591
  }
592
- async function Pt(i, t, e) {
592
+ async function Dt(i, t, e) {
593
593
  const s = "http://www.w3.org/2000/svg", r = document.createElementNS(s, "svg"), n = document.createElementNS(s, "foreignObject");
594
594
  return r.setAttribute("width", `${t}`), r.setAttribute("height", `${e}`), r.setAttribute("viewBox", `0 0 ${t} ${e}`), n.setAttribute("width", "100%"), n.setAttribute("height", "100%"), n.setAttribute("x", "0"), n.setAttribute("y", "0"), n.setAttribute("externalResourcesRequired", "true"), r.appendChild(n), n.appendChild(i), At(r);
595
595
  }
@@ -599,18 +599,18 @@ const h = (i, t) => {
599
599
  const e = Object.getPrototypeOf(i);
600
600
  return e === null ? !1 : e.constructor.name === t.name || h(e, t);
601
601
  };
602
- function Rt(i) {
602
+ function Pt(i) {
603
603
  const t = i.getPropertyValue("content");
604
604
  return `${i.cssText} content: '${t.replace(/'|"/g, "")}';`;
605
605
  }
606
- function Dt(i, t) {
606
+ function Rt(i, t) {
607
607
  return V(t).map((e) => {
608
608
  const s = i.getPropertyValue(e), r = i.getPropertyPriority(e);
609
609
  return `${e}: ${s}${r ? " !important" : ""};`;
610
610
  }).join(" ");
611
611
  }
612
612
  function _t(i, t, e, s) {
613
- const r = `.${i}:${t}`, n = e.cssText ? Rt(e) : Dt(e, s);
613
+ const r = `.${i}:${t}`, n = e.cssText ? Pt(e) : Rt(e, s);
614
614
  return document.createTextNode(`${r}{${n}}`);
615
615
  }
616
616
  function I(i, t, e, s) {
@@ -646,14 +646,14 @@ function It(i) {
646
646
  const t = /\.([^./]*?)$/g.exec(i);
647
647
  return t ? t[1] : "";
648
648
  }
649
- function D(i) {
649
+ function R(i) {
650
650
  const t = It(i).toLowerCase();
651
651
  return $t[t] || "";
652
652
  }
653
653
  function Ot(i) {
654
654
  return i.split(/,/)[1];
655
655
  }
656
- function P(i) {
656
+ function D(i) {
657
657
  return i.search(/^(data:)/) !== -1;
658
658
  }
659
659
  function Ft(i, t) {
@@ -707,7 +707,7 @@ async function zt(i, t) {
707
707
  const a = n.toDataURL();
708
708
  return C(a);
709
709
  }
710
- const e = i.poster, s = D(e), r = await _(e, s, t);
710
+ const e = i.poster, s = R(e), r = await _(e, s, t);
711
711
  return C(r);
712
712
  }
713
713
  async function Bt(i, t) {
@@ -788,11 +788,11 @@ function Zt(i) {
788
788
  }
789
789
  function te(i) {
790
790
  const t = [];
791
- return i.replace(K, (e, s, r) => (t.push(r), e)), t.filter((e) => !P(e));
791
+ return i.replace(K, (e, s, r) => (t.push(r), e)), t.filter((e) => !D(e));
792
792
  }
793
793
  async function ee(i, t, e, s, r) {
794
794
  try {
795
- const n = e ? Et(t, e) : t, o = D(t);
795
+ const n = e ? Et(t, e) : t, o = R(t);
796
796
  let a;
797
797
  return r || (a = await _(n, o, s)), i.replace(Zt(t), `$1${a}$3`);
798
798
  } catch {
@@ -833,9 +833,9 @@ async function se(i, t) {
833
833
  }
834
834
  async function re(i, t) {
835
835
  const e = h(i, HTMLImageElement);
836
- if (!(e && !P(i.src)) && !(h(i, SVGImageElement) && !P(i.href.baseVal)))
836
+ if (!(e && !D(i.src)) && !(h(i, SVGImageElement) && !D(i.href.baseVal)))
837
837
  return;
838
- const s = e ? i.src : i.href.baseVal, r = await _(s, D(s), t);
838
+ const s = e ? i.src : i.href.baseVal, r = await _(s, R(s), t);
839
839
  await new Promise((n, o) => {
840
840
  i.onload = n, i.onerror = t.onImageErrorHandler ? (...l) => {
841
841
  try {
@@ -913,12 +913,12 @@ async function ae(i, t) {
913
913
  p(r.cssRules || []).forEach((n, o) => {
914
914
  if (n.type === CSSRule.IMPORT_RULE) {
915
915
  let a = o + 1;
916
- const l = n.href, c = U(l).then((u) => z(u, t)).then((u) => B(u).forEach((T) => {
916
+ const l = n.href, c = U(l).then((u) => z(u, t)).then((u) => B(u).forEach((L) => {
917
917
  try {
918
- r.insertRule(T, T.startsWith("@import") ? a += 1 : r.cssRules.length);
918
+ r.insertRule(L, L.startsWith("@import") ? a += 1 : r.cssRules.length);
919
919
  } catch (it) {
920
920
  console.error("Error inserting rule from remote css", {
921
- rule: T,
921
+ rule: L,
922
922
  error: it
923
923
  });
924
924
  }
@@ -987,11 +987,11 @@ async function ue(i, t) {
987
987
  }
988
988
  async function pe(i, t = {}) {
989
989
  const { width: e, height: s } = Y(i, t), r = await M(i, t, !0);
990
- return await ue(r, t), await Z(r, t), oe(r, t), await Pt(r, e, s);
990
+ return await ue(r, t), await Z(r, t), oe(r, t), await Dt(r, e, s);
991
991
  }
992
992
  async function fe(i, t = {}) {
993
- const { width: e, height: s } = Y(i, t), r = await pe(i, t), n = await C(r), o = document.createElement("canvas"), a = o.getContext("2d"), l = t.pixelRatio || Tt(), c = t.canvasWidth || e, u = t.canvasHeight || s;
994
- return o.width = c * l, o.height = u * l, t.skipAutoScale || Lt(o), o.style.width = `${c}`, o.style.height = `${u}`, t.backgroundColor && (a.fillStyle = t.backgroundColor, a.fillRect(0, 0, o.width, o.height)), a.drawImage(n, 0, 0, o.width, o.height), o;
993
+ const { width: e, height: s } = Y(i, t), r = await pe(i, t), n = await C(r), o = document.createElement("canvas"), a = o.getContext("2d"), l = t.pixelRatio || Lt(), c = t.canvasWidth || e, u = t.canvasHeight || s;
994
+ return o.width = c * l, o.height = u * l, t.skipAutoScale || Tt(o), o.style.width = `${c}`, o.style.height = `${u}`, t.backgroundColor && (a.fillStyle = t.backgroundColor, a.fillRect(0, 0, o.width, o.height)), a.drawImage(n, 0, 0, o.width, o.height), o;
995
995
  }
996
996
  async function me(i, t = {}) {
997
997
  return (await fe(i, t)).toDataURL();
@@ -1095,7 +1095,7 @@ class Ee {
1095
1095
  this.unsubscribe?.(), this.unsubscribe = null;
1096
1096
  }
1097
1097
  }
1098
- const Se = 3, Ce = 1e3, Me = 3, Te = 5e3, Le = 500, Ae = 500, Pe = 300, Re = /* @__PURE__ */ new Set([
1098
+ const Se = 3, Ce = 1e3, Me = 3, Le = 5e3, Te = 500, Ae = 500, De = 300, Pe = /* @__PURE__ */ new Set([
1099
1099
  "A",
1100
1100
  "BUTTON",
1101
1101
  "INPUT",
@@ -1104,7 +1104,7 @@ const Se = 3, Ce = 1e3, Me = 3, Te = 5e3, Le = 500, Ae = 500, Pe = 300, Re = /*
1104
1104
  "LABEL",
1105
1105
  "SUMMARY",
1106
1106
  "DETAILS"
1107
- ]), De = /* @__PURE__ */ new Set([
1107
+ ]), Re = /* @__PURE__ */ new Set([
1108
1108
  "button",
1109
1109
  "link",
1110
1110
  "checkbox",
@@ -1127,7 +1127,7 @@ const Se = 3, Ce = 1e3, Me = 3, Te = 5e3, Le = 500, Ae = 500, Pe = 300, Re = /*
1127
1127
  "internal server error"
1128
1128
  ], v = class v {
1129
1129
  constructor(t) {
1130
- this.clickHistory = [], this.unsubscribeErrors = null, this.active = !1, this.errorCount = 0, this.deadClickCount = 0, this.cooldownUntil = 0, this.navTimestamps = [], this.boundPopstateHandler = null, this.originalPushState = null, this.originalReplaceState = null, this.installedPushState = null, this.installedReplaceState = null, this.boundSubmitHandler = null, this.boundInvalidHandler = null, this.errorPageUrls = /* @__PURE__ */ new Set(), this.pendingObservers = [], this.onFrustration = t, this.boundClickHandler = (e) => this.handleClick(e);
1130
+ this.clickHistory = [], this.unsubscribeErrors = null, this.active = !1, this.errorCount = 0, this.deadClickCount = 0, this.cooldownUntil = 0, this.navTimestamps = [], this.boundPopstateHandler = null, this.originalPushState = null, this.originalReplaceState = null, this.installedPushState = null, this.installedReplaceState = null, this.boundSubmitHandler = null, this.boundInvalidHandler = null, this.errorPageUrls = /* @__PURE__ */ new Set(), this.domObserver = null, this.pendingDomChecks = 0, this.lastMutationAt = -1, this.onFrustration = t, this.boundClickHandler = (e) => this.handleClick(e);
1131
1131
  }
1132
1132
  start() {
1133
1133
  this.active || (this.active = !0, document.addEventListener("click", this.boundClickHandler, !0), this.unsubscribeErrors = et.subscribe((t) => {
@@ -1135,11 +1135,7 @@ const Se = 3, Ce = 1e3, Me = 3, Te = 5e3, Le = 500, Ae = 500, Pe = 300, Re = /*
1135
1135
  }), this.startNavigationTracking(), this.startFormTracking(), this.checkErrorPage());
1136
1136
  }
1137
1137
  stop() {
1138
- if (this.active) {
1139
- this.active = !1, document.removeEventListener("click", this.boundClickHandler, !0), this.unsubscribeErrors?.(), this.unsubscribeErrors = null, this.clickHistory = [], this.stopNavigationTracking(), this.stopFormTracking(), this.errorPageUrls.clear();
1140
- for (const t of this.pendingObservers) t.disconnect();
1141
- this.pendingObservers = [];
1142
- }
1138
+ this.active && (this.active = !1, document.removeEventListener("click", this.boundClickHandler, !0), this.unsubscribeErrors?.(), this.unsubscribeErrors = null, this.clickHistory = [], this.stopNavigationTracking(), this.stopFormTracking(), this.errorPageUrls.clear(), this.disconnectDomObserver());
1143
1139
  }
1144
1140
  startNavigationTracking() {
1145
1141
  this.boundPopstateHandler = () => this.handleNavigation(), window.addEventListener("popstate", this.boundPopstateHandler), this.originalPushState = history.pushState.bind(history), this.originalReplaceState = history.replaceState.bind(history);
@@ -1182,13 +1178,13 @@ const Se = 3, Ce = 1e3, Me = 3, Te = 5e3, Le = 500, Ae = 500, Pe = 300, Re = /*
1182
1178
  handleNavigation() {
1183
1179
  const t = Date.now();
1184
1180
  this.navTimestamps.push(t);
1185
- const e = t - Te;
1181
+ const e = t - Le;
1186
1182
  this.navTimestamps = this.navTimestamps.filter((s) => s > e), this.navTimestamps.length >= Me && (this.navTimestamps = [], this.emitIfReady({
1187
1183
  signal: "rapid_navigation",
1188
1184
  timestamp: t
1189
1185
  })), setTimeout(() => {
1190
1186
  this.active && this.checkErrorPage();
1191
- }, Pe);
1187
+ }, De);
1192
1188
  }
1193
1189
  handleFormSubmit(t) {
1194
1190
  const e = t.target;
@@ -1198,7 +1194,7 @@ const Se = 3, Ce = 1e3, Me = 3, Te = 5e3, Le = 500, Ae = 500, Pe = 300, Re = /*
1198
1194
  target: y(e),
1199
1195
  timestamp: Date.now()
1200
1196
  });
1201
- }, Le));
1197
+ }, Te));
1202
1198
  }
1203
1199
  handleFormInvalid(t) {
1204
1200
  const e = t.target;
@@ -1237,26 +1233,32 @@ const Se = 3, Ce = 1e3, Me = 3, Te = 5e3, Le = 500, Ae = 500, Pe = 300, Re = /*
1237
1233
  }
1238
1234
  }
1239
1235
  }
1236
+ // One shared observer for all in-flight dead-click checks, connected only
1237
+ // while at least one check is pending — a full-page observer per click was
1238
+ // too heavy on mutation-busy pages.
1240
1239
  checkDeadClickDom(t, e) {
1241
- if (!this.looksInteractive(t)) return;
1242
- let s = !1;
1243
- const r = new MutationObserver(() => {
1244
- s = !0;
1245
- });
1246
- r.observe(document.body, {
1247
- childList: !0,
1248
- subtree: !0,
1249
- attributes: !0,
1250
- characterData: !0
1251
- }), this.pendingObservers.push(r), setTimeout(() => {
1252
- r.disconnect();
1253
- const n = this.pendingObservers.indexOf(r);
1254
- n >= 0 && this.pendingObservers.splice(n, 1), !s && this.active && this.emitIfReady({
1240
+ this.looksInteractive(t) && (this.pendingDomChecks++, this.ensureDomObserver(), setTimeout(() => {
1241
+ this.pendingDomChecks--;
1242
+ const s = this.lastMutationAt >= e;
1243
+ this.pendingDomChecks === 0 && this.disconnectDomObserver(), !s && this.active && this.emitIfReady({
1255
1244
  signal: "dead_click_dom",
1256
1245
  target: y(t),
1257
1246
  timestamp: e
1258
1247
  });
1259
- }, Ae);
1248
+ }, Ae));
1249
+ }
1250
+ ensureDomObserver() {
1251
+ this.domObserver || (this.domObserver = new MutationObserver(() => {
1252
+ this.lastMutationAt = Date.now();
1253
+ }), this.domObserver.observe(document.body, {
1254
+ childList: !0,
1255
+ subtree: !0,
1256
+ attributes: !0,
1257
+ characterData: !0
1258
+ }));
1259
+ }
1260
+ disconnectDomObserver() {
1261
+ this.domObserver?.disconnect(), this.domObserver = null;
1260
1262
  }
1261
1263
  looksInteractive(t) {
1262
1264
  if (window.getComputedStyle(t).cursor === "pointer") return !0;
@@ -1268,9 +1270,9 @@ const Se = 3, Ce = 1e3, Me = 3, Te = 5e3, Le = 500, Ae = 500, Pe = 300, Re = /*
1268
1270
  return !1;
1269
1271
  }
1270
1272
  isInteractive(t) {
1271
- if (Re.has(t.tagName)) return !0;
1273
+ if (Pe.has(t.tagName)) return !0;
1272
1274
  const e = t.getAttribute("role");
1273
- return !!(e && De.has(e) || t.hasAttribute("onclick") || t.hasAttribute("tabindex") || t.contentEditable === "true" || window.getComputedStyle(t).cursor === "pointer" || t.closest('a, button, [role="button"], [role="link"], label'));
1275
+ return !!(e && Re.has(e) || t.hasAttribute("onclick") || t.hasAttribute("tabindex") || t.contentEditable === "true" || window.getComputedStyle(t).cursor === "pointer" || t.closest('a, button, [role="button"], [role="link"], label'));
1274
1276
  }
1275
1277
  isWidgetElement(t) {
1276
1278
  const e = document.getElementById("mtb-widget-host");
@@ -1285,7 +1287,7 @@ const Se = 3, Ce = 1e3, Me = 3, Te = 5e3, Le = 500, Ae = 500, Pe = 300, Re = /*
1285
1287
  }
1286
1288
  };
1287
1289
  v.COOLDOWN_MS = 6e4;
1288
- let R = v;
1290
+ let P = v;
1289
1291
  function y(i) {
1290
1292
  const t = i.tagName.toLowerCase(), e = i.id ? `#${i.id}` : "", s = i.className && typeof i.className == "string" ? "." + i.className.trim().split(/\s+/).slice(0, 2).join(".") : "", r = i.textContent?.trim().slice(0, 30) ?? "";
1291
1293
  return `<${t}${e}${s}>${r ? ` "${r}"` : ""}`;
@@ -1328,7 +1330,7 @@ class Oe {
1328
1330
  }
1329
1331
  e && s.append("feedback[screenshot]", e, "screenshot.png");
1330
1332
  const r = await this.authHeaders();
1331
- return (await this.fetchWithRetry(`${this.apiUrl}/widget/feedbacks`, {
1333
+ return r["X-Idempotency-Key"] = Fe(), (await this.fetchWithRetry(`${this.apiUrl}/widget/feedbacks`, {
1332
1334
  method: "POST",
1333
1335
  headers: r,
1334
1336
  body: s
@@ -1369,7 +1371,10 @@ class Oe {
1369
1371
  function W(i) {
1370
1372
  return i <= 0 ? Promise.resolve() : new Promise((t) => setTimeout(t, i));
1371
1373
  }
1372
- function Fe(i, t, e, s, r, n) {
1374
+ function Fe() {
1375
+ return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
1376
+ }
1377
+ function je(i, t, e, s, r, n) {
1373
1378
  return {
1374
1379
  description: i,
1375
1380
  ...t,
@@ -1387,7 +1392,7 @@ function Fe(i, t, e, s, r, n) {
1387
1392
  recording_duration: n?.duration
1388
1393
  };
1389
1394
  }
1390
- const je = {
1395
+ const Ue = {
1391
1396
  tab: "Feedback",
1392
1397
  toolbar: {
1393
1398
  markup: "Mark up",
@@ -1440,7 +1445,7 @@ const je = {
1440
1445
  send: "Send",
1441
1446
  skip: "Skip"
1442
1447
  }
1443
- }, Ue = {
1448
+ }, ze = {
1444
1449
  tab: "反馈",
1445
1450
  toolbar: {
1446
1451
  markup: "标注",
@@ -1493,7 +1498,7 @@ const je = {
1493
1498
  send: "发送",
1494
1499
  skip: "跳过"
1495
1500
  }
1496
- }, ze = {
1501
+ }, Be = {
1497
1502
  tab: "フィードバック",
1498
1503
  toolbar: {
1499
1504
  markup: "マークアップ",
@@ -1546,7 +1551,7 @@ const je = {
1546
1551
  send: "送信",
1547
1552
  skip: "スキップ"
1548
1553
  }
1549
- }, Be = {
1554
+ }, qe = {
1550
1555
  tab: "피드백",
1551
1556
  toolbar: {
1552
1557
  markup: "마크업",
@@ -1599,7 +1604,7 @@ const je = {
1599
1604
  send: "보내기",
1600
1605
  skip: "건너뛰기"
1601
1606
  }
1602
- }, qe = {
1607
+ }, We = {
1603
1608
  tab: "Comentarios",
1604
1609
  toolbar: {
1605
1610
  markup: "Anotar",
@@ -1652,7 +1657,7 @@ const je = {
1652
1657
  send: "Enviar",
1653
1658
  skip: "Omitir"
1654
1659
  }
1655
- }, We = {
1660
+ }, Ne = {
1656
1661
  tab: "Avis",
1657
1662
  toolbar: {
1658
1663
  markup: "Annoter",
@@ -1705,7 +1710,7 @@ const je = {
1705
1710
  send: "Envoyer",
1706
1711
  skip: "Passer"
1707
1712
  }
1708
- }, Ne = {
1713
+ }, Ve = {
1709
1714
  tab: "Feedback",
1710
1715
  toolbar: {
1711
1716
  markup: "Markieren",
@@ -1759,28 +1764,28 @@ const je = {
1759
1764
  skip: "Überspringen"
1760
1765
  }
1761
1766
  }, k = {
1762
- en: je,
1763
- "zh-CN": Ue,
1764
- ja: ze,
1765
- ko: Be,
1766
- es: qe,
1767
- fr: We,
1768
- de: Ne
1767
+ en: Ue,
1768
+ "zh-CN": ze,
1769
+ ja: Be,
1770
+ ko: qe,
1771
+ es: We,
1772
+ fr: Ne,
1773
+ de: Ve
1769
1774
  };
1770
- function Ve(i) {
1775
+ function Ye(i) {
1771
1776
  if (k[i]) return k[i];
1772
1777
  const t = i.split("-")[0];
1773
1778
  return k[t] ? k[t] : k.en;
1774
1779
  }
1775
- const Ye = 60, Xe = "https://cdn.jsdelivr.net/npm/rrweb@2/dist/rrweb.min.js";
1780
+ const Xe = 60, Ge = "https://cdn.jsdelivr.net/npm/rrweb@2.1.0/dist/rrweb.min.js", Ke = "sha384-6qZKf9GE/E2uhA8IdLwXsQiLN/jVx8mhA0i04rQ1aHLrs2URo3ivHlSbaccG59zt";
1776
1781
  let E = null;
1777
- function Ge() {
1778
- return E || (E = Ke().catch(() => Je()), E);
1782
+ function Je() {
1783
+ return E || (E = Qe().catch(() => Ze()), E);
1779
1784
  }
1780
- async function Ke() {
1785
+ async function Qe() {
1781
1786
  return (await import("rrweb")).record;
1782
1787
  }
1783
- function Je() {
1788
+ function Ze() {
1784
1789
  return new Promise((i, t) => {
1785
1790
  const e = globalThis;
1786
1791
  if (e.rrweb?.record) {
@@ -1788,18 +1793,18 @@ function Je() {
1788
1793
  return;
1789
1794
  }
1790
1795
  const s = document.createElement("script");
1791
- s.src = Xe, s.onload = () => {
1796
+ s.src = Ge, s.integrity = Ke, s.crossOrigin = "anonymous", s.onload = () => {
1792
1797
  const r = globalThis;
1793
1798
  r.rrweb?.record ? i(r.rrweb.record) : t(new Error("rrweb global not found after script load"));
1794
1799
  }, s.onerror = () => t(new Error("Failed to load rrweb from CDN")), document.head.appendChild(s);
1795
1800
  });
1796
1801
  }
1797
- class Qe {
1802
+ class ti {
1798
1803
  constructor(t, e) {
1799
1804
  this.events = [], this.stopFn = null, this.startedAt = 0, this.timer = null, this.clickHandler = null, this.stopped = !1, this.shadow = t, this.onMaxReached = e;
1800
1805
  }
1801
1806
  async start() {
1802
- const t = await Ge();
1807
+ const t = await Je();
1803
1808
  this.startedAt = Date.now(), this.stopped = !1, this.stopFn = t({
1804
1809
  emit: (e) => {
1805
1810
  this.stopped || this.events.push(e);
@@ -1812,7 +1817,7 @@ class Qe {
1812
1817
  });
1813
1818
  }, document.addEventListener("click", this.clickHandler, !0), this.timer = setTimeout(() => {
1814
1819
  this.onMaxReached?.();
1815
- }, Ye * 1e3);
1820
+ }, Xe * 1e3);
1816
1821
  }
1817
1822
  stop() {
1818
1823
  return this.stopped = !0, this.stopFn?.(), this.stopFn = null, this.cleanupTimer(), this.cleanupClickHandler(), {
@@ -1837,7 +1842,7 @@ class Qe {
1837
1842
  s.style.left = `${t}px`, s.style.top = `${e}px`, this.shadow.append(s), s.addEventListener("animationend", () => s.remove());
1838
1843
  }
1839
1844
  }
1840
- class Ze {
1845
+ class ei {
1841
1846
  constructor(t, e, s, r) {
1842
1847
  this.intervalId = null, this.getDuration = s, this.el = t.el("div", "mtb-record-bar"), this.el.innerHTML = `
1843
1848
  <span class="mtb-record-dot"></span>
@@ -1853,12 +1858,12 @@ class Ze {
1853
1858
  this.intervalId && (clearInterval(this.intervalId), this.intervalId = null), this.el.remove();
1854
1859
  }
1855
1860
  }
1856
- class ti {
1861
+ class ii {
1857
1862
  constructor() {
1858
1863
  this.session = null, this.bar = null, this.result = null;
1859
1864
  }
1860
1865
  async start(t, e, s) {
1861
- this.session = new Qe(t, s), this.bar = new Ze(
1866
+ this.session = new ti(t, s), this.bar = new ei(
1862
1867
  t,
1863
1868
  e,
1864
1869
  () => this.session?.getDuration() ?? 0,
@@ -1880,7 +1885,7 @@ class ti {
1880
1885
  }
1881
1886
  class N {
1882
1887
  constructor(t) {
1883
- this.tab = null, this.pet = null, this.toolbar = null, this.session = null, this.popup = null, this.clarify = null, this.success = null, this.frustrationPrompt = null, this.frustrationDetector = null, this.mode = "idle", this.currentAnnotation = null, this.recordingManager = null, this.config = t, this.messages = Ve(t.locale ?? "en"), this.apiClient = new Oe(t.projectKey, t.apiUrl, void 0, t.userToken, t.userTokenFn), this.consoleCollector = new Ee(), this.consoleCollector.start(), this.buildUI(), t.frustrationDetection !== !1 && (this.frustrationDetector = new R(() => this.handleFrustration()), this.frustrationDetector.start());
1888
+ this.tab = null, this.pet = null, this.toolbar = null, this.session = null, this.popup = null, this.clarify = null, this.success = null, this.frustrationPrompt = null, this.frustrationDetector = null, this.mode = "idle", this.currentAnnotation = null, this.recordingManager = null, this.config = t, this.messages = Ye(t.locale ?? "en"), this.apiClient = new Oe(t.projectKey, t.apiUrl, void 0, t.userToken, t.userTokenFn), this.consoleCollector = new Ee(), this.consoleCollector.start(), this.buildUI(), t.frustrationDetection !== !1 && (this.frustrationDetector = new P(() => this.handleFrustration()), this.frustrationDetector.start());
1884
1889
  }
1885
1890
  buildUI() {
1886
1891
  this.shadow = new rt(this.config.theme ?? "auto"), (this.config.entryMode ?? "button") === "pet" ? this.pet = new ot(this.shadow, this.messages, () => this.handleTabClick()) : this.tab = new nt(
@@ -1916,8 +1921,10 @@ class N {
1916
1921
  });
1917
1922
  }
1918
1923
  handleToolbarModeChange(t) {
1919
- t === "record" ? (this.mode = "recording", this.session?.destroy(), this.session = null, this.recordingManager = new ti(), this.recordingManager.start(this.shadow, this.messages, () => {
1924
+ t === "record" ? (this.mode = "recording", this.session?.destroy(), this.session = null, this.recordingManager = new ii(), this.recordingManager.start(this.shadow, this.messages, () => {
1920
1925
  this.recordingManager && (this.recordingManager.stop(), this.showPopup(window.innerWidth / 2, window.innerHeight / 2, this.messages.record.timer_label));
1926
+ }).catch(() => {
1927
+ this.mode === "recording" && (this.toolbar?.setMode("markup"), this.handleToolbarModeChange("markup"));
1921
1928
  })) : (this.recordingManager?.destroy(), this.recordingManager = null, this.session || (this.session = new H(this.shadow, this.messages, (e, s) => {
1922
1929
  this.currentAnnotation = e, this.showPopup(e.x, e.y, s);
1923
1930
  })), this.mode = "annotating");
@@ -1938,7 +1945,7 @@ class N {
1938
1945
  const e = this.currentAnnotation, s = this.recordingManager?.getRecording() ?? void 0, [r, n] = await Promise.all([
1939
1946
  be(e ? [e] : []),
1940
1947
  Promise.resolve(_e())
1941
- ]), o = Fe(
1948
+ ]), o = je(
1942
1949
  t,
1943
1950
  n,
1944
1951
  this.consoleCollector.getErrors(),
@@ -1981,7 +1988,7 @@ class N {
1981
1988
  }
1982
1989
  }
1983
1990
  let f = null;
1984
- const ei = {
1991
+ const si = {
1985
1992
  init(i) {
1986
1993
  f && (f.destroy(), f = null), document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => {
1987
1994
  f = new N(i);
@@ -1991,8 +1998,8 @@ const ei = {
1991
1998
  f?.destroy(), f = null;
1992
1999
  }
1993
2000
  };
1994
- typeof window < "u" && (window.MakeThisBetter = ei);
2001
+ typeof window < "u" && (window.MakeThisBetter = si);
1995
2002
  export {
1996
- ei as MakeThisBetter
2003
+ si as MakeThisBetter
1997
2004
  };
1998
2005
  //# sourceMappingURL=makethisbetter.esm.js.map