@searchcraft/javascript-sdk 0.10.7 → 0.11.0

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 (135) hide show
  1. package/dist/components/defineCustomElements.js +4 -0
  2. package/dist/components/index.d.ts +530 -217
  3. package/dist/components/index.js +1655 -8
  4. package/dist/components/index.js.map +1 -1
  5. package/dist/components/{p-e99cd628.js → p-0c495408.js} +30 -20
  6. package/dist/components/p-0c495408.js.map +1 -0
  7. package/dist/components/{p-b4cac872.js → p-1d5c5536.js} +18 -8
  8. package/dist/components/p-1d5c5536.js.map +1 -0
  9. package/dist/components/{p-274c5cc8.js → p-3286bbb3.js} +22 -10
  10. package/dist/components/p-3286bbb3.js.map +1 -0
  11. package/dist/components/{p-ea48ccae.js → p-3e41546c.js} +17 -8
  12. package/dist/components/p-3e41546c.js.map +1 -0
  13. package/dist/components/{p-adc6236e.js → p-87435aac.js} +31 -20
  14. package/dist/components/p-87435aac.js.map +1 -0
  15. package/dist/components/p-919734fe.js +31 -0
  16. package/dist/components/p-919734fe.js.map +1 -0
  17. package/dist/components/{p-b01f8216.js → p-b13c7fbb.js} +48 -33
  18. package/dist/components/p-b13c7fbb.js.map +1 -0
  19. package/dist/components/{p-810a7850.js → p-b4b67072.js} +2 -2
  20. package/dist/components/p-b4b67072.js.map +1 -0
  21. package/dist/components/{p-acab4d41.js → p-b7e99386.js} +22 -22
  22. package/dist/components/p-b7e99386.js.map +1 -0
  23. package/dist/components/{p-4dd1995c.js → p-c9b65e8f.js} +4 -4
  24. package/dist/components/{p-4dd1995c.js.map → p-c9b65e8f.js.map} +1 -1
  25. package/dist/components/p-d54771ef.js.map +1 -1
  26. package/dist/components/{p-a64b4cba.js → p-e2a10337.js} +2 -2
  27. package/dist/components/{p-a64b4cba.js.map → p-e2a10337.js.map} +1 -1
  28. package/dist/components/p-e30203b1.js +62 -0
  29. package/dist/components/p-e30203b1.js.map +1 -0
  30. package/dist/components/{p-320e3895.js → p-fc8ccffa.js} +22 -11
  31. package/dist/components/p-fc8ccffa.js.map +1 -0
  32. package/dist/components/searchcraft-ad.js +1 -1
  33. package/dist/components/searchcraft-facet-list.js +1 -1
  34. package/dist/components/searchcraft-filter-panel.js +51 -23
  35. package/dist/components/searchcraft-filter-panel.js.map +1 -1
  36. package/dist/components/searchcraft-input-form.js +1 -1
  37. package/dist/components/searchcraft-loading.d.ts +11 -0
  38. package/dist/components/searchcraft-loading.js +8 -0
  39. package/dist/components/searchcraft-loading.js.map +1 -0
  40. package/dist/components/searchcraft-pagination.js +13 -3
  41. package/dist/components/searchcraft-pagination.js.map +1 -1
  42. package/dist/components/searchcraft-popover-button.js +21 -9
  43. package/dist/components/searchcraft-popover-button.js.map +1 -1
  44. package/dist/components/searchcraft-popover-footer.js +1 -1
  45. package/dist/components/searchcraft-popover-form.js +32 -20
  46. package/dist/components/searchcraft-popover-form.js.map +1 -1
  47. package/dist/components/searchcraft-popover-list-item.js +1 -1
  48. package/dist/components/searchcraft-popover-list-view.js +1 -1
  49. package/dist/components/searchcraft-results-info.js +15 -7
  50. package/dist/components/searchcraft-results-info.js.map +1 -1
  51. package/dist/components/searchcraft-search-result.js +1 -1
  52. package/dist/components/searchcraft-search-results-per-page.js +14 -4
  53. package/dist/components/searchcraft-search-results-per-page.js.map +1 -1
  54. package/dist/components/searchcraft-search-results.js +50 -69
  55. package/dist/components/searchcraft-search-results.js.map +1 -1
  56. package/dist/components/searchcraft-slider.js +1 -1
  57. package/dist/components/searchcraft-summary-box.d.ts +11 -0
  58. package/dist/components/searchcraft-summary-box.js +2287 -0
  59. package/dist/components/searchcraft-summary-box.js.map +1 -0
  60. package/dist/components/searchcraft-theme.js +2 -2
  61. package/dist/components/searchcraft-theme.js.map +1 -1
  62. package/dist/components/searchcraft-toggle-button.js +1 -1
  63. package/dist/hydrate/index.js +6072 -4862
  64. package/dist/hydrate/index.mjs +6072 -4862
  65. package/dist/themes/hologram.css +1 -1
  66. package/dist/themes/hologram.css.map +1 -1
  67. package/dist/types/classes/CoreInstanceRegistry.d.ts +38 -0
  68. package/dist/types/classes/Logger.d.ts +25 -0
  69. package/dist/types/classes/SearchcraftCore.d.ts +50 -0
  70. package/dist/types/classes/index.d.ts +3 -0
  71. package/dist/types/clients/MeasureClient.d.ts +27 -0
  72. package/dist/types/clients/SearchClient.d.ts +35 -0
  73. package/dist/types/clients/SummaryClient.d.ts +10 -0
  74. package/dist/types/clients/ad-clients/AdClient.d.ts +20 -0
  75. package/dist/types/clients/ad-clients/AdMarketplaceClient.d.ts +14 -0
  76. package/dist/types/clients/ad-clients/CustomAdClient.d.ts +6 -0
  77. package/dist/types/clients/ad-clients/NativoClient.d.ts +14 -0
  78. package/dist/types/clients/ad-clients/index.d.ts +5 -0
  79. package/dist/types/clients/index.d.ts +4 -0
  80. package/dist/types/components/searchcraft-ad/searchcraft-ad.d.ts +10 -3
  81. package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +9 -2
  82. package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +14 -3
  83. package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +9 -6
  84. package/dist/types/components/searchcraft-loading/searchcraft-loading.d.ts +10 -0
  85. package/dist/types/components/searchcraft-pagination/searchcraft-pagination.d.ts +8 -1
  86. package/dist/types/components/searchcraft-popover-button/searchcraft-popover-button.d.ts +10 -2
  87. package/dist/types/components/searchcraft-popover-footer/searchcraft-popover-footer.d.ts +8 -1
  88. package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +11 -3
  89. package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +9 -1
  90. package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +11 -3
  91. package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +8 -1
  92. package/dist/types/components/searchcraft-search-result/searchcraft-search-result.d.ts +10 -1
  93. package/dist/types/components/searchcraft-search-results/searchcraft-search-results.d.ts +11 -5
  94. package/dist/types/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.d.ts +8 -1
  95. package/dist/types/components/searchcraft-summary-box/searchcraft-summary-box.d.ts +49 -0
  96. package/dist/types/components/searchcraft-toggle-button/searchcraft-toggle-button.d.ts +8 -1
  97. package/dist/types/components.d.ts +256 -6
  98. package/dist/types/index.d.ts +4 -5
  99. package/dist/types/store/SearchcraftStore.types.d.ts +14 -15
  100. package/dist/types/store/SearchcraftStoreFactory.d.ts +13 -0
  101. package/dist/types/store/index.d.ts +1 -1
  102. package/dist/types/types/core-types/AdClientResponses.types.d.ts +24 -0
  103. package/dist/types/types/core-types/Facets.types.d.ts +39 -0
  104. package/dist/types/types/core-types/Measure.types.d.ts +52 -0
  105. package/dist/types/types/core-types/SearchClient.types.d.ts +67 -0
  106. package/dist/types/types/core-types/SearchClientResponses.types.d.ts +7 -0
  107. package/dist/types/types/core-types/SearchcraftAdConfig.types.d.ts +76 -0
  108. package/dist/types/types/core-types/SearchcraftConfig.types.d.ts +65 -0
  109. package/dist/types/types/core-types/SearchcraftResponse.types.d.ts +46 -0
  110. package/dist/types/types/core-types/SubscriptionEvents.types.d.ts +51 -0
  111. package/dist/types/types/core-types/index.d.ts +10 -0
  112. package/dist/types/types/index.d.ts +3 -0
  113. package/dist/types/types/sdk-types/index.d.ts +4 -0
  114. package/dist/types/types/sdk-types/result-mappings.types.d.ts +58 -0
  115. package/dist/types/types/sdk-types/searchcraft-filter-panel.types.d.ts +44 -0
  116. package/dist/types/types/sdk-types/templates.types.d.ts +29 -0
  117. package/dist/types/utils/core-utils/index.d.ts +3 -0
  118. package/dist/types/utils/core-utils/sanitize.d.ts +2 -0
  119. package/dist/types/utils/core-utils/url.d.ts +2 -0
  120. package/dist/types/utils/facets.d.ts +1 -1
  121. package/dist/types/utils/html.d.ts +1 -1
  122. package/dist/types/utils/units.d.ts +1 -1
  123. package/package.json +5 -3
  124. package/dist/components/p-062d6b80.js +0 -1940
  125. package/dist/components/p-062d6b80.js.map +0 -1
  126. package/dist/components/p-274c5cc8.js.map +0 -1
  127. package/dist/components/p-320e3895.js.map +0 -1
  128. package/dist/components/p-810a7850.js.map +0 -1
  129. package/dist/components/p-acab4d41.js.map +0 -1
  130. package/dist/components/p-adc6236e.js.map +0 -1
  131. package/dist/components/p-b01f8216.js.map +0 -1
  132. package/dist/components/p-b4cac872.js.map +0 -1
  133. package/dist/components/p-e99cd628.js.map +0 -1
  134. package/dist/components/p-ea48ccae.js.map +0 -1
  135. package/dist/types/store/SearchcraftStore.d.ts +0 -4
@@ -1,1940 +0,0 @@
1
- var B = Object.defineProperty;
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 h = (a, e, n) => N(a, typeof e != "symbol" ? e + "" : e, n);
4
- var D = /* @__PURE__ */ ((a) => (a[a.DEBUG = 0] = "DEBUG", a[a.INFO = 1] = "INFO", a[a.WARN = 2] = "WARN", a[a.ERROR = 3] = "ERROR", a))(D || {});
5
- class pe {
6
- constructor(e) {
7
- h(this, "logLevel");
8
- h(this, "logFormatter");
9
- this.logLevel = e.logLevel || 1, this.logFormatter = e.logFormatter || this.defaultFormatter;
10
- }
11
- defaultFormatter(e, n) {
12
- return `[${D[e]}] ${( new Date()).toISOString()}: ${n}`;
13
- }
14
- debug(e) {
15
- this.logLevel <= 0 && console.log(this.logFormatter(0, e));
16
- }
17
- info(e) {
18
- this.logLevel <= 1 && console.info(this.logFormatter(1, e));
19
- }
20
- warn(e) {
21
- this.logLevel <= 2 && console.warn(this.logFormatter(2, e));
22
- }
23
- error(e) {
24
- this.logLevel <= 3 && console.error(this.logFormatter(3, e));
25
- }
26
- log(e, n) {
27
- switch (e) {
28
- case 0:
29
- this.debug(n);
30
- break;
31
- case 1:
32
- this.info(n);
33
- break;
34
- case 2:
35
- this.warn(n);
36
- break;
37
- case 3:
38
- this.error(n);
39
- break;
40
- }
41
- }
42
- }
43
- function w(a, e, n, r) {
44
- return new (n || (n = Promise))(function(o, i) {
45
- function t(s) {
46
- try {
47
- l(r.next(s));
48
- } catch (c) {
49
- i(c);
50
- }
51
- }
52
- function u(s) {
53
- try {
54
- l(r.throw(s));
55
- } catch (c) {
56
- i(c);
57
- }
58
- }
59
- function l(s) {
60
- var c;
61
- s.done ? o(s.value) : (c = s.value, c instanceof n ? c : new n(function(g) {
62
- g(c);
63
- })).then(t, u);
64
- }
65
- l((r = r.apply(a, [])).next());
66
- });
67
- }
68
- function y(a, e) {
69
- var n, r, o, i, t = { label: 0, sent: function() {
70
- if (1 & o[0]) throw o[1];
71
- return o[1];
72
- }, trys: [], ops: [] };
73
- return i = { next: u(0), throw: u(1), return: u(2) }, typeof Symbol == "function" && (i[Symbol.iterator] = function() {
74
- return this;
75
- }), i;
76
- function u(l) {
77
- return function(s) {
78
- return function(c) {
79
- if (n) throw new TypeError("Generator is already executing.");
80
- for (; i && (i = 0, c[0] && (t = 0)), t; ) try {
81
- if (n = 1, r && (o = 2 & c[0] ? r.return : c[0] ? r.throw || ((o = r.return) && o.call(r), 0) : r.next) && !(o = o.call(r, c[1])).done) return o;
82
- switch (r = 0, o && (c = [2 & c[0], o.value]), c[0]) {
83
- case 0:
84
- case 1:
85
- o = c;
86
- break;
87
- case 4:
88
- return t.label++, { value: c[1], done: !1 };
89
- case 5:
90
- t.label++, r = c[1], c = [0];
91
- continue;
92
- case 7:
93
- c = t.ops.pop(), t.trys.pop();
94
- continue;
95
- default:
96
- if (o = t.trys, !((o = o.length > 0 && o[o.length - 1]) || c[0] !== 6 && c[0] !== 2)) {
97
- t = 0;
98
- continue;
99
- }
100
- if (c[0] === 3 && (!o || c[1] > o[0] && c[1] < o[3])) {
101
- t.label = c[1];
102
- break;
103
- }
104
- if (c[0] === 6 && t.label < o[1]) {
105
- t.label = o[1], o = c;
106
- break;
107
- }
108
- if (o && t.label < o[2]) {
109
- t.label = o[2], t.ops.push(c);
110
- break;
111
- }
112
- o[2] && t.ops.pop(), t.trys.pop();
113
- continue;
114
- }
115
- c = e.call(a, t);
116
- } catch (g) {
117
- c = [6, g], r = 0;
118
- } finally {
119
- n = o = 0;
120
- }
121
- if (5 & c[0]) throw c[1];
122
- return { value: c[0] ? c[1] : void 0, done: !0 };
123
- }([l, s]);
124
- };
125
- }
126
- }
127
- var S = { exclude: [] }, U = {}, j = { timeout: "true" }, v = function(a, e) {
128
- typeof window < "u" && (U[a] = e);
129
- }, G = function() {
130
- return Object.fromEntries(Object.entries(U).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
- }));
136
- };
137
- function I(a) {
138
- return a ^= a >>> 16, a = Math.imul(a, 2246822507), a ^= a >>> 13, a = Math.imul(a, 3266489909), (a ^= a >>> 16) >>> 0;
139
- }
140
- var m = new Uint32Array([597399067, 2869860233, 951274213, 2716044179]);
141
- function p(a, e) {
142
- return a << e | a >>> 32 - e;
143
- }
144
- function R(a, e) {
145
- var n;
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(i, t) {
149
- for (var u = i.byteLength / 16 | 0, l = new Uint32Array(i, 0, 4 * u), s = 0; s < u; s++) {
150
- var c = l.subarray(4 * s, 4 * (s + 1));
151
- c[0] = Math.imul(c[0], m[0]), c[0] = p(c[0], 15), c[0] = Math.imul(c[0], m[1]), t[0] = t[0] ^ c[0], t[0] = p(t[0], 19), t[0] = t[0] + t[1], t[0] = Math.imul(t[0], 5) + 1444728091, c[1] = Math.imul(c[1], m[1]), c[1] = p(c[1], 16), c[1] = Math.imul(c[1], m[2]), t[1] = t[1] ^ c[1], t[1] = p(t[1], 17), t[1] = t[1] + t[2], t[1] = Math.imul(t[1], 5) + 197830471, c[2] = Math.imul(c[2], m[2]), c[2] = p(c[2], 17), c[2] = Math.imul(c[2], m[3]), t[2] = t[2] ^ c[2], t[2] = p(t[2], 15), t[2] = t[2] + t[3], t[2] = Math.imul(t[2], 5) + 2530024501, c[3] = Math.imul(c[3], m[3]), c[3] = p(c[3], 18), c[3] = Math.imul(c[3], m[0]), t[3] = t[3] ^ c[3], t[3] = p(t[3], 13), t[3] = t[3] + t[0], t[3] = Math.imul(t[3], 5) + 850148119;
152
- }
153
- }))(a, r), function(i, t) {
154
- var u = i.byteLength / 16 | 0, l = i.byteLength % 16, s = new Uint32Array(4), c = new Uint8Array(i, 16 * u, l);
155
- switch (l) {
156
- case 15:
157
- s[3] = s[3] ^ c[14] << 16;
158
- case 14:
159
- s[3] = s[3] ^ c[13] << 8;
160
- case 13:
161
- s[3] = s[3] ^ c[12] << 0, s[3] = Math.imul(s[3], m[3]), s[3] = p(s[3], 18), s[3] = Math.imul(s[3], m[0]), t[3] = t[3] ^ s[3];
162
- case 12:
163
- s[2] = s[2] ^ c[11] << 24;
164
- case 11:
165
- s[2] = s[2] ^ c[10] << 16;
166
- case 10:
167
- s[2] = s[2] ^ c[9] << 8;
168
- case 9:
169
- s[2] = s[2] ^ c[8] << 0, s[2] = Math.imul(s[2], m[2]), s[2] = p(s[2], 17), s[2] = Math.imul(s[2], m[3]), t[2] = t[2] ^ s[2];
170
- case 8:
171
- s[1] = s[1] ^ c[7] << 24;
172
- case 7:
173
- s[1] = s[1] ^ c[6] << 16;
174
- case 6:
175
- s[1] = s[1] ^ c[5] << 8;
176
- case 5:
177
- s[1] = s[1] ^ c[4] << 0, s[1] = Math.imul(s[1], m[1]), s[1] = p(s[1], 16), s[1] = Math.imul(s[1], m[2]), t[1] = t[1] ^ s[1];
178
- case 4:
179
- s[0] = s[0] ^ c[3] << 24;
180
- case 3:
181
- s[0] = s[0] ^ c[2] << 16;
182
- case 2:
183
- s[0] = s[0] ^ c[1] << 8;
184
- case 1:
185
- s[0] = s[0] ^ c[0] << 0, s[0] = Math.imul(s[0], m[0]), s[0] = p(s[0], 15), s[0] = Math.imul(s[0], m[1]), t[0] = t[0] ^ s[0];
186
- }
187
- }(a, r), 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] = I(t[0]), t[1] = I(t[1]), t[2] = I(t[2]), t[3] = I(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 o = new Uint8Array(r.buffer);
191
- return Array.from(o).map(function(i) {
192
- return i.toString(16).padStart(2, "0");
193
- }).join("");
194
- }
195
- function W(a, e) {
196
- return new Promise(function(n) {
197
- setTimeout(function() {
198
- return n(e);
199
- }, a);
200
- });
201
- }
202
- function V(a, e, n) {
203
- return Promise.all(a.map(function(r) {
204
- return Promise.race([r, W(e, n)]);
205
- }));
206
- }
207
- function $() {
208
- return w(this, void 0, void 0, function() {
209
- var a, e, n, r, o;
210
- return y(this, function(i) {
211
- switch (i.label) {
212
- case 0:
213
- return i.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
- case 1:
215
- return n = i.sent(), r = n.filter(function(t) {
216
- return t !== void 0;
217
- }), o = {}, r.forEach(function(t, u) {
218
- o[e[u]] = t;
219
- }), [2, q(o, S.exclude || [])];
220
- case 2:
221
- throw i.sent();
222
- case 3:
223
- return [2];
224
- }
225
- });
226
- });
227
- }
228
- function q(a, e) {
229
- var n = {}, r = function(i) {
230
- if (a.hasOwnProperty(i)) {
231
- var t = a[i];
232
- if (typeof t != "object" || Array.isArray(t)) e.includes(i) || (n[i] = t);
233
- else {
234
- var u = q(t, e.map(function(l) {
235
- return l.startsWith(i + ".") ? l.slice(i.length + 1) : l;
236
- }));
237
- Object.keys(u).length > 0 && (n[i] = u);
238
- }
239
- }
240
- };
241
- for (var o in a) r(o);
242
- return n;
243
- }
244
- function z(a) {
245
- return w(this, void 0, void 0, function() {
246
- var e, n;
247
- return y(this, function(r) {
248
- switch (r.label) {
249
- case 0:
250
- return r.trys.push([0, 2, , 3]), [4, $()];
251
- case 1:
252
- return e = r.sent(), n = R(JSON.stringify(e)), [2, n.toString()];
253
- case 2:
254
- throw r.sent();
255
- case 3:
256
- return [2];
257
- }
258
- });
259
- });
260
- }
261
- function H(a) {
262
- for (var e = 0, n = 0; n < a.length; ++n) e += Math.abs(a[n]);
263
- return e;
264
- }
265
- function L(a, e, n) {
266
- for (var r = [], o = 0; o < a[0].data.length; o++) {
267
- for (var i = [], t = 0; t < a.length; t++) i.push(a[t].data[o]);
268
- r.push(Q(i));
269
- }
270
- var u = new Uint8ClampedArray(r);
271
- return new ImageData(u, e, n);
272
- }
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[i = r[n]] = (e[i] || 0) + 1;
277
- var o = a[0];
278
- for (var i in e) e[i] > e[o] && (o = parseInt(i, 10));
279
- return o;
280
- }
281
- function A() {
282
- if (typeof navigator > "u") return { name: "unknown", version: "unknown" };
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 o = r[n], i = a.match(o);
285
- if (i && i.groups) return { name: e[i.groups.name] || i.groups.name, version: i.groups.version };
286
- }
287
- return { name: "unknown", version: "unknown" };
288
- }
289
- v("audio", function() {
290
- return w(this, void 0, void 0, function() {
291
- return y(this, function(a) {
292
- return [2, new Promise(function(e, n) {
293
- try {
294
- var r = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 5e3, 44100), o = r.createBufferSource(), i = r.createOscillator();
295
- i.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, i.connect(u), u.connect(r.destination), i.start(), r.oncomplete = function(l) {
298
- t = l.renderedBuffer.getChannelData(0), e({ sampleHash: H(t), oscillator: i.type, maxChannels: r.destination.maxChannelCount, channelCountMode: o.channelCountMode });
299
- }, r.startRendering();
300
- } catch (l) {
301
- console.error("Error creating audio fingerprint:", l), n(l);
302
- }
303
- })];
304
- });
305
- });
306
- });
307
- var K = A().name !== "SamsungBrowser" ? 1 : 3, k = 280, F = 20;
308
- A().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
- return function() {
312
- var n = document.createElement("canvas"), r = n.getContext("2d");
313
- if (!r) return new ImageData(1, 1);
314
- n.width = k, n.height = F;
315
- var o = r.createLinearGradient(0, 0, n.width, n.height);
316
- o.addColorStop(0, "red"), o.addColorStop(0.16666666666666666, "orange"), o.addColorStop(0.3333333333333333, "yellow"), o.addColorStop(0.5, "green"), o.addColorStop(0.6666666666666666, "blue"), o.addColorStop(0.8333333333333334, "indigo"), o.addColorStop(1, "violet"), r.fillStyle = o, r.fillRect(0, 0, n.width, n.height);
317
- var i = "Random Text WMwmil10Oo";
318
- r.font = "23.123px Arial", r.fillStyle = "black", r.fillText(i, -5, 15), r.fillStyle = "rgba(0, 0, 255, 0.5)", r.fillText(i, -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
- return t;
321
- }();
322
- });
323
- a({ commonImageDataHash: R(L(e, k, F).data.toString()).toString() });
324
- });
325
- });
326
- var M, 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 O(a, e) {
328
- if (!a) throw new Error("Canvas context not supported");
329
- return a.font = "72px ".concat(e), a.measureText("WwMmLli0Oo").width;
330
- }
331
- function Y() {
332
- var a, e = document.createElement("canvas"), n = (a = e.getContext("webgl")) !== null && a !== void 0 ? a : e.getContext("experimental-webgl");
333
- if (n && "getParameter" in n) try {
334
- var r = (n.getParameter(n.VENDOR) || "").toString(), o = (n.getParameter(n.RENDERER) || "").toString(), i = { vendor: r, renderer: o, version: (n.getParameter(n.VERSION) || "").toString(), shadingLanguageVersion: (n.getParameter(n.SHADING_LANGUAGE_VERSION) || "").toString() };
335
- if (!o.length || !r.length) {
336
- var t = n.getExtension("WEBGL_debug_renderer_info");
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);
340
- }
341
- }
342
- return i;
343
- } catch {
344
- }
345
- return "undefined";
346
- }
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
- }
351
- function ee(a, e) {
352
- var n = {};
353
- return e.forEach(function(r) {
354
- var o = function(i) {
355
- if (i.length === 0) return null;
356
- var t = {};
357
- i.forEach(function(s) {
358
- var c = String(s);
359
- t[c] = (t[c] || 0) + 1;
360
- });
361
- var u = i[0], l = 1;
362
- return Object.keys(t).forEach(function(s) {
363
- t[s] > l && (u = s, l = t[s]);
364
- }), u;
365
- }(a.map(function(i) {
366
- return r in i ? i[r] : void 0;
367
- }).filter(function(i) {
368
- return i !== void 0;
369
- }));
370
- o && (n[r] = o);
371
- }), n;
372
- }
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
- return Object.keys(e).forEach(function(n) {
376
- e[n].forEach(function(r) {
377
- matchMedia("(".concat(n, ": ").concat(r, ")")).matches && a.push("".concat(n, ": ").concat(r));
378
- });
379
- }), a;
380
- }
381
- function ne() {
382
- if (window.location.protocol === "https:" && typeof window.ApplePaySession == "function") try {
383
- for (var a = window.ApplePaySession.supportsVersion, e = 15; e > 0; e--) if (a(e)) return e;
384
- } catch {
385
- return 0;
386
- }
387
- return 0;
388
- }
389
- A().name != "Firefox" && v("fonts", function() {
390
- var a = this;
391
- return new Promise(function(e, n) {
392
- try {
393
- (function(r) {
394
- var o;
395
- w(this, void 0, void 0, function() {
396
- var i, t, u;
397
- return y(this, function(l) {
398
- switch (l.label) {
399
- case 0:
400
- return document.body ? [3, 2] : [4, (s = 50, new Promise(function(g) {
401
- return setTimeout(g, s, c);
402
- }))];
403
- case 1:
404
- return l.sent(), [3, 0];
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 || ((o = i.contentWindow) === null || o === void 0 ? void 0 : o.document))) throw new Error("Iframe document is not accessible");
407
- return r({ iframe: u }), setTimeout(function() {
408
- document.body.removeChild(i);
409
- }, 0), [2];
410
- }
411
- var s, c;
412
- });
413
- });
414
- })(function(r) {
415
- var o = r.iframe;
416
- return w(a, void 0, void 0, function() {
417
- var i, t, u, l;
418
- return y(this, function(s) {
419
- return i = o.createElement("canvas"), t = i.getContext("2d"), u = J.map(function(c) {
420
- return O(t, c);
421
- }), l = {}, X.forEach(function(c) {
422
- var g = O(t, c);
423
- u.includes(g) || (l[c] = g);
424
- }), e(l), [2];
425
- });
426
- });
427
- });
428
- } catch {
429
- n({ error: "unsupported" });
430
- }
431
- });
432
- }), v("hardware", function() {
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
- });
437
- }), v("locales", function() {
438
- return new Promise(function(a) {
439
- a({ languages: navigator.language, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone });
440
- });
441
- }), v("permissions", function() {
442
- return w(this, void 0, void 0, function() {
443
- var a;
444
- return y(this, function(e) {
445
- return M = (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
- return function() {
447
- return w(this, void 0, void 0, function() {
448
- var n, r, o, i, t;
449
- return y(this, function(u) {
450
- switch (u.label) {
451
- case 0:
452
- n = {}, r = 0, o = M, u.label = 1;
453
- case 1:
454
- if (!(r < o.length)) return [3, 6];
455
- i = o[r], u.label = 2;
456
- case 2:
457
- return u.trys.push([2, 4, , 5]), [4, navigator.permissions.query({ name: i })];
458
- case 3:
459
- return t = u.sent(), n[i] = t.state.toString(), [3, 5];
460
- case 4:
461
- return u.sent(), [3, 5];
462
- case 5:
463
- return r++, [3, 1];
464
- case 6:
465
- return [2, n];
466
- }
467
- });
468
- });
469
- }();
470
- }), [2, Promise.all(a).then(function(n) {
471
- return ee(n, M);
472
- })];
473
- });
474
- });
475
- }), v("plugins", function() {
476
- var a = [];
477
- if (navigator.plugins) for (var e = 0; e < navigator.plugins.length; e++) {
478
- var n = navigator.plugins[e];
479
- a.push([n.name, n.filename, n.description].join("|"));
480
- }
481
- return new Promise(function(r) {
482
- r({ plugins: a });
483
- });
484
- }), v("screen", function() {
485
- return new Promise(function(a) {
486
- a({ is_touchscreen: navigator.maxTouchPoints > 0, maxTouchPoints: navigator.maxTouchPoints, colorDepth: screen.colorDepth, mediaMatches: te() });
487
- });
488
- }), v("system", function() {
489
- return new Promise(function(a) {
490
- var e = A();
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
- });
493
- });
494
- var f, re = A().name !== "SamsungBrowser" ? 1 : 3, d = null;
495
- v("webgl", function() {
496
- return w(this, void 0, void 0, function() {
497
- var a;
498
- return y(this, function(e) {
499
- typeof document < "u" && ((f = document.createElement("canvas")).width = 200, f.height = 100, d = f.getContext("webgl"));
500
- try {
501
- if (!d) throw new Error("WebGL not supported");
502
- return a = Array.from({ length: re }, function() {
503
- return function() {
504
- try {
505
- if (!d) throw new Error("WebGL not supported");
506
- var n = `
507
- attribute vec2 position;
508
- void main() {
509
- gl_Position = vec4(position, 0.0, 1.0);
510
- }
511
- `, r = `
512
- precision mediump float;
513
- void main() {
514
- gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
515
- }
516
- `, o = d.createShader(d.VERTEX_SHADER), i = d.createShader(d.FRAGMENT_SHADER);
517
- if (!o || !i) throw new Error("Failed to create shaders");
518
- if (d.shaderSource(o, n), d.shaderSource(i, r), d.compileShader(o), !d.getShaderParameter(o, d.COMPILE_STATUS)) throw new Error("Vertex shader compilation failed: " + d.getShaderInfoLog(o));
519
- if (d.compileShader(i), !d.getShaderParameter(i, d.COMPILE_STATUS)) throw new Error("Fragment shader compilation failed: " + d.getShaderInfoLog(i));
520
- var t = d.createProgram();
521
- if (!t) throw new Error("Failed to create shader program");
522
- if (d.attachShader(t, o), d.attachShader(t, i), d.linkProgram(t), !d.getProgramParameter(t, d.LINK_STATUS)) throw new Error("Shader program linking failed: " + d.getProgramInfoLog(t));
523
- d.useProgram(t);
524
- for (var u = 137, l = new Float32Array(4 * u), s = 2 * Math.PI / u, c = 0; c < u; c++) {
525
- var g = c * s;
526
- l[4 * c] = 0, l[4 * c + 1] = 0, l[4 * c + 2] = Math.cos(g) * (f.width / 2), l[4 * c + 3] = Math.sin(g) * (f.height / 2);
527
- }
528
- var T = d.createBuffer();
529
- d.bindBuffer(d.ARRAY_BUFFER, T), d.bufferData(d.ARRAY_BUFFER, l, d.STATIC_DRAW);
530
- var E = d.getAttribLocation(t, "position");
531
- d.enableVertexAttribArray(E), d.vertexAttribPointer(E, 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 P = new Uint8ClampedArray(f.width * f.height * 4);
533
- return d.readPixels(0, 0, f.width, f.height, d.RGBA, d.UNSIGNED_BYTE, P), new ImageData(P, f.width, f.height);
534
- } catch {
535
- return new ImageData(1, 1);
536
- } finally {
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
- }
539
- }();
540
- }), [2, { commonImageHash: R(L(a, f.width, f.height).data.toString()).toString() }];
541
- } catch {
542
- return [2, { webgl: "unsupported" }];
543
- }
544
- return [2];
545
- });
546
- });
547
- });
548
- var b = function(a, e, n, r) {
549
- for (var o = (n - e) / r, i = 0, t = 0; t < r; t++)
550
- i += a(e + (t + 0.5) * o);
551
- return i * o;
552
- };
553
- v("math", function() {
554
- return w(void 0, void 0, void 0, function() {
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
- });
558
- });
559
- });
560
- const ae = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
561
- let C = (a = 21) => {
562
- let e = "", n = crypto.getRandomValues(new Uint8Array(a |= 0));
563
- for (; a--; )
564
- e += ae[n[a] & 63];
565
- return e;
566
- };
567
- class x {
568
- constructor(e) {
569
- h(this, "config");
570
- this.config = e;
571
- }
572
- async getAds(e) {
573
- return [];
574
- }
575
- async onQuerySubmitted(e) {
576
- }
577
- async onQueryFetched(e, n) {
578
- }
579
- async onInputCleared() {
580
- }
581
- async onAdContainerRendered(e) {
582
- }
583
- async onAdContainerViewed(e) {
584
- }
585
- }
586
- class oe extends x {
587
- /**
588
- * Gets ads from the adMarketplace API based on the search term.
589
- */
590
- async getAds(e) {
591
- if (!this.config.admSub)
592
- return console.error("No admSub specified in config."), [];
593
- const r = `https://demofeed.is.ampfeed.com/is?${new URLSearchParams({
594
- partner: "demofeed",
595
- sub1: this.config.admSub,
596
- qt: e.searchTerm,
597
- v: "2.0",
598
- rfr: "searchcraft.io",
599
- "results-ta": `${this.config.admTextAdQuantity || 0}`,
600
- "results-pa": `${this.config.admProductAdQuantity || 0}`
601
- }).toString()}`, i = await (await fetch(r, { method: "GET" })).json(), t = i.product_ads.map(
602
- (s) => ({
603
- id: C(),
604
- adSource: "adMarketplace",
605
- admAdType: "adm-product-ad",
606
- admAd: s
607
- })
608
- ), u = i.text_ads.map((s) => ({
609
- id: C(),
610
- adSource: "adMarketplace",
611
- admAdType: "adm-text-ad",
612
- admAd: s
613
- }));
614
- return t.concat(u);
615
- }
616
- async onAdContainerViewed(e) {
617
- var r;
618
- const n = e.adClientResponseItem;
619
- (r = n.admAd) != null && r.impression_url && fetch(n.admAd.impression_url);
620
- }
621
- }
622
- class ie extends x {
623
- async getAds(e) {
624
- return [];
625
- }
626
- }
627
- const se = 1e3;
628
- class ce extends x {
629
- constructor(n) {
630
- super(n);
631
- h(this, "adCallTimeout");
632
- this.addScriptTagToDocument();
633
- }
634
- async onQuerySubmitted(n) {
635
- this.addScriptTagToDocument();
636
- }
637
- async onQueryFetched(n, r) {
638
- var o;
639
- if ((((o = r.data.hits) == null ? void 0 : o.length) || 0) === 0) {
640
- this.removeScriptTagFromDocument();
641
- return;
642
- }
643
- this.performAdCall(se);
644
- }
645
- async onInputCleared() {
646
- this.removeScriptTagFromDocument();
647
- }
648
- performAdCall(n) {
649
- this.adCallTimeout && clearTimeout(this.adCallTimeout), this.adCallTimeout = setTimeout(() => {
650
- this.addScriptTagToDocument();
651
- try {
652
- PostRelease == null || PostRelease.Start({ ptd: [this.config.nativoPlacementId] });
653
- } catch (r) {
654
- console.error(r);
655
- }
656
- }, n);
657
- }
658
- async getAds(n) {
659
- return [];
660
- }
661
- addScriptTagToDocument() {
662
- if (!document.head.querySelector("#nativo-tag")) {
663
- const n = document.createElement("script");
664
- n.type = "text/javascript", n.src = "https://s.ntv.io/serve/load.js", n.id = "nativo-tag", n.setAttribute("data-ntv-set-no-auto-start", "true"), document.head.appendChild(n);
665
- }
666
- }
667
- removeScriptTagFromDocument() {
668
- const n = document.head.querySelector("#nativo-tag");
669
- n && document.head.removeChild(n);
670
- }
671
- }
672
- const ue = 600;
673
- class de {
674
- constructor(e, n, r) {
675
- h(this, "measureRequestTimeout");
676
- h(this, "measureRequestsBatched", []);
677
- h(this, "config");
678
- h(this, "sdkInfo");
679
- h(this, "userId");
680
- h(this, "sessionId");
681
- /**
682
- * Sends a measure event to the `/measure/event` endpoint for analytics purposes.
683
- *
684
- * @param {MeasureEventName} eventName - Name of the event.
685
- * @param {Partial<MeasureRequestProperties>} properties - Additional properties to send with the event.
686
- * @param {Partial<MeasureRequestUser>} user - Additional user properites to send with the event.
687
- */
688
- h(this, "sendMeasureEvent", async (e, n = {}, r = {}) => {
689
- const o = {
690
- event_name: e,
691
- properties: {
692
- searchcraft_index_names: this.config.index,
693
- session_id: this.sessionId,
694
- ...n
695
- },
696
- user: {
697
- ...this.measureRequestUser,
698
- ...r
699
- }
700
- };
701
- if (e === "document_clicked") {
702
- const i = JSON.stringify(o), t = `${this.baseMeasureUrl}/event`;
703
- try {
704
- const u = await fetch(t, {
705
- method: "POST",
706
- headers: {
707
- "Content-Type": "application/json",
708
- Authorization: this.config.readKey,
709
- "X-Sc-User-Id": this.userId,
710
- "X-Sc-Session-Id": this.sessionId
711
- },
712
- body: i,
713
- keepalive: !0
714
- });
715
- if (!u.ok)
716
- throw new Error(
717
- `Failed to send request: ${u.status} ${u.statusText}`
718
- );
719
- } catch (u) {
720
- throw console.error("Error sending MeasureRequest:", u), u;
721
- }
722
- } else
723
- this.measureRequestsBatched.push(o), clearTimeout(this.measureRequestTimeout), this.measureRequestTimeout = setTimeout(async () => {
724
- const i = JSON.stringify({ items: this.measureRequestsBatched }), t = `${this.baseMeasureUrl}/batch`;
725
- try {
726
- const u = await fetch(t, {
727
- method: "POST",
728
- headers: {
729
- "Content-Type": "application/json",
730
- Authorization: this.config.readKey,
731
- "X-Sc-User-Id": this.userId,
732
- "X-Sc-Session-Id": this.sessionId
733
- },
734
- body: i,
735
- keepalive: !0
736
- });
737
- if (this.measureRequestsBatched = [], !u.ok)
738
- throw new Error(
739
- `Failed to send request: ${u.status} ${u.statusText}`
740
- );
741
- return;
742
- } catch (u) {
743
- throw this.measureRequestsBatched = [], console.error("Error sending MeasureRequest:", u), u;
744
- }
745
- }, ue);
746
- });
747
- this.config = e, this.sdkInfo = n, this.userId = r, this.sessionId = C(), this.sendMeasureEvent("sdk_initialized");
748
- }
749
- /**
750
- * Getter for the base url used by the /measure endpoints.
751
- */
752
- get baseMeasureUrl() {
753
- return `${this.config.endpointURL}/measure`;
754
- }
755
- /**
756
- * Getter for the measure request user. Uses config values + navigator values.
757
- */
758
- get measureRequestUser() {
759
- return {
760
- user_id: this.userId,
761
- locale: navigator.language || "en-US",
762
- os: navigator.userAgent.includes("Windows") ? "Windows" : navigator.userAgent.includes("Mac") ? "Mac" : navigator.userAgent.includes("Linux") ? "Linux" : "Unknown",
763
- platform: navigator.platform || "Unknown",
764
- sdk_name: this.sdkInfo.sdkName,
765
- sdk_version: this.sdkInfo.sdkVersion,
766
- user_agent: navigator.userAgent || "Unknown"
767
- };
768
- }
769
- }
770
- const le = (a) => a.endsWith("/") ? a.slice(0, -1) : a, _ = (a) => {
771
- let e = "";
772
- if (e = a.trim(), e = e.replace(/[‘’“”]/g, (r) => ({
773
- "‘": "'",
774
- "’": "'",
775
- "“": '"',
776
- "”": '"'
777
- })[r] || r), (e.match(/"/g) || []).length % 2 !== 0)
778
- throw new Error(
779
- "The search term contains an uneven number of quote characters."
780
- );
781
- return e;
782
- }, he = 500;
783
- class me {
784
- constructor(e, n, r) {
785
- h(this, "config");
786
- h(this, "userId");
787
- h(this, "parent");
788
- h(this, "searchCompletedEventTimeout");
789
- h(this, "abortController");
790
- h(this, "supplementalAbortController");
791
- /**
792
- * Make the request to get the search results.
793
- * @param {properties} properties - The properties for the search.
794
- * @param isSupplemental - Whether or not this is a supplemental search request (for the purpose of getting top-level facet counts)
795
- * @returns
796
- */
797
- h(this, "getSearchResponseItems", async (e, n = !1) => {
798
- var t, u, l, s, c, g, T;
799
- let r, o = "", i;
800
- return n ? ((t = this.supplementalAbortController) == null || t.abort(
801
- "A newer search request has replaced this one."
802
- ), i = new AbortController(), this.supplementalAbortController = i) : ((u = this.abortController) == null || u.abort(
803
- "A newer search request has replaced this one."
804
- ), i = new AbortController(), this.abortController = i), typeof e == "string" ? o = _(e) : (e.searchTerm = _(e.searchTerm), o = e.searchTerm), (l = this.parent.measureClient) == null || l.sendMeasureEvent("search_requested", {
805
- search_term: o
806
- }), this.parent.emitEvent("query_submitted", {
807
- name: "query_submitted",
808
- data: {
809
- searchTerm: o
810
- }
811
- }), (s = this.parent.adClient) == null || s.onQuerySubmitted(
812
- typeof e == "string" ? { searchTerm: o, mode: "exact" } : e
813
- ), typeof e == "string" ? r = await this.handleGetSearchResponseItemsWithString(
814
- o,
815
- i
816
- ) : r = await this.handleGetSearchResponseItemsWithObject(
817
- e,
818
- i
819
- ), n || ((c = this.parent.measureClient) == null || c.sendMeasureEvent("search_response_received", {
820
- search_term: o,
821
- number_of_documents: r.data.count
822
- }), clearTimeout(this.searchCompletedEventTimeout), this.searchCompletedEventTimeout = setTimeout(() => {
823
- var E;
824
- (E = this.parent.measureClient) == null || E.sendMeasureEvent("search_completed", {
825
- search_term: o,
826
- number_of_documents: r.data.count
827
- });
828
- }, he), this.parent.emitEvent("query_fetched", {
829
- name: "query_fetched",
830
- data: {
831
- searchTerm: o
832
- }
833
- }), (((g = r.data.hits) == null ? void 0 : g.length) || 0) === 0 && this.parent.emitEvent("no_results_returned", {
834
- name: "no_results_returned"
835
- }), (T = this.parent.adClient) == null || T.onQueryFetched(
836
- typeof e == "string" ? { searchTerm: o, mode: "exact" } : e,
837
- r
838
- )), r;
839
- });
840
- h(this, "handleGetSearchResponseItemsWithString", async (e, n) => {
841
- var i;
842
- let r;
843
- try {
844
- r = JSON.parse(e), r = {
845
- limit: this.config.searchResultsPerPage,
846
- ...r
847
- };
848
- } catch {
849
- throw new Error("Error: Query string is not valid json.");
850
- }
851
- const o = await fetch(this.baseSearchUrl, {
852
- method: "POST",
853
- headers: {
854
- Authorization: this.config.readKey,
855
- "Content-Type": "application/json",
856
- "X-Sc-User-Id": this.userId,
857
- "X-Sc-Session-Id": ((i = this.parent.measureClient) == null ? void 0 : i.sessionId) || C()
858
- },
859
- body: JSON.stringify(r),
860
- signal: n.signal
861
- });
862
- if (!o.ok)
863
- throw new Error(
864
- `Error: ${o.statusText} (Status: ${o.status})`
865
- );
866
- return await o.json();
867
- });
868
- h(this, "handleGetSearchResponseItemsWithObject", async (e, n) => {
869
- var o;
870
- const r = await fetch(this.baseSearchUrl, {
871
- method: "POST",
872
- headers: {
873
- Authorization: this.config.readKey,
874
- "Content-Type": "application/json",
875
- "X-Sc-User-Id": this.userId,
876
- "X-Sc-Session-Id": ((o = this.parent.measureClient) == null ? void 0 : o.sessionId) || C()
877
- },
878
- body: JSON.stringify({
879
- query: this.formatParamsForRequest(e),
880
- offset: e.offset || 0,
881
- limit: e.limit || this.config.searchResultsPerPage || 20,
882
- ...e.order_by && {
883
- order_by: e.order_by
884
- },
885
- ...e.sort && {
886
- sort: e.sort
887
- }
888
- }),
889
- signal: n.signal
890
- });
891
- if (!r.ok)
892
- throw new Error(
893
- `Error: ${r.statusText} (Status: ${r.status})`
894
- );
895
- return await r.json();
896
- });
897
- this.parent = e, this.config = n, this.userId = r;
898
- }
899
- /**
900
- * Getter for the base url used by the /search endpoint.
901
- */
902
- get baseSearchUrl() {
903
- return `${this.config.endpointURL}/index/${this.config.index.join(",")}/search`;
904
- }
905
- /**
906
- * Builds a query object for the SearchClient request.
907
- * @param {properties} properties - The properties for the search.
908
- * @returns {SearchClientQuery} - A properly formatted SearchClient query object.
909
- */
910
- formatParamsForRequest(e) {
911
- const n = [];
912
- let r = "should";
913
- e.facetPathsForIndexFields && Object.keys(e.facetPathsForIndexFields).forEach((t) => {
914
- var l;
915
- const u = (l = e.facetPathsForIndexFields) == null ? void 0 : l[t];
916
- u && (r = "must", n.push({
917
- occur: "must",
918
- exact: {
919
- ctx: _(u.value)
920
- }
921
- }));
922
- }), e.rangeValueForIndexFields && Object.keys(e.rangeValueForIndexFields).forEach((t) => {
923
- var l;
924
- const u = (l = e.rangeValueForIndexFields) == null ? void 0 : l[t];
925
- u && (r = "must", n.push({
926
- occur: "must",
927
- exact: {
928
- ctx: _(u.value)
929
- }
930
- }));
931
- });
932
- const o = e.searchTerm, i = e.mode === "fuzzy" ? { fuzzy: { ctx: o } } : {
933
- exact: {
934
- ctx: `${o.startsWith('"') ? o : `"${o}"`}`
935
- }
936
- };
937
- return n.push({
938
- occur: e.mode === "exact" ? "must" : r,
939
- // Valid, as 'occur' is a required property in SearchClientQuery
940
- ...i
941
- }), n;
942
- }
943
- }
944
- class ve {
945
- constructor(e, n) {
946
- h(this, "config");
947
- h(this, "measureClient");
948
- h(this, "searchClient");
949
- h(this, "adClient");
950
- h(this, "userId");
951
- h(this, "requestTimeout");
952
- h(this, "subscriptionEvents", {});
953
- h(this, "getResponseItems", (e, n, r) => {
954
- const o = async () => {
955
- (async () => {
956
- var l;
957
- if (!this.searchClient) {
958
- console.error("Search client was not initialized.");
959
- return;
960
- }
961
- let i;
962
- try {
963
- i = await this.searchClient.getSearchResponseItems(
964
- e,
965
- !1
966
- );
967
- } catch (s) {
968
- console.info(`Search request error: ${s}`);
969
- return;
970
- }
971
- if (!i) {
972
- console.error("Search request error: Search response was undefined");
973
- return;
974
- }
975
- const t = (i.data.hits || []).filter((s) => !!s.doc).map((s) => ({
976
- id: C(),
977
- document: s.doc || { id: -1 },
978
- source_index: s.source_index,
979
- type: "SearchDocument"
980
- }));
981
- let u;
982
- if (typeof e == "object") {
983
- const s = structuredClone(
984
- e
985
- );
986
- if (s.facetPathsForIndexFields && Object.keys(s.facetPathsForIndexFields).length > 0) {
987
- s.facetPathsForIndexFields = void 0;
988
- try {
989
- u = await ((l = this == null ? void 0 : this.searchClient) == null ? void 0 : l.getSearchResponseItems(s, !0));
990
- } catch (c) {
991
- console.info(`Search request error: ${c}`);
992
- return;
993
- }
994
- }
995
- }
996
- n(e, i, t, u);
997
- })(), (async () => {
998
- if (this.adClient && typeof e != "string") {
999
- const i = await this.adClient.getAds(e);
1000
- r(i);
1001
- }
1002
- })();
1003
- };
1004
- clearTimeout(this.requestTimeout), this.config.searchDebounceDelay ? this.requestTimeout = setTimeout(
1005
- o,
1006
- this.config.searchDebounceDelay
1007
- ) : o();
1008
- });
1009
- if (!e.endpointURL || !e.index || !e.readKey)
1010
- throw new Error(
1011
- "Endpoint URL, Index value(s), and Read Key must be provided"
1012
- );
1013
- this.config = {
1014
- ...e,
1015
- // Strips off the trailing '/' from an endpointURL if one is accidentally added
1016
- endpointURL: le(e.endpointURL)
1017
- }, 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());
1018
- }
1019
- initInputForms() {
1020
- const e = document.querySelectorAll(
1021
- "searchcraft-input-form"
1022
- );
1023
- setTimeout(() => {
1024
- e.forEach((n) => {
1025
- n.core = this;
1026
- });
1027
- }, 40);
1028
- }
1029
- /**
1030
- * When changes happen in the DOM, we want to link any input forms found to the instance of the core.
1031
- */
1032
- startObservingMutations() {
1033
- new MutationObserver((n, r) => {
1034
- let o = !1;
1035
- for (const i of n)
1036
- i.type === "childList" && i.addedNodes.forEach((t) => {
1037
- t.nodeType === 1 && (t.getAttribute("class") || "").toLowerCase() === "searchcraft-input-form" && (o = !0);
1038
- });
1039
- o && this.initInputForms();
1040
- }).observe(document.body, { childList: !0, subtree: !0 });
1041
- }
1042
- initClients(e, n) {
1043
- setTimeout(async () => {
1044
- let r = this.config.userId;
1045
- switch (r || (r = await z()), this.measureClient = new de(e, n, r), this.searchClient = new me(this, e, r), e.adSource) {
1046
- case "adMarketplace":
1047
- this.adClient = new oe(e);
1048
- break;
1049
- case "Nativo":
1050
- this.adClient = new ce(e);
1051
- break;
1052
- case "Custom":
1053
- this.adClient = new ie(e);
1054
- break;
1055
- }
1056
- this.emitEvent("initialized", {
1057
- name: "initialized"
1058
- });
1059
- }, 300);
1060
- }
1061
- emitEvent(e, n) {
1062
- var r;
1063
- (r = this.subscriptionEvents[e]) == null || r.forEach((o) => {
1064
- o(n);
1065
- });
1066
- }
1067
- subscribe(e, n) {
1068
- return this.subscriptionEvents[e] || (this.subscriptionEvents[e] = []), this.subscriptionEvents[e].push(
1069
- n
1070
- ), () => {
1071
- this.subscriptionEvents[e] = this.subscriptionEvents[e].filter((r) => r !== n);
1072
- };
1073
- }
1074
- /**
1075
- * Called when a `<searchcraft-ad>` component is rendered
1076
- */
1077
- handleAdContainerRendered(e) {
1078
- var n;
1079
- (n = this.adClient) == null || n.onAdContainerRendered(e), this.emitEvent("ad_container_rendered", {
1080
- name: "ad_container_rendered",
1081
- data: {
1082
- adContainerId: e.adContainerId,
1083
- adSource: e.adSource,
1084
- searchTerm: e.searchTerm
1085
- }
1086
- });
1087
- }
1088
- /**
1089
- * Called when a `<searchcraft-ad>` is viewed
1090
- */
1091
- handleAdContainerViewed(e) {
1092
- var n;
1093
- (n = this.adClient) == null || n.onAdContainerViewed(e), this.emitEvent("ad_container_viewed", {
1094
- name: "ad_container_viewed",
1095
- data: {
1096
- adContainerId: e.adContainerId,
1097
- adSource: e.adSource,
1098
- searchTerm: e.searchTerm
1099
- }
1100
- });
1101
- }
1102
- /**
1103
- * Perform various actions when the input is cleared
1104
- */
1105
- handleInputCleared() {
1106
- var e;
1107
- this.emitEvent("input_cleared", {
1108
- name: "input_cleared"
1109
- }), (e = this.adClient) == null || e.onInputCleared();
1110
- }
1111
- }
1112
-
1113
- var zustand = {};
1114
-
1115
- var vanilla$1 = {};
1116
-
1117
- const createStoreImpl = (createState) => {
1118
- let state;
1119
- const listeners = /* @__PURE__ */ new Set();
1120
- const setState = (partial, replace) => {
1121
- const nextState = typeof partial === "function" ? partial(state) : partial;
1122
- if (!Object.is(nextState, state)) {
1123
- const previousState = state;
1124
- state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
1125
- listeners.forEach((listener) => listener(state, previousState));
1126
- }
1127
- };
1128
- const getState = () => state;
1129
- const getInitialState = () => initialState;
1130
- const subscribe = (listener) => {
1131
- listeners.add(listener);
1132
- return () => listeners.delete(listener);
1133
- };
1134
- const api = { setState, getState, getInitialState, subscribe };
1135
- const initialState = state = createState(setState, getState, api);
1136
- return api;
1137
- };
1138
- const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
1139
-
1140
- vanilla$1.createStore = createStore;
1141
-
1142
- var react$1 = {};
1143
-
1144
- var react = {exports: {}};
1145
-
1146
- var react_production = {};
1147
-
1148
- /**
1149
- * @license React
1150
- * react.production.js
1151
- *
1152
- * Copyright (c) Meta Platforms, Inc. and affiliates.
1153
- *
1154
- * This source code is licensed under the MIT license found in the
1155
- * LICENSE file in the root directory of this source tree.
1156
- */
1157
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
1158
- REACT_PORTAL_TYPE = Symbol.for("react.portal"),
1159
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
1160
- REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
1161
- REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
1162
- REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
1163
- REACT_CONTEXT_TYPE = Symbol.for("react.context"),
1164
- REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
1165
- REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
1166
- REACT_MEMO_TYPE = Symbol.for("react.memo"),
1167
- REACT_LAZY_TYPE = Symbol.for("react.lazy"),
1168
- MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
1169
- function getIteratorFn(maybeIterable) {
1170
- if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
1171
- maybeIterable =
1172
- (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
1173
- maybeIterable["@@iterator"];
1174
- return "function" === typeof maybeIterable ? maybeIterable : null;
1175
- }
1176
- var ReactNoopUpdateQueue = {
1177
- isMounted: function () {
1178
- return !1;
1179
- },
1180
- enqueueForceUpdate: function () {},
1181
- enqueueReplaceState: function () {},
1182
- enqueueSetState: function () {}
1183
- },
1184
- assign = Object.assign,
1185
- emptyObject = {};
1186
- function Component(props, context, updater) {
1187
- this.props = props;
1188
- this.context = context;
1189
- this.refs = emptyObject;
1190
- this.updater = updater || ReactNoopUpdateQueue;
1191
- }
1192
- Component.prototype.isReactComponent = {};
1193
- Component.prototype.setState = function (partialState, callback) {
1194
- if (
1195
- "object" !== typeof partialState &&
1196
- "function" !== typeof partialState &&
1197
- null != partialState
1198
- )
1199
- throw Error(
1200
- "takes an object of state variables to update or a function which returns an object of state variables."
1201
- );
1202
- this.updater.enqueueSetState(this, partialState, callback, "setState");
1203
- };
1204
- Component.prototype.forceUpdate = function (callback) {
1205
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
1206
- };
1207
- function ComponentDummy() {}
1208
- ComponentDummy.prototype = Component.prototype;
1209
- function PureComponent(props, context, updater) {
1210
- this.props = props;
1211
- this.context = context;
1212
- this.refs = emptyObject;
1213
- this.updater = updater || ReactNoopUpdateQueue;
1214
- }
1215
- var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
1216
- pureComponentPrototype.constructor = PureComponent;
1217
- assign(pureComponentPrototype, Component.prototype);
1218
- pureComponentPrototype.isPureReactComponent = !0;
1219
- var isArrayImpl = Array.isArray,
1220
- ReactSharedInternals = { H: null, A: null, T: null, S: null },
1221
- hasOwnProperty = Object.prototype.hasOwnProperty;
1222
- function ReactElement(type, key, self, source, owner, props) {
1223
- self = props.ref;
1224
- return {
1225
- $$typeof: REACT_ELEMENT_TYPE,
1226
- type: type,
1227
- key: key,
1228
- ref: void 0 !== self ? self : null,
1229
- props: props
1230
- };
1231
- }
1232
- function cloneAndReplaceKey(oldElement, newKey) {
1233
- return ReactElement(
1234
- oldElement.type,
1235
- newKey,
1236
- void 0,
1237
- void 0,
1238
- void 0,
1239
- oldElement.props
1240
- );
1241
- }
1242
- function isValidElement(object) {
1243
- return (
1244
- "object" === typeof object &&
1245
- null !== object &&
1246
- object.$$typeof === REACT_ELEMENT_TYPE
1247
- );
1248
- }
1249
- function escape(key) {
1250
- var escaperLookup = { "=": "=0", ":": "=2" };
1251
- return (
1252
- "$" +
1253
- key.replace(/[=:]/g, function (match) {
1254
- return escaperLookup[match];
1255
- })
1256
- );
1257
- }
1258
- var userProvidedKeyEscapeRegex = /\/+/g;
1259
- function getElementKey(element, index) {
1260
- return "object" === typeof element && null !== element && null != element.key
1261
- ? escape("" + element.key)
1262
- : index.toString(36);
1263
- }
1264
- function noop$1() {}
1265
- function resolveThenable(thenable) {
1266
- switch (thenable.status) {
1267
- case "fulfilled":
1268
- return thenable.value;
1269
- case "rejected":
1270
- throw thenable.reason;
1271
- default:
1272
- switch (
1273
- ("string" === typeof thenable.status
1274
- ? thenable.then(noop$1, noop$1)
1275
- : ((thenable.status = "pending"),
1276
- thenable.then(
1277
- function (fulfilledValue) {
1278
- "pending" === thenable.status &&
1279
- ((thenable.status = "fulfilled"),
1280
- (thenable.value = fulfilledValue));
1281
- },
1282
- function (error) {
1283
- "pending" === thenable.status &&
1284
- ((thenable.status = "rejected"), (thenable.reason = error));
1285
- }
1286
- )),
1287
- thenable.status)
1288
- ) {
1289
- case "fulfilled":
1290
- return thenable.value;
1291
- case "rejected":
1292
- throw thenable.reason;
1293
- }
1294
- }
1295
- throw thenable;
1296
- }
1297
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
1298
- var type = typeof children;
1299
- if ("undefined" === type || "boolean" === type) children = null;
1300
- var invokeCallback = !1;
1301
- if (null === children) invokeCallback = !0;
1302
- else
1303
- switch (type) {
1304
- case "bigint":
1305
- case "string":
1306
- case "number":
1307
- invokeCallback = !0;
1308
- break;
1309
- case "object":
1310
- switch (children.$$typeof) {
1311
- case REACT_ELEMENT_TYPE:
1312
- case REACT_PORTAL_TYPE:
1313
- invokeCallback = !0;
1314
- break;
1315
- case REACT_LAZY_TYPE:
1316
- return (
1317
- (invokeCallback = children._init),
1318
- mapIntoArray(
1319
- invokeCallback(children._payload),
1320
- array,
1321
- escapedPrefix,
1322
- nameSoFar,
1323
- callback
1324
- )
1325
- );
1326
- }
1327
- }
1328
- if (invokeCallback)
1329
- return (
1330
- (callback = callback(children)),
1331
- (invokeCallback =
1332
- "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar),
1333
- isArrayImpl(callback)
1334
- ? ((escapedPrefix = ""),
1335
- null != invokeCallback &&
1336
- (escapedPrefix =
1337
- invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"),
1338
- mapIntoArray(callback, array, escapedPrefix, "", function (c) {
1339
- return c;
1340
- }))
1341
- : null != callback &&
1342
- (isValidElement(callback) &&
1343
- (callback = cloneAndReplaceKey(
1344
- callback,
1345
- escapedPrefix +
1346
- (null == callback.key ||
1347
- (children && children.key === callback.key)
1348
- ? ""
1349
- : ("" + callback.key).replace(
1350
- userProvidedKeyEscapeRegex,
1351
- "$&/"
1352
- ) + "/") +
1353
- invokeCallback
1354
- )),
1355
- array.push(callback)),
1356
- 1
1357
- );
1358
- invokeCallback = 0;
1359
- var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
1360
- if (isArrayImpl(children))
1361
- for (var i = 0; i < children.length; i++)
1362
- (nameSoFar = children[i]),
1363
- (type = nextNamePrefix + getElementKey(nameSoFar, i)),
1364
- (invokeCallback += mapIntoArray(
1365
- nameSoFar,
1366
- array,
1367
- escapedPrefix,
1368
- type,
1369
- callback
1370
- ));
1371
- else if (((i = getIteratorFn(children)), "function" === typeof i))
1372
- for (
1373
- children = i.call(children), i = 0;
1374
- !(nameSoFar = children.next()).done;
1375
-
1376
- )
1377
- (nameSoFar = nameSoFar.value),
1378
- (type = nextNamePrefix + getElementKey(nameSoFar, i++)),
1379
- (invokeCallback += mapIntoArray(
1380
- nameSoFar,
1381
- array,
1382
- escapedPrefix,
1383
- type,
1384
- callback
1385
- ));
1386
- else if ("object" === type) {
1387
- if ("function" === typeof children.then)
1388
- return mapIntoArray(
1389
- resolveThenable(children),
1390
- array,
1391
- escapedPrefix,
1392
- nameSoFar,
1393
- callback
1394
- );
1395
- array = String(children);
1396
- throw Error(
1397
- "Objects are not valid as a React child (found: " +
1398
- ("[object Object]" === array
1399
- ? "object with keys {" + Object.keys(children).join(", ") + "}"
1400
- : array) +
1401
- "). If you meant to render a collection of children, use an array instead."
1402
- );
1403
- }
1404
- return invokeCallback;
1405
- }
1406
- function mapChildren(children, func, context) {
1407
- if (null == children) return children;
1408
- var result = [],
1409
- count = 0;
1410
- mapIntoArray(children, result, "", "", function (child) {
1411
- return func.call(context, child, count++);
1412
- });
1413
- return result;
1414
- }
1415
- function lazyInitializer(payload) {
1416
- if (-1 === payload._status) {
1417
- var ctor = payload._result;
1418
- ctor = ctor();
1419
- ctor.then(
1420
- function (moduleObject) {
1421
- if (0 === payload._status || -1 === payload._status)
1422
- (payload._status = 1), (payload._result = moduleObject);
1423
- },
1424
- function (error) {
1425
- if (0 === payload._status || -1 === payload._status)
1426
- (payload._status = 2), (payload._result = error);
1427
- }
1428
- );
1429
- -1 === payload._status && ((payload._status = 0), (payload._result = ctor));
1430
- }
1431
- if (1 === payload._status) return payload._result.default;
1432
- throw payload._result;
1433
- }
1434
- var reportGlobalError =
1435
- "function" === typeof reportError
1436
- ? reportError
1437
- : function (error) {
1438
- if (
1439
- "object" === typeof window &&
1440
- "function" === typeof window.ErrorEvent
1441
- ) {
1442
- var event = new window.ErrorEvent("error", {
1443
- bubbles: !0,
1444
- cancelable: !0,
1445
- message:
1446
- "object" === typeof error &&
1447
- null !== error &&
1448
- "string" === typeof error.message
1449
- ? String(error.message)
1450
- : String(error),
1451
- error: error
1452
- });
1453
- if (!window.dispatchEvent(event)) return;
1454
- } else if (
1455
- "object" === typeof process &&
1456
- "function" === typeof process.emit
1457
- ) {
1458
- process.emit("uncaughtException", error);
1459
- return;
1460
- }
1461
- console.error(error);
1462
- };
1463
- function noop() {}
1464
- react_production.Children = {
1465
- map: mapChildren,
1466
- forEach: function (children, forEachFunc, forEachContext) {
1467
- mapChildren(
1468
- children,
1469
- function () {
1470
- forEachFunc.apply(this, arguments);
1471
- },
1472
- forEachContext
1473
- );
1474
- },
1475
- count: function (children) {
1476
- var n = 0;
1477
- mapChildren(children, function () {
1478
- n++;
1479
- });
1480
- return n;
1481
- },
1482
- toArray: function (children) {
1483
- return (
1484
- mapChildren(children, function (child) {
1485
- return child;
1486
- }) || []
1487
- );
1488
- },
1489
- only: function (children) {
1490
- if (!isValidElement(children))
1491
- throw Error(
1492
- "React.Children.only expected to receive a single React element child."
1493
- );
1494
- return children;
1495
- }
1496
- };
1497
- react_production.Component = Component;
1498
- react_production.Fragment = REACT_FRAGMENT_TYPE;
1499
- react_production.Profiler = REACT_PROFILER_TYPE;
1500
- react_production.PureComponent = PureComponent;
1501
- react_production.StrictMode = REACT_STRICT_MODE_TYPE;
1502
- react_production.Suspense = REACT_SUSPENSE_TYPE;
1503
- react_production.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
1504
- ReactSharedInternals;
1505
- react_production.act = function () {
1506
- throw Error("act(...) is not supported in production builds of React.");
1507
- };
1508
- react_production.cache = function (fn) {
1509
- return function () {
1510
- return fn.apply(null, arguments);
1511
- };
1512
- };
1513
- react_production.cloneElement = function (element, config, children) {
1514
- if (null === element || void 0 === element)
1515
- throw Error(
1516
- "The argument must be a React element, but you passed " + element + "."
1517
- );
1518
- var props = assign({}, element.props),
1519
- key = element.key,
1520
- owner = void 0;
1521
- if (null != config)
1522
- for (propName in (void 0 !== config.ref && (owner = void 0),
1523
- void 0 !== config.key && (key = "" + config.key),
1524
- config))
1525
- !hasOwnProperty.call(config, propName) ||
1526
- "key" === propName ||
1527
- "__self" === propName ||
1528
- "__source" === propName ||
1529
- ("ref" === propName && void 0 === config.ref) ||
1530
- (props[propName] = config[propName]);
1531
- var propName = arguments.length - 2;
1532
- if (1 === propName) props.children = children;
1533
- else if (1 < propName) {
1534
- for (var childArray = Array(propName), i = 0; i < propName; i++)
1535
- childArray[i] = arguments[i + 2];
1536
- props.children = childArray;
1537
- }
1538
- return ReactElement(element.type, key, void 0, void 0, owner, props);
1539
- };
1540
- react_production.createContext = function (defaultValue) {
1541
- defaultValue = {
1542
- $$typeof: REACT_CONTEXT_TYPE,
1543
- _currentValue: defaultValue,
1544
- _currentValue2: defaultValue,
1545
- _threadCount: 0,
1546
- Provider: null,
1547
- Consumer: null
1548
- };
1549
- defaultValue.Provider = defaultValue;
1550
- defaultValue.Consumer = {
1551
- $$typeof: REACT_CONSUMER_TYPE,
1552
- _context: defaultValue
1553
- };
1554
- return defaultValue;
1555
- };
1556
- react_production.createElement = function (type, config, children) {
1557
- var propName,
1558
- props = {},
1559
- key = null;
1560
- if (null != config)
1561
- for (propName in (void 0 !== config.key && (key = "" + config.key), config))
1562
- hasOwnProperty.call(config, propName) &&
1563
- "key" !== propName &&
1564
- "__self" !== propName &&
1565
- "__source" !== propName &&
1566
- (props[propName] = config[propName]);
1567
- var childrenLength = arguments.length - 2;
1568
- if (1 === childrenLength) props.children = children;
1569
- else if (1 < childrenLength) {
1570
- for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
1571
- childArray[i] = arguments[i + 2];
1572
- props.children = childArray;
1573
- }
1574
- if (type && type.defaultProps)
1575
- for (propName in ((childrenLength = type.defaultProps), childrenLength))
1576
- void 0 === props[propName] &&
1577
- (props[propName] = childrenLength[propName]);
1578
- return ReactElement(type, key, void 0, void 0, null, props);
1579
- };
1580
- react_production.createRef = function () {
1581
- return { current: null };
1582
- };
1583
- react_production.forwardRef = function (render) {
1584
- return { $$typeof: REACT_FORWARD_REF_TYPE, render: render };
1585
- };
1586
- react_production.isValidElement = isValidElement;
1587
- react_production.lazy = function (ctor) {
1588
- return {
1589
- $$typeof: REACT_LAZY_TYPE,
1590
- _payload: { _status: -1, _result: ctor },
1591
- _init: lazyInitializer
1592
- };
1593
- };
1594
- react_production.memo = function (type, compare) {
1595
- return {
1596
- $$typeof: REACT_MEMO_TYPE,
1597
- type: type,
1598
- compare: void 0 === compare ? null : compare
1599
- };
1600
- };
1601
- react_production.startTransition = function (scope) {
1602
- var prevTransition = ReactSharedInternals.T,
1603
- currentTransition = {};
1604
- ReactSharedInternals.T = currentTransition;
1605
- try {
1606
- var returnValue = scope(),
1607
- onStartTransitionFinish = ReactSharedInternals.S;
1608
- null !== onStartTransitionFinish &&
1609
- onStartTransitionFinish(currentTransition, returnValue);
1610
- "object" === typeof returnValue &&
1611
- null !== returnValue &&
1612
- "function" === typeof returnValue.then &&
1613
- returnValue.then(noop, reportGlobalError);
1614
- } catch (error) {
1615
- reportGlobalError(error);
1616
- } finally {
1617
- ReactSharedInternals.T = prevTransition;
1618
- }
1619
- };
1620
- react_production.unstable_useCacheRefresh = function () {
1621
- return ReactSharedInternals.H.useCacheRefresh();
1622
- };
1623
- react_production.use = function (usable) {
1624
- return ReactSharedInternals.H.use(usable);
1625
- };
1626
- react_production.useActionState = function (action, initialState, permalink) {
1627
- return ReactSharedInternals.H.useActionState(action, initialState, permalink);
1628
- };
1629
- react_production.useCallback = function (callback, deps) {
1630
- return ReactSharedInternals.H.useCallback(callback, deps);
1631
- };
1632
- react_production.useContext = function (Context) {
1633
- return ReactSharedInternals.H.useContext(Context);
1634
- };
1635
- react_production.useDebugValue = function () {};
1636
- react_production.useDeferredValue = function (value, initialValue) {
1637
- return ReactSharedInternals.H.useDeferredValue(value, initialValue);
1638
- };
1639
- react_production.useEffect = function (create, deps) {
1640
- return ReactSharedInternals.H.useEffect(create, deps);
1641
- };
1642
- react_production.useId = function () {
1643
- return ReactSharedInternals.H.useId();
1644
- };
1645
- react_production.useImperativeHandle = function (ref, create, deps) {
1646
- return ReactSharedInternals.H.useImperativeHandle(ref, create, deps);
1647
- };
1648
- react_production.useInsertionEffect = function (create, deps) {
1649
- return ReactSharedInternals.H.useInsertionEffect(create, deps);
1650
- };
1651
- react_production.useLayoutEffect = function (create, deps) {
1652
- return ReactSharedInternals.H.useLayoutEffect(create, deps);
1653
- };
1654
- react_production.useMemo = function (create, deps) {
1655
- return ReactSharedInternals.H.useMemo(create, deps);
1656
- };
1657
- react_production.useOptimistic = function (passthrough, reducer) {
1658
- return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
1659
- };
1660
- react_production.useReducer = function (reducer, initialArg, init) {
1661
- return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
1662
- };
1663
- react_production.useRef = function (initialValue) {
1664
- return ReactSharedInternals.H.useRef(initialValue);
1665
- };
1666
- react_production.useState = function (initialState) {
1667
- return ReactSharedInternals.H.useState(initialState);
1668
- };
1669
- react_production.useSyncExternalStore = function (
1670
- subscribe,
1671
- getSnapshot,
1672
- getServerSnapshot
1673
- ) {
1674
- return ReactSharedInternals.H.useSyncExternalStore(
1675
- subscribe,
1676
- getSnapshot,
1677
- getServerSnapshot
1678
- );
1679
- };
1680
- react_production.useTransition = function () {
1681
- return ReactSharedInternals.H.useTransition();
1682
- };
1683
- react_production.version = "19.0.0";
1684
-
1685
- {
1686
- react.exports = react_production;
1687
- }
1688
-
1689
- var React = react.exports;
1690
- var vanilla = vanilla$1;
1691
-
1692
- const identity = (arg) => arg;
1693
- function useStore(api, selector = identity) {
1694
- const slice = React.useSyncExternalStore(
1695
- api.subscribe,
1696
- () => selector(api.getState()),
1697
- () => selector(api.getInitialState())
1698
- );
1699
- React.useDebugValue(slice);
1700
- return slice;
1701
- }
1702
- const createImpl = (createState) => {
1703
- const api = vanilla.createStore(createState);
1704
- const useBoundStore = (selector) => useStore(api, selector);
1705
- Object.assign(useBoundStore, api);
1706
- return useBoundStore;
1707
- };
1708
- const create = (createState) => createState ? createImpl(createState) : createImpl;
1709
-
1710
- react$1.create = create;
1711
- react$1.useStore = useStore;
1712
-
1713
- (function (exports) {
1714
-
1715
- var vanilla = vanilla$1;
1716
- var react = react$1;
1717
-
1718
-
1719
-
1720
- Object.keys(vanilla).forEach(function (k) {
1721
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
1722
- enumerable: true,
1723
- get: function () { return vanilla[k]; }
1724
- });
1725
- });
1726
- Object.keys(react).forEach(function (k) {
1727
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
1728
- enumerable: true,
1729
- get: function () { return react[k]; }
1730
- });
1731
- });
1732
- }(zustand));
1733
-
1734
- const initialSearchcraftStateValues = {
1735
- adClientResponseItems: [],
1736
- core: undefined,
1737
- hotkey: 'k',
1738
- hotkeyModifier: 'meta',
1739
- logger: undefined,
1740
- facetPathsForIndexFields: {},
1741
- initialQuery: '',
1742
- initialSearchClientResponseItems: [],
1743
- isPopoverVisible: false,
1744
- isSearchInProgress: false,
1745
- rangeValueForIndexFields: {},
1746
- searchTerm: '',
1747
- searchMode: 'fuzzy',
1748
- searchClientRequest: undefined,
1749
- searchClientResponseItems: [],
1750
- searchResponseTimeTaken: undefined,
1751
- searchResponseFacetPrime: undefined,
1752
- supplementalFacetPrime: undefined,
1753
- searchResultsCount: 0,
1754
- searchResultsPerPage: 20,
1755
- searchResultsPage: 1,
1756
- sortType: undefined,
1757
- orderByField: undefined,
1758
- // Callbacks
1759
- afterInit: () => { },
1760
- };
1761
- const searchcraftStore = zustand.createStore((_set, get) => {
1762
- const functions = {
1763
- set: (state) => {
1764
- _set(state);
1765
- return get();
1766
- },
1767
- addFacetPathsForIndexField: (facetPaths) => functions.set((state) => ({
1768
- facetPathsForIndexFields: {
1769
- ...state.facetPathsForIndexFields,
1770
- [facetPaths.fieldName]: facetPaths,
1771
- },
1772
- })),
1773
- addRangeValueForIndexField: (rangeValue) => functions.set((state) => ({
1774
- rangeValueForIndexFields: {
1775
- ...state.rangeValueForIndexFields,
1776
- [rangeValue.fieldName]: rangeValue,
1777
- },
1778
- })),
1779
- getSearchcraftCore: () => {
1780
- const { core } = get();
1781
- return core;
1782
- },
1783
- init: (core, debug = false) => {
1784
- const logger = debug
1785
- ? new pe({ logLevel: D.DEBUG })
1786
- : undefined;
1787
- const state = functions.set({
1788
- core,
1789
- logger,
1790
- searchResultsPerPage: core?.config.searchResultsPerPage || 20,
1791
- });
1792
- core?.subscribe('initialized', () => {
1793
- if (state.afterInit) {
1794
- state.afterInit(state);
1795
- }
1796
- });
1797
- },
1798
- removeFacetPathsForIndexField: (fieldName) => functions.set((state) => {
1799
- const currentPaths = state.facetPathsForIndexFields;
1800
- delete currentPaths[fieldName];
1801
- return {
1802
- facetPathsForIndexFields: {
1803
- ...currentPaths,
1804
- },
1805
- };
1806
- }),
1807
- removeRangeValueForIndexField: (fieldName) => functions.set((state) => {
1808
- const currentValues = state.rangeValueForIndexFields;
1809
- delete currentValues[fieldName];
1810
- return {
1811
- rangeValueForIndexFields: {
1812
- ...currentValues,
1813
- },
1814
- };
1815
- }),
1816
- resetFacetPaths: () => {
1817
- functions.set({
1818
- facetPathsForIndexFields: {},
1819
- });
1820
- },
1821
- search: async () => {
1822
- const state = get();
1823
- state.logger?.log(D.INFO, `Starting search with search term: "${state.searchTerm}"`);
1824
- if (!state.core) {
1825
- throw new Error('Searchcraft instance is not initialized.');
1826
- }
1827
- if (!state.searchTerm.trim()) {
1828
- state.logger?.log(D.INFO, 'No search request was made: search term was empty.');
1829
- functions.set({
1830
- searchClientResponseItems: [],
1831
- searchResultsCount: 0,
1832
- searchResultsPage: 1,
1833
- searchTerm: '',
1834
- });
1835
- return;
1836
- }
1837
- functions.set({ isSearchInProgress: true });
1838
- state.core.getResponseItems({
1839
- searchTerm: state.searchTerm,
1840
- mode: state.searchMode,
1841
- sort: state.sortType,
1842
- order_by: state.orderByField,
1843
- facetPathsForIndexFields: state.facetPathsForIndexFields,
1844
- rangeValueForIndexFields: state.rangeValueForIndexFields,
1845
- offset: state.searchResultsPerPage
1846
- ? state.searchResultsPerPage * (state.searchResultsPage - 1)
1847
- : 0,
1848
- limit: state.searchResultsPerPage,
1849
- }, functions.setSearchClientResponseItemsFromResponse, functions.setAdClientResponseItems);
1850
- },
1851
- setAdClientResponseItems: (items) => functions.set({ adClientResponseItems: items }),
1852
- setSearchClientResponseItemsFromResponse: (request, response, items, supplementalResponse) => {
1853
- const { facets, count = 0, time_taken = 0 } = response.data;
1854
- const state = functions.set((state) => {
1855
- return {
1856
- isSearchInProgress: false,
1857
- searchClientResponseItems: items,
1858
- searchResponseTimeTaken: time_taken,
1859
- searchResultsPage:
1860
- // Reset to first page when response count changes
1861
- count === state.searchResultsCount ? state.searchResultsPage : 1,
1862
- searchResultsCount: count,
1863
- searchResponseFacetPrime: facets,
1864
- supplementalFacetPrime: supplementalResponse?.data.facets,
1865
- searchClientRequest: request,
1866
- };
1867
- });
1868
- state.logger?.log(D.DEBUG, `Search results: ${JSON.stringify(items)}`);
1869
- state.logger?.log(D.DEBUG, `Facets from response: ${JSON.stringify(facets)}`);
1870
- },
1871
- setInitialSearchClientResponseItemsFromResponse: (request, response, items) => {
1872
- const state = get();
1873
- const { count = 0, time_taken = 0 } = response.data;
1874
- functions.set((state) => {
1875
- return {
1876
- isSearchInProgress: false,
1877
- initialSearchClientResponseItems: items,
1878
- searchResponseTimeTaken: time_taken,
1879
- searchResultsPage:
1880
- // Reset to first page when response count changes
1881
- count === state.searchResultsCount ? state.searchResultsPage : 1,
1882
- searchResultsCount: count,
1883
- searchClientRequest: request,
1884
- };
1885
- });
1886
- state.logger?.log(D.DEBUG, `Search results: ${JSON.stringify(items)}`);
1887
- },
1888
- setInitialQuery: async (query) => {
1889
- const state = functions.set({ initialQuery: query });
1890
- state.logger?.log(D.INFO, `Starting search with query: "${state.initialQuery}"`);
1891
- if (!state.core) {
1892
- throw new Error('Searchcraft instance is not initialized.');
1893
- }
1894
- await state.core.getResponseItems(query, functions.setInitialSearchClientResponseItemsFromResponse, functions.setAdClientResponseItems);
1895
- },
1896
- setPopoverVisibility: (isVisible) => functions.set({
1897
- isPopoverVisible: isVisible,
1898
- }),
1899
- setSearchMode: (mode) => functions.set({ searchMode: mode }),
1900
- setSortOrder: ({ orderByField, sortType }) => functions.set({ sortType, orderByField }),
1901
- setSearchTerm: (searchTerm) => {
1902
- const { core } = get();
1903
- if (searchTerm.length === 0) {
1904
- core?.handleInputCleared();
1905
- }
1906
- /**
1907
- * When a new searchTerm is set, also reset the sort type, search mode, and facet paths.
1908
- */
1909
- functions.set({
1910
- searchTerm,
1911
- });
1912
- },
1913
- setSearchClientResponseItems: (items) => functions.set({ searchClientResponseItems: items }),
1914
- setSearchResultsCount: (count) => functions.set({ searchResultsCount: count }),
1915
- setSearchResultsPage: async (page) => {
1916
- functions.set({ searchResultsPage: page });
1917
- await functions.search();
1918
- },
1919
- setSearchResultsPerPage: async (perPage) => {
1920
- functions.set({ searchResultsPerPage: perPage });
1921
- await functions.search();
1922
- },
1923
- setHotKeyAndHotKeyModifier: (hotkey, hotkeyModifier) => {
1924
- const { hotkey: initialHotkey, hotkeyModifier: initialHotkeyModifier } = initialSearchcraftStateValues;
1925
- functions.set({
1926
- hotkey: hotkey || initialHotkey,
1927
- hotkeyModifier: hotkeyModifier || initialHotkeyModifier,
1928
- });
1929
- },
1930
- };
1931
- const stateObject = {
1932
- ...initialSearchcraftStateValues,
1933
- ...functions,
1934
- };
1935
- return stateObject;
1936
- });
1937
-
1938
- export { searchcraftStore as s, ve as v };
1939
-
1940
- //# sourceMappingURL=p-062d6b80.js.map