@brainfish-ai/widgets-initiator 1.7.1-alpha.1 → 1.7.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.
package/dist/web.js CHANGED
@@ -11,7 +11,7 @@ var L = (a, t, n) => t in a ? je(a, t, { enumerable: !0, configurable: !0, writa
11
11
  return a;
12
12
  }, $ = (a, t) => Fe(a, Le(t));
13
13
  var S = (a, t, n) => L(a, typeof t != "symbol" ? t + "" : t, n);
14
- var m = (a, t, n) => new Promise((s, i) => {
14
+ var b = (a, t, n) => new Promise((s, i) => {
15
15
  var r = (l) => {
16
16
  try {
17
17
  d(n.next(l));
@@ -31,10 +31,10 @@ var C, q;
31
31
  (function() {
32
32
  try {
33
33
  var a = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {}, t = new a.Error().stack;
34
- t && (a._sentryDebugIds = a._sentryDebugIds || {}, a._sentryDebugIds[t] = "7ac6481a-ccb9-412b-a4dc-a648fae19c84", a._sentryDebugIdIdentifier = "sentry-dbid-7ac6481a-ccb9-412b-a4dc-a648fae19c84");
34
+ t && (a._sentryDebugIds = a._sentryDebugIds || {}, a._sentryDebugIds[t] = "3aa7ffd1-6b63-44f2-a66a-666364221be5", a._sentryDebugIdIdentifier = "sentry-dbid-3aa7ffd1-6b63-44f2-a66a-666364221be5");
35
35
  } catch (n) {
36
36
  }
37
- })(), (typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {}).SENTRY_RELEASE = { id: "5ca6b9ddacf948ca3f64e6093a061beff0894c1e" }, function(a) {
37
+ })(), (typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {}).SENTRY_RELEASE = { id: "7312f55785c72ff2640966e4cbe58f1712202a8d" }, function(a) {
38
38
  a.Sidebar = "sidebar", a.Searchbar = "searchbar";
39
39
  }(C || (C = {})), C.Sidebar, C.Searchbar;
40
40
  class se extends Error {
@@ -62,12 +62,12 @@ const x = (a, t, n, s) => {
62
62
  ((e, d, l) => {
63
63
  if (!navigator || navigator.userAgent.toLowerCase().includes("headless")) return;
64
64
  const o = d.toJSON();
65
- fetch(`${e || "https://app.brainfi.sh"}/api/trackError.widget.create`, { method: "POST", headers: { "Content-Type": "application/json", "api-key": l }, body: JSON.stringify({ error: `WebWidgetVersion: 1.7.1-alpha.1. ${d.message}`, stack: d.stack, cause: { message: o.message, stack: o.stack, cause: o.cause } }) });
65
+ fetch(`${e || "https://app.brainfi.sh"}/api/trackError.widget.create`, { method: "POST", headers: { "Content-Type": "application/json", "api-key": l }, body: JSON.stringify({ error: `WebWidgetVersion: 1.7.1. ${d.message}`, stack: d.stack, cause: { message: o.message, stack: o.stack, cause: o.cause } }) });
66
66
  })(a, new se(i, { cause: r }), s);
67
- }, He = (a) => m(void 0, null, function* () {
67
+ }, He = (a) => b(void 0, null, function* () {
68
68
  let { widgetKey: t, apiHost: n } = a;
69
69
  return function(s, i, r) {
70
- return m(this, null, function* () {
70
+ return b(this, null, function* () {
71
71
  let e, d = 0;
72
72
  for (; d < 3; ) try {
73
73
  const l = yield fetch(`${s}${i}`, { method: "POST", headers: { "Content-Type": "application/json", "api-key": r } });
@@ -93,11 +93,11 @@ const x = (a, t, n, s) => {
93
93
  if (!(a.match(/iPad/i) || a.match(/iPhone/i))) return !1;
94
94
  const t = a.match(/OS (\d+)_/i);
95
95
  return t && parseInt(t[1], 10) <= 14;
96
- })(), qe = (a) => m(void 0, null, function* () {
96
+ })(), qe = (a) => b(void 0, null, function* () {
97
97
  let { apiHost: t, widgetKey: n, version: s } = a;
98
98
  try {
99
99
  const i = `https://cdn.jsdelivr.net/npm/@brainfish-ai/search-widget@${s}/dist/web.js`, r = H ? i.replace("web.js", "web.umd.js") : i;
100
- return { widget: yield ((d) => m(void 0, null, function* () {
100
+ return { widget: yield ((d) => b(void 0, null, function* () {
101
101
  return document.getElementById("brainfish-widget") ? window.Brainfish : new Promise((l, o) => {
102
102
  const u = document.createElement("script");
103
103
  u.id = "brainfish-widget", u.src = d, u.type = H ? "text/javascript" : "module", u.async = !0, u.crossOrigin = "anonymous", u.onload = () => {
@@ -114,7 +114,7 @@ const x = (a, t, n, s) => {
114
114
  } catch (i) {
115
115
  x(t, i, i.message, n);
116
116
  }
117
- }), he = /* @__PURE__ */ new Set(), ze = (a, t) => m(void 0, null, function* () {
117
+ }), he = /* @__PURE__ */ new Set(), ze = (a, t) => b(void 0, null, function* () {
118
118
  const n = de(a.overrides);
119
119
  try {
120
120
  if (he.has(a.widgetKey)) return;
@@ -138,23 +138,23 @@ const x = (a, t, n, s) => {
138
138
  });
139
139
  let me = !1;
140
140
  const Ne = function(s, i, r) {
141
- return m(this, arguments, function* (a, t, n) {
142
- let e = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "", d = arguments.length > 4 && arguments[4] !== void 0 && arguments[4];
141
+ return b(this, arguments, function* (a, t, n) {
142
+ let e = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "", d = arguments.length > 4 && arguments[4] !== void 0 && arguments[4], l = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : [];
143
143
  if (t || x(n, new Error("Access key is required"), "Access key is required", a), !me) try {
144
- const l = (() => {
144
+ const o = (() => {
145
145
  if (typeof window == "undefined" || typeof navigator == "undefined") return !1;
146
- const o = navigator, u = window, c = (o.doNotTrack || u.doNotTrack || o.msDoNotTrack || "0").toString().toLowerCase();
147
- return ["1", "yes", "true"].includes(c);
146
+ const u = navigator, c = window, f = (u.doNotTrack || c.doNotTrack || u.msDoNotTrack || "0").toString().toLowerCase();
147
+ return ["1", "yes", "true"].includes(f);
148
148
  })();
149
- window.BrainfishAnalytics("init", { apiUrl: e, accessKey: t, trackScreenViews: !l, trackAttributes: !l, trackOutgoingLinks: !l, enableRecording: !l && d }), me = !0, yield ((o, u) => m(this, null, function* () {
149
+ window.BrainfishAnalytics("init", { apiUrl: e, accessKey: t, trackScreenViews: !o, trackAttributes: !o, trackOutgoingLinks: !o, enableRecording: !o && d, recordingBlocklist: l }), me = !0, yield ((u, c) => b(this, null, function* () {
150
150
  if (document.getElementById("brainfish-analytics")) return window.BrainfishAnalytics;
151
- const c = document.createElement("script");
152
- c.id = "brainfish-analytics", c.src = "https://cdn.jsdelivr.net/npm/@brainfish-ai/web-tracker@0.0.8-alpha.0/dist/tracker.js", c.type = "module", c.async = !0, c.crossOrigin = "anonymous", c.onerror = () => {
153
- x(o, new Error(`Failed to load script: ${c.src}`), `Failed to load script: ${c.src}`, u);
154
- }, document.head.appendChild(c);
151
+ const f = document.createElement("script");
152
+ f.id = "brainfish-analytics", f.src = "https://cdn.jsdelivr.net/npm/@brainfish-ai/web-tracker@latest/dist/tracker.js", f.type = "module", f.async = !0, f.crossOrigin = "anonymous", f.onerror = () => {
153
+ x(u, new Error(`Failed to load script: ${f.src}`), `Failed to load script: ${f.src}`, c);
154
+ }, document.head.appendChild(f);
155
155
  }))(n, a);
156
- } catch (l) {
157
- x(n, l, "Failed to initialize BrainfishAnalytics", a);
156
+ } catch (o) {
157
+ x(n, o, "Failed to initialize BrainfishAnalytics", a);
158
158
  }
159
159
  });
160
160
  };
@@ -167,7 +167,7 @@ function M(a, t) {
167
167
  }), s;
168
168
  }
169
169
  const j = "bf-iframe-container", F = "bf-trigger-button";
170
- class b {
170
+ class v {
171
171
  static get isWidgetOpen() {
172
172
  return this.isOpen;
173
173
  }
@@ -208,7 +208,7 @@ class b {
208
208
  (t = this.button) === null || t === void 0 || t.classList.add("hidden");
209
209
  }
210
210
  }
211
- S(b, "isOpen", !1), S(b, "button", null), S(b, "icon", null), S(b, "isButtonHidden", !1);
211
+ S(v, "isOpen", !1), S(v, "button", null), S(v, "icon", null), S(v, "isButtonHidden", !1);
212
212
  function Re(a) {
213
213
  let { widgetHost: t, apiHost: n, widgetKey: s, signal: i } = a;
214
214
  window.addEventListener("message", (r) => {
@@ -222,7 +222,7 @@ function Re(a) {
222
222
  const { eventName: d, data: l } = r.data;
223
223
  window.BrainfishAnalytics("track", d, l);
224
224
  }
225
- if (e === "CLOSE_WIDGET" && (window.BrainfishAnalytics("track", "Close Widget"), b.toggleIframeVisibility()), e === "NEXT_BEST_ACTION_CLICKED") {
225
+ if (e === "CLOSE_WIDGET" && (window.BrainfishAnalytics("track", "Close Widget"), v.toggleIframeVisibility()), e === "NEXT_BEST_ACTION_CLICKED") {
226
226
  const { action: d, searchQueryId: l, query: o, answer: u } = r.data, c = { action: d, searchQueryId: l };
227
227
  if (!["function", "callback"].includes(d.type)) return void console.error("Invalid action type", d);
228
228
  if (window.__bfCallbacks = window.__bfCallbacks || {}, window.__bfCallbacks[d.id]) return void window.__bfCallbacks[d.id](o, u, c);
@@ -286,8 +286,8 @@ var De = D.exports, Y = { exports: {} };
286
286
  if (s()) return Reflect.construct.apply(null, arguments);
287
287
  var p = [null];
288
288
  p.push.apply(p, g);
289
- var v = new (f.bind.apply(f, p))();
290
- return h && i(v, h.prototype), v;
289
+ var m = new (f.bind.apply(f, p))();
290
+ return h && i(m, h.prototype), m;
291
291
  }(u, arguments, r(this).constructor);
292
292
  }
293
293
  return c.prototype = Object.create(u.prototype, { constructor: { value: c, enumerable: !1, writable: !0, configurable: !0 } }), i(c, u);
@@ -477,7 +477,7 @@ To pass a single animation please supply them in simple values, e.g. animation('
477
477
  var g;
478
478
  if (process.env.NODE_ENV === "production") g = l.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + f + " for more information.") || this;
479
479
  else {
480
- for (var h = arguments.length, p = new Array(h > 1 ? h - 1 : 0), v = 1; v < h; v++) p[v - 1] = arguments[v];
480
+ for (var h = arguments.length, p = new Array(h > 1 ? h - 1 : 0), m = 1; m < h; m++) p[m - 1] = arguments[m];
481
481
  g = l.call(this, d.apply(void 0, [e[f]].concat(p))) || this;
482
482
  }
483
483
  return function(E) {
@@ -495,8 +495,8 @@ var k = Y.exports;
495
495
  var p = (0, s.default)(h);
496
496
  if (p.match(e)) return { red: parseInt("" + p[1] + p[2], 16), green: parseInt("" + p[3] + p[4], 16), blue: parseInt("" + p[5] + p[6], 16) };
497
497
  if (p.match(d)) {
498
- var v = parseFloat((parseInt("" + p[7] + p[8], 16) / 255).toFixed(2));
499
- return { red: parseInt("" + p[1] + p[2], 16), green: parseInt("" + p[3] + p[4], 16), blue: parseInt("" + p[5] + p[6], 16), alpha: v };
498
+ var m = parseFloat((parseInt("" + p[7] + p[8], 16) / 255).toFixed(2));
499
+ return { red: parseInt("" + p[1] + p[2], 16), green: parseInt("" + p[3] + p[4], 16), blue: parseInt("" + p[5] + p[6], 16), alpha: m };
500
500
  }
501
501
  if (p.match(l)) return { red: parseInt("" + p[1] + p[1], 16), green: parseInt("" + p[2] + p[2], 16), blue: parseInt("" + p[3] + p[3], 16) };
502
502
  if (p.match(o)) {
@@ -507,17 +507,17 @@ var k = Y.exports;
507
507
  if (A) return { red: parseInt("" + A[1], 10), green: parseInt("" + A[2], 10), blue: parseInt("" + A[3], 10) };
508
508
  var y = c.exec(p.substring(0, 50));
509
509
  if (y) return { red: parseInt("" + y[1], 10), green: parseInt("" + y[2], 10), blue: parseInt("" + y[3], 10), alpha: parseFloat("" + y[4]) > 1 ? parseFloat("" + y[4]) / 100 : parseFloat("" + y[4]) };
510
- var I = f.exec(p);
511
- if (I) {
512
- var Ie = parseInt("" + I[1], 10), Oe = parseInt("" + I[2], 10) / 100, Be = parseInt("" + I[3], 10) / 100, ce = "rgb(" + (0, n.default)(Ie, Oe, Be) + ")", O = u.exec(ce);
513
- if (!O) throw new i.default(4, p, ce);
514
- return { red: parseInt("" + O[1], 10), green: parseInt("" + O[2], 10), blue: parseInt("" + O[3], 10) };
510
+ var B = f.exec(p);
511
+ if (B) {
512
+ var Be = parseInt("" + B[1], 10), Ie = parseInt("" + B[2], 10) / 100, Oe = parseInt("" + B[3], 10) / 100, ce = "rgb(" + (0, n.default)(Be, Ie, Oe) + ")", I = u.exec(ce);
513
+ if (!I) throw new i.default(4, p, ce);
514
+ return { red: parseInt("" + I[1], 10), green: parseInt("" + I[2], 10), blue: parseInt("" + I[3], 10) };
515
515
  }
516
516
  var w = g.exec(p.substring(0, 50));
517
517
  if (w) {
518
- var Me = parseInt("" + w[1], 10), Pe = parseInt("" + w[2], 10) / 100, Te = parseInt("" + w[3], 10) / 100, pe = "rgb(" + (0, n.default)(Me, Pe, Te) + ")", B = u.exec(pe);
519
- if (!B) throw new i.default(4, p, pe);
520
- return { red: parseInt("" + B[1], 10), green: parseInt("" + B[2], 10), blue: parseInt("" + B[3], 10), alpha: parseFloat("" + w[4]) > 1 ? parseFloat("" + w[4]) / 100 : parseFloat("" + w[4]) };
518
+ var Me = parseInt("" + w[1], 10), Pe = parseInt("" + w[2], 10) / 100, Te = parseInt("" + w[3], 10) / 100, pe = "rgb(" + (0, n.default)(Me, Pe, Te) + ")", O = u.exec(pe);
519
+ if (!O) throw new i.default(4, p, pe);
520
+ return { red: parseInt("" + O[1], 10), green: parseInt("" + O[2], 10), blue: parseInt("" + O[3], 10), alpha: parseFloat("" + w[4]) > 1 ? parseFloat("" + w[4]) / 100 : parseFloat("" + w[4]) };
521
521
  }
522
522
  throw new i.default(5);
523
523
  };
@@ -784,7 +784,7 @@ function tt(a, t) {
784
784
  ((r) => {
785
785
  var e;
786
786
  const d = { type: "UPDATE_BODY_CLASS", isMobile: r };
787
- (e = a.contentWindow) === null || e === void 0 || e.postMessage(d, "*"), r && (b.isWidgetOpen ? b.hideTriggerButton() : b.showTriggerButton());
787
+ (e = a.contentWindow) === null || e === void 0 || e.postMessage(d, "*"), r && (v.isWidgetOpen ? v.hideTriggerButton() : v.showTriggerButton());
788
788
  })(document.body.clientWidth <= 576);
789
789
  }, i = () => {
790
790
  n && clearTimeout(n), n = window.setTimeout(s, 300);
@@ -806,7 +806,7 @@ function ve(a) {
806
806
  const ye = /* @__PURE__ */ new Set();
807
807
  function nt(a, t, n) {
808
808
  const s = document.createDocumentFragment();
809
- if (n) b.initialize({ isButtonHidden: n });
809
+ if (n) v.initialize({ isButtonHidden: n });
810
810
  else {
811
811
  const { button: e, icon: d } = function(l) {
812
812
  const o = M("button", F, { id: `trigger-button-${l}`, "aria-controls": j, "aria-expanded": "false", "data-name": F }), u = M("div", "trigger-button-icon", { "aria-hidden": "true" });
@@ -819,7 +819,7 @@ function nt(a, t, n) {
819
819
  </svg>
820
820
  `, o.setAttribute("aria-label", "Open Brainfish widget"), o.appendChild(u), { button: o, icon: u };
821
821
  }(a);
822
- s.appendChild(e), b.initialize({ button: e, icon: d });
822
+ s.appendChild(e), v.initialize({ button: e, icon: d });
823
823
  }
824
824
  const { iframeContainer: i, iframe: r } = function(e) {
825
825
  const d = M("div", j, { id: j, "aria-live": "polite", "aria-hidden": "true" }), l = M("iframe", "trigger-iframe", { src: e, sandbox: "allow-scripts allow-same-origin allow-popups allow-forms", allow: "clipboard-write", role: "dialog" });
@@ -896,7 +896,7 @@ const _ = typeof window != "undefined" && window.Brainfish ? window.Brainfish :
896
896
  let K = null;
897
897
  _.Widgets.isReady = !1, _.Widgets.identify = (a) => {
898
898
  window.BrainfishAnalytics("identify", a);
899
- }, _.Widgets.init = (a) => m(void 0, null, function* () {
899
+ }, _.Widgets.init = (a) => b(void 0, null, function* () {
900
900
  window && (window.BrainfishAnalytics = window.BrainfishAnalytics || function() {
901
901
  for (var r = arguments.length, e = new Array(r), d = 0; d < r; d++) e[d] = arguments[d];
902
902
  (window.BrainfishAnalytics.q = window.BrainfishAnalytics.q || []).push(e);
@@ -918,12 +918,12 @@ _.Widgets.isReady = !1, _.Widgets.identify = (a) => {
918
918
  i = r;
919
919
  }
920
920
  K || (K = function(r, e, d, l) {
921
- return m(this, null, function* () {
922
- var o, u, c;
923
- const f = ((o = r.overrides) === null || o === void 0 ? void 0 : o.enableRecording) || (e == null || (u = e.settings) === null || u === void 0 ? void 0 : u.enableRecording) || !1, g = ((c = r.overrides) === null || c === void 0 ? void 0 : c.version) || (e == null ? void 0 : e.version), h = [];
924
- g != null && g.startsWith("2.") ? rt(r, e) : h.push(ze(r, e)), h.push(Ne(r.widgetKey, e.trackingToken || "", d, l, f));
925
- const [p] = yield Promise.allSettled(h);
926
- p && p.status === "fulfilled" && p.value && _._setRealBrainfish(p.value);
921
+ return b(this, null, function* () {
922
+ var o, u, c, f;
923
+ const g = ((o = r.overrides) === null || o === void 0 ? void 0 : o.enableRecording) || (e == null || (u = e.settings) === null || u === void 0 ? void 0 : u.enableRecording) || !1, h = ((c = r.overrides) === null || c === void 0 ? void 0 : c.version) || (e == null ? void 0 : e.version), p = [];
924
+ h != null && h.startsWith("2.") ? rt(r, e) : p.push(ze(r, e)), p.push(Ne(r.widgetKey, e.trackingToken || "", d, l, g, (e == null || (f = e.settings) === null || f === void 0 ? void 0 : f.recordingBlocklist) || []));
925
+ const [m] = yield Promise.allSettled(p);
926
+ m && m.status === "fulfilled" && m.value && _._setRealBrainfish(m.value);
927
927
  });
928
928
  }(a, i, t, n)), yield K, _.Widgets.isReady = !0, window.dispatchEvent(new Event("onBrainfishReady"));
929
929
  });