@smg-automotive/filters 2.1.0 → 2.1.1-fix-declarations.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/cjs/index.js +629 -735
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/esm/index.js +630 -736
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/index.d.ts +436 -20
  6. package/dist/translations.cjs.js +5 -5
  7. package/dist/translations.cjs.js.map +1 -1
  8. package/dist/translations.esm.js +5 -5
  9. package/dist/translations.esm.js.map +1 -1
  10. package/package.json +7 -5
  11. package/dist/api/filtersClient.d.ts +0 -1
  12. package/dist/cjs/api/filtersClient.d.ts +0 -1
  13. package/dist/cjs/contexts/Filter.d.ts +0 -15
  14. package/dist/cjs/filters/__tests__/createTestFilterComponent.d.ts +0 -23
  15. package/dist/cjs/filters/__tests__/createTestHistogramRanges.d.ts +0 -2
  16. package/dist/cjs/filters/__tests__/createTestReferenceData.d.ts +0 -8
  17. package/dist/cjs/filters/useBatteryHealthPercentageFilter.d.ts +0 -3
  18. package/dist/cjs/filters/useBodyTypeFilter.d.ts +0 -6
  19. package/dist/cjs/filters/useConditionTypeFilter.d.ts +0 -4
  20. package/dist/cjs/filters/useDriveTypeFilter.d.ts +0 -4
  21. package/dist/cjs/filters/useFirstRegistrationYearFilter.d.ts +0 -3
  22. package/dist/cjs/filters/useFuelTypeFilter.d.ts +0 -4
  23. package/dist/cjs/filters/useHasBatteryCertificateKeyOnlyFilter.d.ts +0 -5
  24. package/dist/cjs/filters/useMileageFilter.d.ts +0 -3
  25. package/dist/cjs/filters/usePriceFilter.d.ts +0 -3
  26. package/dist/cjs/filters/useTransmissionTypeFilter.d.ts +0 -4
  27. package/dist/cjs/hooks/useBooleanFilter.d.ts +0 -24
  28. package/dist/cjs/hooks/useCheckboxFilter.d.ts +0 -22
  29. package/dist/cjs/hooks/useCheckboxFilterReducer.d.ts +0 -49
  30. package/dist/cjs/hooks/useRangeFilter.d.ts +0 -50
  31. package/dist/cjs/index.d.ts +0 -20
  32. package/dist/cjs/translations/index.d.ts +0 -11
  33. package/dist/cjs/types/brand.d.ts +0 -4
  34. package/dist/cjs/types/enums.d.ts +0 -206
  35. package/dist/cjs/types/facets.d.ts +0 -14
  36. package/dist/cjs/types/interval.d.ts +0 -7
  37. package/dist/cjs/types/query.d.ts +0 -104
  38. package/dist/cjs/types/referenceData.d.ts +0 -23
  39. package/dist/cjs/types/useFilter.d.ts +0 -39
  40. package/dist/cjs/utilities/__tests__/scales.d.ts +0 -1
  41. package/dist/cjs/utilities/boolean.d.ts +0 -8
  42. package/dist/cjs/utilities/checkbox.d.ts +0 -63
  43. package/dist/cjs/utilities/cleanQuery.d.ts +0 -98
  44. package/dist/cjs/utilities/fetchReferenceData.d.ts +0 -2
  45. package/dist/cjs/utilities/fetchSearchConfiguration.d.ts +0 -2
  46. package/dist/cjs/utilities/formatWithUnit.d.ts +0 -28
  47. package/dist/cjs/utilities/isInArray.d.ts +0 -1
  48. package/dist/cjs/utilities/range.d.ts +0 -51
  49. package/dist/cjs/utilities/resetAllFilters.d.ts +0 -2
  50. package/dist/cjs/utilities/scales.d.ts +0 -5
  51. package/dist/contexts/Filter.d.ts +0 -15
  52. package/dist/esm/api/filtersClient.d.ts +0 -1
  53. package/dist/esm/contexts/Filter.d.ts +0 -15
  54. package/dist/esm/filters/__tests__/createTestFilterComponent.d.ts +0 -23
  55. package/dist/esm/filters/__tests__/createTestHistogramRanges.d.ts +0 -2
  56. package/dist/esm/filters/__tests__/createTestReferenceData.d.ts +0 -8
  57. package/dist/esm/filters/useBatteryHealthPercentageFilter.d.ts +0 -3
  58. package/dist/esm/filters/useBodyTypeFilter.d.ts +0 -6
  59. package/dist/esm/filters/useConditionTypeFilter.d.ts +0 -4
  60. package/dist/esm/filters/useDriveTypeFilter.d.ts +0 -4
  61. package/dist/esm/filters/useFirstRegistrationYearFilter.d.ts +0 -3
  62. package/dist/esm/filters/useFuelTypeFilter.d.ts +0 -4
  63. package/dist/esm/filters/useHasBatteryCertificateKeyOnlyFilter.d.ts +0 -5
  64. package/dist/esm/filters/useMileageFilter.d.ts +0 -3
  65. package/dist/esm/filters/usePriceFilter.d.ts +0 -3
  66. package/dist/esm/filters/useTransmissionTypeFilter.d.ts +0 -4
  67. package/dist/esm/hooks/useBooleanFilter.d.ts +0 -24
  68. package/dist/esm/hooks/useCheckboxFilter.d.ts +0 -22
  69. package/dist/esm/hooks/useCheckboxFilterReducer.d.ts +0 -49
  70. package/dist/esm/hooks/useRangeFilter.d.ts +0 -50
  71. package/dist/esm/index.d.ts +0 -20
  72. package/dist/esm/translations/index.d.ts +0 -11
  73. package/dist/esm/types/brand.d.ts +0 -4
  74. package/dist/esm/types/enums.d.ts +0 -206
  75. package/dist/esm/types/facets.d.ts +0 -14
  76. package/dist/esm/types/interval.d.ts +0 -7
  77. package/dist/esm/types/query.d.ts +0 -104
  78. package/dist/esm/types/referenceData.d.ts +0 -23
  79. package/dist/esm/types/useFilter.d.ts +0 -39
  80. package/dist/esm/utilities/__tests__/scales.d.ts +0 -1
  81. package/dist/esm/utilities/boolean.d.ts +0 -8
  82. package/dist/esm/utilities/checkbox.d.ts +0 -63
  83. package/dist/esm/utilities/cleanQuery.d.ts +0 -98
  84. package/dist/esm/utilities/fetchReferenceData.d.ts +0 -2
  85. package/dist/esm/utilities/fetchSearchConfiguration.d.ts +0 -2
  86. package/dist/esm/utilities/formatWithUnit.d.ts +0 -28
  87. package/dist/esm/utilities/isInArray.d.ts +0 -1
  88. package/dist/esm/utilities/range.d.ts +0 -51
  89. package/dist/esm/utilities/resetAllFilters.d.ts +0 -2
  90. package/dist/esm/utilities/scales.d.ts +0 -5
  91. package/dist/filters/__tests__/createTestFilterComponent.d.ts +0 -23
  92. package/dist/filters/__tests__/createTestHistogramRanges.d.ts +0 -2
  93. package/dist/filters/__tests__/createTestReferenceData.d.ts +0 -8
  94. package/dist/filters/useBatteryHealthPercentageFilter.d.ts +0 -3
  95. package/dist/filters/useBodyTypeFilter.d.ts +0 -6
  96. package/dist/filters/useConditionTypeFilter.d.ts +0 -4
  97. package/dist/filters/useDriveTypeFilter.d.ts +0 -4
  98. package/dist/filters/useFirstRegistrationYearFilter.d.ts +0 -3
  99. package/dist/filters/useFuelTypeFilter.d.ts +0 -4
  100. package/dist/filters/useHasBatteryCertificateKeyOnlyFilter.d.ts +0 -5
  101. package/dist/filters/useMileageFilter.d.ts +0 -3
  102. package/dist/filters/usePriceFilter.d.ts +0 -3
  103. package/dist/filters/useTransmissionTypeFilter.d.ts +0 -4
  104. package/dist/hooks/useBooleanFilter.d.ts +0 -24
  105. package/dist/hooks/useCheckboxFilter.d.ts +0 -22
  106. package/dist/hooks/useCheckboxFilterReducer.d.ts +0 -49
  107. package/dist/hooks/useRangeFilter.d.ts +0 -50
  108. package/dist/translations/index.d.ts +0 -11
  109. package/dist/types/brand.d.ts +0 -4
  110. package/dist/types/enums.d.ts +0 -206
  111. package/dist/types/facets.d.ts +0 -14
  112. package/dist/types/interval.d.ts +0 -7
  113. package/dist/types/query.d.ts +0 -104
  114. package/dist/types/referenceData.d.ts +0 -23
  115. package/dist/types/useFilter.d.ts +0 -39
  116. package/dist/utilities/__tests__/scales.d.ts +0 -1
  117. package/dist/utilities/boolean.d.ts +0 -8
  118. package/dist/utilities/checkbox.d.ts +0 -63
  119. package/dist/utilities/cleanQuery.d.ts +0 -98
  120. package/dist/utilities/fetchReferenceData.d.ts +0 -2
  121. package/dist/utilities/fetchSearchConfiguration.d.ts +0 -2
  122. package/dist/utilities/formatWithUnit.d.ts +0 -28
  123. package/dist/utilities/isInArray.d.ts +0 -1
  124. package/dist/utilities/range.d.ts +0 -51
  125. package/dist/utilities/resetAllFilters.d.ts +0 -2
  126. package/dist/utilities/scales.d.ts +0 -5
package/dist/cjs/index.js CHANGED
@@ -216,131 +216,37 @@ exports.LicenseCategory = void 0;
216
216
  LicenseCategory["M"] = "m";
217
217
  })(exports.LicenseCategory || (exports.LicenseCategory = {}));
218
218
 
219
- var FilterContext = React.createContext(null);
220
- var useFilterContext = function () {
221
- var context = React.useContext(FilterContext);
219
+ const FilterContext = React.createContext(null);
220
+ const useFilterContext = () => {
221
+ const context = React.useContext(FilterContext);
222
222
  if (!context) {
223
223
  throw new Error('useFilterContext must be used within a FilterProvider');
224
224
  }
225
225
  return context;
226
226
  };
227
- var FilterProvider = function (_a) {
228
- var t = _a.t, histogramRanges = _a.histogramRanges, brand = _a.brand, referenceData = _a.referenceData, language = _a.language, children = _a.children;
229
- var context = React.useMemo(function () { return ({
230
- t: t,
231
- brand: brand,
232
- histogramRanges: histogramRanges,
233
- referenceData: referenceData,
234
- language: language,
235
- }); }, [t, brand, histogramRanges, referenceData, language]);
227
+ const FilterProvider = ({ t, histogramRanges, brand, referenceData, language, children, }) => {
228
+ const context = React.useMemo(() => ({
229
+ t,
230
+ brand,
231
+ histogramRanges,
232
+ referenceData,
233
+ language,
234
+ }), [t, brand, histogramRanges, referenceData, language]);
236
235
  return (React.createElement(FilterContext.Provider, { value: context }, children));
237
236
  };
238
237
 
239
- var resetAllFilters = function () {
238
+ const resetAllFilters = () => {
240
239
  if (typeof window !== 'undefined') {
241
240
  window.dispatchEvent(new Event('reset-all-filters'));
242
241
  }
243
242
  };
244
- var useResetAllFilters = function (reset) {
245
- React.useEffect(function () {
243
+ const useResetAllFilters = (reset) => {
244
+ React.useEffect(() => {
246
245
  window.addEventListener('reset-all-filters', reset);
247
- return function () { return window.removeEventListener('reset-all-filters', reset); };
246
+ return () => window.removeEventListener('reset-all-filters', reset);
248
247
  }, [reset]);
249
248
  };
250
249
 
251
- /******************************************************************************
252
- Copyright (c) Microsoft Corporation.
253
-
254
- Permission to use, copy, modify, and/or distribute this software for any
255
- purpose with or without fee is hereby granted.
256
-
257
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
258
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
259
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
260
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
261
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
262
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
263
- PERFORMANCE OF THIS SOFTWARE.
264
- ***************************************************************************** */
265
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
266
-
267
-
268
- var __assign = function() {
269
- __assign = Object.assign || function __assign(t) {
270
- for (var s, i = 1, n = arguments.length; i < n; i++) {
271
- s = arguments[i];
272
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
273
- }
274
- return t;
275
- };
276
- return __assign.apply(this, arguments);
277
- };
278
-
279
- function __rest(s, e) {
280
- var t = {};
281
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
282
- t[p] = s[p];
283
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
284
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
285
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
286
- t[p[i]] = s[p[i]];
287
- }
288
- return t;
289
- }
290
-
291
- function __awaiter(thisArg, _arguments, P, generator) {
292
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
293
- return new (P || (P = Promise))(function (resolve, reject) {
294
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
295
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
296
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
297
- step((generator = generator.apply(thisArg, _arguments || [])).next());
298
- });
299
- }
300
-
301
- function __generator(thisArg, body) {
302
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
303
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
304
- function verb(n) { return function (v) { return step([n, v]); }; }
305
- function step(op) {
306
- if (f) throw new TypeError("Generator is already executing.");
307
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
308
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
309
- if (y = 0, t) op = [op[0] & 2, t.value];
310
- switch (op[0]) {
311
- case 0: case 1: t = op; break;
312
- case 4: _.label++; return { value: op[1], done: false };
313
- case 5: _.label++; y = op[1]; op = [0]; continue;
314
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
315
- default:
316
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
317
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
318
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
319
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
320
- if (t[2]) _.ops.pop();
321
- _.trys.pop(); continue;
322
- }
323
- op = body.call(thisArg, _);
324
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
325
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
326
- }
327
- }
328
-
329
- function __spreadArray(to, from, pack) {
330
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
331
- if (ar || !(i in from)) {
332
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
333
- ar[i] = from[i];
334
- }
335
- }
336
- return to.concat(ar || Array.prototype.slice.call(from));
337
- }
338
-
339
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
340
- var e = new Error(message);
341
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
342
- };
343
-
344
250
  var Brand;
345
251
  (function (Brand) {
346
252
  Brand["AutoScout24"] = "autoscout24";
@@ -348,17 +254,16 @@ var Brand;
348
254
  })(Brand || (Brand = {}));
349
255
 
350
256
  /** @internal */
351
- var filtersClient = apiClientPkg.ApiClient({
352
- baseUrl: "https://".concat(process.env.API_ROOT, "/").concat(process.env.API_VERSION),
257
+ const filtersClient = apiClientPkg.ApiClient({
258
+ baseUrl: `https://${process.env.API_ROOT}/${process.env.API_VERSION}`,
353
259
  });
354
260
 
355
261
  function transformSearchConfigurationResponse(data) {
356
- var result = {};
357
- for (var _i = 0, _a = Object.keys(data); _i < _a.length; _i++) {
358
- var key = _a[_i];
359
- var arr = data[key];
262
+ const result = {};
263
+ for (const key of Object.keys(data)) {
264
+ const arr = data[key];
360
265
  if (Array.isArray(arr)) {
361
- result[key] = arr.reduce(function (acc, value) {
266
+ result[key] = arr.reduce((acc, value) => {
362
267
  acc[value] = 0;
363
268
  return acc;
364
269
  }, {});
@@ -366,46 +271,28 @@ function transformSearchConfigurationResponse(data) {
366
271
  }
367
272
  return result;
368
273
  }
369
- var brands = [Brand.AutoScout24, Brand.MotoScout24];
370
- function fetchSearchConfiguration() {
371
- return __awaiter(this, void 0, void 0, function () {
372
- var _a, autoscout24Data, motoscout24Data;
373
- var _b;
374
- var _this = this;
375
- return __generator(this, function (_c) {
376
- switch (_c.label) {
377
- case 0: return [4 /*yield*/, Promise.all(brands.map(function (brand) { return __awaiter(_this, void 0, void 0, function () {
378
- var response, body;
379
- return __generator(this, function (_a) {
380
- switch (_a.label) {
381
- case 0: return [4 /*yield*/, filtersClient
382
- .path('search-configuration')
383
- .get({ searchParams: { brand: brand } })];
384
- case 1:
385
- response = _a.sent();
386
- if (!response.ok) {
387
- throw new Error("Failed to fetch search configuration for ".concat(brand, ": ").concat(response.status));
388
- }
389
- body = response.body;
390
- if (!body) {
391
- throw new Error("Empty search configuration response for brand ".concat(brand));
392
- }
393
- return [2 /*return*/, transformSearchConfigurationResponse(body)];
394
- }
395
- });
396
- }); }))];
397
- case 1:
398
- _a = _c.sent(), autoscout24Data = _a[0], motoscout24Data = _a[1];
399
- return [2 /*return*/, (_b = {},
400
- _b[Brand.AutoScout24] = autoscout24Data,
401
- _b[Brand.MotoScout24] = motoscout24Data,
402
- _b)];
403
- }
404
- });
405
- });
274
+ const brands = [Brand.AutoScout24, Brand.MotoScout24];
275
+ async function fetchSearchConfiguration() {
276
+ const [autoscout24Data, motoscout24Data] = await Promise.all(brands.map(async (brand) => {
277
+ const response = await filtersClient
278
+ .path('search-configuration')
279
+ .get({ searchParams: { brand } });
280
+ if (!response.ok) {
281
+ throw new Error(`Failed to fetch search configuration for ${brand}: ${response.status}`);
282
+ }
283
+ const body = response.body;
284
+ if (!body) {
285
+ throw new Error(`Empty search configuration response for brand ${brand}`);
286
+ }
287
+ return transformSearchConfigurationResponse(body);
288
+ }));
289
+ return {
290
+ [Brand.AutoScout24]: autoscout24Data,
291
+ [Brand.MotoScout24]: motoscout24Data,
292
+ };
406
293
  }
407
294
 
408
- var vehicleCategories = [
295
+ const vehicleCategories = [
409
296
  exports.VehicleCategory.Car,
410
297
  exports.VehicleCategory.Utility,
411
298
  exports.VehicleCategory.Motorcycle,
@@ -413,46 +300,28 @@ var vehicleCategories = [
413
300
  exports.VehicleCategory.Trailer,
414
301
  exports.VehicleCategory.Camper,
415
302
  ];
416
- function fetchReferenceData() {
417
- return __awaiter(this, void 0, void 0, function () {
418
- var _a, car, utility, motorcycle, truck, trailer, camper;
419
- var _b;
420
- var _this = this;
421
- return __generator(this, function (_c) {
422
- switch (_c.label) {
423
- case 0: return [4 /*yield*/, Promise.all(vehicleCategories.map(function (vehicleCategory) { return __awaiter(_this, void 0, void 0, function () {
424
- var response, body;
425
- return __generator(this, function (_a) {
426
- switch (_a.label) {
427
- case 0: return [4 /*yield*/, filtersClient
428
- .path('reference-data')
429
- .get({ searchParams: { vehicleCategory: vehicleCategory } })];
430
- case 1:
431
- response = _a.sent();
432
- if (!response.ok) {
433
- throw new Error("Failed to fetch reference data for ".concat(vehicleCategory, ": ").concat(response.status));
434
- }
435
- body = response.body;
436
- if (!body) {
437
- throw new Error("Empty reference data response for vehicle category ".concat(vehicleCategory));
438
- }
439
- return [2 /*return*/, body];
440
- }
441
- });
442
- }); }))];
443
- case 1:
444
- _a = _c.sent(), car = _a[0], utility = _a[1], motorcycle = _a[2], truck = _a[3], trailer = _a[4], camper = _a[5];
445
- return [2 /*return*/, (_b = {},
446
- _b[exports.VehicleCategory.Car] = car,
447
- _b[exports.VehicleCategory.Utility] = utility,
448
- _b[exports.VehicleCategory.Motorcycle] = motorcycle,
449
- _b[exports.VehicleCategory.Truck] = truck,
450
- _b[exports.VehicleCategory.Trailer] = trailer,
451
- _b[exports.VehicleCategory.Camper] = camper,
452
- _b)];
453
- }
454
- });
455
- });
303
+ async function fetchReferenceData() {
304
+ const [car, utility, motorcycle, truck, trailer, camper] = await Promise.all(vehicleCategories.map(async (vehicleCategory) => {
305
+ const response = await filtersClient
306
+ .path('reference-data')
307
+ .get({ searchParams: { vehicleCategory } });
308
+ if (!response.ok) {
309
+ throw new Error(`Failed to fetch reference data for ${vehicleCategory}: ${response.status}`);
310
+ }
311
+ const body = response.body;
312
+ if (!body) {
313
+ throw new Error(`Empty reference data response for vehicle category ${vehicleCategory}`);
314
+ }
315
+ return body;
316
+ }));
317
+ return {
318
+ [exports.VehicleCategory.Car]: car,
319
+ [exports.VehicleCategory.Utility]: utility,
320
+ [exports.VehicleCategory.Motorcycle]: motorcycle,
321
+ [exports.VehicleCategory.Truck]: truck,
322
+ [exports.VehicleCategory.Trailer]: trailer,
323
+ [exports.VehicleCategory.Camper]: camper,
324
+ };
456
325
  }
457
326
 
458
327
  var batteryHealthPercentage$3 = "Batteria (SoH)";
@@ -935,18 +804,18 @@ var de = {
935
804
  "bodyType.wood-transporter": "Holz-Transporter"
936
805
  };
937
806
 
938
- var filterTranslationsDe = de;
939
- var filterTranslationsEn = en;
940
- var filterTranslationsFr = fr;
941
- var filterTranslationsIt = it;
942
- var filterTranslations = {
807
+ const filterTranslationsDe = de;
808
+ const filterTranslationsEn = en;
809
+ const filterTranslationsFr = fr;
810
+ const filterTranslationsIt = it;
811
+ const filterTranslations = {
943
812
  de: filterTranslationsDe,
944
813
  en: filterTranslationsEn,
945
814
  fr: filterTranslationsFr,
946
815
  it: filterTranslationsIt,
947
816
  };
948
817
 
949
- var validQueryKeys = {
818
+ const validQueryKeys = {
950
819
  ageFrom: true,
951
820
  availableForExchangeOnly: true,
952
821
  axisFrom: true,
@@ -1042,26 +911,23 @@ var validQueryKeys = {
1042
911
  weightTotalFrom: true,
1043
912
  weightTotalTo: true,
1044
913
  };
1045
- var cleanQuery = function (query) {
1046
- var _a;
1047
- var acc = {};
1048
- for (var _i = 0, _b = Object.keys(query); _i < _b.length; _i++) {
1049
- var key = _b[_i];
914
+ const cleanQuery = (query) => {
915
+ const acc = {};
916
+ for (const key of Object.keys(query)) {
1050
917
  if (key in validQueryKeys) {
1051
- Object.assign(acc, (_a = {}, _a[key] = query[key], _a));
918
+ Object.assign(acc, { [key]: query[key] });
1052
919
  }
1053
920
  }
1054
921
  return acc;
1055
922
  };
1056
923
 
1057
- var convertIntervalListToFacetRange = function (intervalList) {
1058
- var generatedFacetRanges = [];
1059
- intervalList.forEach(function (_a) {
1060
- var from = _a.from, to = _a.to, increment = _a.increment;
1061
- var currentRangeFrom = from;
924
+ const convertIntervalListToFacetRange = (intervalList) => {
925
+ const generatedFacetRanges = [];
926
+ intervalList.forEach(({ from, to, increment }) => {
927
+ let currentRangeFrom = from;
1062
928
  while (currentRangeFrom < to) {
1063
- var currentRangeTo = Math.min(currentRangeFrom + increment, to);
1064
- var rangeKey = "".concat(currentRangeFrom, "-").concat(currentRangeTo);
929
+ const currentRangeTo = Math.min(currentRangeFrom + increment, to);
930
+ const rangeKey = `${currentRangeFrom}-${currentRangeTo}`;
1065
931
  generatedFacetRanges.push({
1066
932
  from: currentRangeFrom,
1067
933
  to: currentRangeTo,
@@ -1070,55 +936,52 @@ var convertIntervalListToFacetRange = function (intervalList) {
1070
936
  currentRangeFrom = currentRangeTo;
1071
937
  }
1072
938
  });
1073
- var lastIntervalTo = intervalList[intervalList.length - 1].to;
939
+ const { to: lastIntervalTo } = intervalList[intervalList.length - 1];
1074
940
  generatedFacetRanges.push({
1075
941
  from: lastIntervalTo,
1076
942
  to: undefined,
1077
- key: "".concat(lastIntervalTo, "-*"),
943
+ key: `${lastIntervalTo}-*`,
1078
944
  });
1079
945
  return generatedFacetRanges;
1080
946
  };
1081
- var convertIntervalListToRangeSliderScale = function (intervalList) { return convertIntervalListToFacetRange(intervalList).map(function (_a) {
1082
- var from = _a.from;
1083
- return from;
1084
- }); };
1085
- var batteryHealthPercentageScale = convertIntervalListToRangeSliderScale([{ from: 10, to: 100, increment: 5 }]);
947
+ const convertIntervalListToRangeSliderScale = (intervalList) => convertIntervalListToFacetRange(intervalList).map(({ from }) => from);
948
+ const batteryHealthPercentageScale = convertIntervalListToRangeSliderScale([{ from: 10, to: 100, increment: 5 }]);
1086
949
 
1087
- var Unit = {
950
+ const Unit = {
1088
951
  kilometers: 'km',
1089
952
  swissFrancs: 'CHF',
1090
953
  percentage: '%',
1091
954
  };
1092
- var formatNumber = function (value) {
955
+ const formatNumber = (value) => {
1093
956
  return (value || 0).toLocaleString('de-ch').replace(/’/g, "'");
1094
957
  };
1095
- var formatPriceWithCurrency = function (price, options) {
1096
- if (options === void 0) { options = { minimumFractionDigits: 2, maximumFractionDigits: 2 }; }
1097
- return typeof price === 'number' && !Number.isNaN(price)
1098
- ? price
1099
- .toLocaleString('de-ch', __assign(__assign({}, options), { currency: 'CHF', currencyDisplay: 'symbol', style: 'currency' }))
1100
- .replace('.00', '.–')
1101
- .replace(/’/g, "'")
1102
- : null;
1103
- };
1104
- var formatValueWithUnit = function (_a) {
1105
- var _b, _c;
1106
- var value = _a.value, unit = _a.unit, _d = _a.options, options = _d === void 0 ? { thousandSeparator: true } : _d;
1107
- var parsedValue = parseFloat(value);
958
+ const formatPriceWithCurrency = (price, options = { minimumFractionDigits: 2, maximumFractionDigits: 2 }) => typeof price === 'number' && !Number.isNaN(price)
959
+ ? price
960
+ .toLocaleString('de-ch', {
961
+ ...options,
962
+ currency: 'CHF',
963
+ currencyDisplay: 'symbol',
964
+ style: 'currency',
965
+ })
966
+ .replace('.00', '.–')
967
+ .replace(/’/g, "'")
968
+ : null;
969
+ const formatValueWithUnit = ({ value, unit, options = { thousandSeparator: true }, }) => {
970
+ const parsedValue = parseFloat(value);
1108
971
  if (Number.isNaN(parsedValue)) {
1109
972
  return null;
1110
973
  }
1111
974
  if (unit === Unit.swissFrancs) {
1112
975
  return formatPriceWithCurrency(parsedValue, {
1113
- maximumFractionDigits: (_b = options === null || options === void 0 ? void 0 : options.fixedDecimalSpaces) !== null && _b !== void 0 ? _b : 0,
1114
- minimumFractionDigits: (_c = options === null || options === void 0 ? void 0 : options.fixedDecimalSpaces) !== null && _c !== void 0 ? _c : 0,
976
+ maximumFractionDigits: options?.fixedDecimalSpaces ?? 0,
977
+ minimumFractionDigits: options?.fixedDecimalSpaces ?? 0,
1115
978
  });
1116
979
  }
1117
- var formattedNumber = value;
1118
- if (options === null || options === void 0 ? void 0 : options.fixedDecimalSpaces) {
980
+ let formattedNumber = value;
981
+ if (options?.fixedDecimalSpaces) {
1119
982
  formattedNumber = parsedValue.toFixed(options.fixedDecimalSpaces);
1120
983
  }
1121
- if (options === null || options === void 0 ? void 0 : options.thousandSeparator) {
984
+ if (options?.thousandSeparator) {
1122
985
  formattedNumber = parsedValue
1123
986
  .toLocaleString('de-ch', {
1124
987
  maximumFractionDigits: options.fixedDecimalSpaces,
@@ -1126,26 +989,24 @@ var formatValueWithUnit = function (_a) {
1126
989
  })
1127
990
  .replace(/’/g, "'");
1128
991
  }
1129
- return "".concat(formattedNumber, " ").concat(unit);
992
+ return `${formattedNumber} ${unit}`;
1130
993
  };
1131
994
 
1132
- var getRangeDisplayValue = function (_a) {
1133
- var from = _a.from, to = _a.to, unit = _a.unit, t = _a.t;
1134
- var formatter = unit
1135
- ? function (value) { return formatValueWithUnit({ value: value, unit: unit }); }
1136
- : function (value) { return value; };
995
+ const getRangeDisplayValue = ({ from, to, unit, t, }) => {
996
+ const formatter = unit
997
+ ? (value) => formatValueWithUnit({ value, unit })
998
+ : (value) => value;
1137
999
  if (from && to)
1138
- return "".concat(formatter(from), " - ").concat(formatter(to));
1000
+ return `${formatter(from)} - ${formatter(to)}`;
1139
1001
  if (from)
1140
- return "".concat(t('filtersPkg.from'), " ").concat(formatter(from));
1002
+ return `${t('filtersPkg.from')} ${formatter(from)}`;
1141
1003
  if (to)
1142
- return "".concat(t('filtersPkg.to'), " ").concat(formatter(to));
1004
+ return `${t('filtersPkg.to')} ${formatter(to)}`;
1143
1005
  return null;
1144
1006
  };
1145
- var inRange = function (_a) {
1146
- var value = _a.value, minValue = _a.minValue, maxValue = _a.maxValue;
1147
- var hasMaxValue = typeof maxValue === 'number';
1148
- var hasMinValue = typeof minValue === 'number';
1007
+ const inRange = ({ value, minValue, maxValue, }) => {
1008
+ const hasMaxValue = typeof maxValue === 'number';
1009
+ const hasMinValue = typeof minValue === 'number';
1149
1010
  if (hasMaxValue && hasMinValue) {
1150
1011
  return value >= minValue && value <= maxValue;
1151
1012
  }
@@ -1157,145 +1018,140 @@ var inRange = function (_a) {
1157
1018
  }
1158
1019
  return true;
1159
1020
  };
1160
- var getMaxValueFromFacetRangeGroups = function (facets) {
1021
+ const getMaxValueFromFacetRangeGroups = (facets) => {
1161
1022
  if (!facets) {
1162
1023
  return '';
1163
1024
  }
1164
- var intervalList = Object.keys(facets).map(function (el) {
1165
- var _a = el.split('-'), to = _a[1];
1166
- var parsedStringToNumber = Number(to);
1025
+ const intervalList = Object.keys(facets).map((el) => {
1026
+ const [, to] = el.split('-');
1027
+ const parsedStringToNumber = Number(to);
1167
1028
  return Number.isFinite(parsedStringToNumber) ? parsedStringToNumber : 0;
1168
1029
  });
1169
- if (!(intervalList === null || intervalList === void 0 ? void 0 : intervalList.length))
1030
+ if (!intervalList?.length)
1170
1031
  return '';
1171
- var maxValue = Math.max.apply(Math, intervalList);
1172
- return "".concat(formatNumber(maxValue), "+");
1032
+ const maxValue = Math.max(...intervalList);
1033
+ return `${formatNumber(maxValue)}+`;
1173
1034
  };
1174
- var getMaxValueFromRangeSliderScale = function (scale, limit) {
1035
+ const getMaxValueFromRangeSliderScale = (scale, limit) => {
1175
1036
  if (!scale.length) {
1176
1037
  return '';
1177
1038
  }
1178
- var maxValue = Math.max.apply(Math, scale);
1179
- var formattedMaxValue = formatNumber(maxValue);
1039
+ const maxValue = Math.max(...scale);
1040
+ const formattedMaxValue = formatNumber(maxValue);
1180
1041
  if (maxValue === limit) {
1181
1042
  return formattedMaxValue;
1182
1043
  }
1183
- return "".concat(formattedMaxValue, "+");
1044
+ return `${formattedMaxValue}+`;
1184
1045
  };
1185
- var convertFacetRangesToHistogramFacet = function (_a) {
1186
- var defaultFacets = _a.defaultFacets, facets = _a.facets;
1046
+ const convertFacetRangesToHistogramFacet = ({ defaultFacets, facets, }) => {
1187
1047
  if (!defaultFacets) {
1188
1048
  return [];
1189
1049
  }
1190
- return Object.entries(defaultFacets).map(function (_a) {
1191
- var key = _a[0], value = _a[1];
1192
- var _b = key.split('-'), from = _b[0], to = _b[1];
1050
+ return Object.entries(defaultFacets).map(([key, value]) => {
1051
+ const [from, to] = key.split('-');
1193
1052
  return {
1194
1053
  from: Number(from),
1195
1054
  to: Number.isFinite(Number(to)) ? Number(to) : undefined,
1196
- value: (facets === null || facets === void 0 ? void 0 : facets[key]) || value,
1055
+ value: facets?.[key] || value,
1197
1056
  };
1198
1057
  });
1199
1058
  };
1200
- var getRangeSliderScale = function (defaultFacets) {
1059
+ const getRangeSliderScale = (defaultFacets) => {
1201
1060
  return Object.keys(defaultFacets)
1202
- .map(function (key) {
1203
- var _a = key.split('-'); _a[0]; var to = _a[1];
1061
+ .map((key) => {
1062
+ const [_from, to] = key.split('-');
1204
1063
  return Number(to);
1205
1064
  })
1206
1065
  .filter(Boolean);
1207
1066
  };
1208
- var getFacetConfig = function (_a) {
1209
- var brand = _a.brand, facets = _a.facets, loadHistogram = _a.loadHistogram, _b = _a.chartHeight, chartHeight = _b === void 0 ? '3xl' : _b, histogramRangesWithDefaultValue = _a.histogramRangesWithDefaultValue, name = _a.name;
1210
- var defaultFacets = (histogramRangesWithDefaultValue === null || histogramRangesWithDefaultValue === void 0 ? void 0 : histogramRangesWithDefaultValue[brand][name]) || {};
1211
- var histogramFacet = loadHistogram
1067
+ const getFacetConfig = ({ brand, facets, loadHistogram, chartHeight = '3xl', histogramRangesWithDefaultValue, name, }) => {
1068
+ const defaultFacets = histogramRangesWithDefaultValue?.[brand][name] || {};
1069
+ const histogramFacet = loadHistogram
1212
1070
  ? convertFacetRangesToHistogramFacet({
1213
- defaultFacets: defaultFacets,
1214
- facets: facets === null || facets === void 0 ? void 0 : facets[name],
1071
+ defaultFacets,
1072
+ facets: facets?.[name],
1215
1073
  })
1216
1074
  : null;
1217
- var scaleProps = loadHistogram && histogramFacet
1218
- ? { facets: histogramFacet, chartHeight: chartHeight }
1075
+ const scaleProps = loadHistogram && histogramFacet
1076
+ ? { facets: histogramFacet, chartHeight }
1219
1077
  : {
1220
1078
  rangeSliderScale: getRangeSliderScale(defaultFacets),
1221
1079
  };
1222
1080
  return {
1223
- defaultFacets: defaultFacets,
1224
- scaleProps: scaleProps,
1081
+ defaultFacets,
1082
+ scaleProps,
1225
1083
  };
1226
1084
  };
1227
1085
 
1228
- var useRangeFilter = function (_a) {
1229
- var _b;
1230
- var from = _a.from, to = _a.to, minValue = _a.minValue, maxValue = _a.maxValue, filters = _a.filters, onAddFilter = _a.onAddFilter, onChange = _a.onChange, unit = _a.unit, toPlaceholder = _a.toPlaceholder, fromPlaceholder = _a.fromPlaceholder;
1231
- var t = useFilterContext().t;
1232
- var filterFromValue = filters[from];
1233
- var filterToValue = filters[to];
1234
- var _c = React.useState((_b = {},
1235
- _b[from] = filterFromValue,
1236
- _b[to] = filterToValue,
1237
- _b)), range = _c[0], setRange = _c[1];
1238
- React.useEffect(function () {
1239
- setRange(function (prevState) {
1240
- var _a;
1086
+ const useRangeFilter = ({ from, to, minValue, maxValue, filters, onAddFilter, onChange, unit, toPlaceholder, fromPlaceholder, }) => {
1087
+ const { t } = useFilterContext();
1088
+ const filterFromValue = filters[from];
1089
+ const filterToValue = filters[to];
1090
+ const [range, setRange] = React.useState({
1091
+ [from]: filterFromValue,
1092
+ [to]: filterToValue,
1093
+ });
1094
+ React.useEffect(() => {
1095
+ setRange((prevState) => {
1241
1096
  if (prevState[from] === filterFromValue &&
1242
1097
  prevState[to] === filterToValue)
1243
1098
  return prevState;
1244
- return _a = {},
1245
- _a[from] = filterFromValue,
1246
- _a[to] = filterToValue,
1247
- _a;
1099
+ return {
1100
+ [from]: filterFromValue,
1101
+ [to]: filterToValue,
1102
+ };
1248
1103
  });
1249
1104
  }, [filterFromValue, filterToValue, from, to]);
1250
- var handleChange = function (_a) {
1251
- var _b;
1252
- var value = _a.value, name = _a.name, changeType = _a.changeType;
1253
- var isValid = function () {
1105
+ const handleChange = ({ value, name, changeType, }) => {
1106
+ const isValid = () => {
1254
1107
  if (!value)
1255
1108
  return true;
1256
- return inRange({ value: value, minValue: minValue, maxValue: maxValue });
1109
+ return inRange({ value, minValue, maxValue });
1257
1110
  };
1258
1111
  if (!isValid() || value === range[name])
1259
1112
  return;
1260
- var newState = __assign(__assign({}, range), (_b = {}, _b[name] = value !== null && value !== void 0 ? value : undefined, _b));
1113
+ const newState = {
1114
+ ...range,
1115
+ [name]: value ?? undefined,
1116
+ };
1261
1117
  setRange(newState);
1262
- onChange === null || onChange === void 0 ? void 0 : onChange(newState);
1118
+ onChange?.(newState);
1263
1119
  if (value && onAddFilter) {
1264
1120
  onAddFilter({
1265
1121
  appliedFilter: name,
1266
- value: value,
1122
+ value,
1267
1123
  formattedValue: unit
1268
- ? formatValueWithUnit({ value: value, unit: unit })
1124
+ ? formatValueWithUnit({ value, unit })
1269
1125
  : value.toString(),
1270
- changeType: changeType,
1126
+ changeType,
1271
1127
  });
1272
1128
  }
1273
1129
  };
1274
- var reset = function () {
1275
- var _a;
1276
- var resetQuery = (_a = {},
1277
- _a[from] = undefined,
1278
- _a[to] = undefined,
1279
- _a);
1130
+ const reset = () => {
1131
+ const resetQuery = {
1132
+ [from]: undefined,
1133
+ [to]: undefined,
1134
+ };
1280
1135
  setRange(resetQuery);
1281
1136
  return resetQuery;
1282
1137
  };
1283
1138
  useResetAllFilters(reset);
1284
- var valueFrom = range[from];
1285
- var valueTo = range[to];
1286
- var numberOfAppliedFilters = [valueFrom, valueTo].filter(Boolean).length;
1287
- var props = {
1288
- unit: unit,
1139
+ const valueFrom = range[from];
1140
+ const valueTo = range[to];
1141
+ const numberOfAppliedFilters = [valueFrom, valueTo].filter(Boolean).length;
1142
+ const props = {
1143
+ unit,
1289
1144
  from: {
1290
1145
  name: from,
1291
1146
  value: valueFrom,
1292
- placeholder: fromPlaceholder !== null && fromPlaceholder !== void 0 ? fromPlaceholder : minValue === null || minValue === void 0 ? void 0 : minValue.toString(),
1147
+ placeholder: fromPlaceholder ?? minValue?.toString(),
1293
1148
  ariaLabel: t('filtersPkg.from'),
1294
1149
  },
1295
1150
  to: {
1296
1151
  name: to,
1297
1152
  value: valueTo,
1298
- placeholder: toPlaceholder !== null && toPlaceholder !== void 0 ? toPlaceholder : (typeof maxValue === 'number' ? "".concat(maxValue, "+") : undefined),
1153
+ placeholder: toPlaceholder ??
1154
+ (typeof maxValue === 'number' ? `${maxValue}+` : undefined),
1299
1155
  ariaLabel: t('filtersPkg.to'),
1300
1156
  },
1301
1157
  onChange: handleChange,
@@ -1304,78 +1160,74 @@ var useRangeFilter = function (_a) {
1304
1160
  max: maxValue,
1305
1161
  };
1306
1162
  return {
1307
- numberOfAppliedFilters: numberOfAppliedFilters,
1163
+ numberOfAppliedFilters,
1308
1164
  isApplied: !!numberOfAppliedFilters,
1309
- props: props,
1165
+ props,
1310
1166
  state: range,
1311
- reset: reset,
1167
+ reset,
1312
1168
  };
1313
1169
  };
1314
1170
 
1315
- var unit$2 = Unit.percentage;
1316
- var useBatteryHealthPercentageFilter = function (_a) {
1317
- var filters = _a.filters, onAddFilter = _a.onAddFilter, onChange = _a.onChange;
1318
- var t = useFilterContext().t;
1319
- var _b = useRangeFilter({
1171
+ const unit$2 = Unit.percentage;
1172
+ const useBatteryHealthPercentageFilter = ({ filters, onAddFilter, onChange }) => {
1173
+ const { t } = useFilterContext();
1174
+ const { props, ...rest } = useRangeFilter({
1320
1175
  unit: unit$2,
1321
- filters: filters,
1176
+ filters,
1322
1177
  toPlaceholder: getMaxValueFromRangeSliderScale(batteryHealthPercentageScale, 100),
1323
1178
  from: 'batteryHealthPercentageFrom',
1324
1179
  to: 'batteryHealthPercentageTo',
1325
1180
  minValue: 10,
1326
1181
  maxValue: 100,
1327
- onAddFilter: onAddFilter,
1328
- onChange: onChange,
1329
- }), props = _b.props, rest = __rest(_b, ["props"]);
1330
- return __assign(__assign({ ui: (React.createElement(components.RangeFilterInputWithSlider, __assign({}, props, { rangeSliderScale: batteryHealthPercentageScale }))) }, rest), { label: t('filtersPkg.batteryHealthPercentage'), getDisplayValue: function (query) {
1331
- var _a = query || rest.state, batteryHealthPercentageFrom = _a.batteryHealthPercentageFrom, batteryHealthPercentageTo = _a.batteryHealthPercentageTo;
1182
+ onAddFilter,
1183
+ onChange,
1184
+ });
1185
+ return {
1186
+ ui: (React.createElement(components.RangeFilterInputWithSlider, { ...props, rangeSliderScale: batteryHealthPercentageScale })),
1187
+ ...rest,
1188
+ label: t('filtersPkg.batteryHealthPercentage'),
1189
+ getDisplayValue: (query) => {
1190
+ const { batteryHealthPercentageFrom, batteryHealthPercentageTo } = query || rest.state;
1332
1191
  return (getRangeDisplayValue({
1333
1192
  from: batteryHealthPercentageFrom,
1334
1193
  to: batteryHealthPercentageTo,
1335
1194
  unit: unit$2,
1336
- t: t,
1195
+ t,
1337
1196
  }) || '');
1338
- } });
1197
+ },
1198
+ };
1339
1199
  };
1340
1200
 
1341
- var getFacetForBooleanCheckboxFilter = function (facets, key) {
1342
- var _a, _b;
1201
+ const getFacetForBooleanCheckboxFilter = (facets, key) => {
1343
1202
  if (!facets)
1344
1203
  return null;
1345
- return (_b = (_a = facets === null || facets === void 0 ? void 0 : facets[key]) === null || _a === void 0 ? void 0 : _a['true']) !== null && _b !== void 0 ? _b : 0;
1204
+ return facets?.[key]?.['true'] ?? 0;
1346
1205
  };
1347
- var getBooleanDisplayValue = function (_a) {
1348
- var label = _a.label, filterKey = _a.filterKey, filters = _a.filters;
1206
+ const getBooleanDisplayValue = ({ label, filterKey, filters, }) => {
1349
1207
  return filters[filterKey] === true ? label : '';
1350
1208
  };
1351
1209
 
1352
- var useBooleanFilter = function (_a) {
1353
- var filters = _a.filters, getFacet = _a.getFacet, options = _a.options, onChange = _a.onChange, onAddFilter = _a.onAddFilter;
1354
- var t = useFilterContext().t;
1355
- var generateState = React.useCallback(function () {
1356
- return Object.fromEntries(options.map(function (_a) {
1357
- var key = _a.key;
1358
- return [key, filters[key]];
1359
- }));
1210
+ const useBooleanFilter = ({ filters, getFacet, options, onChange, onAddFilter, }) => {
1211
+ const { t } = useFilterContext();
1212
+ const generateState = React.useCallback(() => {
1213
+ return Object.fromEntries(options.map(({ key }) => [key, filters[key]]));
1360
1214
  }, [filters, options]);
1361
- var _b = React.useState(generateState()), state = _b[0], setState = _b[1];
1362
- React.useEffect(function () {
1363
- setState(function (prevState) {
1364
- var newState = generateState();
1365
- var hasChanged = Object.keys(newState).some(function (key) {
1366
- return prevState[key] !== newState[key];
1367
- });
1215
+ const [state, setState] = React.useState(generateState());
1216
+ React.useEffect(() => {
1217
+ setState((prevState) => {
1218
+ const newState = generateState();
1219
+ const hasChanged = Object.keys(newState).some((key) => prevState[key] !== newState[key]);
1368
1220
  return hasChanged ? newState : prevState;
1369
1221
  });
1370
1222
  }, [generateState]);
1371
- var items = options.map(function (option) { return ({
1223
+ const items = options.map((option) => ({
1372
1224
  key: option.key,
1373
1225
  label: t(option.translationKey),
1374
1226
  isChecked: !!state[option.key],
1375
1227
  facet: getFacet(option.key),
1376
- }); });
1377
- var reset = function () {
1378
- var newState = options.reduce(function (acc, option) {
1228
+ }));
1229
+ const reset = () => {
1230
+ const newState = options.reduce((acc, option) => {
1379
1231
  acc[option.key] = undefined;
1380
1232
  return acc;
1381
1233
  }, {});
@@ -1383,11 +1235,13 @@ var useBooleanFilter = function (_a) {
1383
1235
  return newState;
1384
1236
  };
1385
1237
  useResetAllFilters(reset);
1386
- var onApply = function (updatedItem) {
1387
- var _a;
1388
- var newState = __assign(__assign({}, state), (_a = {}, _a[updatedItem.key] = updatedItem.isChecked || undefined, _a));
1238
+ const onApply = (updatedItem) => {
1239
+ const newState = {
1240
+ ...state,
1241
+ [updatedItem.key]: updatedItem.isChecked || undefined,
1242
+ };
1389
1243
  setState(newState);
1390
- onChange === null || onChange === void 0 ? void 0 : onChange(newState);
1244
+ onChange?.(newState);
1391
1245
  if (updatedItem.isChecked && onAddFilter) {
1392
1246
  onAddFilter({
1393
1247
  appliedFilter: updatedItem.key,
@@ -1396,157 +1250,167 @@ var useBooleanFilter = function (_a) {
1396
1250
  });
1397
1251
  }
1398
1252
  };
1399
- var numberOfAppliedFilters = items.filter(function (item) { return item.isChecked; }).length;
1400
- var isApplied = !!numberOfAppliedFilters;
1253
+ const numberOfAppliedFilters = items.filter((item) => item.isChecked).length;
1254
+ const isApplied = !!numberOfAppliedFilters;
1401
1255
  return {
1402
- items: items,
1403
- reset: reset,
1404
- state: state,
1405
- isApplied: isApplied,
1406
- numberOfAppliedFilters: numberOfAppliedFilters,
1407
- onApply: onApply,
1256
+ items,
1257
+ reset,
1258
+ state,
1259
+ isApplied,
1260
+ numberOfAppliedFilters,
1261
+ onApply,
1408
1262
  };
1409
1263
  };
1410
1264
 
1411
- var key = 'hasBatteryCertificateOnly';
1412
- var option = {
1413
- key: key,
1414
- translationKey: "filtersPkg.".concat(key),
1265
+ const key = 'hasBatteryCertificateOnly';
1266
+ const option = {
1267
+ key,
1268
+ translationKey: `filtersPkg.${key}`,
1415
1269
  };
1416
- var options = [option];
1417
- var useHasBatteryCertificateKeyOnlyFilter = function (_a) {
1418
- var filters = _a.filters, onAddFilter = _a.onAddFilter, onChange = _a.onChange, facets = _a.facets;
1419
- var _b = useFilterContext(), t = _b.t, language = _b.language;
1420
- var label = t(option.translationKey);
1421
- var _c = useBooleanFilter({
1422
- filters: filters,
1423
- options: options,
1424
- getFacet: function (facetKey) {
1425
- return getFacetForBooleanCheckboxFilter(facets !== null && facets !== void 0 ? facets : null, facetKey);
1426
- },
1427
- onAddFilter: onAddFilter,
1428
- onChange: onChange,
1429
- }), items = _c.items, onApply = _c.onApply, rest = __rest(_c, ["items", "onApply"]);
1430
- return __assign({ ui: React.createElement(components.CheckboxFilter, { items: items, onApply: onApply, language: language }), label: label, getDisplayValue: function (query) {
1431
- return getBooleanDisplayValue({
1432
- label: label,
1433
- filterKey: key,
1434
- filters: query || rest.state,
1435
- });
1436
- } }, rest);
1270
+ const options = [option];
1271
+ const useHasBatteryCertificateKeyOnlyFilter = ({ filters, onAddFilter, onChange, facets }) => {
1272
+ const { t, language } = useFilterContext();
1273
+ const label = t(option.translationKey);
1274
+ const { items, onApply, ...rest } = useBooleanFilter({
1275
+ filters,
1276
+ options,
1277
+ getFacet: (facetKey) => getFacetForBooleanCheckboxFilter(facets ?? null, facetKey),
1278
+ onAddFilter,
1279
+ onChange,
1280
+ });
1281
+ return {
1282
+ ui: React.createElement(components.CheckboxFilter, { items: items, onApply: onApply, language: language }),
1283
+ label,
1284
+ getDisplayValue: (query) => getBooleanDisplayValue({
1285
+ label,
1286
+ filterKey: key,
1287
+ filters: query || rest.state,
1288
+ }),
1289
+ ...rest,
1290
+ };
1437
1291
  };
1438
1292
 
1439
- var minValue = 1900;
1440
- var useFirstRegistrationYearFilter = function (_a) {
1441
- var filters = _a.filters, facets = _a.facets, onAddFilter = _a.onAddFilter, onChange = _a.onChange, loadHistogram = _a.loadHistogram, chartHeight = _a.chartHeight;
1442
- var _b = useFilterContext(), t = _b.t, brand = _b.brand, histogramRanges = _b.histogramRanges;
1443
- var maxValue = new Date().getFullYear();
1444
- var scaleProps = getFacetConfig({
1445
- brand: brand,
1446
- facets: facets,
1447
- loadHistogram: loadHistogram,
1448
- chartHeight: chartHeight,
1293
+ const minValue = 1900;
1294
+ const useFirstRegistrationYearFilter = ({ filters, facets, onAddFilter, onChange, loadHistogram, chartHeight, }) => {
1295
+ const { t, brand, histogramRanges } = useFilterContext();
1296
+ const maxValue = new Date().getFullYear();
1297
+ const { scaleProps } = getFacetConfig({
1298
+ brand,
1299
+ facets,
1300
+ loadHistogram,
1301
+ chartHeight,
1449
1302
  histogramRangesWithDefaultValue: histogramRanges,
1450
1303
  name: 'firstRegistrationYearRanges',
1451
- }).scaleProps;
1452
- var _c = useRangeFilter({
1453
- filters: filters,
1304
+ });
1305
+ const { props, ...rest } = useRangeFilter({
1306
+ filters,
1454
1307
  toPlaceholder: maxValue.toString(),
1455
1308
  from: 'firstRegistrationYearFrom',
1456
1309
  to: 'firstRegistrationYearTo',
1457
- minValue: minValue,
1458
- maxValue: maxValue,
1459
- onAddFilter: onAddFilter,
1460
- onChange: onChange,
1461
- }), props = _c.props, rest = __rest(_c, ["props"]);
1462
- return __assign(__assign({ ui: React.createElement(components.RangeFilterInputWithSlider, __assign({}, props, scaleProps)) }, rest), { label: t('filtersPkg.firstRegistrationYear'), getDisplayValue: function (query) {
1463
- var _a = query || rest.state, firstRegistrationYearFrom = _a.firstRegistrationYearFrom, firstRegistrationYearTo = _a.firstRegistrationYearTo;
1310
+ minValue,
1311
+ maxValue,
1312
+ onAddFilter,
1313
+ onChange,
1314
+ });
1315
+ return {
1316
+ ui: React.createElement(components.RangeFilterInputWithSlider, { ...props, ...scaleProps }),
1317
+ ...rest,
1318
+ label: t('filtersPkg.firstRegistrationYear'),
1319
+ getDisplayValue: (query) => {
1320
+ const { firstRegistrationYearFrom, firstRegistrationYearTo } = query || rest.state;
1464
1321
  return (getRangeDisplayValue({
1465
1322
  from: firstRegistrationYearFrom,
1466
1323
  to: firstRegistrationYearTo,
1467
- t: t,
1324
+ t,
1468
1325
  }) || '');
1469
- } });
1326
+ },
1327
+ };
1470
1328
  };
1471
1329
 
1472
- var unit$1 = Unit.kilometers;
1473
- var useMileageFilter = function (_a) {
1474
- var filters = _a.filters, facets = _a.facets, onAddFilter = _a.onAddFilter, onChange = _a.onChange, loadHistogram = _a.loadHistogram, chartHeight = _a.chartHeight;
1475
- var _b = useFilterContext(), t = _b.t, brand = _b.brand, histogramRanges = _b.histogramRanges;
1476
- var _c = getFacetConfig({
1477
- brand: brand,
1478
- facets: facets,
1479
- loadHistogram: loadHistogram,
1480
- chartHeight: chartHeight,
1330
+ const unit$1 = Unit.kilometers;
1331
+ const useMileageFilter = ({ filters, facets, onAddFilter, onChange, loadHistogram, chartHeight, }) => {
1332
+ const { t, brand, histogramRanges } = useFilterContext();
1333
+ const { defaultFacets, scaleProps } = getFacetConfig({
1334
+ brand,
1335
+ facets,
1336
+ loadHistogram,
1337
+ chartHeight,
1481
1338
  histogramRangesWithDefaultValue: histogramRanges,
1482
1339
  name: 'mileageRanges',
1483
- }), defaultFacets = _c.defaultFacets, scaleProps = _c.scaleProps;
1484
- var _d = useRangeFilter({
1340
+ });
1341
+ const { props, ...rest } = useRangeFilter({
1485
1342
  unit: unit$1,
1486
- filters: filters,
1343
+ filters,
1487
1344
  toPlaceholder: getMaxValueFromFacetRangeGroups(defaultFacets),
1488
1345
  from: 'mileageFrom',
1489
1346
  to: 'mileageTo',
1490
1347
  minValue: 0,
1491
1348
  maxValue: 99999999,
1492
- onAddFilter: onAddFilter,
1493
- onChange: onChange,
1494
- }), props = _d.props, rest = __rest(_d, ["props"]);
1495
- return __assign(__assign({ ui: React.createElement(components.RangeFilterInputWithSlider, __assign({}, props, scaleProps)) }, rest), { label: t('filtersPkg.mileage'), getDisplayValue: function (query) {
1496
- var _a = query || rest.state, mileageFrom = _a.mileageFrom, mileageTo = _a.mileageTo;
1349
+ onAddFilter,
1350
+ onChange,
1351
+ });
1352
+ return {
1353
+ ui: React.createElement(components.RangeFilterInputWithSlider, { ...props, ...scaleProps }),
1354
+ ...rest,
1355
+ label: t('filtersPkg.mileage'),
1356
+ getDisplayValue: (query) => {
1357
+ const { mileageFrom, mileageTo } = query || rest.state;
1497
1358
  return (getRangeDisplayValue({
1498
1359
  from: mileageFrom,
1499
1360
  to: mileageTo,
1500
1361
  unit: unit$1,
1501
- t: t,
1362
+ t,
1502
1363
  }) || '');
1503
- } });
1364
+ },
1365
+ };
1504
1366
  };
1505
1367
 
1506
- var unit = Unit.swissFrancs;
1507
- var usePriceFilter = function (_a) {
1508
- var filters = _a.filters, facets = _a.facets, onAddFilter = _a.onAddFilter, onChange = _a.onChange, loadHistogram = _a.loadHistogram, chartHeight = _a.chartHeight;
1509
- var _b = useFilterContext(), t = _b.t, brand = _b.brand, histogramRanges = _b.histogramRanges;
1510
- var _c = getFacetConfig({
1511
- brand: brand,
1512
- facets: facets,
1513
- loadHistogram: loadHistogram,
1514
- chartHeight: chartHeight,
1368
+ const unit = Unit.swissFrancs;
1369
+ const usePriceFilter = ({ filters, facets, onAddFilter, onChange, loadHistogram, chartHeight, }) => {
1370
+ const { t, brand, histogramRanges } = useFilterContext();
1371
+ const { defaultFacets, scaleProps } = getFacetConfig({
1372
+ brand,
1373
+ facets,
1374
+ loadHistogram,
1375
+ chartHeight,
1515
1376
  histogramRangesWithDefaultValue: histogramRanges,
1516
1377
  name: 'priceRanges',
1517
- }), defaultFacets = _c.defaultFacets, scaleProps = _c.scaleProps;
1518
- var _d = useRangeFilter({
1519
- unit: unit,
1520
- filters: filters,
1378
+ });
1379
+ const { props, ...rest } = useRangeFilter({
1380
+ unit,
1381
+ filters,
1521
1382
  toPlaceholder: getMaxValueFromFacetRangeGroups(defaultFacets),
1522
1383
  from: 'priceFrom',
1523
1384
  to: 'priceTo',
1524
1385
  minValue: 0,
1525
1386
  maxValue: 9999999,
1526
- onAddFilter: onAddFilter,
1527
- onChange: onChange,
1528
- }), props = _d.props, rest = __rest(_d, ["props"]);
1529
- return __assign(__assign({ ui: React.createElement(components.RangeFilterInputWithSlider, __assign({}, props, scaleProps)) }, rest), { label: t('filtersPkg.price'), getDisplayValue: function (query) {
1530
- var _a = query || rest.state, priceFrom = _a.priceFrom, priceTo = _a.priceTo;
1387
+ onAddFilter,
1388
+ onChange,
1389
+ });
1390
+ return {
1391
+ ui: React.createElement(components.RangeFilterInputWithSlider, { ...props, ...scaleProps }),
1392
+ ...rest,
1393
+ label: t('filtersPkg.price'),
1394
+ getDisplayValue: (query) => {
1395
+ const { priceFrom, priceTo } = query || rest.state;
1531
1396
  return (getRangeDisplayValue({
1532
1397
  from: priceFrom,
1533
1398
  to: priceTo,
1534
- unit: unit,
1535
- t: t,
1399
+ unit,
1400
+ t,
1536
1401
  }) || '');
1537
- } });
1402
+ },
1403
+ };
1538
1404
  };
1539
1405
 
1540
- var isInArray = function (item, array) { return array.includes(item); };
1406
+ const isInArray = (item, array) => array.includes(item);
1541
1407
 
1542
- var sortCheckboxOptions = function (a, b, language, customOrder) {
1543
- if (language === void 0) { language = 'de'; }
1544
- if (customOrder === void 0) { customOrder = null; }
1408
+ const sortCheckboxOptions = (a, b, language = 'de', customOrder = null) => {
1545
1409
  if (!customOrder || !a.key || !b.key) {
1546
1410
  return a.label.localeCompare(b.label, language, { sensitivity: 'base' });
1547
1411
  }
1548
- var indexA = customOrder.indexOf(a.key);
1549
- var indexB = customOrder.indexOf(b.key);
1412
+ const indexA = customOrder.indexOf(a.key);
1413
+ const indexB = customOrder.indexOf(b.key);
1550
1414
  if (indexA === -1 && indexB === -1) {
1551
1415
  return a.label.localeCompare(b.label, language, { sensitivity: 'base' });
1552
1416
  }
@@ -1558,25 +1422,21 @@ var sortCheckboxOptions = function (a, b, language, customOrder) {
1558
1422
  }
1559
1423
  return indexA - indexB;
1560
1424
  };
1561
- var getFacet = function (_a) {
1562
- var _b;
1563
- var key = _a.key, filterName = _a.filterName, facets = _a.facets;
1425
+ const getFacet = ({ key, filterName, facets, }) => {
1564
1426
  if (!facets)
1565
1427
  return null;
1566
- return (filterName && ((_b = facets[filterName]) === null || _b === void 0 ? void 0 : _b[key])) || 0;
1428
+ return (filterName && facets[filterName]?.[key]) || 0;
1567
1429
  };
1568
- var getCheckboxDisplayValue = function (options, filters) {
1430
+ const getCheckboxDisplayValue = (options, filters) => {
1569
1431
  return options
1570
- .reduce(function (acc, parent) {
1571
- var _a, _b, _c;
1572
- var filterName = (_a = parent.filterName) !== null && _a !== void 0 ? _a : '';
1573
- if (isInArray(parent.key, (_b = filters[filterName]) !== null && _b !== void 0 ? _b : [])) {
1432
+ .reduce((acc, parent) => {
1433
+ const filterName = parent.filterName ?? '';
1434
+ if (isInArray(parent.key, filters[filterName] ?? [])) {
1574
1435
  acc.push(parent.label);
1575
1436
  }
1576
- (_c = parent.childCheckboxes) === null || _c === void 0 ? void 0 : _c.forEach(function (child) {
1577
- var _a, _b;
1578
- var childFilterName = (_a = child.filterName) !== null && _a !== void 0 ? _a : '';
1579
- if (isInArray(child.key, (_b = filters[childFilterName]) !== null && _b !== void 0 ? _b : [])) {
1437
+ parent.childCheckboxes?.forEach((child) => {
1438
+ const childFilterName = child.filterName ?? '';
1439
+ if (isInArray(child.key, filters[childFilterName] ?? [])) {
1580
1440
  acc.push(child.label);
1581
1441
  }
1582
1442
  });
@@ -1584,30 +1444,27 @@ var getCheckboxDisplayValue = function (options, filters) {
1584
1444
  }, [])
1585
1445
  .join(', ');
1586
1446
  };
1587
- var mapCheckboxItem = function (_a) {
1588
- var item = _a.item, filterName = _a.filterName, translationKey = _a.translationKey, t = _a.t, getFacetFn = _a.getFacet;
1447
+ const mapCheckboxItem = ({ item, filterName, translationKey, t, getFacet: getFacetFn, }) => {
1589
1448
  return {
1590
- filterName: filterName,
1449
+ filterName,
1591
1450
  key: item,
1592
- label: t(['filtersPkg', "".concat(translationKey, ".").concat(item)]),
1451
+ label: t(['filtersPkg', `${translationKey}.${item}`]),
1593
1452
  facet: getFacetFn({
1594
1453
  key: item,
1595
- filterName: filterName,
1454
+ filterName,
1596
1455
  }),
1597
1456
  };
1598
1457
  };
1599
- var mapTypesToGroups = function (_a) {
1600
- var options = _a.options, groups = _a.groups, mapping = _a.mapping;
1601
- var result = {
1602
- groups: groups.reduce(function (acc, group) {
1458
+ const mapTypesToGroups = ({ options, groups, mapping, }) => {
1459
+ const result = {
1460
+ groups: groups.reduce((acc, group) => {
1603
1461
  acc[group] = [];
1604
1462
  return acc;
1605
1463
  }, {}),
1606
1464
  options: [],
1607
1465
  };
1608
- for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
1609
- var option = options_1[_i];
1610
- var group = mapping && mapping[option];
1466
+ for (const option of options) {
1467
+ const group = mapping && mapping[option];
1611
1468
  if (group) {
1612
1469
  result.groups[group].push(option);
1613
1470
  }
@@ -1617,68 +1474,80 @@ var mapTypesToGroups = function (_a) {
1617
1474
  }
1618
1475
  return result;
1619
1476
  };
1620
- var generateCheckboxFilterItems = function (_a) {
1621
- var options = _a.options, groups = _a.groups, groupMapping = _a.groupMapping, getFacetFn = _a.getFacet, t = _a.t, language = _a.language, _b = _a.customOrder, customOrder = _b === void 0 ? null : _b;
1622
- var hasOptions = !!(options === null || options === void 0 ? void 0 : options.items.length);
1623
- var hasGroups = !!(groups === null || groups === void 0 ? void 0 : groups.items.length);
1624
- var getImage = options === null || options === void 0 ? void 0 : options.getImage;
1477
+ const generateCheckboxFilterItems = ({ options, groups, groupMapping, getFacet: getFacetFn, t, language, customOrder = null, }) => {
1478
+ const hasOptions = !!options?.items.length;
1479
+ const hasGroups = !!groups?.items.length;
1480
+ const getImage = options?.getImage;
1625
1481
  if (!hasGroups && !hasOptions) {
1626
1482
  return [];
1627
1483
  }
1628
- var sortItems = function (a, b) {
1484
+ const sortItems = (a, b) => {
1629
1485
  return sortCheckboxOptions(a, b, language, customOrder);
1630
1486
  };
1631
1487
  if (!hasGroups && hasOptions && options.key) {
1632
1488
  return options.items
1633
- .map(function (option) { return (__assign(__assign({}, mapCheckboxItem({
1634
- item: option,
1635
- filterName: options.key,
1636
- translationKey: options.translationKey,
1637
- t: t,
1638
- getFacet: getFacetFn,
1639
- })), { image: getImage === null || getImage === void 0 ? void 0 : getImage(option), childCheckboxes: [] })); })
1489
+ .map((option) => ({
1490
+ ...mapCheckboxItem({
1491
+ item: option,
1492
+ filterName: options.key,
1493
+ translationKey: options.translationKey,
1494
+ t,
1495
+ getFacet: getFacetFn,
1496
+ }),
1497
+ image: getImage?.(option),
1498
+ childCheckboxes: [],
1499
+ }))
1640
1500
  .sort(sortItems);
1641
1501
  }
1642
1502
  if (hasGroups && groups.key && !hasOptions) {
1643
1503
  return groups.items
1644
- .map(function (group) { return (__assign(__assign({}, mapCheckboxItem({
1645
- item: group,
1646
- filterName: groups.key,
1647
- translationKey: groups.translationKey,
1648
- t: t,
1649
- getFacet: getFacetFn,
1650
- })), { childCheckboxes: [] })); })
1504
+ .map((group) => ({
1505
+ ...mapCheckboxItem({
1506
+ item: group,
1507
+ filterName: groups.key,
1508
+ translationKey: groups.translationKey,
1509
+ t,
1510
+ getFacet: getFacetFn,
1511
+ }),
1512
+ childCheckboxes: [],
1513
+ }))
1651
1514
  .sort(sortItems);
1652
1515
  }
1653
- var mappedOptions = mapTypesToGroups({
1654
- options: (options === null || options === void 0 ? void 0 : options.items) || [],
1655
- groups: (groups === null || groups === void 0 ? void 0 : groups.items) || [],
1516
+ const mappedOptions = mapTypesToGroups({
1517
+ options: options?.items || [],
1518
+ groups: groups?.items || [],
1656
1519
  mapping: groupMapping,
1657
1520
  });
1658
- var groupEntries = Object.entries(mappedOptions.groups).map(function (_a) {
1659
- var group = _a[0], types = _a[1];
1660
- return (__assign(__assign({}, mapCheckboxItem({
1521
+ const groupEntries = Object.entries(mappedOptions.groups).map(([group, types]) => ({
1522
+ ...mapCheckboxItem({
1661
1523
  item: group,
1662
- filterName: groups === null || groups === void 0 ? void 0 : groups.key,
1663
- translationKey: (groups === null || groups === void 0 ? void 0 : groups.translationKey) || '',
1664
- t: t,
1524
+ filterName: groups?.key,
1525
+ translationKey: groups?.translationKey || '',
1526
+ t,
1665
1527
  getFacet: getFacetFn,
1666
- })), { childCheckboxes: types.map(function (type) { return (__assign({}, mapCheckboxItem({
1528
+ }),
1529
+ childCheckboxes: types.map((type) => ({
1530
+ ...mapCheckboxItem({
1667
1531
  item: type,
1668
- filterName: options === null || options === void 0 ? void 0 : options.key,
1669
- translationKey: (options === null || options === void 0 ? void 0 : options.translationKey) || '',
1670
- t: t,
1532
+ filterName: options?.key,
1533
+ translationKey: options?.translationKey || '',
1534
+ t,
1671
1535
  getFacet: getFacetFn,
1672
- }))); }) }));
1673
- });
1674
- var ungroupedOptions = mappedOptions.options.map(function (option) { return (__assign(__assign({}, mapCheckboxItem({
1675
- item: option,
1676
- filterName: options === null || options === void 0 ? void 0 : options.key,
1677
- translationKey: (options === null || options === void 0 ? void 0 : options.translationKey) || '',
1678
- t: t,
1679
- getFacet: getFacetFn,
1680
- })), { image: getImage === null || getImage === void 0 ? void 0 : getImage(option), childCheckboxes: [] })); });
1681
- return __spreadArray(__spreadArray([], groupEntries, true), ungroupedOptions, true).sort(sortItems);
1536
+ }),
1537
+ })),
1538
+ }));
1539
+ const ungroupedOptions = mappedOptions.options.map((option) => ({
1540
+ ...mapCheckboxItem({
1541
+ item: option,
1542
+ filterName: options?.key,
1543
+ translationKey: options?.translationKey || '',
1544
+ t,
1545
+ getFacet: getFacetFn,
1546
+ }),
1547
+ image: getImage?.(option),
1548
+ childCheckboxes: [],
1549
+ }));
1550
+ return [...groupEntries, ...ungroupedOptions].sort(sortItems);
1682
1551
  };
1683
1552
 
1684
1553
  var ActionType;
@@ -1691,31 +1560,51 @@ var ActionType;
1691
1560
  ActionType["SetFilter"] = "SET_FILTER";
1692
1561
  ActionType["Reset"] = "RESET";
1693
1562
  })(ActionType || (ActionType = {}));
1694
- var reducer = function (state, action) {
1695
- var _a, _b;
1563
+ const reducer = (state, action) => {
1696
1564
  switch (action.type) {
1697
1565
  case ActionType.DeselectChildOption:
1698
- return __assign(__assign({}, state), { options: state.options.filter(function (option) { var _a; return option !== ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.key); }) });
1566
+ return {
1567
+ ...state,
1568
+ options: state.options.filter((option) => option !== action.payload?.key),
1569
+ };
1699
1570
  case ActionType.SelectChildOption:
1700
- return __assign(__assign({}, state), { options: __spreadArray(__spreadArray([], state.options, true), [(_a = action.payload) === null || _a === void 0 ? void 0 : _a.key], false) });
1571
+ return {
1572
+ ...state,
1573
+ options: [...state.options, action.payload?.key],
1574
+ };
1701
1575
  case ActionType.DeselectGroup:
1702
- return __assign(__assign({}, state), { groups: state.groups.filter(function (group) { var _a; return group !== ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.key); }) });
1576
+ return {
1577
+ ...state,
1578
+ groups: state.groups.filter((group) => group !== action.payload?.key),
1579
+ };
1703
1580
  case ActionType.SelectGroup:
1704
- return __assign(__assign({}, state), { options: state.options.filter(function (option) { return !action.payload.parentGroupChildItems.includes(option); }), groups: __spreadArray(__spreadArray([], state.groups, true), [(_b = action.payload) === null || _b === void 0 ? void 0 : _b.key], false) });
1581
+ return {
1582
+ ...state,
1583
+ options: state.options.filter((option) => !action.payload.parentGroupChildItems.includes(option)),
1584
+ groups: [...state.groups, action.payload?.key],
1585
+ };
1705
1586
  case ActionType.DeselectChildAndGroupAndAddAllOtherChildOptions: {
1706
- var _c = action.payload, parentGroup_1 = _c.parentGroup, parentGroupChildItems = _c.parentGroupChildItems, key_1 = _c.key;
1707
- var updatedOptions = parentGroupChildItems === null || parentGroupChildItems === void 0 ? void 0 : parentGroupChildItems.filter(function (option) { return option !== key_1; });
1708
- var updatedGroups = state.groups.filter(function (group) { return group !== parentGroup_1; });
1709
- return __assign(__assign({}, state), { options: __spreadArray(__spreadArray([], state.options, true), (updatedOptions !== null && updatedOptions !== void 0 ? updatedOptions : []), true), groups: updatedGroups });
1587
+ const { parentGroup, parentGroupChildItems, key } = action.payload;
1588
+ const updatedOptions = parentGroupChildItems?.filter((option) => option !== key);
1589
+ const updatedGroups = state.groups.filter((group) => group !== parentGroup);
1590
+ return {
1591
+ ...state,
1592
+ options: [...state.options, ...(updatedOptions ?? [])],
1593
+ groups: updatedGroups,
1594
+ };
1710
1595
  }
1711
1596
  case ActionType.SetFilter: {
1712
- var isStateDifferent = function (arr1, arr2) {
1597
+ const isStateDifferent = (arr1, arr2) => {
1713
1598
  return (arr1.length !== arr2.length ||
1714
- !arr1.every(function (option) { return arr2.includes(option); }));
1599
+ !arr1.every((option) => arr2.includes(option)));
1715
1600
  };
1716
1601
  if (isStateDifferent(action.payload.options, state.options) ||
1717
1602
  isStateDifferent(action.payload.groups, state.groups)) {
1718
- return __assign(__assign({}, state), { options: action.payload.options, groups: action.payload.groups });
1603
+ return {
1604
+ ...state,
1605
+ options: action.payload.options,
1606
+ groups: action.payload.groups,
1607
+ };
1719
1608
  }
1720
1609
  return state;
1721
1610
  }
@@ -1728,49 +1617,38 @@ var reducer = function (state, action) {
1728
1617
  return state;
1729
1618
  }
1730
1619
  };
1731
- var useCheckboxFilterReducer = function (_a) {
1732
- var initialState = _a.initialState, onChange = _a.onChange;
1733
- var _b = React.useReducer(reducer, initialState), state = _b[0], dispatchBase = _b[1];
1734
- var onChangeRef = React.useRef(onChange);
1735
- var lastActionType = React.useRef(null);
1736
- React.useEffect(function () {
1620
+ const useCheckboxFilterReducer = ({ initialState, onChange, }) => {
1621
+ const [state, dispatchBase] = React.useReducer(reducer, initialState);
1622
+ const onChangeRef = React.useRef(onChange);
1623
+ const lastActionType = React.useRef(null);
1624
+ React.useEffect(() => {
1737
1625
  onChangeRef.current = onChange;
1738
1626
  }, [onChange]);
1739
- React.useEffect(function () {
1740
- var _a;
1627
+ React.useEffect(() => {
1741
1628
  if (![ActionType.Reset, ActionType.SetFilter].includes(lastActionType.current)) {
1742
- (_a = onChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onChangeRef, state);
1629
+ onChangeRef.current?.(state);
1743
1630
  }
1744
1631
  }, [state]);
1745
- var dispatch = React.useCallback(function (action) {
1632
+ const dispatch = React.useCallback((action) => {
1746
1633
  lastActionType.current = action.type;
1747
1634
  dispatchBase(action);
1748
1635
  }, []);
1749
- return { state: state, dispatch: dispatch };
1636
+ return { state, dispatch };
1750
1637
  };
1751
1638
 
1752
- var getParentGroupWithChildItems = function (_a) {
1753
- var itemKey = _a.itemKey, mapping = _a.mapping;
1639
+ const getParentGroupWithChildItems = ({ itemKey, mapping, }) => {
1754
1640
  if (!mapping)
1755
1641
  return { parentGroup: null, parentGroupChildItems: [] };
1756
- var parentGroup = mapping[itemKey];
1757
- var parentGroupChildItems = Object.entries(mapping)
1758
- .filter(function (_a) {
1759
- var group = _a[1];
1760
- return group === parentGroup;
1761
- })
1762
- .map(function (_a) {
1763
- var key = _a[0];
1764
- return key;
1765
- });
1766
- return { parentGroup: parentGroup, parentGroupChildItems: parentGroupChildItems };
1642
+ const parentGroup = mapping[itemKey];
1643
+ const parentGroupChildItems = Object.entries(mapping)
1644
+ .filter(([, group]) => group === parentGroup)
1645
+ .map(([key]) => key);
1646
+ return { parentGroup, parentGroupChildItems };
1767
1647
  };
1768
- var mapToSearchableListItems = function (items, handleApply) {
1769
- return items.map(function (item) {
1770
- var _a, _b;
1771
- var isParentSelected = item.isChecked;
1772
- var children = (_a = item.childCheckboxes) === null || _a === void 0 ? void 0 : _a.map(function (child) {
1773
- var _a;
1648
+ const mapToSearchableListItems = (items, handleApply) => {
1649
+ return items.map((item) => {
1650
+ const isParentSelected = item.isChecked;
1651
+ const children = item.childCheckboxes?.map((child) => {
1774
1652
  return {
1775
1653
  key: child.key,
1776
1654
  value: child.key,
@@ -1779,48 +1657,47 @@ var mapToSearchableListItems = function (items, handleApply) {
1779
1657
  isSelected: isParentSelected || !!child.isChecked,
1780
1658
  showChevron: false,
1781
1659
  isCheckbox: true,
1782
- onClick: function () { return handleApply(child); },
1783
- facet: (_a = child.facet) === null || _a === void 0 ? void 0 : _a.toString(),
1660
+ onClick: () => handleApply(child),
1661
+ facet: child.facet?.toString(),
1784
1662
  };
1785
1663
  });
1786
- var isIndeterminate = !item.isChecked && (children === null || children === void 0 ? void 0 : children.some(function (child) { return child.isSelected; }));
1664
+ const isIndeterminate = !item.isChecked && children?.some((child) => child.isSelected);
1787
1665
  return {
1788
1666
  key: item.key,
1789
1667
  label: item.label,
1790
1668
  value: item.key,
1791
1669
  filterName: item.filterName,
1792
1670
  isSelected: !!item.isChecked,
1793
- onClick: function () { return handleApply(item); },
1671
+ onClick: () => handleApply(item),
1794
1672
  showChevron: false,
1795
1673
  isCheckbox: true,
1796
1674
  isIndeterminate: !!isIndeterminate,
1797
- facet: (_b = item.facet) === null || _b === void 0 ? void 0 : _b.toString(),
1798
- children: children,
1675
+ facet: item.facet?.toString(),
1676
+ children,
1799
1677
  };
1800
1678
  });
1801
1679
  };
1802
- var useCheckboxFilter = function (_a) {
1803
- var _b, _c;
1804
- var _d, _e;
1805
- var filters = _a.filters, onAddFilter = _a.onAddFilter, onFilterChange = _a.onChange, generateCheckboxFilterItemsArgs = __rest(_a, ["filters", "onAddFilter", "onChange"]);
1806
- var language = useFilterContext().language;
1807
- var groupFilterName = (_d = generateCheckboxFilterItemsArgs.groups) === null || _d === void 0 ? void 0 : _d.key;
1808
- var optionFilterName = (_e = generateCheckboxFilterItemsArgs.options) === null || _e === void 0 ? void 0 : _e.key;
1809
- var initOptionParam = React.useMemo(function () { var _a; return (_a = (optionFilterName && filters[optionFilterName])) !== null && _a !== void 0 ? _a : []; }, [filters, optionFilterName]);
1810
- var initGroupParam = React.useMemo(function () { var _a; return (_a = (groupFilterName && filters[groupFilterName])) !== null && _a !== void 0 ? _a : []; }, [filters, groupFilterName]);
1811
- var _f = useCheckboxFilterReducer({
1680
+ const useCheckboxFilter = ({ filters, onAddFilter, onChange: onFilterChange, ...generateCheckboxFilterItemsArgs }) => {
1681
+ const { language } = useFilterContext();
1682
+ const groupFilterName = generateCheckboxFilterItemsArgs.groups?.key;
1683
+ const optionFilterName = generateCheckboxFilterItemsArgs.options?.key;
1684
+ const initOptionParam = React.useMemo(() => (optionFilterName && filters[optionFilterName]) ?? [], [filters, optionFilterName]);
1685
+ const initGroupParam = React.useMemo(() => (groupFilterName && filters[groupFilterName]) ?? [], [filters, groupFilterName]);
1686
+ const { state: { options, groups }, dispatch, } = useCheckboxFilterReducer({
1812
1687
  initialState: {
1813
1688
  groups: initGroupParam,
1814
1689
  options: initOptionParam,
1815
1690
  },
1816
- onChange: function (state) {
1817
- var _a, _b;
1691
+ onChange: (state) => {
1818
1692
  if (!onFilterChange)
1819
1693
  return;
1820
- onFilterChange(__assign(__assign({}, (groupFilterName ? (_a = {}, _a[groupFilterName] = state.groups, _a) : {})), (optionFilterName ? (_b = {}, _b[optionFilterName] = state.options, _b) : {})));
1694
+ onFilterChange({
1695
+ ...(groupFilterName ? { [groupFilterName]: state.groups } : {}),
1696
+ ...(optionFilterName ? { [optionFilterName]: state.options } : {}),
1697
+ });
1821
1698
  },
1822
- }), _g = _f.state, options = _g.options, groups = _g.groups, dispatch = _f.dispatch;
1823
- React.useEffect(function () {
1699
+ });
1700
+ React.useEffect(() => {
1824
1701
  dispatch({
1825
1702
  type: ActionType.SetFilter,
1826
1703
  payload: {
@@ -1829,19 +1706,16 @@ var useCheckboxFilter = function (_a) {
1829
1706
  },
1830
1707
  });
1831
1708
  }, [initOptionParam, initGroupParam, dispatch]);
1832
- var handleGroupApply = React.useCallback(function (updatedItem) {
1833
- var _a, _b;
1834
- var key = updatedItem.key;
1709
+ const handleGroupApply = React.useCallback((updatedItem) => {
1710
+ const { key } = updatedItem;
1835
1711
  if (isInArray(key, groups)) {
1836
1712
  return dispatch({
1837
1713
  type: ActionType.DeselectGroup,
1838
- payload: { key: key },
1714
+ payload: { key },
1839
1715
  });
1840
1716
  }
1841
- var selectedParentGroupChildItems = (_b = (_a = updatedItem.childCheckboxes) === null || _a === void 0 ? void 0 : _a.filter(function (child) {
1842
- return isInArray(child.key, options);
1843
- })) !== null && _b !== void 0 ? _b : [];
1844
- onAddFilter === null || onAddFilter === void 0 ? void 0 : onAddFilter({
1717
+ const selectedParentGroupChildItems = updatedItem.childCheckboxes?.filter((child) => isInArray(child.key, options)) ?? [];
1718
+ onAddFilter?.({
1845
1719
  appliedFilter: updatedItem.filterName,
1846
1720
  value: updatedItem.key,
1847
1721
  formattedValue: updatedItem.label,
@@ -1850,35 +1724,35 @@ var useCheckboxFilter = function (_a) {
1850
1724
  dispatch({
1851
1725
  type: ActionType.SelectGroup,
1852
1726
  payload: {
1853
- key: key,
1854
- parentGroupChildItems: selectedParentGroupChildItems.map(function (option) { return option.key; }),
1727
+ key,
1728
+ parentGroupChildItems: selectedParentGroupChildItems.map((option) => option.key),
1855
1729
  },
1856
1730
  });
1857
1731
  }, [groups, dispatch, onAddFilter, options]);
1858
- var handleOptionApply = React.useCallback(function (updatedItem) {
1859
- var key = updatedItem.key;
1732
+ const handleOptionApply = React.useCallback((updatedItem) => {
1733
+ const { key } = updatedItem;
1860
1734
  if (isInArray(key, options)) {
1861
1735
  return dispatch({
1862
1736
  type: ActionType.DeselectChildOption,
1863
- payload: { key: key },
1737
+ payload: { key },
1864
1738
  });
1865
1739
  }
1866
- var _a = getParentGroupWithChildItems({
1740
+ const { parentGroup, parentGroupChildItems } = getParentGroupWithChildItems({
1867
1741
  itemKey: updatedItem.key,
1868
1742
  mapping: generateCheckboxFilterItemsArgs.groupMapping,
1869
- }), parentGroup = _a.parentGroup, parentGroupChildItems = _a.parentGroupChildItems;
1743
+ });
1870
1744
  if (parentGroup && groups.includes(parentGroup)) {
1871
1745
  return dispatch({
1872
1746
  type: ActionType.DeselectChildAndGroupAndAddAllOtherChildOptions,
1873
- payload: { key: key, parentGroup: parentGroup, parentGroupChildItems: parentGroupChildItems },
1747
+ payload: { key, parentGroup, parentGroupChildItems },
1874
1748
  });
1875
1749
  }
1876
- var optionsFromParentGroupInCurrentState = options.filter(function (type) {
1877
- return parentGroupChildItems === null || parentGroupChildItems === void 0 ? void 0 : parentGroupChildItems.includes(type);
1750
+ const optionsFromParentGroupInCurrentState = options.filter((type) => {
1751
+ return parentGroupChildItems?.includes(type);
1878
1752
  });
1879
- var allParentGroupTypesSelected = optionsFromParentGroupInCurrentState.length + 1 ===
1880
- (parentGroupChildItems === null || parentGroupChildItems === void 0 ? void 0 : parentGroupChildItems.length);
1881
- onAddFilter === null || onAddFilter === void 0 ? void 0 : onAddFilter({
1753
+ const allParentGroupTypesSelected = optionsFromParentGroupInCurrentState.length + 1 ===
1754
+ parentGroupChildItems?.length;
1755
+ onAddFilter?.({
1882
1756
  appliedFilter: updatedItem.filterName,
1883
1757
  value: updatedItem.key,
1884
1758
  formattedValue: updatedItem.label,
@@ -1887,12 +1761,12 @@ var useCheckboxFilter = function (_a) {
1887
1761
  if (allParentGroupTypesSelected && parentGroup) {
1888
1762
  return dispatch({
1889
1763
  type: ActionType.SelectGroup,
1890
- payload: { key: parentGroup, parentGroupChildItems: parentGroupChildItems },
1764
+ payload: { key: parentGroup, parentGroupChildItems },
1891
1765
  });
1892
1766
  }
1893
1767
  dispatch({
1894
1768
  type: ActionType.SelectChildOption,
1895
- payload: { key: key },
1769
+ payload: { key },
1896
1770
  });
1897
1771
  }, [
1898
1772
  dispatch,
@@ -1901,7 +1775,7 @@ var useCheckboxFilter = function (_a) {
1901
1775
  onAddFilter,
1902
1776
  options,
1903
1777
  ]);
1904
- var handleApply = React.useCallback(function (updatedItem) {
1778
+ const handleApply = React.useCallback((updatedItem) => {
1905
1779
  if (updatedItem.filterName === optionFilterName) {
1906
1780
  handleOptionApply(updatedItem);
1907
1781
  }
@@ -1909,14 +1783,15 @@ var useCheckboxFilter = function (_a) {
1909
1783
  handleGroupApply(updatedItem);
1910
1784
  }
1911
1785
  }, [groupFilterName, handleGroupApply, handleOptionApply, optionFilterName]);
1912
- var reset = function () {
1913
- var _a, _b;
1786
+ const reset = () => {
1914
1787
  dispatch({ type: ActionType.Reset });
1915
- return __assign(__assign({}, (groupFilterName ? (_a = {}, _a[groupFilterName] = [], _a) : {})), (optionFilterName ? (_b = {}, _b[optionFilterName] = [], _b) : {}));
1788
+ return {
1789
+ ...(groupFilterName ? { [groupFilterName]: [] } : {}),
1790
+ ...(optionFilterName ? { [optionFilterName]: [] } : {}),
1791
+ };
1916
1792
  };
1917
1793
  useResetAllFilters(reset);
1918
- var isChecked = React.useCallback(function (_a) {
1919
- var filterName = _a.filterName, key = _a.key;
1794
+ const isChecked = React.useCallback(({ filterName, key, }) => {
1920
1795
  if (filterName === optionFilterName) {
1921
1796
  return isInArray(key, options);
1922
1797
  }
@@ -1925,47 +1800,56 @@ var useCheckboxFilter = function (_a) {
1925
1800
  }
1926
1801
  return false;
1927
1802
  }, [groupFilterName, groups, optionFilterName, options]);
1928
- var items = generateCheckboxFilterItems(__assign(__assign({}, generateCheckboxFilterItemsArgs), { language: language }));
1929
- var itemsWithCheckedState = React.useMemo(function () {
1930
- return items.map(function (item) {
1931
- var _a;
1932
- return __assign(__assign({}, item), { isChecked: isChecked({
1803
+ const items = generateCheckboxFilterItems({
1804
+ ...generateCheckboxFilterItemsArgs,
1805
+ language,
1806
+ });
1807
+ const itemsWithCheckedState = React.useMemo(() => {
1808
+ return items.map((item) => {
1809
+ return {
1810
+ ...item,
1811
+ isChecked: isChecked({
1933
1812
  filterName: item.filterName,
1934
1813
  key: item.key,
1935
- }), childCheckboxes: (_a = item.childCheckboxes) === null || _a === void 0 ? void 0 : _a.map(function (childItem) {
1936
- return __assign(__assign({}, childItem), { isChecked: isChecked({
1814
+ }),
1815
+ childCheckboxes: item.childCheckboxes?.map((childItem) => {
1816
+ return {
1817
+ ...childItem,
1818
+ isChecked: isChecked({
1937
1819
  filterName: childItem.filterName,
1938
1820
  key: childItem.key,
1939
- }) });
1940
- }) });
1821
+ }),
1822
+ };
1823
+ }),
1824
+ };
1941
1825
  });
1942
1826
  }, [items, isChecked]);
1943
- var checkboxItems = React.useMemo(function () {
1944
- return generateCheckboxFilterItemsArgs.isSearchable
1945
- ? mapToSearchableListItems(itemsWithCheckedState, handleApply)
1946
- : itemsWithCheckedState;
1947
- }, [
1827
+ const checkboxItems = React.useMemo(() => generateCheckboxFilterItemsArgs.isSearchable
1828
+ ? mapToSearchableListItems(itemsWithCheckedState, handleApply)
1829
+ : itemsWithCheckedState, [
1948
1830
  itemsWithCheckedState,
1949
1831
  generateCheckboxFilterItemsArgs.isSearchable,
1950
1832
  handleApply,
1951
1833
  ]);
1952
- var numberOfAppliedFilters = groups.length + options.length;
1834
+ const numberOfAppliedFilters = groups.length + options.length;
1953
1835
  return {
1954
- state: __assign(__assign({}, (groupFilterName ? (_b = {}, _b[groupFilterName] = groups, _b) : {})), (optionFilterName ? (_c = {}, _c[optionFilterName] = options, _c) : {})),
1955
- checkboxItems: checkboxItems,
1836
+ state: {
1837
+ ...(groupFilterName ? { [groupFilterName]: groups } : {}),
1838
+ ...(optionFilterName ? { [optionFilterName]: options } : {}),
1839
+ },
1840
+ checkboxItems,
1956
1841
  onApply: handleApply,
1957
- numberOfAppliedFilters: numberOfAppliedFilters,
1842
+ numberOfAppliedFilters,
1958
1843
  isApplied: !!numberOfAppliedFilters,
1959
- reset: reset,
1844
+ reset,
1960
1845
  };
1961
1846
  };
1962
1847
 
1963
- var useFuelTypeFilter = function (_a) {
1964
- var filters = _a.filters, vehicleCategory = _a.vehicleCategory, facets = _a.facets, onAddFilter = _a.onAddFilter, onChange = _a.onChange;
1965
- var _b = useFilterContext(), t = _b.t, referenceData = _b.referenceData, language = _b.language;
1966
- var categoryData = referenceData[vehicleCategory];
1967
- var _c = useCheckboxFilter({
1968
- filters: filters,
1848
+ const useFuelTypeFilter = ({ filters, vehicleCategory, facets, onAddFilter, onChange }) => {
1849
+ const { t, referenceData, language } = useFilterContext();
1850
+ const categoryData = referenceData[vehicleCategory];
1851
+ const { checkboxItems, onApply, ...rest } = useCheckboxFilter({
1852
+ filters,
1969
1853
  isSearchable: false,
1970
1854
  options: {
1971
1855
  items: categoryData.fuelTypes,
@@ -1978,7 +1862,7 @@ var useFuelTypeFilter = function (_a) {
1978
1862
  translationKey: 'fuelTypeGroup',
1979
1863
  },
1980
1864
  groupMapping: categoryData.fuelTypeGroupMapping,
1981
- getFacet: function (args) { return getFacet(__assign(__assign({}, args), { facets: facets })); },
1865
+ getFacet: (args) => getFacet({ ...args, facets }),
1982
1866
  customOrder: [
1983
1867
  exports.FuelTypeGroup.Petrol,
1984
1868
  exports.FuelTypeGroup.Diesel,
@@ -1987,21 +1871,23 @@ var useFuelTypeFilter = function (_a) {
1987
1871
  exports.FuelTypeGroup.Gas,
1988
1872
  exports.FuelTypeGroup.Other,
1989
1873
  ],
1990
- t: t,
1991
- onAddFilter: onAddFilter,
1992
- onChange: onChange,
1993
- }), checkboxItems = _c.checkboxItems, onApply = _c.onApply, rest = __rest(_c, ["checkboxItems", "onApply"]);
1994
- return __assign({ ui: (React.createElement(components.CheckboxFilter, { items: checkboxItems, onApply: onApply, language: language })), label: t('filtersPkg.fuelType'), getDisplayValue: function (query) {
1995
- return getCheckboxDisplayValue(checkboxItems, query || rest.state);
1996
- } }, rest);
1874
+ t,
1875
+ onAddFilter,
1876
+ onChange,
1877
+ });
1878
+ return {
1879
+ ui: (React.createElement(components.CheckboxFilter, { items: checkboxItems, onApply: onApply, language: language })),
1880
+ label: t('filtersPkg.fuelType'),
1881
+ getDisplayValue: (query) => getCheckboxDisplayValue(checkboxItems, query || rest.state),
1882
+ ...rest,
1883
+ };
1997
1884
  };
1998
1885
 
1999
- var useConditionTypeFilter = function (_a) {
2000
- var filters = _a.filters, vehicleCategory = _a.vehicleCategory, facets = _a.facets, onAddFilter = _a.onAddFilter, onChange = _a.onChange;
2001
- var _b = useFilterContext(), t = _b.t, referenceData = _b.referenceData, language = _b.language;
2002
- var categoryData = referenceData[vehicleCategory];
2003
- var _c = useCheckboxFilter({
2004
- filters: filters,
1886
+ const useConditionTypeFilter = ({ filters, vehicleCategory, facets, onAddFilter, onChange }) => {
1887
+ const { t, referenceData, language } = useFilterContext();
1888
+ const categoryData = referenceData[vehicleCategory];
1889
+ const { checkboxItems, onApply, ...rest } = useCheckboxFilter({
1890
+ filters,
2005
1891
  isSearchable: false,
2006
1892
  options: {
2007
1893
  items: categoryData.conditionTypes,
@@ -2014,30 +1900,32 @@ var useConditionTypeFilter = function (_a) {
2014
1900
  translationKey: 'conditionTypeGroup',
2015
1901
  },
2016
1902
  groupMapping: categoryData.conditionTypeGroupMapping,
2017
- getFacet: function (args) { return getFacet(__assign(__assign({}, args), { facets: facets })); },
2018
- t: t,
2019
- onAddFilter: onAddFilter,
2020
- onChange: onChange,
2021
- }), checkboxItems = _c.checkboxItems, onApply = _c.onApply, rest = __rest(_c, ["checkboxItems", "onApply"]);
2022
- return __assign({ ui: (React.createElement(components.CheckboxFilter, { items: checkboxItems, onApply: onApply, language: language })), label: t('filtersPkg.conditionType'), getDisplayValue: function (query) {
2023
- return getCheckboxDisplayValue(checkboxItems, query || rest.state);
2024
- } }, rest);
1903
+ getFacet: (args) => getFacet({ ...args, facets }),
1904
+ t,
1905
+ onAddFilter,
1906
+ onChange,
1907
+ });
1908
+ return {
1909
+ ui: (React.createElement(components.CheckboxFilter, { items: checkboxItems, onApply: onApply, language: language })),
1910
+ label: t('filtersPkg.conditionType'),
1911
+ getDisplayValue: (query) => getCheckboxDisplayValue(checkboxItems, query || rest.state),
1912
+ ...rest,
1913
+ };
2025
1914
  };
2026
1915
 
2027
- var _a, _b;
2028
- var bodyTypeIconMap = (_a = {},
2029
- _a[exports.BodyType.Bus] = components.VanIcon,
2030
- _a[exports.BodyType.Cabriolet] = components.CabrioletIcon,
2031
- _a[exports.BodyType.Coupe] = components.CoupeIcon,
2032
- _a[exports.BodyType.Estate] = components.WagonIcon,
2033
- _a[exports.BodyType.Minivan] = components.MiniVanIcon,
2034
- _a[exports.BodyType.Pickup] = components.PickUpIcon,
2035
- _a[exports.BodyType.Saloon] = components.SedanIcon,
2036
- _a[exports.BodyType.Smallcar] = components.SmallCarIcon,
2037
- _a[exports.BodyType.SUV] = components.SuvIcon,
2038
- _a);
2039
- var bodyTypeCustomOrder = (_b = {},
2040
- _b[exports.VehicleCategory.Car] = [
1916
+ const bodyTypeIconMap = {
1917
+ [exports.BodyType.Bus]: components.VanIcon,
1918
+ [exports.BodyType.Cabriolet]: components.CabrioletIcon,
1919
+ [exports.BodyType.Coupe]: components.CoupeIcon,
1920
+ [exports.BodyType.Estate]: components.WagonIcon,
1921
+ [exports.BodyType.Minivan]: components.MiniVanIcon,
1922
+ [exports.BodyType.Pickup]: components.PickUpIcon,
1923
+ [exports.BodyType.Saloon]: components.SedanIcon,
1924
+ [exports.BodyType.Smallcar]: components.SmallCarIcon,
1925
+ [exports.BodyType.SUV]: components.SuvIcon,
1926
+ };
1927
+ const bodyTypeCustomOrder = {
1928
+ [exports.VehicleCategory.Car]: [
2041
1929
  exports.BodyType.Estate,
2042
1930
  exports.BodyType.SUV,
2043
1931
  exports.BodyType.Saloon,
@@ -2048,66 +1936,69 @@ var bodyTypeCustomOrder = (_b = {},
2048
1936
  exports.BodyType.Minivan,
2049
1937
  exports.BodyType.Bus,
2050
1938
  ],
2051
- _b);
2052
- var useBodyTypeFilter = function (_a) {
2053
- var filters = _a.filters, vehicleCategory = _a.vehicleCategory, facets = _a.facets, onAddFilter = _a.onAddFilter, onChange = _a.onChange, numberOfColumnsOnDesktop = _a.numberOfColumnsOnDesktop;
2054
- var _b = useFilterContext(), t = _b.t, referenceData = _b.referenceData, language = _b.language;
2055
- var categoryData = referenceData[vehicleCategory];
2056
- var _c = useCheckboxFilter({
2057
- filters: filters,
1939
+ };
1940
+ const useBodyTypeFilter = ({ filters, vehicleCategory, facets, onAddFilter, onChange, numberOfColumnsOnDesktop, }) => {
1941
+ const { t, referenceData, language } = useFilterContext();
1942
+ const categoryData = referenceData[vehicleCategory];
1943
+ const { checkboxItems, onApply, ...rest } = useCheckboxFilter({
1944
+ filters,
2058
1945
  isSearchable: false,
2059
1946
  options: {
2060
1947
  items: categoryData.bodyTypes,
2061
1948
  key: 'bodyTypes',
2062
1949
  translationKey: 'bodyType',
2063
- getImage: function (key) {
1950
+ getImage: (key) => {
2064
1951
  if (vehicleCategory !== exports.VehicleCategory.Car)
2065
1952
  return null;
2066
- var Icon = bodyTypeIconMap[key];
1953
+ const Icon = bodyTypeIconMap[key];
2067
1954
  if (!Icon)
2068
1955
  return null;
2069
1956
  return React.createElement(Icon, { w: 75, h: 51 });
2070
1957
  },
2071
1958
  },
2072
1959
  customOrder: bodyTypeCustomOrder[vehicleCategory],
2073
- getFacet: function (args) { return getFacet(__assign(__assign({}, args), { facets: facets })); },
2074
- t: t,
2075
- onAddFilter: onAddFilter,
2076
- onChange: onChange,
2077
- }), checkboxItems = _c.checkboxItems, onApply = _c.onApply, rest = __rest(_c, ["checkboxItems", "onApply"]);
2078
- return __assign({ ui: (React.createElement(components.CheckboxFilter, { items: checkboxItems, onApply: onApply, language: language, numberOfColumnsOnDesktop: numberOfColumnsOnDesktop })), label: t('filtersPkg.bodyType'), getDisplayValue: function (query) {
2079
- return getCheckboxDisplayValue(checkboxItems, query || rest.state);
2080
- } }, rest);
1960
+ getFacet: (args) => getFacet({ ...args, facets }),
1961
+ t,
1962
+ onAddFilter,
1963
+ onChange,
1964
+ });
1965
+ return {
1966
+ ui: (React.createElement(components.CheckboxFilter, { items: checkboxItems, onApply: onApply, language: language, numberOfColumnsOnDesktop: numberOfColumnsOnDesktop })),
1967
+ label: t('filtersPkg.bodyType'),
1968
+ getDisplayValue: (query) => getCheckboxDisplayValue(checkboxItems, query || rest.state),
1969
+ ...rest,
1970
+ };
2081
1971
  };
2082
1972
 
2083
- var useDriveTypeFilter = function (_a) {
2084
- var filters = _a.filters, vehicleCategory = _a.vehicleCategory, facets = _a.facets, onAddFilter = _a.onAddFilter, onChange = _a.onChange;
2085
- var _b = useFilterContext(), t = _b.t, referenceData = _b.referenceData, language = _b.language;
2086
- var categoryData = referenceData[vehicleCategory];
2087
- var _c = useCheckboxFilter({
2088
- filters: filters,
1973
+ const useDriveTypeFilter = ({ filters, vehicleCategory, facets, onAddFilter, onChange }) => {
1974
+ const { t, referenceData, language } = useFilterContext();
1975
+ const categoryData = referenceData[vehicleCategory];
1976
+ const { checkboxItems, onApply, ...rest } = useCheckboxFilter({
1977
+ filters,
2089
1978
  isSearchable: false,
2090
1979
  options: {
2091
1980
  items: categoryData.driveTypes,
2092
1981
  key: 'driveTypes',
2093
1982
  translationKey: 'driveType',
2094
1983
  },
2095
- getFacet: function (args) { return getFacet(__assign(__assign({}, args), { facets: facets })); },
2096
- t: t,
2097
- onAddFilter: onAddFilter,
2098
- onChange: onChange,
2099
- }), checkboxItems = _c.checkboxItems, onApply = _c.onApply, rest = __rest(_c, ["checkboxItems", "onApply"]);
2100
- return __assign({ ui: (React.createElement(components.CheckboxFilter, { items: checkboxItems, onApply: onApply, language: language })), label: t('filtersPkg.driveType'), getDisplayValue: function (query) {
2101
- return getCheckboxDisplayValue(checkboxItems, query || rest.state);
2102
- } }, rest);
1984
+ getFacet: (args) => getFacet({ ...args, facets }),
1985
+ t,
1986
+ onAddFilter,
1987
+ onChange,
1988
+ });
1989
+ return {
1990
+ ui: (React.createElement(components.CheckboxFilter, { items: checkboxItems, onApply: onApply, language: language })),
1991
+ label: t('filtersPkg.driveType'),
1992
+ getDisplayValue: (query) => getCheckboxDisplayValue(checkboxItems, query || rest.state),
1993
+ ...rest,
1994
+ };
2103
1995
  };
2104
1996
 
2105
- var useTransmissionTypeFilter = function (_a) {
2106
- var filters = _a.filters, vehicleCategory = _a.vehicleCategory, facets = _a.facets, onAddFilter = _a.onAddFilter, onChange = _a.onChange;
2107
- var _b = useFilterContext(), t = _b.t, referenceData = _b.referenceData, language = _b.language;
2108
- var categoryData = referenceData[vehicleCategory];
2109
- var _c = useCheckboxFilter({
2110
- filters: filters,
1997
+ const useTransmissionTypeFilter = ({ filters, vehicleCategory, facets, onAddFilter, onChange }) => {
1998
+ const { t, referenceData, language } = useFilterContext();
1999
+ const categoryData = referenceData[vehicleCategory];
2000
+ const { checkboxItems, onApply, ...rest } = useCheckboxFilter({
2001
+ filters,
2111
2002
  isSearchable: false,
2112
2003
  options: {
2113
2004
  items: categoryData.transmissionTypes,
@@ -2120,14 +2011,17 @@ var useTransmissionTypeFilter = function (_a) {
2120
2011
  translationKey: 'transmissionTypeGroup',
2121
2012
  },
2122
2013
  groupMapping: categoryData.transmissionTypeGroupMapping,
2123
- getFacet: function (args) { return getFacet(__assign(__assign({}, args), { facets: facets })); },
2124
- t: t,
2125
- onAddFilter: onAddFilter,
2126
- onChange: onChange,
2127
- }), checkboxItems = _c.checkboxItems, onApply = _c.onApply, rest = __rest(_c, ["checkboxItems", "onApply"]);
2128
- return __assign({ ui: (React.createElement(components.CheckboxFilter, { items: checkboxItems, onApply: onApply, language: language })), label: t('filtersPkg.transmissionType'), getDisplayValue: function (query) {
2129
- return getCheckboxDisplayValue(checkboxItems, query || rest.state);
2130
- } }, rest);
2014
+ getFacet: (args) => getFacet({ ...args, facets }),
2015
+ t,
2016
+ onAddFilter,
2017
+ onChange,
2018
+ });
2019
+ return {
2020
+ ui: (React.createElement(components.CheckboxFilter, { items: checkboxItems, onApply: onApply, language: language })),
2021
+ label: t('filtersPkg.transmissionType'),
2022
+ getDisplayValue: (query) => getCheckboxDisplayValue(checkboxItems, query || rest.state),
2023
+ ...rest,
2024
+ };
2131
2025
  };
2132
2026
 
2133
2027
  exports.FilterProvider = FilterProvider;