@brainfish-ai/widgets-initiator 1.7.0-alpha.8 → 1.7.0-alpha.9

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
@@ -1,17 +1,17 @@
1
- var $e = Object.defineProperty, We = Object.defineProperties;
2
- var Ke = Object.getOwnPropertyDescriptors;
1
+ var Le = Object.defineProperty, $e = Object.defineProperties;
2
+ var We = Object.getOwnPropertyDescriptors;
3
3
  var ge = Object.getOwnPropertySymbols;
4
- var De = Object.prototype.hasOwnProperty, He = Object.prototype.propertyIsEnumerable;
5
- var F = (a, t, n) => t in a ? $e(a, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[t] = n, L = (a, t) => {
4
+ var Ke = Object.prototype.hasOwnProperty, De = Object.prototype.propertyIsEnumerable;
5
+ var F = (a, t, n) => t in a ? Le(a, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[t] = n, L = (a, t) => {
6
6
  for (var n in t || (t = {}))
7
- De.call(t, n) && F(a, n, t[n]);
7
+ Ke.call(t, n) && F(a, n, t[n]);
8
8
  if (ge)
9
9
  for (var n of ge(t))
10
- He.call(t, n) && F(a, n, t[n]);
10
+ De.call(t, n) && F(a, n, t[n]);
11
11
  return a;
12
- }, $ = (a, t) => We(a, Ke(t));
13
- var S = (a, t, n) => F(a, typeof t != "symbol" ? t + "" : t, n);
14
- var b = (a, t, n) => new Promise((s, o) => {
12
+ }, $ = (a, t) => $e(a, We(t));
13
+ var _ = (a, t, n) => F(a, typeof t != "symbol" ? t + "" : t, n);
14
+ var m = (a, t, n) => new Promise((s, o) => {
15
15
  var r = (d) => {
16
16
  try {
17
17
  i(n.next(d));
@@ -31,16 +31,16 @@ var k, D;
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] = "7c753b14-8b80-484d-bbb3-5b506f7d1f49", a._sentryDebugIdIdentifier = "sentry-dbid-7c753b14-8b80-484d-bbb3-5b506f7d1f49");
34
+ t && (a._sentryDebugIds = a._sentryDebugIds || {}, a._sentryDebugIds[t] = "cbaaaf7c-e9d7-4d60-bd33-6cfca407b55b", a._sentryDebugIdIdentifier = "sentry-dbid-cbaaaf7c-e9d7-4d60-bd33-6cfca407b55b");
35
35
  } catch (n) {
36
36
  }
37
- })(), (typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {}).SENTRY_RELEASE = { id: "8a3a404ac565df533fcdadb2d8643b8a71d2ced6" }, function(a) {
37
+ })(), (typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {}).SENTRY_RELEASE = { id: "466cdacfb9bdaded272e64f3dd9464641cf9e32e" }, function(a) {
38
38
  a.Sidebar = "sidebar", a.Searchbar = "searchbar";
39
39
  }(k || (k = {})), k.Sidebar, k.Searchbar;
40
40
  class se extends Error {
41
41
  constructor(n, s) {
42
42
  super(n, s);
43
- S(this, "cause");
43
+ _(this, "cause");
44
44
  this.name = "BrainfishWidgetError", this.cause = s == null ? void 0 : s.cause, Error.captureStackTrace && Error.captureStackTrace(this, se), this.cause instanceof Error && this.cause.stack && (this.stack = this.stack + `
45
45
  Caused by: ` + this.cause.stack);
46
46
  }
@@ -62,12 +62,12 @@ const x = (a, t, n, s) => {
62
62
  ((e, i, d) => {
63
63
  if (!navigator || navigator.userAgent.toLowerCase().includes("headless")) return;
64
64
  const l = i.toJSON();
65
- fetch(`${e || "https://app.brainfi.sh"}/api/trackError.widget.create`, { method: "POST", headers: { "Content-Type": "application/json", "api-key": d }, body: JSON.stringify({ error: `WebWidgetVersion: 1.7.0-alpha.8. ${i.message}`, stack: i.stack, cause: { message: l.message, stack: l.stack, cause: l.cause } }) });
65
+ fetch(`${e || "https://app.brainfi.sh"}/api/trackError.widget.create`, { method: "POST", headers: { "Content-Type": "application/json", "api-key": d }, body: JSON.stringify({ error: `WebWidgetVersion: 1.7.0-alpha.9. ${i.message}`, stack: i.stack, cause: { message: l.message, stack: l.stack, cause: l.cause } }) });
66
66
  })(a, new se(o, { cause: r }), s);
67
- }, Ne = (a) => b(void 0, null, function* () {
67
+ }, He = (a) => m(void 0, null, function* () {
68
68
  let { widgetKey: t, apiHost: n } = a;
69
69
  return function(s, o, r) {
70
- return b(this, null, function* () {
70
+ return m(this, null, function* () {
71
71
  let e, i = 0;
72
72
  for (; i < 3; ) try {
73
73
  const d = yield fetch(`${s}${o}`, { method: "POST", headers: { "Content-Type": "application/json", "api-key": r } });
@@ -81,7 +81,7 @@ const x = (a, t, n, s) => {
81
81
  }
82
82
  });
83
83
  }(n, "/api/searchWidgets.getConfigByKey", t);
84
- }), ze = (a) => {
84
+ }), Ne = (a) => {
85
85
  let { config: t, apiKey: n, apiHost: s } = a;
86
86
  const o = t.settings || {};
87
87
  return ["bodyActionButtons", "footerActionButtons", "nextBestActions"].forEach((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) => b(void 0, null, function* () {
96
+ })(), qe = (a) => m(void 0, null, function* () {
97
97
  let { apiHost: t, widgetKey: n, version: s } = a;
98
98
  try {
99
99
  const o = `https://cdn.jsdelivr.net/npm/@brainfish-ai/search-widget@${s}/dist/web.js`, r = W ? o.replace("web.js", "web.umd.js") : o;
100
- return { widget: yield ((i) => b(void 0, null, function* () {
100
+ return { widget: yield ((i) => m(void 0, null, function* () {
101
101
  return document.getElementById("brainfish-widget") ? window.Brainfish : new Promise((d, l) => {
102
102
  const f = document.createElement("script");
103
103
  f.id = "brainfish-widget", f.src = i, f.type = W ? "text/javascript" : "module", f.async = !0, f.crossOrigin = "anonymous", f.onload = () => {
@@ -114,13 +114,13 @@ const x = (a, t, n, s) => {
114
114
  } catch (o) {
115
115
  x(t, o, o.message, n);
116
116
  }
117
- }), he = /* @__PURE__ */ new Set(), Re = (a, t) => b(void 0, null, function* () {
117
+ }), he = /* @__PURE__ */ new Set(), ze = (a, t) => m(void 0, null, function* () {
118
118
  const n = de(a.overrides);
119
119
  try {
120
120
  if (he.has(a.widgetKey)) return;
121
121
  const s = yield qe({ apiHost: n, widgetKey: a.widgetKey, version: t.version || "latest" });
122
122
  if (s) {
123
- const { widget: o } = s, r = ze({ config: t, apiKey: a.widgetKey, apiHost: n });
123
+ const { widget: o } = s, r = Ne({ config: t, apiKey: a.widgetKey, apiHost: n });
124
124
  return a.overrides && t.settings && Object.entries(a.overrides).forEach((e) => {
125
125
  let [i, d] = e;
126
126
  t.settings && i in t.settings && (t.settings[i] = function() {
@@ -137,8 +137,8 @@ const x = (a, t, n, s) => {
137
137
  }
138
138
  });
139
139
  let me = !1;
140
- const Ye = function(s, o, r) {
141
- return b(this, arguments, function* (a, t, n) {
140
+ const Re = function(s, o, r) {
141
+ return m(this, arguments, function* (a, t, n) {
142
142
  let e = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "", i = arguments.length > 4 && arguments[4] !== void 0 && arguments[4];
143
143
  if (t || x(n, new Error("Access key is required"), "Access key is required", a), !me) try {
144
144
  const d = (() => {
@@ -150,9 +150,8 @@ const Ye = function(s, o, r) {
150
150
  const l = window.BrainfishAnalytics;
151
151
  window.BrainfishAnalytics = function() {
152
152
  for (var f = arguments.length, c = new Array(f), u = 0; u < f; u++) c[u] = arguments[u];
153
- var g;
154
- return c[0] === "identify" && (g = c[1], window.dispatchEvent(new CustomEvent("brainfish:identify", { detail: g }))), l.apply(this, c);
155
- }, me = !0, yield ((f, c) => b(this, null, function* () {
153
+ return c[0] === "identify" && (console.log("------- brainfish:identify custom event-------"), window.dispatchEvent(new CustomEvent("brainfish:identify", { detail: c[1] }))), l.apply(this, c);
154
+ }, me = !0, yield ((f, c) => m(this, null, function* () {
156
155
  if (document.getElementById("brainfish-analytics")) return window.BrainfishAnalytics;
157
156
  const u = document.createElement("script");
158
157
  u.id = "brainfish-analytics", u.src = "https://cdn.jsdelivr.net/npm/@brainfish-ai/web-tracker@latest/dist/tracker.js", u.type = "module", u.async = !0, u.crossOrigin = "anonymous", u.onerror = () => {
@@ -164,7 +163,7 @@ const Ye = function(s, o, r) {
164
163
  }
165
164
  });
166
165
  };
167
- function T(a, t) {
166
+ function B(a, t) {
168
167
  let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
169
168
  const s = document.createElement(a);
170
169
  return s.className = t, Object.entries(n).forEach((o) => {
@@ -196,8 +195,8 @@ class v {
196
195
  (t = this.button) === null || t === void 0 || t.classList.add("hidden");
197
196
  }
198
197
  }
199
- S(v, "isOpen", !1), S(v, "button", null), S(v, "icon", null);
200
- function Je(a) {
198
+ _(v, "isOpen", !1), _(v, "button", null), _(v, "icon", null);
199
+ function Ye(a) {
201
200
  let { widgetHost: t, apiHost: n, widgetKey: s, signal: o } = a;
202
201
  window.addEventListener("message", (r) => {
203
202
  if (r.origin !== t) return;
@@ -226,7 +225,7 @@ function Je(a) {
226
225
  function le(a) {
227
226
  return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a;
228
227
  }
229
- var H = { exports: {} }, N = { exports: {} }, z = { exports: {} };
228
+ var H = { exports: {} }, N = { exports: {} }, q = { exports: {} };
230
229
  (function(a, t) {
231
230
  function n(o) {
232
231
  return Math.round(255 * o);
@@ -241,8 +240,8 @@ var H = { exports: {} }, N = { exports: {} }, z = { exports: {} };
241
240
  var h = e - l / 2;
242
241
  return i(c + h, u + h, g + h);
243
242
  }, a.exports = t.default;
244
- })(z, z.exports);
245
- var ue = z.exports, q = { exports: {} };
243
+ })(q, q.exports);
244
+ var ue = q.exports, z = { exports: {} };
246
245
  (function(a, t) {
247
246
  t.__esModule = !0, t.default = void 0;
248
247
  var n = { aliceblue: "f0f8ff", antiquewhite: "faebd7", aqua: "00ffff", aquamarine: "7fffd4", azure: "f0ffff", beige: "f5f5dc", bisque: "ffe4c4", black: "000", blanchedalmond: "ffebcd", blue: "0000ff", blueviolet: "8a2be2", brown: "a52a2a", burlywood: "deb887", cadetblue: "5f9ea0", chartreuse: "7fff00", chocolate: "d2691e", coral: "ff7f50", cornflowerblue: "6495ed", cornsilk: "fff8dc", crimson: "dc143c", cyan: "00ffff", darkblue: "00008b", darkcyan: "008b8b", darkgoldenrod: "b8860b", darkgray: "a9a9a9", darkgreen: "006400", darkgrey: "a9a9a9", darkkhaki: "bdb76b", darkmagenta: "8b008b", darkolivegreen: "556b2f", darkorange: "ff8c00", darkorchid: "9932cc", darkred: "8b0000", darksalmon: "e9967a", darkseagreen: "8fbc8f", darkslateblue: "483d8b", darkslategray: "2f4f4f", darkslategrey: "2f4f4f", darkturquoise: "00ced1", darkviolet: "9400d3", deeppink: "ff1493", deepskyblue: "00bfff", dimgray: "696969", dimgrey: "696969", dodgerblue: "1e90ff", firebrick: "b22222", floralwhite: "fffaf0", forestgreen: "228b22", fuchsia: "ff00ff", gainsboro: "dcdcdc", ghostwhite: "f8f8ff", gold: "ffd700", goldenrod: "daa520", gray: "808080", green: "008000", greenyellow: "adff2f", grey: "808080", honeydew: "f0fff0", hotpink: "ff69b4", indianred: "cd5c5c", indigo: "4b0082", ivory: "fffff0", khaki: "f0e68c", lavender: "e6e6fa", lavenderblush: "fff0f5", lawngreen: "7cfc00", lemonchiffon: "fffacd", lightblue: "add8e6", lightcoral: "f08080", lightcyan: "e0ffff", lightgoldenrodyellow: "fafad2", lightgray: "d3d3d3", lightgreen: "90ee90", lightgrey: "d3d3d3", lightpink: "ffb6c1", lightsalmon: "ffa07a", lightseagreen: "20b2aa", lightskyblue: "87cefa", lightslategray: "789", lightslategrey: "789", lightsteelblue: "b0c4de", lightyellow: "ffffe0", lime: "0f0", limegreen: "32cd32", linen: "faf0e6", magenta: "f0f", maroon: "800000", mediumaquamarine: "66cdaa", mediumblue: "0000cd", mediumorchid: "ba55d3", mediumpurple: "9370db", mediumseagreen: "3cb371", mediumslateblue: "7b68ee", mediumspringgreen: "00fa9a", mediumturquoise: "48d1cc", mediumvioletred: "c71585", midnightblue: "191970", mintcream: "f5fffa", mistyrose: "ffe4e1", moccasin: "ffe4b5", navajowhite: "ffdead", navy: "000080", oldlace: "fdf5e6", olive: "808000", olivedrab: "6b8e23", orange: "ffa500", orangered: "ff4500", orchid: "da70d6", palegoldenrod: "eee8aa", palegreen: "98fb98", paleturquoise: "afeeee", palevioletred: "db7093", papayawhip: "ffefd5", peachpuff: "ffdab9", peru: "cd853f", pink: "ffc0cb", plum: "dda0dd", powderblue: "b0e0e6", purple: "800080", rebeccapurple: "639", red: "f00", rosybrown: "bc8f8f", royalblue: "4169e1", saddlebrown: "8b4513", salmon: "fa8072", sandybrown: "f4a460", seagreen: "2e8b57", seashell: "fff5ee", sienna: "a0522d", silver: "c0c0c0", skyblue: "87ceeb", slateblue: "6a5acd", slategray: "708090", slategrey: "708090", snow: "fffafa", springgreen: "00ff7f", steelblue: "4682b4", tan: "d2b48c", teal: "008080", thistle: "d8bfd8", tomato: "ff6347", turquoise: "40e0d0", violet: "ee82ee", wheat: "f5deb3", white: "fff", whitesmoke: "f5f5f5", yellow: "ff0", yellowgreen: "9acd32" };
@@ -251,8 +250,8 @@ var ue = z.exports, q = { exports: {} };
251
250
  var o = s.toLowerCase();
252
251
  return n[o] ? "#" + n[o] : s;
253
252
  }, a.exports = t.default;
254
- })(q, q.exports);
255
- var Ue = q.exports, R = { exports: {} };
253
+ })(z, z.exports);
254
+ var Je = z.exports, R = { exports: {} };
256
255
  (function(a, t) {
257
256
  function n(d) {
258
257
  var l = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
@@ -274,8 +273,8 @@ var Ue = q.exports, R = { exports: {} };
274
273
  if (s()) return Reflect.construct.apply(null, arguments);
275
274
  var p = [null];
276
275
  p.push.apply(p, g);
277
- var m = new (u.bind.apply(u, p))();
278
- return h && o(m, h.prototype), m;
276
+ var b = new (u.bind.apply(u, p))();
277
+ return h && o(b, h.prototype), b;
279
278
  }(f, arguments, r(this).constructor);
280
279
  }
281
280
  return c.prototype = Object.create(f.prototype, { constructor: { value: c, enumerable: !1, writable: !0, configurable: !0 } }), o(c, f);
@@ -465,7 +464,7 @@ To pass a single animation please supply them in simple values, e.g. animation('
465
464
  var g;
466
465
  if (process.env.NODE_ENV === "production") g = d.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + u + " for more information.") || this;
467
466
  else {
468
- for (var h = arguments.length, p = new Array(h > 1 ? h - 1 : 0), m = 1; m < h; m++) p[m - 1] = arguments[m];
467
+ for (var h = arguments.length, p = new Array(h > 1 ? h - 1 : 0), b = 1; b < h; b++) p[b - 1] = arguments[b];
469
468
  g = d.call(this, i.apply(void 0, [e[u]].concat(p))) || this;
470
469
  }
471
470
  return function(E) {
@@ -476,15 +475,15 @@ To pass a single animation please supply them in simple values, e.g. animation('
476
475
  return f = d, (l = c).prototype = Object.create(f.prototype), l.prototype.constructor = l, o(l, f), c;
477
476
  }(n(Error)), a.exports = t.default;
478
477
  })(R, R.exports);
479
- var _ = R.exports;
478
+ var S = R.exports;
480
479
  (function(a, t) {
481
480
  t.__esModule = !0, t.default = function(h) {
482
481
  if (typeof h != "string") throw new o.default(3);
483
482
  var p = (0, s.default)(h);
484
483
  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) };
485
484
  if (p.match(i)) {
486
- var m = parseFloat((parseInt("" + p[7] + p[8], 16) / 255).toFixed(2));
487
- return { red: parseInt("" + p[1] + p[2], 16), green: parseInt("" + p[3] + p[4], 16), blue: parseInt("" + p[5] + p[6], 16), alpha: m };
485
+ var b = parseFloat((parseInt("" + p[7] + p[8], 16) / 255).toFixed(2));
486
+ return { red: parseInt("" + p[1] + p[2], 16), green: parseInt("" + p[3] + p[4], 16), blue: parseInt("" + p[5] + p[6], 16), alpha: b };
488
487
  }
489
488
  if (p.match(d)) return { red: parseInt("" + p[1] + p[1], 16), green: parseInt("" + p[2] + p[2], 16), blue: parseInt("" + p[3] + p[3], 16) };
490
489
  if (p.match(l)) {
@@ -497,19 +496,19 @@ var _ = R.exports;
497
496
  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]) };
498
497
  var I = u.exec(p);
499
498
  if (I) {
500
- var Te = parseInt("" + I[1], 10), Be = parseInt("" + I[2], 10) / 100, Pe = parseInt("" + I[3], 10) / 100, ce = "rgb(" + (0, n.default)(Te, Be, Pe) + ")", O = f.exec(ce);
499
+ var Me = parseInt("" + I[1], 10), Be = parseInt("" + I[2], 10) / 100, Te = parseInt("" + I[3], 10) / 100, ce = "rgb(" + (0, n.default)(Me, Be, Te) + ")", O = f.exec(ce);
501
500
  if (!O) throw new o.default(4, p, ce);
502
501
  return { red: parseInt("" + O[1], 10), green: parseInt("" + O[2], 10), blue: parseInt("" + O[3], 10) };
503
502
  }
504
503
  var w = g.exec(p.substring(0, 50));
505
504
  if (w) {
506
- var je = parseInt("" + w[1], 10), Fe = parseInt("" + w[2], 10) / 100, Le = parseInt("" + w[3], 10) / 100, pe = "rgb(" + (0, n.default)(je, Fe, Le) + ")", M = f.exec(pe);
505
+ var Pe = parseInt("" + w[1], 10), je = parseInt("" + w[2], 10) / 100, Fe = parseInt("" + w[3], 10) / 100, pe = "rgb(" + (0, n.default)(Pe, je, Fe) + ")", M = f.exec(pe);
507
506
  if (!M) throw new o.default(4, p, pe);
508
507
  return { red: parseInt("" + M[1], 10), green: parseInt("" + M[2], 10), blue: parseInt("" + M[3], 10), alpha: parseFloat("" + w[4]) > 1 ? parseFloat("" + w[4]) / 100 : parseFloat("" + w[4]) };
509
508
  }
510
509
  throw new o.default(5);
511
510
  };
512
- var n = r(ue), s = r(Ue), o = r(_);
511
+ var n = r(ue), s = r(Je), o = r(S);
513
512
  function r(h) {
514
513
  return h && h.__esModule ? h : { default: h };
515
514
  }
@@ -529,7 +528,7 @@ var fe = N.exports;
529
528
  var n, s = (n = fe) && n.__esModule ? n : { default: n };
530
529
  a.exports = t.default;
531
530
  })(H, H.exports);
532
- const Ge = le(H.exports);
531
+ const Ue = le(H.exports);
533
532
  var Y = { exports: {} }, J = { exports: {} };
534
533
  (function(a, t) {
535
534
  function n(s, o, r) {
@@ -542,11 +541,11 @@ var Y = { exports: {} }, J = { exports: {} };
542
541
  return n(s, s.length, []);
543
542
  }, a.exports = t.default;
544
543
  })(J, J.exports);
545
- var be, B, _e = J.exports, U = { exports: {} };
546
- be = U, (B = U.exports).__esModule = !0, B.default = void 0, B.default = function(a, t, n) {
544
+ var be, T, Se = J.exports, U = { exports: {} };
545
+ be = U, (T = U.exports).__esModule = !0, T.default = void 0, T.default = function(a, t, n) {
547
546
  return Math.max(a, Math.min(t, n));
548
- }, be.exports = B.default;
549
- var Se = U.exports, G = { exports: {} }, V = { exports: {} };
547
+ }, be.exports = T.default;
548
+ var _e = U.exports, G = { exports: {} }, V = { exports: {} };
550
549
  (function(a, t) {
551
550
  t.__esModule = !0, t.default = void 0, t.default = function(n) {
552
551
  var s, o = n.red / 255, r = n.green / 255, e = n.blue / 255, i = Math.max(o, r, e), d = Math.min(o, r, e), l = (i + d) / 2;
@@ -565,12 +564,12 @@ var Se = U.exports, G = { exports: {} }, V = { exports: {} };
565
564
  return s *= 60, n.alpha !== void 0 ? { hue: s, saturation: c, lightness: l, alpha: n.alpha } : { hue: s, saturation: c, lightness: l };
566
565
  }, a.exports = t.default;
567
566
  })(V, V.exports);
568
- var Ve = V.exports;
567
+ var Ge = V.exports;
569
568
  (function(a, t) {
570
569
  t.__esModule = !0, t.default = function(r) {
571
570
  return (0, s.default)((0, n.default)(r));
572
571
  };
573
- var n = o(fe), s = o(Ve);
572
+ var n = o(fe), s = o(Ge);
574
573
  function o(r) {
575
574
  return r && r.__esModule ? r : { default: r };
576
575
  }
@@ -613,33 +612,33 @@ var Ae = X.exports;
613
612
  if (typeof r == "object" && e === void 0 && i === void 0) return (0, n.default)(r.hue, r.saturation, r.lightness);
614
613
  throw new s.default(1);
615
614
  };
616
- var n = o(Ae), s = o(_);
615
+ var n = o(Ae), s = o(S);
617
616
  function o(r) {
618
617
  return r && r.__esModule ? r : { default: r };
619
618
  }
620
619
  a.exports = t.default;
621
620
  })(Q, Q.exports);
622
- var Ze = Q.exports, ne = { exports: {} };
621
+ var Ve = Q.exports, ne = { exports: {} };
623
622
  (function(a, t) {
624
623
  t.__esModule = !0, t.default = function(e, i, d, l) {
625
624
  if (typeof e == "number" && typeof i == "number" && typeof d == "number" && typeof l == "number") return l >= 1 ? (0, n.default)(e, i, d) : "rgba(" + (0, s.default)(e, i, d) + "," + l + ")";
626
625
  if (typeof e == "object" && i === void 0 && d === void 0 && l === void 0) return e.alpha >= 1 ? (0, n.default)(e.hue, e.saturation, e.lightness) : "rgba(" + (0, s.default)(e.hue, e.saturation, e.lightness) + "," + e.alpha + ")";
627
626
  throw new o.default(2);
628
627
  };
629
- var n = r(Ae), s = r(ue), o = r(_);
628
+ var n = r(Ae), s = r(ue), o = r(S);
630
629
  function r(e) {
631
630
  return e && e.__esModule ? e : { default: e };
632
631
  }
633
632
  a.exports = t.default;
634
633
  })(ne, ne.exports);
635
- var Qe = ne.exports, re = { exports: {} };
634
+ var Ze = ne.exports, re = { exports: {} };
636
635
  (function(a, t) {
637
636
  t.__esModule = !0, t.default = function(e, i, d) {
638
637
  if (typeof e == "number" && typeof i == "number" && typeof d == "number") return (0, n.default)("#" + (0, s.default)(e) + (0, s.default)(i) + (0, s.default)(d));
639
638
  if (typeof e == "object" && i === void 0 && d === void 0) return (0, n.default)("#" + (0, s.default)(e.red) + (0, s.default)(e.green) + (0, s.default)(e.blue));
640
639
  throw new o.default(6);
641
640
  };
642
- var n = r(Ce), s = r(Ee), o = r(_);
641
+ var n = r(Ce), s = r(Ee), o = r(S);
643
642
  function r(e) {
644
643
  return e && e.__esModule ? e : { default: e };
645
644
  }
@@ -656,13 +655,13 @@ var Ie = re.exports, ae = { exports: {} };
656
655
  if (typeof e == "object" && i === void 0 && d === void 0 && l === void 0) return e.alpha >= 1 ? (0, s.default)(e.red, e.green, e.blue) : "rgba(" + e.red + "," + e.green + "," + e.blue + "," + e.alpha + ")";
657
656
  throw new o.default(7);
658
657
  };
659
- var n = r(fe), s = r(Ie), o = r(_);
658
+ var n = r(fe), s = r(Ie), o = r(S);
660
659
  function r(e) {
661
660
  return e && e.__esModule ? e : { default: e };
662
661
  }
663
662
  a.exports = t.default;
664
663
  })(ae, ae.exports);
665
- var Xe = ae.exports;
664
+ var Qe = ae.exports;
666
665
  (function(a, t) {
667
666
  t.__esModule = !0, t.default = function(u) {
668
667
  if (typeof u != "object") throw new e.default(8);
@@ -672,7 +671,7 @@ var Xe = ae.exports;
672
671
  if (f(u)) return (0, n.default)(u);
673
672
  throw new e.default(8);
674
673
  };
675
- var n = i(Ze), s = i(Qe), o = i(Ie), r = i(Xe), e = i(_);
674
+ var n = i(Ve), s = i(Ze), o = i(Ie), r = i(Qe), e = i(S);
676
675
  function i(u) {
677
676
  return u && u.__esModule ? u : { default: u };
678
677
  }
@@ -690,7 +689,7 @@ var Xe = ae.exports;
690
689
  var Oe = Z.exports;
691
690
  (function(a, t) {
692
691
  t.__esModule = !0, t.default = void 0;
693
- var n = e(_e), s = e(Se), o = e(ke), r = e(Oe);
692
+ var n = e(Se), s = e(_e), o = e(ke), r = e(Oe);
694
693
  function e(l) {
695
694
  return l && l.__esModule ? l : { default: l };
696
695
  }
@@ -710,11 +709,11 @@ var Oe = Z.exports;
710
709
  });
711
710
  t.default = d, a.exports = t.default;
712
711
  })(Y, Y.exports);
713
- const et = le(Y.exports);
712
+ const Xe = le(Y.exports);
714
713
  var oe = { exports: {} };
715
714
  (function(a, t) {
716
715
  t.__esModule = !0, t.default = void 0;
717
- var n = e(_e), s = e(Se), o = e(ke), r = e(Oe);
716
+ var n = e(Se), s = e(_e), o = e(ke), r = e(Oe);
718
717
  function e(l) {
719
718
  return l && l.__esModule ? l : { default: l };
720
719
  }
@@ -734,27 +733,27 @@ var oe = { exports: {} };
734
733
  });
735
734
  t.default = d, a.exports = t.default;
736
735
  })(oe, oe.exports);
737
- const tt = le(oe.exports);
738
- function nt(a) {
736
+ const et = le(oe.exports);
737
+ function tt(a) {
739
738
  if (!document.querySelector("style[data-widget-styles]")) {
740
739
  var t, n;
741
740
  (function() {
742
741
  let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "#000", o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "FFF";
743
742
  const r = document.createElement("style");
744
743
  r.attributes.setNamedItem(document.createAttribute("data-widget-styles"));
745
- const e = Ge(s) > 0.5;
744
+ const e = Ue(s) > 0.5;
746
745
  r.textContent = `
747
746
  .bf-trigger-button{position:fixed;bottom:16px;right:16px;width:56px;height:56px;border-radius:50%;border:none;box-shadow:0 20px 25px -5px #1212171a,0 10px 10px -5px #1212170a;display:flex;align-items:center;justify-content:center;cursor:pointer;z-index:1000;padding:12px;gap:10px;overflow:hidden}.bf-trigger-button.hidden{display:none}.trigger-button-icon{width:36px;height:36px;position:relative}.trigger-button-icon svg{width:100%;height:100%;position:absolute;inset:0}.trigger-button-icon>svg>path{transition:transform .3s ease,opacity .3s ease;transform:scale(.5);transform-origin:center;opacity:0}.trigger-button-icon svg.visible{display:block}.trigger-button-icon>svg.visible>path{opacity:1;transform:scale(1)}.trigger-iframe{position:relative;width:100%;height:100%;border:none;outline:none;transform:translateZ(0)}.bf-iframe-container{position:fixed;bottom:0;right:0;width:100vw;height:100vh;border:none;overflow:hidden;z-index:999;opacity:0;pointer-events:none;transform:translateY(20px);transition:opacity .3s ease,transform .3s ease,width .2s ease-in-out,height .2s ease-in-out}.bf-iframe-container.open{opacity:1;transform:translateY(0);pointer-events:auto;top:0;left:0}@media (min-width: 576px){.bf-iframe-container{bottom:80px;right:24px;width:448px;height:min(750px,calc(100vh - 80px));border-radius:8px;border:1px solid var(--Dark-300, #D4D4D4);box-shadow:0 20px 25px -5px #1212171a,0 10px 10px -5px #1212170a}.bf-iframe-container.open{top:unset;left:unset}.bf-iframe-container.expanded{width:min(calc(448px * 1.35),calc(100vw - 16px));height:min(calc(750px * 1.35),calc(100vh - 80px))}}
748
747
  .${j} { background: ${s}; }
749
748
  .${j}:hover {
750
- background: ${e ? et(0.05, s) : tt(0.05, s)};
749
+ background: ${e ? Xe(0.05, s) : et(0.05, s)};
751
750
  }
752
751
  .trigger-button-icon { color: ${o}; }
753
752
  `, document.head.appendChild(r);
754
753
  })((a == null || (t = a.theme) === null || t === void 0 ? void 0 : t.inputButtonBgColor) || "#007bff", (a == null || (n = a.theme) === null || n === void 0 ? void 0 : n.textBaseColor) || "#ffffff");
755
754
  }
756
755
  }
757
- function rt(a, t) {
756
+ function nt(a, t) {
758
757
  const n = () => {
759
758
  ((s) => {
760
759
  var o;
@@ -766,7 +765,7 @@ function rt(a, t) {
766
765
  s.observe(document.body, { attributes: !0, attributeFilter: ["class"] }), t.addEventListener("abort", () => s.disconnect());
767
766
  })();
768
767
  }
769
- function at(a, t) {
768
+ function rt(a, t) {
770
769
  let n;
771
770
  const s = () => {
772
771
  ((r) => {
@@ -791,10 +790,10 @@ function ve(a) {
791
790
  if (typeof Buffer != "undefined") return Buffer.from(t).toString("base64");
792
791
  throw new Error("[utils.base64Encode]: Unsupported environment");
793
792
  }
794
- const ye = /* @__PURE__ */ new Set(), ie = [];
795
- function ot(a, t) {
793
+ const ye = /* @__PURE__ */ new Set();
794
+ function at(a, t) {
796
795
  const n = document.createDocumentFragment(), s = function(e) {
797
- const i = T("button", j, { id: `trigger-button-${e}`, "aria-controls": C, "aria-expanded": "false", "data-name": j }), d = T("div", "trigger-button-icon", { "aria-hidden": "true" });
796
+ const i = B("button", j, { id: `trigger-button-${e}`, "aria-controls": C, "aria-expanded": "false", "data-name": j }), d = B("div", "trigger-button-icon", { "aria-hidden": "true" });
798
797
  return d.innerHTML = `
799
798
  <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256" class="close-icon">
800
799
  <path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"></path>
@@ -804,12 +803,12 @@ function ot(a, t) {
804
803
  </svg>
805
804
  `, i.setAttribute("aria-label", "Open Brainfish widget"), i.appendChild(d), v.initialize(i, d), i;
806
805
  }(a), { iframeContainer: o, iframe: r } = function(e) {
807
- const i = T("div", C, { id: C, "aria-live": "polite", "aria-hidden": "true" }), d = T("iframe", xe, { src: e, sandbox: "allow-scripts allow-same-origin allow-popups allow-forms", allow: "clipboard-write", role: "dialog" });
806
+ const i = B("div", C, { id: C, "aria-live": "polite", "aria-hidden": "true" }), d = B("iframe", xe, { src: e, sandbox: "allow-scripts allow-same-origin allow-popups allow-forms", allow: "clipboard-write", role: "dialog" });
808
807
  return i.appendChild(d), { iframeContainer: i, iframe: d };
809
808
  }(t);
810
809
  return n.appendChild(s), n.appendChild(o), { fragment: n, iframe: r };
811
810
  }
812
- const it = function(a, t) {
811
+ const ot = function(a, t) {
813
812
  let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
814
813
  const s = de(a.overrides), o = ((r = a.overrides) == null ? void 0 : r.widgetHost) || "https://agent.brainfi.sh";
815
814
  var r;
@@ -818,18 +817,13 @@ const it = function(a, t) {
818
817
  if (l = a.widgetKey, ye.has(l) || function(p) {
819
818
  return !!document.getElementById(`trigger-button-${p}`);
820
819
  }(a.widgetKey)) return;
821
- nt(t);
822
- const { fragment: f, iframe: c } = ot(a.widgetKey, d), u = new AbortController(), { signal: g } = u;
820
+ tt(t);
821
+ const { fragment: f, iframe: c } = at(a.widgetKey, d), u = new AbortController(), { signal: g } = u;
823
822
  c.onload = () => {
824
823
  setTimeout(() => {
825
- rt(c, g), Je({ widgetHost: o, apiHost: s, widgetKey: a.widgetKey, signal: g }), at(c, g), c.contentWindow && n.length > 0 && (n.forEach((p) => {
824
+ nt(c, g), Ye({ widgetHost: o, apiHost: s, widgetKey: a.widgetKey, signal: g }), rt(c, g), console.log("------- earlyIdentifyQueue-------", n), c.contentWindow && n.length > 0 && (n.forEach((p) => {
826
825
  c.contentWindow.postMessage({ type: "IDENTIFY_DATA", data: p }, "*");
827
- }), n.length = 0), ((p) => {
828
- if (p.contentWindow) for (; ie.length > 0; ) {
829
- const m = ie.shift();
830
- m && p.contentWindow.postMessage({ type: "IDENTIFY_DATA", data: m.detail }, "*");
831
- }
832
- })(c);
826
+ }), n.length = 0);
833
827
  }, 0);
834
828
  }, document.body.appendChild(f), ye.add(a.widgetKey);
835
829
  const h = () => {
@@ -843,15 +837,11 @@ const it = function(a, t) {
843
837
  }
844
838
  var l;
845
839
  };
846
- window.addEventListener("brainfish:identify", (a) => {
847
- const t = a, n = document.querySelector(`#${C} .${xe}`);
848
- n != null && n.contentWindow ? n.contentWindow.postMessage({ type: "IDENTIFY_DATA", data: t.detail }, "*") : ie.push(t);
849
- });
850
840
  let P = null;
851
- const Me = [];
841
+ const ie = [];
852
842
  typeof window != "undefined" && window.addEventListener("brainfish:identify", (a) => {
853
- const t = a;
854
- Me.push(t.detail);
843
+ const t = a, n = document.querySelector(`#${C} .${xe}`);
844
+ n != null && n.contentWindow ? (console.log("------- iframe is ready-------"), n.contentWindow.postMessage({ type: "IDENTIFY_DATA", data: t.detail }, "*")) : (console.log("------- pushing event to queue -------"), ie.push(t.detail)), console.log("------- identifyEventQueue-------", ie);
855
845
  });
856
846
  const we = typeof window != "undefined" && window.Brainfish ? window.Brainfish : (P || (P = /* @__PURE__ */ function() {
857
847
  let a = [], t = null;
@@ -890,7 +880,7 @@ const we = typeof window != "undefined" && window.Brainfish ? window.Brainfish :
890
880
  } };
891
881
  }(), typeof window != "undefined" && (window.Brainfish = P)), P);
892
882
  let K = null;
893
- we.Widgets.init = (a) => b(void 0, null, function* () {
883
+ we.Widgets.init = (a) => m(void 0, null, function* () {
894
884
  window && (window.BrainfishAnalytics = window.BrainfishAnalytics || function() {
895
885
  for (var r = arguments.length, e = new Array(r), i = 0; i < r; i++) e[i] = arguments[i];
896
886
  (window.BrainfishAnalytics.q = window.BrainfishAnalytics.q || []).push(e);
@@ -908,24 +898,24 @@ we.Widgets.init = (a) => b(void 0, null, function* () {
908
898
  throw new Error("[utils.base64Decode]: Unsupported environment");
909
899
  })(a.config));
910
900
  else {
911
- const { config: r } = yield Ne({ widgetKey: a.widgetKey, apiHost: t });
901
+ const { config: r } = yield He({ widgetKey: a.widgetKey, apiHost: t });
912
902
  o = r;
913
903
  }
914
904
  K || (K = function(r, e, i, d) {
915
- return b(this, null, function* () {
905
+ return m(this, null, function* () {
916
906
  var l, f, c;
917
907
  const u = ((l = r.overrides) === null || l === void 0 ? void 0 : l.enableRecording) || (e == null || (f = e.settings) === null || f === void 0 ? void 0 : f.enableRecording) || !1, g = ((c = r.overrides) === null || c === void 0 ? void 0 : c.version) || (e == null ? void 0 : e.version), h = [];
918
- g != null && g.startsWith("2.") ? it(r, e, Me) : h.push(Re(r, e)), h.push(Ye(r.widgetKey, e.trackingToken || "", i, d, u));
908
+ g != null && g.startsWith("2.") ? ot(r, e, ie) : h.push(ze(r, e)), h.push(Re(r.widgetKey, e.trackingToken || "", i, d, u));
919
909
  const [p] = yield Promise.allSettled(h);
920
910
  p && p.status === "fulfilled" && p.value && we._setRealBrainfish(p.value);
921
911
  });
922
912
  }(a, o, t, n)), yield K;
923
913
  });
924
- const dt = function() {
914
+ const st = function() {
925
915
  typeof window != "undefined" && window.BrainfishAnalytics && window.BrainfishAnalytics(...arguments);
926
916
  };
927
917
  export {
928
- dt as BrainfishAnalytics,
918
+ st as BrainfishAnalytics,
929
919
  we as default
930
920
  };
931
921
  //# sourceMappingURL=web.js.map