@searchcraft/javascript-sdk 0.10.1 → 0.10.3

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.
Files changed (70) hide show
  1. package/dist/components/index.d.ts +148 -83
  2. package/dist/components/index.js +7 -33
  3. package/dist/components/index.js.map +1 -1
  4. package/dist/components/{p-84e2cbd6.js → p-06bac1fc.js} +3 -3
  5. package/dist/components/{p-84e2cbd6.js.map → p-06bac1fc.js.map} +1 -1
  6. package/dist/components/p-4d37616e.js +105 -0
  7. package/dist/components/p-4d37616e.js.map +1 -0
  8. package/dist/components/{p-172a848d.js → p-508ee769.js} +8 -7
  9. package/dist/components/p-508ee769.js.map +1 -0
  10. package/dist/components/{p-3e65aa91.js → p-53c795bd.js} +4 -10
  11. package/dist/components/p-53c795bd.js.map +1 -0
  12. package/dist/components/{p-0077f677.js → p-5a4be632.js} +34 -22
  13. package/dist/components/p-5a4be632.js.map +1 -0
  14. package/dist/components/{p-5d17ace0.js → p-6717ab82.js} +7 -7
  15. package/dist/components/{p-5d17ace0.js.map → p-6717ab82.js.map} +1 -1
  16. package/dist/components/{p-868803f9.js → p-7c650118.js} +2 -2
  17. package/dist/components/{p-868803f9.js.map → p-7c650118.js.map} +1 -1
  18. package/dist/components/{p-13e81b5d.js → p-ad569b01.js} +12 -7
  19. package/dist/components/p-ad569b01.js.map +1 -0
  20. package/dist/components/{p-17c646e2.js → p-d4558d44.js} +563 -476
  21. package/dist/components/p-d4558d44.js.map +1 -0
  22. package/dist/components/{p-2be1a382.js → p-da1fb5c0.js} +2 -2
  23. package/dist/components/{p-2be1a382.js.map → p-da1fb5c0.js.map} +1 -1
  24. package/dist/components/{p-a62a2e74.js → p-fd564261.js} +4 -4
  25. package/dist/components/{p-a62a2e74.js.map → p-fd564261.js.map} +1 -1
  26. package/dist/components/searchcraft-ad.js +1 -1
  27. package/dist/components/searchcraft-facet-list.js +1 -1
  28. package/dist/components/searchcraft-filter-panel.js +20 -9
  29. package/dist/components/searchcraft-filter-panel.js.map +1 -1
  30. package/dist/components/searchcraft-input-form.js +1 -1
  31. package/dist/components/searchcraft-pagination.js +1 -1
  32. package/dist/components/searchcraft-popover-button.js +5 -3
  33. package/dist/components/searchcraft-popover-button.js.map +1 -1
  34. package/dist/components/searchcraft-popover-footer.js +1 -1
  35. package/dist/components/searchcraft-popover-form.js +8 -8
  36. package/dist/components/searchcraft-popover-form.js.map +1 -1
  37. package/dist/components/searchcraft-popover-list-item.js +1 -1
  38. package/dist/components/searchcraft-popover-list-view.js +1 -1
  39. package/dist/components/searchcraft-results-info.js +2 -2
  40. package/dist/components/searchcraft-search-result.js +1 -1
  41. package/dist/components/searchcraft-search-results-per-page.js +1 -1
  42. package/dist/components/searchcraft-search-results.js +69 -32
  43. package/dist/components/searchcraft-search-results.js.map +1 -1
  44. package/dist/components/searchcraft-slider.js +1 -1
  45. package/dist/components/searchcraft-theme.js +1 -1
  46. package/dist/components/searchcraft-theme.js.map +1 -1
  47. package/dist/components/searchcraft-toggle-button.js +1 -1
  48. package/dist/hydrate/index.js +491 -377
  49. package/dist/hydrate/index.mjs +491 -377
  50. package/dist/themes/hologram.css +1 -1
  51. package/dist/themes/hologram.css.map +1 -1
  52. package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +1 -1
  53. package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +1 -1
  54. package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +7 -3
  55. package/dist/types/components/searchcraft-popover-button/searchcraft-popover-button.d.ts +3 -3
  56. package/dist/types/components/searchcraft-search-results/searchcraft-search-results.d.ts +10 -5
  57. package/dist/types/components.d.ts +20 -12
  58. package/dist/types/index.d.ts +0 -1
  59. package/dist/types/store/SearchcraftStore.types.d.ts +21 -8
  60. package/dist/types/utils/index.d.ts +0 -1
  61. package/dist/types/utils/units.d.ts +19 -6
  62. package/package.json +4 -7
  63. package/dist/components/p-0077f677.js.map +0 -1
  64. package/dist/components/p-13e81b5d.js.map +0 -1
  65. package/dist/components/p-172a848d.js.map +0 -1
  66. package/dist/components/p-17c646e2.js.map +0 -1
  67. package/dist/components/p-3e65aa91.js.map +0 -1
  68. package/dist/components/p-6104fe5d.js +0 -84
  69. package/dist/components/p-6104fe5d.js.map +0 -1
  70. package/dist/types/utils/styles.d.ts +0 -3
@@ -1,15 +1,15 @@
1
1
  var B = Object.defineProperty;
2
- var q = (r, e, n) => e in r ? B(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var h = (r, e, n) => q(r, typeof e != "symbol" ? e + "" : e, n);
4
- var D = /* @__PURE__ */ ((r) => (r[r.DEBUG = 0] = "DEBUG", r[r.INFO = 1] = "INFO", r[r.WARN = 2] = "WARN", r[r.ERROR = 3] = "ERROR", r))(D || {});
5
- class ve {
2
+ var N = (a, e, n) => e in a ? B(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n;
3
+ var l = (a, e, n) => N(a, typeof e != "symbol" ? e + "" : e, n);
4
+ var O = /* @__PURE__ */ ((a) => (a[a.DEBUG = 0] = "DEBUG", a[a.INFO = 1] = "INFO", a[a.WARN = 2] = "WARN", a[a.ERROR = 3] = "ERROR", a))(O || {});
5
+ class pe {
6
6
  constructor(e) {
7
- h(this, "logLevel");
8
- h(this, "logFormatter");
7
+ l(this, "logLevel");
8
+ l(this, "logFormatter");
9
9
  this.logLevel = e.logLevel || 1, this.logFormatter = e.logFormatter || this.defaultFormatter;
10
10
  }
11
11
  defaultFormatter(e, n) {
12
- return `[${D[e]}] ${( new Date()).toISOString()}: ${n}`;
12
+ return `[${O[e]}] ${( new Date()).toISOString()}: ${n}`;
13
13
  }
14
14
  debug(e) {
15
15
  this.logLevel <= 0 && console.log(this.logFormatter(0, e));
@@ -40,119 +40,119 @@ class ve {
40
40
  }
41
41
  }
42
42
  }
43
- function w(r, e, n, o) {
44
- return new (n || (n = Promise))(function(a, i) {
43
+ function w(a, e, n, r) {
44
+ return new (n || (n = Promise))(function(i, o) {
45
45
  function t(c) {
46
46
  try {
47
- l(o.next(c));
47
+ h(r.next(c));
48
48
  } catch (s) {
49
- i(s);
49
+ o(s);
50
50
  }
51
51
  }
52
52
  function u(c) {
53
53
  try {
54
- l(o.throw(c));
54
+ h(r.throw(c));
55
55
  } catch (s) {
56
- i(s);
56
+ o(s);
57
57
  }
58
58
  }
59
- function l(c) {
59
+ function h(c) {
60
60
  var s;
61
- c.done ? a(c.value) : (s = c.value, s instanceof n ? s : new n(function(f) {
62
- f(s);
61
+ c.done ? i(c.value) : (s = c.value, s instanceof n ? s : new n(function(p) {
62
+ p(s);
63
63
  })).then(t, u);
64
64
  }
65
- l((o = o.apply(r, [])).next());
65
+ h((r = r.apply(a, [])).next());
66
66
  });
67
67
  }
68
- function y(r, e) {
69
- var n, o, a, i, t = { label: 0, sent: function() {
70
- if (1 & a[0]) throw a[1];
71
- return a[1];
68
+ function y(a, e) {
69
+ var n, r, i, o, t = { label: 0, sent: function() {
70
+ if (1 & i[0]) throw i[1];
71
+ return i[1];
72
72
  }, trys: [], ops: [] };
73
- return i = { next: u(0), throw: u(1), return: u(2) }, typeof Symbol == "function" && (i[Symbol.iterator] = function() {
73
+ return o = { next: u(0), throw: u(1), return: u(2) }, typeof Symbol == "function" && (o[Symbol.iterator] = function() {
74
74
  return this;
75
- }), i;
76
- function u(l) {
75
+ }), o;
76
+ function u(h) {
77
77
  return function(c) {
78
78
  return function(s) {
79
79
  if (n) throw new TypeError("Generator is already executing.");
80
- for (; i && (i = 0, s[0] && (t = 0)), t; ) try {
81
- if (n = 1, o && (a = 2 & s[0] ? o.return : s[0] ? o.throw || ((a = o.return) && a.call(o), 0) : o.next) && !(a = a.call(o, s[1])).done) return a;
82
- switch (o = 0, a && (s = [2 & s[0], a.value]), s[0]) {
80
+ for (; o && (o = 0, s[0] && (t = 0)), t; ) try {
81
+ if (n = 1, r && (i = 2 & s[0] ? r.return : s[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, s[1])).done) return i;
82
+ switch (r = 0, i && (s = [2 & s[0], i.value]), s[0]) {
83
83
  case 0:
84
84
  case 1:
85
- a = s;
85
+ i = s;
86
86
  break;
87
87
  case 4:
88
88
  return t.label++, { value: s[1], done: !1 };
89
89
  case 5:
90
- t.label++, o = s[1], s = [0];
90
+ t.label++, r = s[1], s = [0];
91
91
  continue;
92
92
  case 7:
93
93
  s = t.ops.pop(), t.trys.pop();
94
94
  continue;
95
95
  default:
96
- if (a = t.trys, !((a = a.length > 0 && a[a.length - 1]) || s[0] !== 6 && s[0] !== 2)) {
96
+ if (i = t.trys, !((i = i.length > 0 && i[i.length - 1]) || s[0] !== 6 && s[0] !== 2)) {
97
97
  t = 0;
98
98
  continue;
99
99
  }
100
- if (s[0] === 3 && (!a || s[1] > a[0] && s[1] < a[3])) {
100
+ if (s[0] === 3 && (!i || s[1] > i[0] && s[1] < i[3])) {
101
101
  t.label = s[1];
102
102
  break;
103
103
  }
104
- if (s[0] === 6 && t.label < a[1]) {
105
- t.label = a[1], a = s;
104
+ if (s[0] === 6 && t.label < i[1]) {
105
+ t.label = i[1], i = s;
106
106
  break;
107
107
  }
108
- if (a && t.label < a[2]) {
109
- t.label = a[2], t.ops.push(s);
108
+ if (i && t.label < i[2]) {
109
+ t.label = i[2], t.ops.push(s);
110
110
  break;
111
111
  }
112
- a[2] && t.ops.pop(), t.trys.pop();
112
+ i[2] && t.ops.pop(), t.trys.pop();
113
113
  continue;
114
114
  }
115
- s = e.call(r, t);
116
- } catch (f) {
117
- s = [6, f], o = 0;
115
+ s = e.call(a, t);
116
+ } catch (p) {
117
+ s = [6, p], r = 0;
118
118
  } finally {
119
- n = a = 0;
119
+ n = i = 0;
120
120
  }
121
121
  if (5 & s[0]) throw s[1];
122
122
  return { value: s[0] ? s[1] : void 0, done: !0 };
123
- }([l, c]);
123
+ }([h, c]);
124
124
  };
125
125
  }
126
126
  }
127
- var b = { exclude: [] }, O = {}, N = { timeout: "true" }, v = function(r, e) {
128
- typeof window < "u" && (O[r] = e);
129
- }, j = function() {
130
- return Object.fromEntries(Object.entries(O).filter(function(r) {
131
- var e, n = r[0];
132
- return !(!((e = b == null ? void 0 : b.exclude) === null || e === void 0) && e.includes(n));
133
- }).map(function(r) {
134
- return [r[0], (0, r[1])()];
127
+ var S = { exclude: [] }, D = {}, j = { timeout: "true" }, v = function(a, e) {
128
+ typeof window < "u" && (D[a] = e);
129
+ }, G = function() {
130
+ return Object.fromEntries(Object.entries(D).filter(function(a) {
131
+ var e, n = a[0];
132
+ return !(!((e = S == null ? void 0 : S.exclude) === null || e === void 0) && e.includes(n));
133
+ }).map(function(a) {
134
+ return [a[0], (0, a[1])()];
135
135
  }));
136
136
  };
137
- function A(r) {
138
- return r ^= r >>> 16, r = Math.imul(r, 2246822507), r ^= r >>> 13, r = Math.imul(r, 3266489909), (r ^= r >>> 16) >>> 0;
137
+ function T(a) {
138
+ return a ^= a >>> 16, a = Math.imul(a, 2246822507), a ^= a >>> 13, a = Math.imul(a, 3266489909), (a ^= a >>> 16) >>> 0;
139
139
  }
140
140
  var m = new Uint32Array([597399067, 2869860233, 951274213, 2716044179]);
141
- function g(r, e) {
142
- return r << e | r >>> 32 - e;
141
+ function g(a, e) {
142
+ return a << e | a >>> 32 - e;
143
143
  }
144
- function M(r, e) {
144
+ function I(a, e) {
145
145
  var n;
146
- if (e === void 0 && (e = 0), e = e ? 0 | e : 0, typeof r == "string" && (n = r, r = new TextEncoder().encode(n).buffer), !(r instanceof ArrayBuffer)) throw new TypeError("Expected key to be ArrayBuffer or string");
147
- var o = new Uint32Array([e, e, e, e]);
148
- ((function(i, t) {
149
- for (var u = i.byteLength / 16 | 0, l = new Uint32Array(i, 0, 4 * u), c = 0; c < u; c++) {
150
- var s = l.subarray(4 * c, 4 * (c + 1));
146
+ if (e === void 0 && (e = 0), e = e ? 0 | e : 0, typeof a == "string" && (n = a, a = new TextEncoder().encode(n).buffer), !(a instanceof ArrayBuffer)) throw new TypeError("Expected key to be ArrayBuffer or string");
147
+ var r = new Uint32Array([e, e, e, e]);
148
+ ((function(o, t) {
149
+ for (var u = o.byteLength / 16 | 0, h = new Uint32Array(o, 0, 4 * u), c = 0; c < u; c++) {
150
+ var s = h.subarray(4 * c, 4 * (c + 1));
151
151
  s[0] = Math.imul(s[0], m[0]), s[0] = g(s[0], 15), s[0] = Math.imul(s[0], m[1]), t[0] = t[0] ^ s[0], t[0] = g(t[0], 19), t[0] = t[0] + t[1], t[0] = Math.imul(t[0], 5) + 1444728091, s[1] = Math.imul(s[1], m[1]), s[1] = g(s[1], 16), s[1] = Math.imul(s[1], m[2]), t[1] = t[1] ^ s[1], t[1] = g(t[1], 17), t[1] = t[1] + t[2], t[1] = Math.imul(t[1], 5) + 197830471, s[2] = Math.imul(s[2], m[2]), s[2] = g(s[2], 17), s[2] = Math.imul(s[2], m[3]), t[2] = t[2] ^ s[2], t[2] = g(t[2], 15), t[2] = t[2] + t[3], t[2] = Math.imul(t[2], 5) + 2530024501, s[3] = Math.imul(s[3], m[3]), s[3] = g(s[3], 18), s[3] = Math.imul(s[3], m[0]), t[3] = t[3] ^ s[3], t[3] = g(t[3], 13), t[3] = t[3] + t[0], t[3] = Math.imul(t[3], 5) + 850148119;
152
152
  }
153
- }))(r, o), function(i, t) {
154
- var u = i.byteLength / 16 | 0, l = i.byteLength % 16, c = new Uint32Array(4), s = new Uint8Array(i, 16 * u, l);
155
- switch (l) {
153
+ }))(a, r), function(o, t) {
154
+ var u = o.byteLength / 16 | 0, h = o.byteLength % 16, c = new Uint32Array(4), s = new Uint8Array(o, 16 * u, h);
155
+ switch (h) {
156
156
  case 15:
157
157
  c[3] = c[3] ^ s[14] << 16;
158
158
  case 14:
@@ -184,244 +184,244 @@ function M(r, e) {
184
184
  case 1:
185
185
  c[0] = c[0] ^ s[0] << 0, c[0] = Math.imul(c[0], m[0]), c[0] = g(c[0], 15), c[0] = Math.imul(c[0], m[1]), t[0] = t[0] ^ c[0];
186
186
  }
187
- }(r, o), function(i, t) {
188
- t[0] = t[0] ^ i.byteLength, t[1] = t[1] ^ i.byteLength, t[2] = t[2] ^ i.byteLength, t[3] = t[3] ^ i.byteLength, t[0] = t[0] + t[1] | 0, t[0] = t[0] + t[2] | 0, t[0] = t[0] + t[3] | 0, t[1] = t[1] + t[0] | 0, t[2] = t[2] + t[0] | 0, t[3] = t[3] + t[0] | 0, t[0] = A(t[0]), t[1] = A(t[1]), t[2] = A(t[2]), t[3] = A(t[3]), t[0] = t[0] + t[1] | 0, t[0] = t[0] + t[2] | 0, t[0] = t[0] + t[3] | 0, t[1] = t[1] + t[0] | 0, t[2] = t[2] + t[0] | 0, t[3] = t[3] + t[0] | 0;
189
- }(r, o);
190
- var a = new Uint8Array(o.buffer);
191
- return Array.from(a).map(function(i) {
192
- return i.toString(16).padStart(2, "0");
187
+ }(a, r), function(o, t) {
188
+ t[0] = t[0] ^ o.byteLength, t[1] = t[1] ^ o.byteLength, t[2] = t[2] ^ o.byteLength, t[3] = t[3] ^ o.byteLength, t[0] = t[0] + t[1] | 0, t[0] = t[0] + t[2] | 0, t[0] = t[0] + t[3] | 0, t[1] = t[1] + t[0] | 0, t[2] = t[2] + t[0] | 0, t[3] = t[3] + t[0] | 0, t[0] = T(t[0]), t[1] = T(t[1]), t[2] = T(t[2]), t[3] = T(t[3]), t[0] = t[0] + t[1] | 0, t[0] = t[0] + t[2] | 0, t[0] = t[0] + t[3] | 0, t[1] = t[1] + t[0] | 0, t[2] = t[2] + t[0] | 0, t[3] = t[3] + t[0] | 0;
189
+ }(a, r);
190
+ var i = new Uint8Array(r.buffer);
191
+ return Array.from(i).map(function(o) {
192
+ return o.toString(16).padStart(2, "0");
193
193
  }).join("");
194
194
  }
195
- function V(r, e) {
195
+ function W(a, e) {
196
196
  return new Promise(function(n) {
197
197
  setTimeout(function() {
198
198
  return n(e);
199
- }, r);
199
+ }, a);
200
200
  });
201
201
  }
202
- function G(r, e, n) {
203
- return Promise.all(r.map(function(o) {
204
- return Promise.race([o, V(e, n)]);
202
+ function V(a, e, n) {
203
+ return Promise.all(a.map(function(r) {
204
+ return Promise.race([r, W(e, n)]);
205
205
  }));
206
206
  }
207
- function W() {
207
+ function $() {
208
208
  return w(this, void 0, void 0, function() {
209
- var r, e, n, o, a;
210
- return y(this, function(i) {
211
- switch (i.label) {
209
+ var a, e, n, r, i;
210
+ return y(this, function(o) {
211
+ switch (o.label) {
212
212
  case 0:
213
- return i.trys.push([0, 2, , 3]), r = j(), e = Object.keys(r), [4, G(Object.values(r), (b == null ? void 0 : b.timeout) || 1e3, N)];
213
+ return o.trys.push([0, 2, , 3]), a = G(), e = Object.keys(a), [4, V(Object.values(a), (S == null ? void 0 : S.timeout) || 1e3, j)];
214
214
  case 1:
215
- return n = i.sent(), o = n.filter(function(t) {
215
+ return n = o.sent(), r = n.filter(function(t) {
216
216
  return t !== void 0;
217
- }), a = {}, o.forEach(function(t, u) {
218
- a[e[u]] = t;
219
- }), [2, U(a, b.exclude || [])];
217
+ }), i = {}, r.forEach(function(t, u) {
218
+ i[e[u]] = t;
219
+ }), [2, U(i, S.exclude || [])];
220
220
  case 2:
221
- throw i.sent();
221
+ throw o.sent();
222
222
  case 3:
223
223
  return [2];
224
224
  }
225
225
  });
226
226
  });
227
227
  }
228
- function U(r, e) {
229
- var n = {}, o = function(i) {
230
- if (r.hasOwnProperty(i)) {
231
- var t = r[i];
232
- if (typeof t != "object" || Array.isArray(t)) e.includes(i) || (n[i] = t);
228
+ function U(a, e) {
229
+ var n = {}, r = function(o) {
230
+ if (a.hasOwnProperty(o)) {
231
+ var t = a[o];
232
+ if (typeof t != "object" || Array.isArray(t)) e.includes(o) || (n[o] = t);
233
233
  else {
234
- var u = U(t, e.map(function(l) {
235
- return l.startsWith(i + ".") ? l.slice(i.length + 1) : l;
234
+ var u = U(t, e.map(function(h) {
235
+ return h.startsWith(o + ".") ? h.slice(o.length + 1) : h;
236
236
  }));
237
- Object.keys(u).length > 0 && (n[i] = u);
237
+ Object.keys(u).length > 0 && (n[o] = u);
238
238
  }
239
239
  }
240
240
  };
241
- for (var a in r) o(a);
241
+ for (var i in a) r(i);
242
242
  return n;
243
243
  }
244
- function $(r) {
244
+ function z(a) {
245
245
  return w(this, void 0, void 0, function() {
246
246
  var e, n;
247
- return y(this, function(o) {
248
- switch (o.label) {
247
+ return y(this, function(r) {
248
+ switch (r.label) {
249
249
  case 0:
250
- return o.trys.push([0, 2, , 3]), [4, W()];
250
+ return r.trys.push([0, 2, , 3]), [4, $()];
251
251
  case 1:
252
- return e = o.sent(), n = M(JSON.stringify(e)), [2, n.toString()];
252
+ return e = r.sent(), n = I(JSON.stringify(e)), [2, n.toString()];
253
253
  case 2:
254
- throw o.sent();
254
+ throw r.sent();
255
255
  case 3:
256
256
  return [2];
257
257
  }
258
258
  });
259
259
  });
260
260
  }
261
- function H(r) {
262
- for (var e = 0, n = 0; n < r.length; ++n) e += Math.abs(r[n]);
261
+ function H(a) {
262
+ for (var e = 0, n = 0; n < a.length; ++n) e += Math.abs(a[n]);
263
263
  return e;
264
264
  }
265
- function L(r, e, n) {
266
- for (var o = [], a = 0; a < r[0].data.length; a++) {
267
- for (var i = [], t = 0; t < r.length; t++) i.push(r[t].data[a]);
268
- o.push(Q(i));
265
+ function L(a, e, n) {
266
+ for (var r = [], i = 0; i < a[0].data.length; i++) {
267
+ for (var o = [], t = 0; t < a.length; t++) o.push(a[t].data[i]);
268
+ r.push(Q(o));
269
269
  }
270
- var u = new Uint8ClampedArray(o);
270
+ var u = new Uint8ClampedArray(r);
271
271
  return new ImageData(u, e, n);
272
272
  }
273
- function Q(r) {
274
- if (r.length === 0) return 0;
275
- for (var e = {}, n = 0, o = r; n < o.length; n++)
276
- e[i = o[n]] = (e[i] || 0) + 1;
277
- var a = r[0];
278
- for (var i in e) e[i] > e[a] && (a = parseInt(i, 10));
279
- return a;
273
+ function Q(a) {
274
+ if (a.length === 0) return 0;
275
+ for (var e = {}, n = 0, r = a; n < r.length; n++)
276
+ e[o = r[n]] = (e[o] || 0) + 1;
277
+ var i = a[0];
278
+ for (var o in e) e[o] > e[i] && (i = parseInt(o, 10));
279
+ return i;
280
280
  }
281
- function E() {
281
+ function C() {
282
282
  if (typeof navigator > "u") return { name: "unknown", version: "unknown" };
283
- for (var r = navigator.userAgent, e = { Edg: "Edge", OPR: "Opera" }, n = 0, o = [/(?<name>Edge|Edg)\/(?<version>\d+(?:\.\d+)?)/, /(?<name>(?:Chrome|Chromium|OPR|Opera|Vivaldi|Brave))\/(?<version>\d+(?:\.\d+)?)/, /(?<name>(?:Firefox|Waterfox|Iceweasel|IceCat))\/(?<version>\d+(?:\.\d+)?)/, /(?<name>Safari)\/(?<version>\d+(?:\.\d+)?)/, /(?<name>MSIE|Trident|IEMobile).+?(?<version>\d+(?:\.\d+)?)/, /(?<name>[A-Za-z]+)\/(?<version>\d+(?:\.\d+)?)/, /(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)?)/]; n < o.length; n++) {
284
- var a = o[n], i = r.match(a);
285
- if (i && i.groups) return { name: e[i.groups.name] || i.groups.name, version: i.groups.version };
283
+ for (var a = navigator.userAgent, e = { Edg: "Edge", OPR: "Opera" }, n = 0, r = [/(?<name>Edge|Edg)\/(?<version>\d+(?:\.\d+)?)/, /(?<name>(?:Chrome|Chromium|OPR|Opera|Vivaldi|Brave))\/(?<version>\d+(?:\.\d+)?)/, /(?<name>(?:Firefox|Waterfox|Iceweasel|IceCat))\/(?<version>\d+(?:\.\d+)?)/, /(?<name>Safari)\/(?<version>\d+(?:\.\d+)?)/, /(?<name>MSIE|Trident|IEMobile).+?(?<version>\d+(?:\.\d+)?)/, /(?<name>[A-Za-z]+)\/(?<version>\d+(?:\.\d+)?)/, /(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)?)/]; n < r.length; n++) {
284
+ var i = r[n], o = a.match(i);
285
+ if (o && o.groups) return { name: e[o.groups.name] || o.groups.name, version: o.groups.version };
286
286
  }
287
287
  return { name: "unknown", version: "unknown" };
288
288
  }
289
289
  v("audio", function() {
290
290
  return w(this, void 0, void 0, function() {
291
- return y(this, function(r) {
291
+ return y(this, function(a) {
292
292
  return [2, new Promise(function(e, n) {
293
293
  try {
294
- var o = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 5e3, 44100), a = o.createBufferSource(), i = o.createOscillator();
295
- i.frequency.value = 1e3;
296
- var t, u = o.createDynamicsCompressor();
297
- u.threshold.value = -50, u.knee.value = 40, u.ratio.value = 12, u.attack.value = 0, u.release.value = 0.2, i.connect(u), u.connect(o.destination), i.start(), o.oncomplete = function(l) {
298
- t = l.renderedBuffer.getChannelData(0), e({ sampleHash: H(t), oscillator: i.type, maxChannels: o.destination.maxChannelCount, channelCountMode: a.channelCountMode });
299
- }, o.startRendering();
300
- } catch (l) {
301
- console.error("Error creating audio fingerprint:", l), n(l);
294
+ var r = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 5e3, 44100), i = r.createBufferSource(), o = r.createOscillator();
295
+ o.frequency.value = 1e3;
296
+ var t, u = r.createDynamicsCompressor();
297
+ u.threshold.value = -50, u.knee.value = 40, u.ratio.value = 12, u.attack.value = 0, u.release.value = 0.2, o.connect(u), u.connect(r.destination), o.start(), r.oncomplete = function(h) {
298
+ t = h.renderedBuffer.getChannelData(0), e({ sampleHash: H(t), oscillator: o.type, maxChannels: r.destination.maxChannelCount, channelCountMode: i.channelCountMode });
299
+ }, r.startRendering();
300
+ } catch (h) {
301
+ console.error("Error creating audio fingerprint:", h), n(h);
302
302
  }
303
303
  })];
304
304
  });
305
305
  });
306
306
  });
307
- var z = E().name !== "SamsungBrowser" ? 1 : 3, k = 280, F = 20;
308
- E().name != "Firefox" && v("canvas", function() {
309
- return document.createElement("canvas").getContext("2d"), new Promise(function(r) {
310
- var e = Array.from({ length: z }, function() {
307
+ var K = C().name !== "SamsungBrowser" ? 1 : 3, P = 280, k = 20;
308
+ C().name != "Firefox" && v("canvas", function() {
309
+ return document.createElement("canvas").getContext("2d"), new Promise(function(a) {
310
+ var e = Array.from({ length: K }, function() {
311
311
  return function() {
312
- var n = document.createElement("canvas"), o = n.getContext("2d");
313
- if (!o) return new ImageData(1, 1);
314
- n.width = k, n.height = F;
315
- var a = o.createLinearGradient(0, 0, n.width, n.height);
316
- a.addColorStop(0, "red"), a.addColorStop(0.16666666666666666, "orange"), a.addColorStop(0.3333333333333333, "yellow"), a.addColorStop(0.5, "green"), a.addColorStop(0.6666666666666666, "blue"), a.addColorStop(0.8333333333333334, "indigo"), a.addColorStop(1, "violet"), o.fillStyle = a, o.fillRect(0, 0, n.width, n.height);
317
- var i = "Random Text WMwmil10Oo";
318
- o.font = "23.123px Arial", o.fillStyle = "black", o.fillText(i, -5, 15), o.fillStyle = "rgba(0, 0, 255, 0.5)", o.fillText(i, -3.3, 17.7), o.beginPath(), o.moveTo(0, 0), o.lineTo(2 * n.width / 7, n.height), o.strokeStyle = "white", o.lineWidth = 2, o.stroke();
319
- var t = o.getImageData(0, 0, n.width, n.height);
312
+ var n = document.createElement("canvas"), r = n.getContext("2d");
313
+ if (!r) return new ImageData(1, 1);
314
+ n.width = P, n.height = k;
315
+ var i = r.createLinearGradient(0, 0, n.width, n.height);
316
+ i.addColorStop(0, "red"), i.addColorStop(0.16666666666666666, "orange"), i.addColorStop(0.3333333333333333, "yellow"), i.addColorStop(0.5, "green"), i.addColorStop(0.6666666666666666, "blue"), i.addColorStop(0.8333333333333334, "indigo"), i.addColorStop(1, "violet"), r.fillStyle = i, r.fillRect(0, 0, n.width, n.height);
317
+ var o = "Random Text WMwmil10Oo";
318
+ r.font = "23.123px Arial", r.fillStyle = "black", r.fillText(o, -5, 15), r.fillStyle = "rgba(0, 0, 255, 0.5)", r.fillText(o, -3.3, 17.7), r.beginPath(), r.moveTo(0, 0), r.lineTo(2 * n.width / 7, n.height), r.strokeStyle = "white", r.lineWidth = 2, r.stroke();
319
+ var t = r.getImageData(0, 0, n.width, n.height);
320
320
  return t;
321
321
  }();
322
322
  });
323
- r({ commonImageDataHash: M(L(e, k, F).data.toString()).toString() });
323
+ a({ commonImageDataHash: I(L(e, P, k).data.toString()).toString() });
324
324
  });
325
325
  });
326
- var _, K = ["Arial", "Arial Black", "Arial Narrow", "Arial Rounded MT", "Arimo", "Archivo", "Barlow", "Bebas Neue", "Bitter", "Bookman", "Calibri", "Cabin", "Candara", "Century", "Century Gothic", "Comic Sans MS", "Constantia", "Courier", "Courier New", "Crimson Text", "DM Mono", "DM Sans", "DM Serif Display", "DM Serif Text", "Dosis", "Droid Sans", "Exo", "Fira Code", "Fira Sans", "Franklin Gothic Medium", "Garamond", "Geneva", "Georgia", "Gill Sans", "Helvetica", "Impact", "Inconsolata", "Indie Flower", "Inter", "Josefin Sans", "Karla", "Lato", "Lexend", "Lucida Bright", "Lucida Console", "Lucida Sans Unicode", "Manrope", "Merriweather", "Merriweather Sans", "Montserrat", "Myriad", "Noto Sans", "Nunito", "Nunito Sans", "Open Sans", "Optima", "Orbitron", "Oswald", "Pacifico", "Palatino", "Perpetua", "PT Sans", "PT Serif", "Poppins", "Prompt", "Public Sans", "Quicksand", "Rajdhani", "Recursive", "Roboto", "Roboto Condensed", "Rockwell", "Rubik", "Segoe Print", "Segoe Script", "Segoe UI", "Sora", "Source Sans Pro", "Space Mono", "Tahoma", "Taviraj", "Times", "Times New Roman", "Titillium Web", "Trebuchet MS", "Ubuntu", "Varela Round", "Verdana", "Work Sans"], J = ["monospace", "sans-serif", "serif"];
327
- function P(r, e) {
328
- if (!r) throw new Error("Canvas context not supported");
329
- return r.font = "72px ".concat(e), r.measureText("WwMmLli0Oo").width;
326
+ var A, X = ["Arial", "Arial Black", "Arial Narrow", "Arial Rounded MT", "Arimo", "Archivo", "Barlow", "Bebas Neue", "Bitter", "Bookman", "Calibri", "Cabin", "Candara", "Century", "Century Gothic", "Comic Sans MS", "Constantia", "Courier", "Courier New", "Crimson Text", "DM Mono", "DM Sans", "DM Serif Display", "DM Serif Text", "Dosis", "Droid Sans", "Exo", "Fira Code", "Fira Sans", "Franklin Gothic Medium", "Garamond", "Geneva", "Georgia", "Gill Sans", "Helvetica", "Impact", "Inconsolata", "Indie Flower", "Inter", "Josefin Sans", "Karla", "Lato", "Lexend", "Lucida Bright", "Lucida Console", "Lucida Sans Unicode", "Manrope", "Merriweather", "Merriweather Sans", "Montserrat", "Myriad", "Noto Sans", "Nunito", "Nunito Sans", "Open Sans", "Optima", "Orbitron", "Oswald", "Pacifico", "Palatino", "Perpetua", "PT Sans", "PT Serif", "Poppins", "Prompt", "Public Sans", "Quicksand", "Rajdhani", "Recursive", "Roboto", "Roboto Condensed", "Rockwell", "Rubik", "Segoe Print", "Segoe Script", "Segoe UI", "Sora", "Source Sans Pro", "Space Mono", "Tahoma", "Taviraj", "Times", "Times New Roman", "Titillium Web", "Trebuchet MS", "Ubuntu", "Varela Round", "Verdana", "Work Sans"], J = ["monospace", "sans-serif", "serif"];
327
+ function F(a, e) {
328
+ if (!a) throw new Error("Canvas context not supported");
329
+ return a.font = "72px ".concat(e), a.measureText("WwMmLli0Oo").width;
330
330
  }
331
331
  function Y() {
332
- var r, e = document.createElement("canvas"), n = (r = e.getContext("webgl")) !== null && r !== void 0 ? r : e.getContext("experimental-webgl");
332
+ var a, e = document.createElement("canvas"), n = (a = e.getContext("webgl")) !== null && a !== void 0 ? a : e.getContext("experimental-webgl");
333
333
  if (n && "getParameter" in n) try {
334
- var o = (n.getParameter(n.VENDOR) || "").toString(), a = (n.getParameter(n.RENDERER) || "").toString(), i = { vendor: o, renderer: a, version: (n.getParameter(n.VERSION) || "").toString(), shadingLanguageVersion: (n.getParameter(n.SHADING_LANGUAGE_VERSION) || "").toString() };
335
- if (!a.length || !o.length) {
334
+ var r = (n.getParameter(n.VENDOR) || "").toString(), i = (n.getParameter(n.RENDERER) || "").toString(), o = { vendor: r, renderer: i, version: (n.getParameter(n.VERSION) || "").toString(), shadingLanguageVersion: (n.getParameter(n.SHADING_LANGUAGE_VERSION) || "").toString() };
335
+ if (!i.length || !r.length) {
336
336
  var t = n.getExtension("WEBGL_debug_renderer_info");
337
337
  if (t) {
338
- var u = (n.getParameter(t.UNMASKED_VENDOR_WEBGL) || "").toString(), l = (n.getParameter(t.UNMASKED_RENDERER_WEBGL) || "").toString();
339
- u && (i.vendorUnmasked = u), l && (i.rendererUnmasked = l);
338
+ var u = (n.getParameter(t.UNMASKED_VENDOR_WEBGL) || "").toString(), h = (n.getParameter(t.UNMASKED_RENDERER_WEBGL) || "").toString();
339
+ u && (o.vendorUnmasked = u), h && (o.rendererUnmasked = h);
340
340
  }
341
341
  }
342
- return i;
342
+ return o;
343
343
  } catch {
344
344
  }
345
345
  return "undefined";
346
346
  }
347
- function X() {
348
- var r = new Float32Array(1), e = new Uint8Array(r.buffer);
349
- return r[0] = 1 / 0, r[0] = r[0] - r[0], e[3];
347
+ function Z() {
348
+ var a = new Float32Array(1), e = new Uint8Array(a.buffer);
349
+ return a[0] = 1 / 0, a[0] = a[0] - a[0], e[3];
350
350
  }
351
- function Z(r, e) {
351
+ function ee(a, e) {
352
352
  var n = {};
353
- return e.forEach(function(o) {
354
- var a = function(i) {
355
- if (i.length === 0) return null;
353
+ return e.forEach(function(r) {
354
+ var i = function(o) {
355
+ if (o.length === 0) return null;
356
356
  var t = {};
357
- i.forEach(function(c) {
357
+ o.forEach(function(c) {
358
358
  var s = String(c);
359
359
  t[s] = (t[s] || 0) + 1;
360
360
  });
361
- var u = i[0], l = 1;
361
+ var u = o[0], h = 1;
362
362
  return Object.keys(t).forEach(function(c) {
363
- t[c] > l && (u = c, l = t[c]);
363
+ t[c] > h && (u = c, h = t[c]);
364
364
  }), u;
365
- }(r.map(function(i) {
366
- return o in i ? i[o] : void 0;
367
- }).filter(function(i) {
368
- return i !== void 0;
365
+ }(a.map(function(o) {
366
+ return r in o ? o[r] : void 0;
367
+ }).filter(function(o) {
368
+ return o !== void 0;
369
369
  }));
370
- a && (n[o] = a);
370
+ i && (n[r] = i);
371
371
  }), n;
372
372
  }
373
- function ee() {
374
- var r = [], e = { "prefers-contrast": ["high", "more", "low", "less", "forced", "no-preference"], "any-hover": ["hover", "none"], "any-pointer": ["none", "coarse", "fine"], pointer: ["none", "coarse", "fine"], hover: ["hover", "none"], update: ["fast", "slow"], "inverted-colors": ["inverted", "none"], "prefers-reduced-motion": ["reduce", "no-preference"], "prefers-reduced-transparency": ["reduce", "no-preference"], scripting: ["none", "initial-only", "enabled"], "forced-colors": ["active", "none"] };
373
+ function te() {
374
+ var a = [], e = { "prefers-contrast": ["high", "more", "low", "less", "forced", "no-preference"], "any-hover": ["hover", "none"], "any-pointer": ["none", "coarse", "fine"], pointer: ["none", "coarse", "fine"], hover: ["hover", "none"], update: ["fast", "slow"], "inverted-colors": ["inverted", "none"], "prefers-reduced-motion": ["reduce", "no-preference"], "prefers-reduced-transparency": ["reduce", "no-preference"], scripting: ["none", "initial-only", "enabled"], "forced-colors": ["active", "none"] };
375
375
  return Object.keys(e).forEach(function(n) {
376
- e[n].forEach(function(o) {
377
- matchMedia("(".concat(n, ": ").concat(o, ")")).matches && r.push("".concat(n, ": ").concat(o));
376
+ e[n].forEach(function(r) {
377
+ matchMedia("(".concat(n, ": ").concat(r, ")")).matches && a.push("".concat(n, ": ").concat(r));
378
378
  });
379
- }), r;
379
+ }), a;
380
380
  }
381
- function te() {
381
+ function ne() {
382
382
  if (window.location.protocol === "https:" && typeof window.ApplePaySession == "function") try {
383
- for (var r = window.ApplePaySession.supportsVersion, e = 15; e > 0; e--) if (r(e)) return e;
383
+ for (var a = window.ApplePaySession.supportsVersion, e = 15; e > 0; e--) if (a(e)) return e;
384
384
  } catch {
385
385
  return 0;
386
386
  }
387
387
  return 0;
388
388
  }
389
- E().name != "Firefox" && v("fonts", function() {
390
- var r = this;
389
+ C().name != "Firefox" && v("fonts", function() {
390
+ var a = this;
391
391
  return new Promise(function(e, n) {
392
392
  try {
393
- (function(o) {
394
- var a;
393
+ (function(r) {
394
+ var i;
395
395
  w(this, void 0, void 0, function() {
396
- var i, t, u;
397
- return y(this, function(l) {
398
- switch (l.label) {
396
+ var o, t, u;
397
+ return y(this, function(h) {
398
+ switch (h.label) {
399
399
  case 0:
400
- return document.body ? [3, 2] : [4, (c = 50, new Promise(function(f) {
401
- return setTimeout(f, c, s);
400
+ return document.body ? [3, 2] : [4, (c = 50, new Promise(function(p) {
401
+ return setTimeout(p, c, s);
402
402
  }))];
403
403
  case 1:
404
- return l.sent(), [3, 0];
404
+ return h.sent(), [3, 0];
405
405
  case 2:
406
- if ((i = document.createElement("iframe")).setAttribute("frameBorder", "0"), (t = i.style).setProperty("position", "fixed"), t.setProperty("display", "block", "important"), t.setProperty("visibility", "visible"), t.setProperty("border", "0"), t.setProperty("opacity", "0"), i.src = "about:blank", document.body.appendChild(i), !(u = i.contentDocument || ((a = i.contentWindow) === null || a === void 0 ? void 0 : a.document))) throw new Error("Iframe document is not accessible");
407
- return o({ iframe: u }), setTimeout(function() {
408
- document.body.removeChild(i);
406
+ if ((o = document.createElement("iframe")).setAttribute("frameBorder", "0"), (t = o.style).setProperty("position", "fixed"), t.setProperty("display", "block", "important"), t.setProperty("visibility", "visible"), t.setProperty("border", "0"), t.setProperty("opacity", "0"), o.src = "about:blank", document.body.appendChild(o), !(u = o.contentDocument || ((i = o.contentWindow) === null || i === void 0 ? void 0 : i.document))) throw new Error("Iframe document is not accessible");
407
+ return r({ iframe: u }), setTimeout(function() {
408
+ document.body.removeChild(o);
409
409
  }, 0), [2];
410
410
  }
411
411
  var c, s;
412
412
  });
413
413
  });
414
- })(function(o) {
415
- var a = o.iframe;
416
- return w(r, void 0, void 0, function() {
417
- var i, t, u, l;
414
+ })(function(r) {
415
+ var i = r.iframe;
416
+ return w(a, void 0, void 0, function() {
417
+ var o, t, u, h;
418
418
  return y(this, function(c) {
419
- return i = a.createElement("canvas"), t = i.getContext("2d"), u = J.map(function(s) {
420
- return P(t, s);
421
- }), l = {}, K.forEach(function(s) {
422
- var f = P(t, s);
423
- u.includes(f) || (l[s] = f);
424
- }), e(l), [2];
419
+ return o = i.createElement("canvas"), t = o.getContext("2d"), u = J.map(function(s) {
420
+ return F(t, s);
421
+ }), h = {}, X.forEach(function(s) {
422
+ var p = F(t, s);
423
+ u.includes(p) || (h[s] = p);
424
+ }), e(h), [2];
425
425
  });
426
426
  });
427
427
  });
@@ -430,76 +430,76 @@ E().name != "Firefox" && v("fonts", function() {
430
430
  }
431
431
  });
432
432
  }), v("hardware", function() {
433
- return new Promise(function(r, e) {
434
- var n = navigator.deviceMemory !== void 0 ? navigator.deviceMemory : 0, o = window.performance && window.performance.memory ? window.performance.memory : 0;
435
- r({ videocard: Y(), architecture: X(), deviceMemory: n.toString() || "undefined", jsHeapSizeLimit: o.jsHeapSizeLimit || 0 });
433
+ return new Promise(function(a, e) {
434
+ var n = navigator.deviceMemory !== void 0 ? navigator.deviceMemory : 0, r = window.performance && window.performance.memory ? window.performance.memory : 0;
435
+ a({ videocard: Y(), architecture: Z(), deviceMemory: n.toString() || "undefined", jsHeapSizeLimit: r.jsHeapSizeLimit || 0 });
436
436
  });
437
437
  }), v("locales", function() {
438
- return new Promise(function(r) {
439
- r({ languages: navigator.language, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone });
438
+ return new Promise(function(a) {
439
+ a({ languages: navigator.language, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone });
440
440
  });
441
441
  }), v("permissions", function() {
442
442
  return w(this, void 0, void 0, function() {
443
- var r;
443
+ var a;
444
444
  return y(this, function(e) {
445
- return _ = (b == null ? void 0 : b.permissions_to_check) || ["accelerometer", "accessibility", "accessibility-events", "ambient-light-sensor", "background-fetch", "background-sync", "bluetooth", "camera", "clipboard-read", "clipboard-write", "device-info", "display-capture", "gyroscope", "geolocation", "local-fonts", "magnetometer", "microphone", "midi", "nfc", "notifications", "payment-handler", "persistent-storage", "push", "speaker", "storage-access", "top-level-storage-access", "window-management", "query"], r = Array.from({ length: (b == null ? void 0 : b.retries) || 3 }, function() {
445
+ return A = (S == null ? void 0 : S.permissions_to_check) || ["accelerometer", "accessibility", "accessibility-events", "ambient-light-sensor", "background-fetch", "background-sync", "bluetooth", "camera", "clipboard-read", "clipboard-write", "device-info", "display-capture", "gyroscope", "geolocation", "local-fonts", "magnetometer", "microphone", "midi", "nfc", "notifications", "payment-handler", "persistent-storage", "push", "speaker", "storage-access", "top-level-storage-access", "window-management", "query"], a = Array.from({ length: (S == null ? void 0 : S.retries) || 3 }, function() {
446
446
  return function() {
447
447
  return w(this, void 0, void 0, function() {
448
- var n, o, a, i, t;
448
+ var n, r, i, o, t;
449
449
  return y(this, function(u) {
450
450
  switch (u.label) {
451
451
  case 0:
452
- n = {}, o = 0, a = _, u.label = 1;
452
+ n = {}, r = 0, i = A, u.label = 1;
453
453
  case 1:
454
- if (!(o < a.length)) return [3, 6];
455
- i = a[o], u.label = 2;
454
+ if (!(r < i.length)) return [3, 6];
455
+ o = i[r], u.label = 2;
456
456
  case 2:
457
- return u.trys.push([2, 4, , 5]), [4, navigator.permissions.query({ name: i })];
457
+ return u.trys.push([2, 4, , 5]), [4, navigator.permissions.query({ name: o })];
458
458
  case 3:
459
- return t = u.sent(), n[i] = t.state.toString(), [3, 5];
459
+ return t = u.sent(), n[o] = t.state.toString(), [3, 5];
460
460
  case 4:
461
461
  return u.sent(), [3, 5];
462
462
  case 5:
463
- return o++, [3, 1];
463
+ return r++, [3, 1];
464
464
  case 6:
465
465
  return [2, n];
466
466
  }
467
467
  });
468
468
  });
469
469
  }();
470
- }), [2, Promise.all(r).then(function(n) {
471
- return Z(n, _);
470
+ }), [2, Promise.all(a).then(function(n) {
471
+ return ee(n, A);
472
472
  })];
473
473
  });
474
474
  });
475
475
  }), v("plugins", function() {
476
- var r = [];
476
+ var a = [];
477
477
  if (navigator.plugins) for (var e = 0; e < navigator.plugins.length; e++) {
478
478
  var n = navigator.plugins[e];
479
- r.push([n.name, n.filename, n.description].join("|"));
479
+ a.push([n.name, n.filename, n.description].join("|"));
480
480
  }
481
- return new Promise(function(o) {
482
- o({ plugins: r });
481
+ return new Promise(function(r) {
482
+ r({ plugins: a });
483
483
  });
484
484
  }), v("screen", function() {
485
- return new Promise(function(r) {
486
- r({ is_touchscreen: navigator.maxTouchPoints > 0, maxTouchPoints: navigator.maxTouchPoints, colorDepth: screen.colorDepth, mediaMatches: ee() });
485
+ return new Promise(function(a) {
486
+ a({ is_touchscreen: navigator.maxTouchPoints > 0, maxTouchPoints: navigator.maxTouchPoints, colorDepth: screen.colorDepth, mediaMatches: te() });
487
487
  });
488
488
  }), v("system", function() {
489
- return new Promise(function(r) {
490
- var e = E();
491
- r({ platform: window.navigator.platform, cookieEnabled: window.navigator.cookieEnabled, productSub: navigator.productSub, product: navigator.product, useragent: navigator.userAgent, hardwareConcurrency: navigator.hardwareConcurrency, browser: { name: e.name, version: e.version }, applePayVersion: te() });
489
+ return new Promise(function(a) {
490
+ var e = C();
491
+ a({ platform: window.navigator.platform, cookieEnabled: window.navigator.cookieEnabled, productSub: navigator.productSub, product: navigator.product, useragent: navigator.userAgent, hardwareConcurrency: navigator.hardwareConcurrency, browser: { name: e.name, version: e.version }, applePayVersion: ne() });
492
492
  });
493
493
  });
494
- var p, ne = E().name !== "SamsungBrowser" ? 1 : 3, d = null;
494
+ var f, re = C().name !== "SamsungBrowser" ? 1 : 3, d = null;
495
495
  v("webgl", function() {
496
496
  return w(this, void 0, void 0, function() {
497
- var r;
497
+ var a;
498
498
  return y(this, function(e) {
499
- typeof document < "u" && ((p = document.createElement("canvas")).width = 200, p.height = 100, d = p.getContext("webgl"));
499
+ typeof document < "u" && ((f = document.createElement("canvas")).width = 200, f.height = 100, d = f.getContext("webgl"));
500
500
  try {
501
501
  if (!d) throw new Error("WebGL not supported");
502
- return r = Array.from({ length: ne }, function() {
502
+ return a = Array.from({ length: re }, function() {
503
503
  return function() {
504
504
  try {
505
505
  if (!d) throw new Error("WebGL not supported");
@@ -508,36 +508,36 @@ v("webgl", function() {
508
508
  void main() {
509
509
  gl_Position = vec4(position, 0.0, 1.0);
510
510
  }
511
- `, o = `
511
+ `, r = `
512
512
  precision mediump float;
513
513
  void main() {
514
514
  gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
515
515
  }
516
- `, a = d.createShader(d.VERTEX_SHADER), i = d.createShader(d.FRAGMENT_SHADER);
517
- if (!a || !i) throw new Error("Failed to create shaders");
518
- if (d.shaderSource(a, n), d.shaderSource(i, o), d.compileShader(a), !d.getShaderParameter(a, d.COMPILE_STATUS)) throw new Error("Vertex shader compilation failed: " + d.getShaderInfoLog(a));
519
- if (d.compileShader(i), !d.getShaderParameter(i, d.COMPILE_STATUS)) throw new Error("Fragment shader compilation failed: " + d.getShaderInfoLog(i));
516
+ `, i = d.createShader(d.VERTEX_SHADER), o = d.createShader(d.FRAGMENT_SHADER);
517
+ if (!i || !o) throw new Error("Failed to create shaders");
518
+ if (d.shaderSource(i, n), d.shaderSource(o, r), d.compileShader(i), !d.getShaderParameter(i, d.COMPILE_STATUS)) throw new Error("Vertex shader compilation failed: " + d.getShaderInfoLog(i));
519
+ if (d.compileShader(o), !d.getShaderParameter(o, d.COMPILE_STATUS)) throw new Error("Fragment shader compilation failed: " + d.getShaderInfoLog(o));
520
520
  var t = d.createProgram();
521
521
  if (!t) throw new Error("Failed to create shader program");
522
- if (d.attachShader(t, a), d.attachShader(t, i), d.linkProgram(t), !d.getProgramParameter(t, d.LINK_STATUS)) throw new Error("Shader program linking failed: " + d.getProgramInfoLog(t));
522
+ if (d.attachShader(t, i), d.attachShader(t, o), d.linkProgram(t), !d.getProgramParameter(t, d.LINK_STATUS)) throw new Error("Shader program linking failed: " + d.getProgramInfoLog(t));
523
523
  d.useProgram(t);
524
- for (var u = 137, l = new Float32Array(4 * u), c = 2 * Math.PI / u, s = 0; s < u; s++) {
525
- var f = s * c;
526
- l[4 * s] = 0, l[4 * s + 1] = 0, l[4 * s + 2] = Math.cos(f) * (p.width / 2), l[4 * s + 3] = Math.sin(f) * (p.height / 2);
524
+ for (var u = 137, h = new Float32Array(4 * u), c = 2 * Math.PI / u, s = 0; s < u; s++) {
525
+ var p = s * c;
526
+ h[4 * s] = 0, h[4 * s + 1] = 0, h[4 * s + 2] = Math.cos(p) * (f.width / 2), h[4 * s + 3] = Math.sin(p) * (f.height / 2);
527
527
  }
528
- var C = d.createBuffer();
529
- d.bindBuffer(d.ARRAY_BUFFER, C), d.bufferData(d.ARRAY_BUFFER, l, d.STATIC_DRAW);
528
+ var q = d.createBuffer();
529
+ d.bindBuffer(d.ARRAY_BUFFER, q), d.bufferData(d.ARRAY_BUFFER, h, d.STATIC_DRAW);
530
530
  var R = d.getAttribLocation(t, "position");
531
- d.enableVertexAttribArray(R), d.vertexAttribPointer(R, 2, d.FLOAT, !1, 0, 0), d.viewport(0, 0, p.width, p.height), d.clearColor(0, 0, 0, 1), d.clear(d.COLOR_BUFFER_BIT), d.drawArrays(d.LINES, 0, 2 * u);
532
- var x = new Uint8ClampedArray(p.width * p.height * 4);
533
- return d.readPixels(0, 0, p.width, p.height, d.RGBA, d.UNSIGNED_BYTE, x), new ImageData(x, p.width, p.height);
531
+ d.enableVertexAttribArray(R), d.vertexAttribPointer(R, 2, d.FLOAT, !1, 0, 0), d.viewport(0, 0, f.width, f.height), d.clearColor(0, 0, 0, 1), d.clear(d.COLOR_BUFFER_BIT), d.drawArrays(d.LINES, 0, 2 * u);
532
+ var x = new Uint8ClampedArray(f.width * f.height * 4);
533
+ return d.readPixels(0, 0, f.width, f.height, d.RGBA, d.UNSIGNED_BYTE, x), new ImageData(x, f.width, f.height);
534
534
  } catch {
535
535
  return new ImageData(1, 1);
536
536
  } finally {
537
537
  d && (d.bindBuffer(d.ARRAY_BUFFER, null), d.useProgram(null), d.viewport(0, 0, d.drawingBufferWidth, d.drawingBufferHeight), d.clearColor(0, 0, 0, 0));
538
538
  }
539
539
  }();
540
- }), [2, { commonImageHash: M(L(r, p.width, p.height).data.toString()).toString() }];
540
+ }), [2, { commonImageHash: I(L(a, f.width, f.height).data.toString()).toString() }];
541
541
  } catch {
542
542
  return [2, { webgl: "unsupported" }];
543
543
  }
@@ -545,31 +545,31 @@ v("webgl", function() {
545
545
  });
546
546
  });
547
547
  });
548
- var S = function(r, e, n, o) {
549
- for (var a = (n - e) / o, i = 0, t = 0; t < o; t++)
550
- i += r(e + (t + 0.5) * a);
551
- return i * a;
548
+ var b = function(a, e, n, r) {
549
+ for (var i = (n - e) / r, o = 0, t = 0; t < r; t++)
550
+ o += a(e + (t + 0.5) * i);
551
+ return o * i;
552
552
  };
553
553
  v("math", function() {
554
554
  return w(void 0, void 0, void 0, function() {
555
- return y(this, function(r) {
556
- return [2, { acos: Math.acos(0.5), asin: S(Math.asin, -1, 1, 97), atan: S(Math.atan, -1, 1, 97), cos: S(Math.cos, 0, Math.PI, 97), cosh: Math.cosh(9 / 7), e: Math.E, largeCos: Math.cos(1e20), largeSin: Math.sin(1e20), largeTan: Math.tan(1e20), log: Math.log(1e3), pi: Math.PI, sin: S(Math.sin, -Math.PI, Math.PI, 97), sinh: S(Math.sinh, -9 / 7, 7 / 9, 97), sqrt: Math.sqrt(2), tan: S(Math.tan, 0, 2 * Math.PI, 97), tanh: S(Math.tanh, -9 / 7, 7 / 9, 97) }];
555
+ return y(this, function(a) {
556
+ return [2, { acos: Math.acos(0.5), asin: b(Math.asin, -1, 1, 97), atan: b(Math.atan, -1, 1, 97), cos: b(Math.cos, 0, Math.PI, 97), cosh: Math.cosh(9 / 7), e: Math.E, largeCos: Math.cos(1e20), largeSin: Math.sin(1e20), largeTan: Math.tan(1e20), log: Math.log(1e3), pi: Math.PI, sin: b(Math.sin, -Math.PI, Math.PI, 97), sinh: b(Math.sinh, -9 / 7, 7 / 9, 97), sqrt: Math.sqrt(2), tan: b(Math.tan, 0, 2 * Math.PI, 97), tanh: b(Math.tanh, -9 / 7, 7 / 9, 97) }];
557
557
  });
558
558
  });
559
559
  });
560
- const re = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
561
- let T = (r = 21) => {
562
- let e = "", n = crypto.getRandomValues(new Uint8Array(r |= 0));
563
- for (; r--; )
564
- e += re[n[r] & 63];
560
+ const ae = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
561
+ let E = (a = 21) => {
562
+ let e = "", n = crypto.getRandomValues(new Uint8Array(a |= 0));
563
+ for (; a--; )
564
+ e += ae[n[a] & 63];
565
565
  return e;
566
566
  };
567
- class I {
567
+ class M {
568
568
  constructor(e) {
569
- h(this, "config");
569
+ l(this, "config");
570
570
  this.config = e;
571
571
  }
572
- async getAdsForSearchParams(e) {
572
+ async getAds(e) {
573
573
  return [];
574
574
  }
575
575
  async onQuerySubmitted(e) {
@@ -583,14 +583,14 @@ class I {
583
583
  async onAdContainerViewed(e) {
584
584
  }
585
585
  }
586
- class oe extends I {
586
+ class oe extends M {
587
587
  /**
588
588
  * Gets ads from the adMarketplace API based on the search term.
589
589
  */
590
- async getAdsForSearchParams(e) {
590
+ async getAds(e) {
591
591
  if (!this.config.admSub)
592
592
  return console.error("No admSub specified in config."), [];
593
- const o = `https://demofeed.is.ampfeed.com/is?${new URLSearchParams({
593
+ const r = `https://demofeed.is.ampfeed.com/is?${new URLSearchParams({
594
594
  partner: "demofeed",
595
595
  sub1: this.config.admSub,
596
596
  qt: e.searchTerm,
@@ -598,15 +598,15 @@ class oe extends I {
598
598
  rfr: "searchcraft.io",
599
599
  "results-ta": `${this.config.admTextAdQuantity || 0}`,
600
600
  "results-pa": `${this.config.admProductAdQuantity || 0}`
601
- }).toString()}`, i = await (await fetch(o, { method: "GET" })).json(), t = i.product_ads.map(
601
+ }).toString()}`, o = await (await fetch(r, { method: "GET" })).json(), t = o.product_ads.map(
602
602
  (c) => ({
603
- id: T(),
603
+ id: E(),
604
604
  adSource: "adMarketplace",
605
605
  admAdType: "adm-product-ad",
606
606
  admAd: c
607
607
  })
608
- ), u = i.text_ads.map((c) => ({
609
- id: T(),
608
+ ), u = o.text_ads.map((c) => ({
609
+ id: E(),
610
610
  adSource: "adMarketplace",
611
611
  admAdType: "adm-text-ad",
612
612
  admAd: c
@@ -614,33 +614,33 @@ class oe extends I {
614
614
  return t.concat(u);
615
615
  }
616
616
  async onAdContainerViewed(e) {
617
- var o;
617
+ var r;
618
618
  const n = e.adClientResponseItem;
619
- (o = n.admAd) != null && o.impression_url && fetch(n.admAd.impression_url);
619
+ (r = n.admAd) != null && r.impression_url && fetch(n.admAd.impression_url);
620
620
  }
621
621
  }
622
- class ie extends I {
623
- async getAdsForSearchParams(e) {
622
+ class ie extends M {
623
+ async getAds(e) {
624
624
  return [];
625
625
  }
626
626
  }
627
- const ae = 1e3;
628
- class se extends I {
627
+ const se = 1e3;
628
+ class ce extends M {
629
629
  constructor(n) {
630
630
  super(n);
631
- h(this, "adCallTimeout");
631
+ l(this, "adCallTimeout");
632
632
  this.addScriptTagToDocument();
633
633
  }
634
634
  async onQuerySubmitted(n) {
635
635
  this.addScriptTagToDocument();
636
636
  }
637
- async onQueryFetched(n, o) {
638
- var a;
639
- if ((((a = o.data.hits) == null ? void 0 : a.length) || 0) === 0) {
637
+ async onQueryFetched(n, r) {
638
+ var i;
639
+ if ((((i = r.data.hits) == null ? void 0 : i.length) || 0) === 0) {
640
640
  this.removeScriptTagFromDocument();
641
641
  return;
642
642
  }
643
- this.performAdCall(ae);
643
+ this.performAdCall(se);
644
644
  }
645
645
  async onInputCleared() {
646
646
  this.removeScriptTagFromDocument();
@@ -650,12 +650,12 @@ class se extends I {
650
650
  this.addScriptTagToDocument();
651
651
  try {
652
652
  PostRelease == null || PostRelease.Start({ ptd: [this.config.nativoPlacementId] });
653
- } catch (o) {
654
- console.error(o);
653
+ } catch (r) {
654
+ console.error(r);
655
655
  }
656
656
  }, n);
657
657
  }
658
- async getAdsForSearchParams(n) {
658
+ async getAds(n) {
659
659
  return [];
660
660
  }
661
661
  addScriptTagToDocument() {
@@ -669,15 +669,15 @@ class se extends I {
669
669
  n && document.head.removeChild(n);
670
670
  }
671
671
  }
672
- const ce = 600;
673
- class ue {
674
- constructor(e, n, o) {
675
- h(this, "measureRequestTimeout");
676
- h(this, "measureRequestsBatched", []);
677
- h(this, "config");
678
- h(this, "sdkInfo");
679
- h(this, "userId");
680
- h(this, "sessionId");
672
+ const ue = 600;
673
+ class de {
674
+ constructor(e, n, r) {
675
+ l(this, "measureRequestTimeout");
676
+ l(this, "measureRequestsBatched", []);
677
+ l(this, "config");
678
+ l(this, "sdkInfo");
679
+ l(this, "userId");
680
+ l(this, "sessionId");
681
681
  /**
682
682
  * Sends a measure event to the `/measure/event` endpoint for analytics purposes.
683
683
  *
@@ -685,8 +685,8 @@ class ue {
685
685
  * @param {Partial<MeasureRequestProperties>} properties - Additional properties to send with the event.
686
686
  * @param {Partial<MeasureRequestUser>} user - Additional user properites to send with the event.
687
687
  */
688
- h(this, "sendMeasureEvent", async (e, n = {}, o = {}) => {
689
- const a = {
688
+ l(this, "sendMeasureEvent", async (e, n = {}, r = {}) => {
689
+ const i = {
690
690
  event_name: e,
691
691
  properties: {
692
692
  searchcraft_index_names: this.config.index,
@@ -695,20 +695,21 @@ class ue {
695
695
  },
696
696
  user: {
697
697
  ...this.measureRequestUser,
698
- ...o
698
+ ...r
699
699
  }
700
700
  };
701
701
  if (e === "document_clicked") {
702
- const i = JSON.stringify(a), t = `${this.baseMeasureUrl}/event`;
702
+ const o = JSON.stringify(i), t = `${this.baseMeasureUrl}/event`;
703
703
  try {
704
704
  const u = await fetch(t, {
705
705
  method: "POST",
706
706
  headers: {
707
707
  "Content-Type": "application/json",
708
708
  Authorization: this.config.readKey,
709
- "X-Sc-User-Id": this.userId
709
+ "X-Sc-User-Id": this.userId,
710
+ "X-Sc-Session-Id": this.sessionId
710
711
  },
711
- body: i,
712
+ body: o,
712
713
  keepalive: !0
713
714
  });
714
715
  if (!u.ok)
@@ -719,17 +720,18 @@ class ue {
719
720
  throw console.error("Error sending MeasureRequest:", u), u;
720
721
  }
721
722
  } else
722
- this.measureRequestsBatched.push(a), clearTimeout(this.measureRequestTimeout), this.measureRequestTimeout = setTimeout(async () => {
723
- const i = JSON.stringify({ items: this.measureRequestsBatched }), t = `${this.baseMeasureUrl}/batch`;
723
+ this.measureRequestsBatched.push(i), clearTimeout(this.measureRequestTimeout), this.measureRequestTimeout = setTimeout(async () => {
724
+ const o = JSON.stringify({ items: this.measureRequestsBatched }), t = `${this.baseMeasureUrl}/batch`;
724
725
  try {
725
726
  const u = await fetch(t, {
726
727
  method: "POST",
727
728
  headers: {
728
729
  "Content-Type": "application/json",
729
730
  Authorization: this.config.readKey,
730
- "X-Sc-User-Id": this.userId
731
+ "X-Sc-User-Id": this.userId,
732
+ "X-Sc-Session-Id": this.sessionId
731
733
  },
732
- body: i,
734
+ body: o,
733
735
  keepalive: !0
734
736
  });
735
737
  if (this.measureRequestsBatched = [], !u.ok)
@@ -740,9 +742,9 @@ class ue {
740
742
  } catch (u) {
741
743
  throw this.measureRequestsBatched = [], console.error("Error sending MeasureRequest:", u), u;
742
744
  }
743
- }, ce);
745
+ }, ue);
744
746
  });
745
- this.config = e, this.sdkInfo = n, this.userId = o, this.sessionId = T(), this.sendMeasureEvent("sdk_initialized");
747
+ this.config = e, this.sdkInfo = n, this.userId = r, this.sessionId = E(), this.sendMeasureEvent("sdk_initialized");
746
748
  }
747
749
  /**
748
750
  * Getter for the base url used by the /measure endpoints.
@@ -765,113 +767,128 @@ class ue {
765
767
  };
766
768
  }
767
769
  }
768
- function de(r) {
769
- const e = [];
770
- let n = "should";
771
- return r.facetPathsForIndexFields && Object.keys(r.facetPathsForIndexFields).forEach((o) => {
772
- var i;
773
- const a = (i = r.facetPathsForIndexFields) == null ? void 0 : i[o];
774
- a && (n = "must", e.push({
775
- occur: n,
776
- exact: {
777
- ctx: a.value
778
- }
779
- }));
780
- }), r.rangeValueForIndexFields && Object.keys(r.rangeValueForIndexFields).forEach((o) => {
781
- var i;
782
- const a = (i = r.rangeValueForIndexFields) == null ? void 0 : i[o];
783
- a && (n = "must", e.push({
784
- occur: n,
785
- exact: {
786
- ctx: a.value
787
- }
788
- }));
789
- }), r.sort === "desc" ? r.order_by = "date_published" : r.order_by = "", e.push({
790
- occur: n,
791
- // Valid, as 'occur' is a required property in QueryItem
792
- [r.mode]: { ctx: r.searchTerm }
793
- // Ensure dynamic mode is inside queryType
794
- }), e;
795
- }
796
- const le = (r) => r.endsWith("/") ? r.slice(0, -1) : r, he = (r) => {
770
+ const he = (a) => a.endsWith("/") ? a.slice(0, -1) : a, _ = (a) => {
797
771
  let e = "";
798
- if (e = r.trim(), e = e.replace(/[‘’“”]/g, (o) => ({
772
+ if (e = a.trim(), e = e.replace(/[‘’“”]/g, (r) => ({
799
773
  "‘": "'",
800
774
  "’": "'",
801
775
  "“": '"',
802
776
  "”": '"'
803
- })[o] || o), (e.match(/"/g) || []).length % 2 !== 0)
777
+ })[r] || r), (e.match(/"/g) || []).length % 2 !== 0)
804
778
  throw new Error(
805
779
  "The search term contains an uneven number of quote characters."
806
780
  );
807
781
  return e;
808
- }, fe = 500;
782
+ }, le = 500;
809
783
  class me {
810
- constructor(e, n, o) {
811
- h(this, "config");
812
- h(this, "userId");
813
- h(this, "parent");
814
- h(this, "searchCompletedEventTimeout");
784
+ constructor(e, n, r) {
785
+ l(this, "config");
786
+ l(this, "userId");
787
+ l(this, "parent");
788
+ l(this, "searchCompletedEventTimeout");
815
789
  /**
816
- * Performs a search operation.
817
- * @param {SearchParams} searchParams - The parameters for the search.
790
+ * Make the request to get the search results.
791
+ * @param {properties} properties - The properties for the search.
792
+ * @returns
818
793
  */
819
- h(this, "getSearchResponse", async (e) => {
820
- var o, a, i, t, u;
821
- const n = he(e.searchTerm);
822
- (o = this.parent.measureClient) == null || o.sendMeasureEvent("search_requested", {
823
- search_term: n
824
- }), this.parent.emitEvent("query_submitted", {
825
- name: "query_submitted",
826
- data: {
827
- searchTerm: n
828
- }
829
- }), (a = this.parent.adClient) == null || a.onQuerySubmitted(e);
794
+ l(this, "getSearchResponseItems", async (e) => {
795
+ var i, o, t, u, h;
796
+ let n;
797
+ const r = typeof e == "string" ? e : e.searchTerm;
830
798
  try {
831
- const l = {
832
- query: de(e),
833
- offset: e.offset || 0,
834
- // Default to 0 (first page) if not provided
835
- limit: e.limit || this.config.searchResultsPerPage || 20
836
- // Default to 20 if not provided
799
+ return (i = this.parent.measureClient) == null || i.sendMeasureEvent("search_requested", {
800
+ search_term: r
801
+ }), this.parent.emitEvent("query_submitted", {
802
+ name: "query_submitted",
803
+ data: {
804
+ searchTerm: r
805
+ }
806
+ }), (o = this.parent.adClient) == null || o.onQuerySubmitted(
807
+ typeof e == "string" ? { searchTerm: r, mode: "exact" } : e
808
+ ), typeof e == "string" ? n = await this.handleGetSearchResponseItemsWithString(e) : n = await this.handleGetSearchResponseItemsWithObject(e), (t = this.parent.measureClient) == null || t.sendMeasureEvent("search_response_received", {
809
+ search_term: r,
810
+ number_of_documents: n.data.count
811
+ }), clearTimeout(this.searchCompletedEventTimeout), this.searchCompletedEventTimeout = setTimeout(() => {
812
+ var c;
813
+ (c = this.parent.measureClient) == null || c.sendMeasureEvent("search_completed", {
814
+ search_term: r,
815
+ number_of_documents: n.data.count
816
+ });
817
+ }, le), this.parent.emitEvent("query_fetched", {
818
+ name: "query_fetched",
819
+ data: {
820
+ searchTerm: r
821
+ }
822
+ }), (((u = n.data.hits) == null ? void 0 : u.length) || 0) === 0 && this.parent.emitEvent("no_results_returned", {
823
+ name: "no_results_returned"
824
+ }), (h = this.parent.adClient) == null || h.onQueryFetched(
825
+ typeof e == "string" ? { searchTerm: r, mode: "exact" } : e,
826
+ n
827
+ ), n;
828
+ } catch (c) {
829
+ throw console.error("Error parsing response:", c), c;
830
+ }
831
+ });
832
+ l(this, "handleGetSearchResponseItemsWithString", async (e) => {
833
+ var i;
834
+ let n;
835
+ try {
836
+ n = JSON.parse(e), n = {
837
+ limit: this.config.searchResultsPerPage,
838
+ ...n
837
839
  };
838
- e.order_by && (l.order_by = e.order_by, l.sort = e.sort === "desc" || e.sort === "asc" ? e.sort : "asc");
839
- const c = {
840
+ } catch {
841
+ throw new Error("Error: Query string is not valid json.");
842
+ }
843
+ const r = await fetch(this.baseSearchUrl, {
844
+ method: "POST",
845
+ headers: {
846
+ Authorization: this.config.readKey,
847
+ "Content-Type": "application/json",
848
+ "X-Sc-User-Id": this.userId,
849
+ "X-Sc-Session-Id": ((i = this.parent.measureClient) == null ? void 0 : i.sessionId) || E()
850
+ },
851
+ body: JSON.stringify(n)
852
+ });
853
+ if (!r.ok)
854
+ throw new Error(
855
+ `Error: ${r.statusText} (Status: ${r.status})`
856
+ );
857
+ return await r.json();
858
+ });
859
+ l(this, "handleGetSearchResponseItemsWithObject", async (e) => {
860
+ var n;
861
+ try {
862
+ const r = await fetch(this.baseSearchUrl, {
840
863
  method: "POST",
841
864
  headers: {
842
865
  Authorization: this.config.readKey,
843
866
  "Content-Type": "application/json",
844
- "X-Sc-User-Id": this.userId
867
+ "X-Sc-User-Id": this.userId,
868
+ "X-Sc-Session-Id": ((n = this.parent.measureClient) == null ? void 0 : n.sessionId) || E()
845
869
  },
846
- body: JSON.stringify(l)
847
- }, s = await fetch(this.baseSearchUrl, c);
848
- if (!s.ok)
870
+ body: JSON.stringify({
871
+ query: this.formatParamsForRequest(e),
872
+ offset: e.offset || 0,
873
+ limit: e.limit || this.config.searchResultsPerPage || 20,
874
+ ...e.order_by && {
875
+ order_by: e.order_by
876
+ },
877
+ ...e.sort && {
878
+ sort: e.sort
879
+ }
880
+ })
881
+ });
882
+ if (!r.ok)
849
883
  throw new Error(
850
- `Error: ${s.statusText} (Status: ${s.status})`
884
+ `Error: ${r.statusText} (Status: ${r.status})`
851
885
  );
852
- const f = await s.json();
853
- return (i = this.parent.measureClient) == null || i.sendMeasureEvent("search_response_received", {
854
- search_term: n,
855
- number_of_documents: f.data.count
856
- }), clearTimeout(this.searchCompletedEventTimeout), this.searchCompletedEventTimeout = setTimeout(() => {
857
- var C;
858
- (C = this.parent.measureClient) == null || C.sendMeasureEvent("search_completed", {
859
- search_term: n,
860
- number_of_documents: f.data.count
861
- });
862
- }, fe), this.parent.emitEvent("query_fetched", {
863
- name: "query_fetched",
864
- data: {
865
- searchTerm: n
866
- }
867
- }), (((t = f.data.hits) == null ? void 0 : t.length) || 0) === 0 && this.parent.emitEvent("no_results_returned", {
868
- name: "no_results_returned"
869
- }), (u = this.parent.adClient) == null || u.onQueryFetched(e, f), f;
870
- } catch (l) {
871
- throw console.error("Error parsing response:", l), l;
886
+ return await r.json();
887
+ } catch (r) {
888
+ throw console.error("Error parsing response:", r), r;
872
889
  }
873
890
  });
874
- this.parent = e, this.config = n, this.userId = o;
891
+ this.parent = e, this.config = n, this.userId = r;
875
892
  }
876
893
  /**
877
894
  * Getter for the base url used by the /search endpoint.
@@ -879,43 +896,78 @@ class me {
879
896
  get baseSearchUrl() {
880
897
  return `${this.config.endpointURL}/index/${this.config.index.join(",")}/search`;
881
898
  }
899
+ /**
900
+ * Builds a query object for the SearchClient request.
901
+ * @param {properties} properties - The properties for the search.
902
+ * @returns {SearchClientQuery} - A properly formatted SearchClient query object.
903
+ */
904
+ formatParamsForRequest(e) {
905
+ const n = [];
906
+ e.facetPathsForIndexFields && Object.keys(e.facetPathsForIndexFields).forEach((o) => {
907
+ var u;
908
+ const t = (u = e.facetPathsForIndexFields) == null ? void 0 : u[o];
909
+ t && n.push({
910
+ occur: "must",
911
+ exact: {
912
+ ctx: _(t.value)
913
+ }
914
+ });
915
+ }), e.rangeValueForIndexFields && Object.keys(e.rangeValueForIndexFields).forEach((o) => {
916
+ var u;
917
+ const t = (u = e.rangeValueForIndexFields) == null ? void 0 : u[o];
918
+ t && n.push({
919
+ occur: "must",
920
+ exact: {
921
+ ctx: _(t.value)
922
+ }
923
+ });
924
+ });
925
+ const r = _(e.searchTerm), i = e.mode === "fuzzy" ? { fuzzy: { ctx: r } } : {
926
+ exact: {
927
+ ctx: `${r.startsWith('"') ? r : `"${r}"`}`
928
+ }
929
+ };
930
+ return n.push({
931
+ occur: e.mode === "exact" ? "must" : "should",
932
+ // Valid, as 'occur' is a required property in SearchClientQuery
933
+ ...i
934
+ }), n;
935
+ }
882
936
  }
883
- class we {
937
+ class ve {
884
938
  constructor(e, n) {
885
- h(this, "config");
886
- h(this, "measureClient");
887
- h(this, "searchClient");
888
- h(this, "adClient");
889
- h(this, "userId");
890
- h(this, "requestTimeout");
891
- h(this, "subscriptionEvents", {});
892
- /**
893
- * Gets items from the SearchClient and the AdClient.
894
- */
895
- h(this, "getItems", (e, n, o) => {
896
- const a = async () => {
939
+ l(this, "config");
940
+ l(this, "measureClient");
941
+ l(this, "searchClient");
942
+ l(this, "adClient");
943
+ l(this, "userId");
944
+ l(this, "requestTimeout");
945
+ l(this, "subscriptionEvents", {});
946
+ l(this, "getResponseItems", (e, n, r) => {
947
+ const i = async () => {
897
948
  (async () => {
898
- var u, l;
899
- const i = await ((u = this == null ? void 0 : this.searchClient) == null ? void 0 : u.getSearchResponse(e));
900
- if (!i)
949
+ var u;
950
+ const o = await ((u = this == null ? void 0 : this.searchClient) == null ? void 0 : u.getSearchResponseItems(e));
951
+ if (!o)
901
952
  throw new Error("Search client was not initialized.");
902
- const t = (l = i.data.hits || []) == null ? void 0 : l.map((c) => c.doc).filter((c) => !!c).map((c) => ({
903
- type: "SearchDocument",
904
- id: T(),
905
- document: c
953
+ const t = (o.data.hits || []).filter((h) => !!h.doc).map((h) => ({
954
+ id: E(),
955
+ document: h.doc || { id: -1 },
956
+ source_index: h.source_index,
957
+ type: "SearchDocument"
906
958
  }));
907
- n(i, t);
959
+ n(o, t);
908
960
  })(), (async () => {
909
- if (this.adClient) {
910
- const i = await this.adClient.getAdsForSearchParams(e);
911
- o(i);
961
+ if (this.adClient && typeof e != "string") {
962
+ const o = await this.adClient.getAds(e);
963
+ r(o);
912
964
  }
913
965
  })();
914
966
  };
915
967
  clearTimeout(this.requestTimeout), this.config.searchDebounceDelay ? this.requestTimeout = setTimeout(
916
- a,
968
+ i,
917
969
  this.config.searchDebounceDelay
918
- ) : a();
970
+ ) : i();
919
971
  });
920
972
  if (!e.endpointURL || !e.index || !e.readKey)
921
973
  throw new Error(
@@ -924,7 +976,7 @@ class we {
924
976
  this.config = {
925
977
  ...e,
926
978
  // Strips off the trailing '/' from an endpointURL if one is accidentally added
927
- endpointURL: le(e.endpointURL)
979
+ endpointURL: he(e.endpointURL)
928
980
  }, this.userId = "", typeof window < "u" && typeof customElements < "u" && n.sdkName === "@searchcraft/javascript-sdk" && globalThis.__scDefineCustomElements__ && globalThis.__scDefineCustomElements__(), typeof window < "u" && (this.initClients(this.config, n), this.initInputForms(), this.startObservingMutations());
929
981
  }
930
982
  initInputForms() {
@@ -941,42 +993,45 @@ class we {
941
993
  * When changes happen in the DOM, we want to link any input forms found to the instance of the core.
942
994
  */
943
995
  startObservingMutations() {
944
- new MutationObserver((n, o) => {
945
- let a = !1;
946
- for (const i of n)
947
- i.type === "childList" && i.addedNodes.forEach((t) => {
948
- t.nodeType === 1 && (t.getAttribute("class") || "").toLowerCase() === "searchcraft-input-form" && (a = !0);
996
+ new MutationObserver((n, r) => {
997
+ let i = !1;
998
+ for (const o of n)
999
+ o.type === "childList" && o.addedNodes.forEach((t) => {
1000
+ t.nodeType === 1 && (t.getAttribute("class") || "").toLowerCase() === "searchcraft-input-form" && (i = !0);
949
1001
  });
950
- a && this.initInputForms();
1002
+ i && this.initInputForms();
951
1003
  }).observe(document.body, { childList: !0, subtree: !0 });
952
1004
  }
953
1005
  initClients(e, n) {
954
1006
  setTimeout(async () => {
955
- let o = this.config.userId;
956
- switch (o || (o = await $()), this.measureClient = new ue(e, n, o), this.searchClient = new me(this, e, o), e.adSource) {
1007
+ let r = this.config.userId;
1008
+ switch (r || (r = await z()), this.measureClient = new de(e, n, r), this.searchClient = new me(this, e, r), e.adSource) {
957
1009
  case "adMarketplace":
958
1010
  this.adClient = new oe(e);
959
1011
  break;
960
1012
  case "Nativo":
961
- this.adClient = new se(e);
1013
+ this.adClient = new ce(e);
962
1014
  break;
963
1015
  case "Custom":
964
1016
  this.adClient = new ie(e);
965
1017
  break;
966
1018
  }
1019
+ this.emitEvent("initialized", {
1020
+ name: "initialized"
1021
+ });
967
1022
  }, 300);
968
1023
  }
969
1024
  emitEvent(e, n) {
970
- var o;
971
- (o = this.subscriptionEvents[e]) == null || o.forEach((a) => {
972
- a(n);
1025
+ var r;
1026
+ (r = this.subscriptionEvents[e]) == null || r.forEach((i) => {
1027
+ i(n);
973
1028
  });
974
1029
  }
975
1030
  subscribe(e, n) {
976
1031
  return this.subscriptionEvents[e] || (this.subscriptionEvents[e] = []), this.subscriptionEvents[e].push(
977
1032
  n
978
1033
  ), () => {
979
- this.subscriptionEvents[e] = this.subscriptionEvents[e].filter((o) => o !== n);
1034
+ this.subscriptionEvents[e] = this.subscriptionEvents[e].filter((r) => r !== n);
980
1035
  };
981
1036
  }
982
1037
  /**
@@ -1646,10 +1701,12 @@ const initialSearchcraftStateValues = {
1646
1701
  hotkeyModifier: 'meta',
1647
1702
  logger: undefined,
1648
1703
  facetPathsForIndexFields: {},
1704
+ initialQuery: '',
1705
+ initialSearchClientResponseItems: [],
1649
1706
  isPopoverVisible: false,
1650
1707
  isSearchInProgress: false,
1651
- searchTerm: '',
1652
1708
  rangeValueForIndexFields: {},
1709
+ searchTerm: '',
1653
1710
  searchMode: 'fuzzy',
1654
1711
  searchClientResponseItems: [],
1655
1712
  searchResponseTimeTaken: undefined,
@@ -1657,38 +1714,49 @@ const initialSearchcraftStateValues = {
1657
1714
  searchResultsCount: 0,
1658
1715
  searchResultsPerPage: 20,
1659
1716
  searchResultsPage: 1,
1660
- sortType: 'asc',
1717
+ sortType: undefined,
1718
+ orderByField: undefined,
1719
+ // Callbacks
1720
+ afterInit: () => { },
1661
1721
  };
1662
- const searchcraftStore = zustand.createStore((set, get) => {
1722
+ const searchcraftStore = zustand.createStore((_set, get) => {
1663
1723
  const functions = {
1664
- addFacetPathsForIndexField: (data) => set((state) => ({
1724
+ set: (state) => {
1725
+ _set(state);
1726
+ return get();
1727
+ },
1728
+ addFacetPathsForIndexField: (facetPaths) => functions.set((state) => ({
1665
1729
  facetPathsForIndexFields: {
1666
1730
  ...state.facetPathsForIndexFields,
1667
- [data.fieldName]: data,
1731
+ [facetPaths.fieldName]: facetPaths,
1668
1732
  },
1669
1733
  })),
1670
- addRangeValueForIndexField: (data) => set((state) => ({
1734
+ addRangeValueForIndexField: (rangeValue) => functions.set((state) => ({
1671
1735
  rangeValueForIndexFields: {
1672
1736
  ...state.rangeValueForIndexFields,
1673
- [data.fieldName]: data,
1737
+ [rangeValue.fieldName]: rangeValue,
1674
1738
  },
1675
1739
  })),
1676
- getSearchcraftInstance: () => {
1740
+ getSearchcraftCore: () => {
1677
1741
  const { core } = get();
1678
1742
  return core;
1679
1743
  },
1680
- initialize: (searchcraftInstance, debug = false) => {
1681
- const core = searchcraftInstance;
1744
+ init: (core, debug = false) => {
1682
1745
  const logger = debug
1683
- ? new ve({ logLevel: D.DEBUG })
1746
+ ? new pe({ logLevel: O.DEBUG })
1684
1747
  : undefined;
1685
- set({
1748
+ const state = functions.set({
1686
1749
  core,
1687
1750
  logger,
1688
- searchResultsPerPage: core.config.searchResultsPerPage || 20,
1751
+ searchResultsPerPage: core?.config.searchResultsPerPage || 20,
1752
+ });
1753
+ core?.subscribe('initialized', () => {
1754
+ if (state.afterInit) {
1755
+ state.afterInit(state);
1756
+ }
1689
1757
  });
1690
1758
  },
1691
- removeFacetPathsForIndexField: (fieldName) => set((state) => {
1759
+ removeFacetPathsForIndexField: (fieldName) => functions.set((state) => {
1692
1760
  const currentPaths = state.facetPathsForIndexFields;
1693
1761
  delete currentPaths[fieldName];
1694
1762
  return {
@@ -1697,7 +1765,7 @@ const searchcraftStore = zustand.createStore((set, get) => {
1697
1765
  },
1698
1766
  };
1699
1767
  }),
1700
- removeRangeValueForIndexField: (fieldName) => set((state) => {
1768
+ removeRangeValueForIndexField: (fieldName) => functions.set((state) => {
1701
1769
  const currentValues = state.rangeValueForIndexFields;
1702
1770
  delete currentValues[fieldName];
1703
1771
  return {
@@ -1707,19 +1775,19 @@ const searchcraftStore = zustand.createStore((set, get) => {
1707
1775
  };
1708
1776
  }),
1709
1777
  resetFacetPaths: () => {
1710
- set({
1778
+ functions.set({
1711
1779
  facetPathsForIndexFields: {},
1712
1780
  });
1713
1781
  },
1714
1782
  search: async () => {
1715
1783
  const state = get();
1716
- state.logger?.log(D.INFO, `Starting search with search term: "${state.searchTerm}"`);
1784
+ state.logger?.log(O.INFO, `Starting search with search term: "${state.searchTerm}"`);
1717
1785
  if (!state.core) {
1718
1786
  throw new Error('Searchcraft instance is not initialized.');
1719
1787
  }
1720
1788
  if (!state.searchTerm.trim()) {
1721
- state.logger?.log(D.INFO, 'No search request was made: search term was empty.');
1722
- set({
1789
+ state.logger?.log(O.INFO, 'No search request was made: search term was empty.');
1790
+ functions.set({
1723
1791
  searchClientResponseItems: [],
1724
1792
  searchResultsCount: 0,
1725
1793
  searchResultsPage: 1,
@@ -1727,50 +1795,67 @@ const searchcraftStore = zustand.createStore((set, get) => {
1727
1795
  });
1728
1796
  return;
1729
1797
  }
1730
- set({ isSearchInProgress: true });
1731
- const handleSearchcraftResponse = (response, items) => {
1732
- const facetsFromResponse = response.data.facets;
1733
- set((state) => {
1734
- return {
1735
- isSearchInProgress: false,
1736
- searchClientResponseItems: items,
1737
- searchResponseTimeTaken: response.data.time_taken || 0,
1738
- searchResultsPage:
1739
- // reset to first page when response count changes
1740
- response.data.count === state.searchResultsCount
1741
- ? state.searchResultsPage
1742
- : 1,
1743
- searchResultsCount: response.data.count || 0,
1744
- };
1745
- });
1746
- if (facetsFromResponse) {
1747
- set({ searchResponseFacetPrime: facetsFromResponse });
1748
- }
1749
- state.logger?.log(D.DEBUG, `Search results: ${JSON.stringify(items)}`);
1750
- state.logger?.log(D.DEBUG, `Facets from response: ${JSON.stringify(facetsFromResponse)}`);
1751
- };
1752
- const handleAdResponse = (adClientResponseItems) => {
1753
- set({ adClientResponseItems });
1754
- };
1755
- state.core.getItems({
1798
+ functions.set({ isSearchInProgress: true });
1799
+ state.core.getResponseItems({
1756
1800
  searchTerm: state.searchTerm,
1757
1801
  mode: state.searchMode,
1758
1802
  sort: state.sortType,
1803
+ order_by: state.orderByField,
1759
1804
  facetPathsForIndexFields: state.facetPathsForIndexFields,
1760
1805
  rangeValueForIndexFields: state.rangeValueForIndexFields,
1761
1806
  offset: state.searchResultsPerPage
1762
1807
  ? state.searchResultsPerPage * (state.searchResultsPage - 1)
1763
1808
  : 0,
1764
1809
  limit: state.searchResultsPerPage,
1765
- }, handleSearchcraftResponse, handleAdResponse);
1810
+ }, functions.setSearchClientResponseItemsFromResponse, functions.setAdClientResponseItems);
1766
1811
  },
1767
- setPopoverVisibility: (isVisible) => {
1768
- set({
1769
- isPopoverVisible: isVisible,
1812
+ setAdClientResponseItems: (items) => functions.set({ adClientResponseItems: items }),
1813
+ setSearchClientResponseItemsFromResponse: (response, items) => {
1814
+ const { facets, count = 0, time_taken = 0 } = response.data;
1815
+ const state = functions.set((state) => {
1816
+ return {
1817
+ isSearchInProgress: false,
1818
+ searchClientResponseItems: items,
1819
+ searchResponseTimeTaken: time_taken,
1820
+ searchResultsPage:
1821
+ // Reset to first page when response count changes
1822
+ count === state.searchResultsCount ? state.searchResultsPage : 1,
1823
+ searchResultsCount: count,
1824
+ ...(facets && { searchResponseFacetPrime: facets }),
1825
+ };
1826
+ });
1827
+ state.logger?.log(O.DEBUG, `Search results: ${JSON.stringify(items)}`);
1828
+ state.logger?.log(O.DEBUG, `Facets from response: ${JSON.stringify(facets)}`);
1829
+ },
1830
+ setInitialSearchClientResponseItemsFromResponse: (response, items) => {
1831
+ const state = get();
1832
+ const { count = 0, time_taken = 0 } = response.data;
1833
+ functions.set((state) => {
1834
+ return {
1835
+ isSearchInProgress: false,
1836
+ initialSearchClientResponseItems: items,
1837
+ searchResponseTimeTaken: time_taken,
1838
+ searchResultsPage:
1839
+ // Reset to first page when response count changes
1840
+ count === state.searchResultsCount ? state.searchResultsPage : 1,
1841
+ searchResultsCount: count,
1842
+ };
1770
1843
  });
1844
+ state.logger?.log(O.DEBUG, `Search results: ${JSON.stringify(items)}`);
1771
1845
  },
1772
- setSearchMode: (mode) => set({ searchMode: mode }),
1773
- setSortType: (type) => set({ sortType: type }),
1846
+ setInitialQuery: async (query) => {
1847
+ const state = functions.set({ initialQuery: query });
1848
+ state.logger?.log(O.INFO, `Starting search with query: "${state.initialQuery}"`);
1849
+ if (!state.core) {
1850
+ throw new Error('Searchcraft instance is not initialized.');
1851
+ }
1852
+ await state.core.getResponseItems(query, functions.setInitialSearchClientResponseItemsFromResponse, functions.setAdClientResponseItems);
1853
+ },
1854
+ setPopoverVisibility: (isVisible) => functions.set({
1855
+ isPopoverVisible: isVisible,
1856
+ }),
1857
+ setSearchMode: (mode) => functions.set({ searchMode: mode }),
1858
+ setSortOrder: ({ orderByField, sortType }) => functions.set({ sortType, orderByField }),
1774
1859
  setSearchTerm: (searchTerm) => {
1775
1860
  const { core } = get();
1776
1861
  if (searchTerm.length === 0) {
@@ -1779,27 +1864,29 @@ const searchcraftStore = zustand.createStore((set, get) => {
1779
1864
  /**
1780
1865
  * When a new searchTerm is set, also reset the sort type, search mode, and facet paths.
1781
1866
  */
1782
- set({
1867
+ functions.set({
1783
1868
  searchTerm,
1784
1869
  facetPathsForIndexFields: {},
1785
1870
  ...(searchTerm.trim().length === 0 && {
1786
1871
  searchMode: 'fuzzy',
1787
- sortType: 'asc',
1872
+ sortType: null,
1873
+ orderByField: null,
1788
1874
  }),
1789
1875
  });
1790
1876
  },
1791
- setSearchClientResponseItems: (items) => set({ searchClientResponseItems: items }),
1877
+ setSearchClientResponseItems: (items) => functions.set({ searchClientResponseItems: items }),
1878
+ setSearchResultsCount: (count) => functions.set({ searchResultsCount: count }),
1792
1879
  setSearchResultsPage: async (page) => {
1793
- set({ searchResultsPage: page });
1880
+ functions.set({ searchResultsPage: page });
1794
1881
  await functions.search();
1795
1882
  },
1796
1883
  setSearchResultsPerPage: async (perPage) => {
1797
- set({ searchResultsPerPage: perPage });
1884
+ functions.set({ searchResultsPerPage: perPage });
1798
1885
  await functions.search();
1799
1886
  },
1800
1887
  setHotKeyAndHotKeyModifier: (hotkey, hotkeyModifier) => {
1801
1888
  const { hotkey: initialHotkey, hotkeyModifier: initialHotkeyModifier } = initialSearchcraftStateValues;
1802
- set({
1889
+ functions.set({
1803
1890
  hotkey: hotkey || initialHotkey,
1804
1891
  hotkeyModifier: hotkeyModifier || initialHotkeyModifier,
1805
1892
  });
@@ -1812,6 +1899,6 @@ const searchcraftStore = zustand.createStore((set, get) => {
1812
1899
  return stateObject;
1813
1900
  });
1814
1901
 
1815
- export { searchcraftStore as s, we as w };
1902
+ export { searchcraftStore as s, ve as v };
1816
1903
 
1817
- //# sourceMappingURL=p-17c646e2.js.map
1904
+ //# sourceMappingURL=p-d4558d44.js.map