@brainfish-ai/widgets-initiator 1.7.0-alpha.4 → 1.7.0-alpha.6

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,16 +1,16 @@
1
- var je = Object.defineProperty, Fe = Object.defineProperties;
2
- var Le = Object.getOwnPropertyDescriptors;
3
- var pe = Object.getOwnPropertySymbols;
4
- var $e = Object.prototype.hasOwnProperty, Ke = Object.prototype.propertyIsEnumerable;
5
- var F = (a, t, r) => t in a ? je(a, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[t] = r, L = (a, t) => {
1
+ var Fe = Object.defineProperty, Le = Object.defineProperties;
2
+ var $e = Object.getOwnPropertyDescriptors;
3
+ var ge = Object.getOwnPropertySymbols;
4
+ var We = Object.prototype.hasOwnProperty, Ke = Object.prototype.propertyIsEnumerable;
5
+ var F = (a, t, r) => t in a ? Fe(a, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[t] = r, L = (a, t) => {
6
6
  for (var r in t || (t = {}))
7
- $e.call(t, r) && F(a, r, t[r]);
8
- if (pe)
9
- for (var r of pe(t))
7
+ We.call(t, r) && F(a, r, t[r]);
8
+ if (ge)
9
+ for (var r of ge(t))
10
10
  Ke.call(t, r) && F(a, r, t[r]);
11
11
  return a;
12
- }, $ = (a, t) => Fe(a, Le(t));
13
- var _ = (a, t, r) => F(a, typeof t != "symbol" ? t + "" : t, r);
12
+ }, $ = (a, t) => Le(a, $e(t));
13
+ var k = (a, t, r) => F(a, typeof t != "symbol" ? t + "" : t, r);
14
14
  var m = (a, t, r) => new Promise((d, o) => {
15
15
  var n = (s) => {
16
16
  try {
@@ -31,17 +31,17 @@ var S, H;
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] = "c2e4d529-5343-4185-ae6a-5d6f260a70e0", a._sentryDebugIdIdentifier = "sentry-dbid-c2e4d529-5343-4185-ae6a-5d6f260a70e0");
34
+ t && (a._sentryDebugIds = a._sentryDebugIds || {}, a._sentryDebugIds[t] = "ef3d6dd3-1c8b-462d-bfc6-c7cd629e6c2a", a._sentryDebugIdIdentifier = "sentry-dbid-ef3d6dd3-1c8b-462d-bfc6-c7cd629e6c2a");
35
35
  } catch (r) {
36
36
  }
37
- })(), (typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {}).SENTRY_RELEASE = { id: "651c59539d178331f755a564d3ff100ea1dba17c" }, function(a) {
37
+ })(), (typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {}).SENTRY_RELEASE = { id: "9a381691e353ad27b69792e87217d32d705b3020" }, function(a) {
38
38
  a.Sidebar = "sidebar", a.Searchbar = "searchbar";
39
39
  }(S || (S = {})), S.Sidebar, S.Searchbar;
40
- class ie extends Error {
40
+ class se extends Error {
41
41
  constructor(r, d) {
42
42
  super(r, d);
43
- _(this, "cause");
44
- this.name = "BrainfishWidgetError", this.cause = d == null ? void 0 : d.cause, Error.captureStackTrace && Error.captureStackTrace(this, ie), this.cause instanceof Error && this.cause.stack && (this.stack = this.stack + `
43
+ k(this, "cause");
44
+ this.name = "BrainfishWidgetError", this.cause = d == null ? void 0 : d.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
  }
47
47
  toJSON() {
@@ -62,9 +62,9 @@ const x = (a, t, r, d) => {
62
62
  ((e, i, s) => {
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": s }, body: JSON.stringify({ error: `WebWidgetVersion: 1.7.0-alpha.4. ${i.message}`, stack: i.stack, cause: { message: l.message, stack: l.stack, cause: l.cause } }) });
66
- })(a, new ie(o, { cause: n }), d);
67
- }, We = (a) => m(void 0, null, function* () {
65
+ fetch(`${e || "https://app.brainfi.sh"}/api/trackError.widget.create`, { method: "POST", headers: { "Content-Type": "application/json", "api-key": s }, body: JSON.stringify({ error: `WebWidgetVersion: 1.7.0-alpha.6. ${i.message}`, stack: i.stack, cause: { message: l.message, stack: l.stack, cause: l.cause } }) });
66
+ })(a, new se(o, { cause: n }), d);
67
+ }, De = (a) => m(void 0, null, function* () {
68
68
  let { widgetKey: t, apiHost: r } = a;
69
69
  return function(d, o, n) {
70
70
  return m(this, null, function* () {
@@ -87,20 +87,20 @@ const x = (a, t, r, d) => {
87
87
  return ["bodyActionButtons", "footerActionButtons", "nextBestActions"].forEach((n) => {
88
88
  o[n] && (o[n] = o[n].map((e) => e.type === H.CALLBACK && e.value ? $(L({}, e), { value: new Function(`return ${e.value}`)() }) : e));
89
89
  }), $(L({}, t), { settings: o, apiHost: d, widgetMode: t.widgetType, apiKey: r });
90
- }, se = (a) => (a == null ? void 0 : a.apiHost) || "https://app.brainfi.sh", K = (() => {
90
+ }, de = (a) => (a == null ? void 0 : a.apiHost) || "https://app.brainfi.sh", W = (() => {
91
91
  if (typeof window == "undefined") return;
92
92
  const a = window.navigator.userAgent;
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
- })(), ze = (a) => m(void 0, null, function* () {
96
+ })(), Ne = (a) => m(void 0, null, function* () {
97
97
  let { apiHost: t, widgetKey: r, version: d } = a;
98
98
  try {
99
- const o = `https://cdn.jsdelivr.net/npm/@brainfish-ai/search-widget@${d}/dist/web.js`, n = K ? o.replace("web.js", "web.umd.js") : o;
99
+ const o = `https://cdn.jsdelivr.net/npm/@brainfish-ai/search-widget@${d}/dist/web.js`, n = W ? o.replace("web.js", "web.umd.js") : o;
100
100
  return { widget: yield ((i) => m(void 0, null, function* () {
101
101
  return document.getElementById("brainfish-widget") ? window.Brainfish : new Promise((s, l) => {
102
102
  const u = document.createElement("script");
103
- u.id = "brainfish-widget", u.src = i, u.type = K ? "text/javascript" : "module", u.async = !0, u.crossOrigin = "anonymous", u.onload = () => {
103
+ u.id = "brainfish-widget", u.src = i, u.type = W ? "text/javascript" : "module", u.async = !0, u.crossOrigin = "anonymous", u.onload = () => {
104
104
  setTimeout(() => {
105
105
  const c = window.Brainfish;
106
106
  c ? s(c) : l(new Error("Failed to load Brainfish module"));
@@ -108,17 +108,17 @@ const x = (a, t, r, d) => {
108
108
  }, u.onerror = (c) => {
109
109
  const f = c, g = { message: `Failed to load script: ${i}`, type: f.type, fileName: f.filename, lineNumber: f.lineno, columnNumber: f.colno, error: f.error ? f.error.toString() : "Unknown error" };
110
110
  l(new Error(JSON.stringify(g)));
111
- }, K || document.head.appendChild(u);
111
+ }, W || document.head.appendChild(u);
112
112
  });
113
113
  }))(n) };
114
114
  } catch (o) {
115
115
  x(t, o, o.message, r);
116
116
  }
117
- }), ge = /* @__PURE__ */ new Set(), De = (a, t) => m(void 0, null, function* () {
118
- const r = se(a.overrides);
117
+ }), he = /* @__PURE__ */ new Set(), ze = (a, t) => m(void 0, null, function* () {
118
+ const r = de(a.overrides);
119
119
  try {
120
- if (ge.has(a.widgetKey)) return;
121
- const d = yield ze({ apiHost: r, widgetKey: a.widgetKey, version: t.version || "latest" });
120
+ if (he.has(a.widgetKey)) return;
121
+ const d = yield Ne({ apiHost: r, widgetKey: a.widgetKey, version: t.version || "latest" });
122
122
  if (d) {
123
123
  const { widget: o } = d, n = He({ config: t, apiKey: a.widgetKey, apiHost: r });
124
124
  return a.overrides && t.settings && Object.entries(a.overrides).forEach((e) => {
@@ -130,17 +130,17 @@ const x = (a, t, r, d) => {
130
130
  }(t.settings[i], s));
131
131
  }), function(e, i) {
132
132
  i.widgetType === S.Searchbar || i.widgetType === "Search" ? e.SearchWidget.initStandard(i) : e.HelpWidget.initPopup(i);
133
- }(o, n), ge.add(a.widgetKey), o;
133
+ }(o, n), he.add(a.widgetKey), o;
134
134
  }
135
135
  } catch (d) {
136
136
  x(r, d, d.message, a.widgetKey);
137
137
  }
138
138
  });
139
- let he = !1;
140
- const Ne = function(d, o, n) {
139
+ let me = !1;
140
+ const qe = function(d, o, n) {
141
141
  return m(this, arguments, function* (a, t, r) {
142
142
  let e = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "", i = arguments.length > 4 && arguments[4] !== void 0 && arguments[4];
143
- if (t || x(r, new Error("Access key is required"), "Access key is required", a), !he) try {
143
+ if (t || x(r, new Error("Access key is required"), "Access key is required", a), !me) try {
144
144
  const s = (() => {
145
145
  if (typeof window == "undefined" || typeof navigator == "undefined") return !1;
146
146
  const u = navigator, c = window, f = (u.doNotTrack || c.doNotTrack || u.msDoNotTrack || "0").toString().toLowerCase();
@@ -152,7 +152,7 @@ const Ne = function(d, o, n) {
152
152
  for (var u = arguments.length, c = new Array(u), f = 0; f < u; f++) c[f] = arguments[f];
153
153
  var g;
154
154
  return c[0] === "identify" && (g = c[1], window.dispatchEvent(new CustomEvent("brainfish:identify", { detail: g }))), l.apply(this, c);
155
- }, he = !0, yield ((u, c) => m(this, null, function* () {
155
+ }, me = !0, yield ((u, c) => m(this, null, function* () {
156
156
  if (document.getElementById("brainfish-analytics")) return window.BrainfishAnalytics;
157
157
  const f = document.createElement("script");
158
158
  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 = () => {
@@ -164,7 +164,7 @@ const Ne = function(d, o, n) {
164
164
  }
165
165
  });
166
166
  };
167
- function B(a, t) {
167
+ function M(a, t) {
168
168
  let r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
169
169
  const d = document.createElement(a);
170
170
  return d.className = t, Object.entries(r).forEach((o) => {
@@ -172,7 +172,7 @@ function B(a, t) {
172
172
  d.setAttribute(n, e);
173
173
  }), d;
174
174
  }
175
- const T = "bf-iframe-container", j = "bf-trigger-button";
175
+ const P = "bf-iframe-container", j = "bf-trigger-button";
176
176
  class v {
177
177
  static get isWidgetOpen() {
178
178
  return this.isOpen;
@@ -196,14 +196,14 @@ class v {
196
196
  (t = this.button) === null || t === void 0 || t.classList.add("hidden");
197
197
  }
198
198
  }
199
- _(v, "isOpen", !1), _(v, "button", null), _(v, "icon", null);
200
- function qe(a) {
199
+ k(v, "isOpen", !1), k(v, "button", null), k(v, "icon", null);
200
+ function Re(a) {
201
201
  let { widgetHost: t, apiHost: r, widgetKey: d, signal: o } = a;
202
202
  window.addEventListener("message", (n) => {
203
203
  if (n.origin !== t) return;
204
204
  const { type: e } = n.data;
205
205
  if (e === "TOGGLE_WIDGET_SIZE" && function() {
206
- const i = document.querySelector(`.${T}`);
206
+ const i = document.querySelector(`.${P}`);
207
207
  i.classList.contains("expanded") ? i.classList.remove("expanded") : i.classList.add("expanded");
208
208
  }(), e === "TRACK_EVENT") {
209
209
  if (!window.BrainfishAnalytics) return;
@@ -223,10 +223,10 @@ function qe(a) {
223
223
  }
224
224
  }, { signal: o });
225
225
  }
226
- function de(a) {
226
+ function le(a) {
227
227
  return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a;
228
228
  }
229
- var z = { exports: {} }, D = { exports: {} }, N = { exports: {} };
229
+ var N = { exports: {} }, z = { exports: {} }, q = { exports: {} };
230
230
  (function(a, t) {
231
231
  function r(o) {
232
232
  return Math.round(255 * o);
@@ -241,8 +241,8 @@ var z = { exports: {} }, D = { exports: {} }, N = { exports: {} };
241
241
  var h = e - l / 2;
242
242
  return i(c + h, f + h, g + h);
243
243
  }, a.exports = t.default;
244
- })(N, N.exports);
245
- var le = N.exports, q = { exports: {} };
244
+ })(q, q.exports);
245
+ var ue = q.exports, R = { exports: {} };
246
246
  (function(a, t) {
247
247
  t.__esModule = !0, t.default = void 0;
248
248
  var r = { 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 +251,8 @@ var le = N.exports, q = { exports: {} };
251
251
  var o = d.toLowerCase();
252
252
  return r[o] ? "#" + r[o] : d;
253
253
  }, a.exports = t.default;
254
- })(q, q.exports);
255
- var Re = q.exports, R = { exports: {} };
254
+ })(R, R.exports);
255
+ var Ye = R.exports, Y = { exports: {} };
256
256
  (function(a, t) {
257
257
  function r(s) {
258
258
  var l = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
@@ -475,8 +475,8 @@ To pass a single animation please supply them in simple values, e.g. animation('
475
475
  }
476
476
  return u = s, (l = c).prototype = Object.create(u.prototype), l.prototype.constructor = l, o(l, u), c;
477
477
  }(r(Error)), a.exports = t.default;
478
- })(R, R.exports);
479
- var k = R.exports;
478
+ })(Y, Y.exports);
479
+ var _ = Y.exports;
480
480
  (function(a, t) {
481
481
  t.__esModule = !0, t.default = function(h) {
482
482
  if (typeof h != "string") throw new o.default(3);
@@ -497,26 +497,26 @@ var k = R.exports;
497
497
  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
498
  var A = f.exec(p);
499
499
  if (A) {
500
- var Ie = parseInt("" + A[1], 10), Oe = parseInt("" + A[2], 10) / 100, Be = parseInt("" + A[3], 10) / 100, fe = "rgb(" + (0, r.default)(Ie, Oe, Be) + ")", I = u.exec(fe);
501
- if (!I) throw new o.default(4, p, fe);
500
+ var Oe = parseInt("" + A[1], 10), Me = parseInt("" + A[2], 10) / 100, Be = parseInt("" + A[3], 10) / 100, ce = "rgb(" + (0, r.default)(Oe, Me, Be) + ")", I = u.exec(ce);
501
+ if (!I) throw new o.default(4, p, ce);
502
502
  return { red: parseInt("" + I[1], 10), green: parseInt("" + I[2], 10), blue: parseInt("" + I[3], 10) };
503
503
  }
504
504
  var w = g.exec(p.substring(0, 50));
505
505
  if (w) {
506
- var Me = parseInt("" + w[1], 10), Pe = parseInt("" + w[2], 10) / 100, Te = parseInt("" + w[3], 10) / 100, ce = "rgb(" + (0, r.default)(Me, Pe, Te) + ")", O = u.exec(ce);
507
- if (!O) throw new o.default(4, p, ce);
506
+ var Te = parseInt("" + w[1], 10), Pe = parseInt("" + w[2], 10) / 100, je = parseInt("" + w[3], 10) / 100, pe = "rgb(" + (0, r.default)(Te, Pe, je) + ")", O = u.exec(pe);
507
+ if (!O) throw new o.default(4, p, pe);
508
508
  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]) };
509
509
  }
510
510
  throw new o.default(5);
511
511
  };
512
- var r = n(le), d = n(Re), o = n(k);
512
+ var r = n(ue), d = n(Ye), o = n(_);
513
513
  function n(h) {
514
514
  return h && h.__esModule ? h : { default: h };
515
515
  }
516
516
  var e = /^#[a-fA-F0-9]{6}$/, i = /^#[a-fA-F0-9]{8}$/, s = /^#[a-fA-F0-9]{3}$/, l = /^#[a-fA-F0-9]{4}$/, u = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i, c = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i, f = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i, g = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
517
517
  a.exports = t.default;
518
- })(D, D.exports);
519
- var ue = D.exports;
518
+ })(z, z.exports);
519
+ var fe = z.exports;
520
520
  (function(a, t) {
521
521
  t.__esModule = !0, t.default = function(o) {
522
522
  if (o === "transparent") return 0;
@@ -526,11 +526,11 @@ var ue = D.exports;
526
526
  }), i = e[0], s = e[1], l = e[2];
527
527
  return parseFloat((0.2126 * i + 0.7152 * s + 0.0722 * l).toFixed(3));
528
528
  };
529
- var r, d = (r = ue) && r.__esModule ? r : { default: r };
529
+ var r, d = (r = fe) && r.__esModule ? r : { default: r };
530
530
  a.exports = t.default;
531
- })(z, z.exports);
532
- const Ye = de(z.exports);
533
- var Y = { exports: {} }, J = { exports: {} };
531
+ })(N, N.exports);
532
+ const Je = le(N.exports);
533
+ var J = { exports: {} }, U = { exports: {} };
534
534
  (function(a, t) {
535
535
  function r(d, o, n) {
536
536
  return function() {
@@ -541,12 +541,12 @@ var Y = { exports: {} }, J = { exports: {} };
541
541
  t.__esModule = !0, t.default = function(d) {
542
542
  return r(d, d.length, []);
543
543
  }, a.exports = t.default;
544
- })(J, J.exports);
545
- var me, M, we = J.exports, U = { exports: {} };
546
- me = U, (M = U.exports).__esModule = !0, M.default = void 0, M.default = function(a, t, r) {
544
+ })(U, U.exports);
545
+ var be, B, xe = U.exports, G = { exports: {} };
546
+ be = G, (B = G.exports).__esModule = !0, B.default = void 0, B.default = function(a, t, r) {
547
547
  return Math.max(a, Math.min(t, r));
548
- }, me.exports = M.default;
549
- var xe = U.exports, G = { exports: {} }, V = { exports: {} };
548
+ }, be.exports = B.default;
549
+ var _e = G.exports, V = { exports: {} }, Z = { exports: {} };
550
550
  (function(a, t) {
551
551
  t.__esModule = !0, t.default = void 0, t.default = function(r) {
552
552
  var d, o = r.red / 255, n = r.green / 255, e = r.blue / 255, i = Math.max(o, n, e), s = Math.min(o, n, e), l = (i + s) / 2;
@@ -564,35 +564,35 @@ var xe = U.exports, G = { exports: {} }, V = { exports: {} };
564
564
  }
565
565
  return d *= 60, r.alpha !== void 0 ? { hue: d, saturation: c, lightness: l, alpha: r.alpha } : { hue: d, saturation: c, lightness: l };
566
566
  }, a.exports = t.default;
567
- })(V, V.exports);
568
- var Je = V.exports;
567
+ })(Z, Z.exports);
568
+ var Ue = Z.exports;
569
569
  (function(a, t) {
570
570
  t.__esModule = !0, t.default = function(n) {
571
571
  return (0, d.default)((0, r.default)(n));
572
572
  };
573
- var r = o(ue), d = o(Je);
573
+ var r = o(fe), d = o(Ue);
574
574
  function o(n) {
575
575
  return n && n.__esModule ? n : { default: n };
576
576
  }
577
577
  a.exports = t.default;
578
- })(G, G.exports);
579
- var ke = G.exports, Z = { exports: {} }, Q = { exports: {} }, X = { exports: {} }, ee = { exports: {} };
578
+ })(V, V.exports);
579
+ var ke = V.exports, Q = { exports: {} }, X = { exports: {} }, ee = { exports: {} }, te = { exports: {} };
580
580
  (function(a, t) {
581
581
  t.__esModule = !0, t.default = void 0, t.default = function(r) {
582
582
  return r.length === 7 && r[1] === r[2] && r[3] === r[4] && r[5] === r[6] ? "#" + r[1] + r[3] + r[5] : r;
583
583
  }, a.exports = t.default;
584
- })(ee, ee.exports);
585
- var _e = ee.exports, te = { exports: {} };
584
+ })(te, te.exports);
585
+ var Se = te.exports, ne = { exports: {} };
586
586
  (function(a, t) {
587
587
  t.__esModule = !0, t.default = void 0, t.default = function(r) {
588
588
  var d = r.toString(16);
589
589
  return d.length === 1 ? "0" + d : d;
590
590
  }, a.exports = t.default;
591
- })(te, te.exports);
592
- var Se = te.exports;
591
+ })(ne, ne.exports);
592
+ var Ce = ne.exports;
593
593
  (function(a, t) {
594
594
  t.__esModule = !0, t.default = void 0;
595
- var r = n(le), d = n(_e), o = n(Se);
595
+ var r = n(ue), d = n(Se), o = n(Ce);
596
596
  function n(s) {
597
597
  return s && s.__esModule ? s : { default: s };
598
598
  }
@@ -605,47 +605,47 @@ var Se = te.exports;
605
605
  t.default = function(s, l, u) {
606
606
  return (0, r.default)(s, l, u, i);
607
607
  }, a.exports = t.default;
608
- })(X, X.exports);
609
- var Ce = X.exports;
608
+ })(ee, ee.exports);
609
+ var Ee = ee.exports;
610
610
  (function(a, t) {
611
611
  t.__esModule = !0, t.default = function(n, e, i) {
612
612
  if (typeof n == "number" && typeof e == "number" && typeof i == "number") return (0, r.default)(n, e, i);
613
613
  if (typeof n == "object" && e === void 0 && i === void 0) return (0, r.default)(n.hue, n.saturation, n.lightness);
614
614
  throw new d.default(1);
615
615
  };
616
- var r = o(Ce), d = o(k);
616
+ var r = o(Ee), d = o(_);
617
617
  function o(n) {
618
618
  return n && n.__esModule ? n : { default: n };
619
619
  }
620
620
  a.exports = t.default;
621
- })(Q, Q.exports);
622
- var Ue = Q.exports, ne = { exports: {} };
621
+ })(X, X.exports);
622
+ var Ge = X.exports, re = { exports: {} };
623
623
  (function(a, t) {
624
624
  t.__esModule = !0, t.default = function(e, i, s, l) {
625
625
  if (typeof e == "number" && typeof i == "number" && typeof s == "number" && typeof l == "number") return l >= 1 ? (0, r.default)(e, i, s) : "rgba(" + (0, d.default)(e, i, s) + "," + l + ")";
626
626
  if (typeof e == "object" && i === void 0 && s === void 0 && l === void 0) return e.alpha >= 1 ? (0, r.default)(e.hue, e.saturation, e.lightness) : "rgba(" + (0, d.default)(e.hue, e.saturation, e.lightness) + "," + e.alpha + ")";
627
627
  throw new o.default(2);
628
628
  };
629
- var r = n(Ce), d = n(le), o = n(k);
629
+ var r = n(Ee), d = n(ue), o = n(_);
630
630
  function n(e) {
631
631
  return e && e.__esModule ? e : { default: e };
632
632
  }
633
633
  a.exports = t.default;
634
- })(ne, ne.exports);
635
- var Ge = ne.exports, re = { exports: {} };
634
+ })(re, re.exports);
635
+ var Ve = re.exports, ae = { exports: {} };
636
636
  (function(a, t) {
637
637
  t.__esModule = !0, t.default = function(e, i, s) {
638
638
  if (typeof e == "number" && typeof i == "number" && typeof s == "number") return (0, r.default)("#" + (0, d.default)(e) + (0, d.default)(i) + (0, d.default)(s));
639
639
  if (typeof e == "object" && i === void 0 && s === void 0) return (0, r.default)("#" + (0, d.default)(e.red) + (0, d.default)(e.green) + (0, d.default)(e.blue));
640
640
  throw new o.default(6);
641
641
  };
642
- var r = n(_e), d = n(Se), o = n(k);
642
+ var r = n(Se), d = n(Ce), o = n(_);
643
643
  function n(e) {
644
644
  return e && e.__esModule ? e : { default: e };
645
645
  }
646
646
  a.exports = t.default;
647
- })(re, re.exports);
648
- var Ee = re.exports, ae = { exports: {} };
647
+ })(ae, ae.exports);
648
+ var Ae = ae.exports, oe = { exports: {} };
649
649
  (function(a, t) {
650
650
  t.__esModule = !0, t.default = function(e, i, s, l) {
651
651
  if (typeof e == "string" && typeof i == "number") {
@@ -656,13 +656,13 @@ var Ee = re.exports, ae = { exports: {} };
656
656
  if (typeof e == "object" && i === void 0 && s === void 0 && l === void 0) return e.alpha >= 1 ? (0, d.default)(e.red, e.green, e.blue) : "rgba(" + e.red + "," + e.green + "," + e.blue + "," + e.alpha + ")";
657
657
  throw new o.default(7);
658
658
  };
659
- var r = n(ue), d = n(Ee), o = n(k);
659
+ var r = n(fe), d = n(Ae), o = n(_);
660
660
  function n(e) {
661
661
  return e && e.__esModule ? e : { default: e };
662
662
  }
663
663
  a.exports = t.default;
664
- })(ae, ae.exports);
665
- var Ve = ae.exports;
664
+ })(oe, oe.exports);
665
+ var Ze = oe.exports;
666
666
  (function(a, t) {
667
667
  t.__esModule = !0, t.default = function(f) {
668
668
  if (typeof f != "object") throw new e.default(8);
@@ -672,7 +672,7 @@ var Ve = ae.exports;
672
672
  if (u(f)) return (0, r.default)(f);
673
673
  throw new e.default(8);
674
674
  };
675
- var r = i(Ue), d = i(Ge), o = i(Ee), n = i(Ve), e = i(k);
675
+ var r = i(Ge), d = i(Ve), o = i(Ae), n = i(Ze), e = i(_);
676
676
  function i(f) {
677
677
  return f && f.__esModule ? f : { default: f };
678
678
  }
@@ -686,11 +686,11 @@ var Ve = ae.exports;
686
686
  return typeof f.hue == "number" && typeof f.saturation == "number" && typeof f.lightness == "number" && typeof f.alpha == "number";
687
687
  };
688
688
  a.exports = t.default;
689
- })(Z, Z.exports);
690
- var Ae = Z.exports;
689
+ })(Q, Q.exports);
690
+ var Ie = Q.exports;
691
691
  (function(a, t) {
692
692
  t.__esModule = !0, t.default = void 0;
693
- var r = e(we), d = e(xe), o = e(ke), n = e(Ae);
693
+ var r = e(xe), d = e(_e), o = e(ke), n = e(Ie);
694
694
  function e(l) {
695
695
  return l && l.__esModule ? l : { default: l };
696
696
  }
@@ -709,12 +709,12 @@ var Ae = Z.exports;
709
709
  return (0, n.default)(i({}, c, { lightness: (0, d.default)(0, 1, c.lightness - parseFloat(l)) }));
710
710
  });
711
711
  t.default = s, a.exports = t.default;
712
- })(Y, Y.exports);
713
- const Ze = de(Y.exports);
714
- var oe = { exports: {} };
712
+ })(J, J.exports);
713
+ const Qe = le(J.exports);
714
+ var ie = { exports: {} };
715
715
  (function(a, t) {
716
716
  t.__esModule = !0, t.default = void 0;
717
- var r = e(we), d = e(xe), o = e(ke), n = e(Ae);
717
+ var r = e(xe), d = e(_e), o = e(ke), n = e(Ie);
718
718
  function e(l) {
719
719
  return l && l.__esModule ? l : { default: l };
720
720
  }
@@ -733,28 +733,28 @@ var oe = { exports: {} };
733
733
  return (0, n.default)(i({}, c, { lightness: (0, d.default)(0, 1, c.lightness + parseFloat(l)) }));
734
734
  });
735
735
  t.default = s, a.exports = t.default;
736
- })(oe, oe.exports);
737
- const Qe = de(oe.exports);
738
- function Xe(a) {
736
+ })(ie, ie.exports);
737
+ const Xe = le(ie.exports);
738
+ function et(a) {
739
739
  if (!document.querySelector("style[data-widget-styles]")) {
740
740
  var t, r;
741
741
  (function() {
742
742
  let d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "#000", o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "FFF";
743
743
  const n = document.createElement("style");
744
744
  n.attributes.setNamedItem(document.createAttribute("data-widget-styles"));
745
- const e = Ye(d) > 0.5;
745
+ const e = Je(d) > 0.5;
746
746
  n.textContent = `
747
747
  .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
748
  .${j} { background: ${d}; }
749
749
  .${j}:hover {
750
- background: ${e ? Ze(0.05, d) : Qe(0.05, d)};
750
+ background: ${e ? Qe(0.05, d) : Xe(0.05, d)};
751
751
  }
752
752
  .trigger-button-icon { color: ${o}; }
753
753
  `, document.head.appendChild(n);
754
754
  })((a == null || (t = a.theme) === null || t === void 0 ? void 0 : t.inputButtonBgColor) || "#007bff", (a == null || (r = a.theme) === null || r === void 0 ? void 0 : r.textBaseColor) || "#ffffff");
755
755
  }
756
756
  }
757
- function et(a, t) {
757
+ function tt(a, t) {
758
758
  const r = () => {
759
759
  ((d) => {
760
760
  var o;
@@ -766,7 +766,7 @@ function et(a, t) {
766
766
  d.observe(document.body, { attributes: !0, attributeFilter: ["class"] }), t.addEventListener("abort", () => d.disconnect());
767
767
  })();
768
768
  }
769
- function tt(a, t) {
769
+ function nt(a, t) {
770
770
  let r;
771
771
  const d = () => {
772
772
  ((n) => {
@@ -782,7 +782,7 @@ function tt(a, t) {
782
782
  n.observe(document.body), t.addEventListener("abort", () => n.disconnect());
783
783
  })();
784
784
  }
785
- function be(a) {
785
+ function ve(a) {
786
786
  const t = new TextEncoder().encode(a);
787
787
  if (typeof window != "undefined" && typeof window.btoa == "function") {
788
788
  const r = Array.from(t, (d) => String.fromCharCode(d)).join("");
@@ -791,10 +791,10 @@ function be(a) {
791
791
  if (typeof Buffer != "undefined") return Buffer.from(t).toString("base64");
792
792
  throw new Error("[utils.base64Encode]: Unsupported environment");
793
793
  }
794
- const ve = /* @__PURE__ */ new Set();
795
- function nt(a, t) {
794
+ const ye = /* @__PURE__ */ new Set(), K = [];
795
+ function rt(a, t) {
796
796
  const r = document.createDocumentFragment(), d = function(e) {
797
- const i = B("button", j, { id: `trigger-button-${e}`, "aria-controls": T, "aria-expanded": "false", "data-name": j }), s = B("div", "trigger-button-icon", { "aria-hidden": "true" });
797
+ const i = M("button", j, { id: `trigger-button-${e}`, "aria-controls": P, "aria-expanded": "false", "data-name": j }), s = M("div", "trigger-button-icon", { "aria-hidden": "true" });
798
798
  return s.innerHTML = `
799
799
  <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256" class="close-icon">
800
800
  <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,34 +804,38 @@ function nt(a, t) {
804
804
  </svg>
805
805
  `, i.setAttribute("aria-label", "Open Brainfish widget"), i.appendChild(s), v.initialize(i, s), i;
806
806
  }(a), { iframeContainer: o, iframe: n } = function(e) {
807
- const i = B("div", T, { id: T, "aria-live": "polite", "aria-hidden": "true" }), s = B("iframe", "trigger-iframe", { src: e, sandbox: "allow-scripts allow-same-origin allow-popups allow-forms", allow: "clipboard-write", role: "dialog" });
808
- return window.addEventListener("brainfish:identify", (l) => {
809
- var u;
810
- const c = l;
811
- (u = s.contentWindow) === null || u === void 0 || u.postMessage({ type: "IDENTIFY_DATA", data: c.detail }, "*");
812
- }), i.appendChild(s), { iframeContainer: i, iframe: s };
807
+ const i = M("div", P, { id: P, "aria-live": "polite", "aria-hidden": "true" }), s = M("iframe", "trigger-iframe", { src: e, sandbox: "allow-scripts allow-same-origin allow-popups allow-forms", allow: "clipboard-write", role: "dialog" });
808
+ return i.appendChild(s), { iframeContainer: i, iframe: s };
813
809
  }(t);
814
810
  return r.appendChild(d), r.appendChild(o), { fragment: r, iframe: n };
815
811
  }
816
- const rt = (a, t) => {
817
- const r = se(a.overrides), d = ((o = a.overrides) == null ? void 0 : o.widgetHost) || "https://agent.brainfi.sh";
812
+ const at = (a, t) => {
813
+ const r = de(a.overrides), d = ((o = a.overrides) == null ? void 0 : o.widgetHost) || "https://agent.brainfi.sh";
818
814
  var o;
819
- const { theme: n, settings: e } = t, i = `${d}/?widgetKey=${a.widgetKey}&themeParam=${be(JSON.stringify(n))}&settingsParam=${be(JSON.stringify(e))}`;
815
+ const { theme: n, settings: e } = t, i = `${d}/?widgetKey=${a.widgetKey}&themeParam=${ve(JSON.stringify(n))}&settingsParam=${ve(JSON.stringify(e))}`;
820
816
  try {
821
- if (s = a.widgetKey, ve.has(s) || function(h) {
817
+ if (s = a.widgetKey, ye.has(s) || function(h) {
822
818
  return !!document.getElementById(`trigger-button-${h}`);
823
819
  }(a.widgetKey)) return;
824
- Xe(t);
825
- const { fragment: l, iframe: u } = nt(a.widgetKey, i), c = new AbortController(), { signal: f } = c;
820
+ et(t);
821
+ const { fragment: l, iframe: u } = rt(a.widgetKey, i), c = new AbortController(), { signal: f } = c;
826
822
  u.onload = () => {
827
823
  setTimeout(() => {
828
- et(u, f), qe({ widgetHost: d, apiHost: r, widgetKey: a.widgetKey, signal: f }), tt(u, f);
824
+ tt(u, f), Re({ widgetHost: d, apiHost: r, widgetKey: a.widgetKey, signal: f }), nt(u, f), ((h) => {
825
+ if (h.contentWindow) for (; K.length > 0; ) {
826
+ const p = K.shift();
827
+ p && h.contentWindow.postMessage({ type: "IDENTIFY_DATA", data: p.detail }, "*");
828
+ }
829
+ })(u);
829
830
  }, 0);
830
- }, document.body.appendChild(l), ve.add(a.widgetKey);
831
+ }, document.body.appendChild(l), ye.add(a.widgetKey);
831
832
  const g = () => {
832
833
  c.abort(), window.removeEventListener("beforeunload", g);
833
834
  };
834
- return void window.addEventListener("beforeunload", g);
835
+ return window.addEventListener("beforeunload", g), void window.addEventListener("brainfish:identify", (h) => {
836
+ const p = h;
837
+ u.contentWindow ? u.contentWindow.postMessage({ type: "IDENTIFY_DATA", data: p.detail }, "*") : K.push(p);
838
+ });
835
839
  } catch (l) {
836
840
  (function(u, c, f) {
837
841
  x(u, c, c.message, f);
@@ -839,8 +843,8 @@ const rt = (a, t) => {
839
843
  }
840
844
  var s;
841
845
  };
842
- let P = null;
843
- const ye = typeof window != "undefined" && window.Brainfish ? window.Brainfish : (P || (P = /* @__PURE__ */ function() {
846
+ let T = null;
847
+ const we = typeof window != "undefined" && window.Brainfish ? window.Brainfish : (T || (T = /* @__PURE__ */ function() {
844
848
  let a = [], t = null;
845
849
  function r(o, n) {
846
850
  if (t) {
@@ -875,14 +879,14 @@ const ye = typeof window != "undefined" && window.Brainfish ? window.Brainfish :
875
879
  r(n, e);
876
880
  }
877
881
  } };
878
- }(), typeof window != "undefined" && (window.Brainfish = P)), P);
879
- let W = null;
880
- ye.Widgets.init = (a) => m(void 0, null, function* () {
882
+ }(), typeof window != "undefined" && (window.Brainfish = T)), T);
883
+ let D = null;
884
+ we.Widgets.init = (a) => m(void 0, null, function* () {
881
885
  window && (window.BrainfishAnalytics = window.BrainfishAnalytics || function() {
882
886
  for (var n = arguments.length, e = new Array(n), i = 0; i < n; i++) e[i] = arguments[i];
883
887
  (window.BrainfishAnalytics.q = window.BrainfishAnalytics.q || []).push(e);
884
888
  });
885
- const t = se(a.overrides), r = ((d = a.overrides) == null ? void 0 : d.analyticsApiHost) || "";
889
+ const t = de(a.overrides), r = ((d = a.overrides) == null ? void 0 : d.analyticsApiHost) || "";
886
890
  var d;
887
891
  let o;
888
892
  if (a.config) o = JSON.parse(((n) => {
@@ -895,24 +899,24 @@ ye.Widgets.init = (a) => m(void 0, null, function* () {
895
899
  throw new Error("[utils.base64Decode]: Unsupported environment");
896
900
  })(a.config));
897
901
  else {
898
- const { config: n } = yield We({ widgetKey: a.widgetKey, apiHost: t });
902
+ const { config: n } = yield De({ widgetKey: a.widgetKey, apiHost: t });
899
903
  o = n;
900
904
  }
901
- W || (W = function(n, e, i, s) {
905
+ D || (D = function(n, e, i, s) {
902
906
  return m(this, null, function* () {
903
907
  var l, u, c;
904
908
  const f = ((l = n.overrides) === null || l === void 0 ? void 0 : l.enableRecording) || (e == null || (u = e.settings) === null || u === void 0 ? void 0 : u.enableRecording) || !1, g = ((c = n.overrides) === null || c === void 0 ? void 0 : c.version) || (e == null ? void 0 : e.version), h = [];
905
- g != null && g.startsWith("2.") ? rt(n, e) : h.push(De(n, e)), h.push(Ne(n.widgetKey, e.trackingToken || "", i, s, f));
909
+ g != null && g.startsWith("2.") ? at(n, e) : h.push(ze(n, e)), h.push(qe(n.widgetKey, e.trackingToken || "", i, s, f));
906
910
  const [p] = yield Promise.allSettled(h);
907
- p && p.status === "fulfilled" && p.value && ye._setRealBrainfish(p.value);
911
+ p && p.status === "fulfilled" && p.value && we._setRealBrainfish(p.value);
908
912
  });
909
- }(a, o, t, r)), yield W;
913
+ }(a, o, t, r)), yield D;
910
914
  });
911
- const ot = function() {
915
+ const it = function() {
912
916
  typeof window != "undefined" && window.BrainfishAnalytics && window.BrainfishAnalytics(...arguments);
913
917
  };
914
918
  export {
915
- ot as BrainfishAnalytics,
916
- ye as default
919
+ it as BrainfishAnalytics,
920
+ we as default
917
921
  };
918
922
  //# sourceMappingURL=web.js.map