@wayke-se/components-react 3.0.0-beta.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist-node/index.js +3203 -1047
  2. package/dist-node/index.js.map +1 -1
  3. package/dist-src/State/CentralStorage/useCentralStorage.js +7 -8
  4. package/dist-src/State/Path/PathProvider.js +1 -1
  5. package/dist-src/State/RelatedSearch/RelatedSearchProvider.js +1 -1
  6. package/dist-src/State/Search/SearchProvider.js +7 -10
  7. package/dist-src/components/ActionList/index.js +2 -3
  8. package/dist-src/components/Checklist/index.js +1 -1
  9. package/dist-src/components/ExtendContent/index.js +1 -1
  10. package/dist-src/components/Filter/index.js +10 -7
  11. package/dist-src/components/FilterPanel/checkListFacet.js +1 -1
  12. package/dist-src/components/FilterPanel/colorFacet.js +1 -1
  13. package/dist-src/components/FilterPanel/index.js +1 -1
  14. package/dist-src/components/FilterPanel/rangeFacet.js +14 -16
  15. package/dist-src/components/FinancialOptions/LoanModal.js +27 -29
  16. package/dist-src/components/FinancialOptions/leasing.js +6 -6
  17. package/dist-src/components/FinancialOptions/loan.js +5 -6
  18. package/dist-src/components/Gallery/index.js +11 -16
  19. package/dist-src/components/Grid/index.js +2 -3
  20. package/dist-src/components/InputSelect/index.js +1 -1
  21. package/dist-src/components/InsuranceOptions/InsuranceFree.js +1 -2
  22. package/dist-src/components/InsuranceOptions/InsuranceFreeModal.js +4 -5
  23. package/dist-src/components/InsuranceOptions/InsuranceModal.js +3 -3
  24. package/dist-src/components/Lightbox/index.js +1 -1
  25. package/dist-src/components/OpeningHours/index.js +9 -9
  26. package/dist-src/components/RangeSlider/SliderWithLabel.js +1 -1
  27. package/dist-src/components/Result/index.js +7 -6
  28. package/dist-src/components/Video/EmbededVideo.js +1 -1
  29. package/dist-src/components/Video/QuickNavEmbeded.js +2 -2
  30. package/dist-src/components/Video/useThumbnail.js +1 -1
  31. package/dist-src/components/Video/utils.js +2 -2
  32. package/dist-src/hooks/useFetch.js +1 -1
  33. package/dist-src/hooks/useVimeoThumbnail.js +1 -1
  34. package/dist-src/layouts/searchItem/Branch.js +9 -10
  35. package/dist-src/layouts/searchItem/BranchModal.js +1 -1
  36. package/dist-src/layouts/searchItem/CheckList.js +16 -16
  37. package/dist-src/layouts/searchItem/ManufacturerPackagesOption.js +1 -2
  38. package/dist-src/layouts/searchItem/PackageOptionModal.js +7 -10
  39. package/dist-src/layouts/searchItem/PackageOptions.js +11 -14
  40. package/dist-src/layouts/searchItem/Property.js +4 -6
  41. package/dist-src/layouts/searchItem/Related.js +3 -4
  42. package/dist-src/layouts/searchItem/index.js +15 -17
  43. package/dist-src/providers/WaykeItemProvidet.js +7 -11
  44. package/dist-src/providers/WaykeProvider.js +8 -12
  45. package/dist-src/utils/phonenumbers.js +1 -1
  46. package/dist-src/utils/specification.js +9 -13
  47. package/dist-src/utils/vehicle-properties/property-tree-creator.js +5 -5
  48. package/dist-types/components/InputSearch/index.d.ts +5 -3
  49. package/dist-types/components/RangeSlider/handle.d.ts +2 -2
  50. package/dist-types/components/RangeSlider/track.d.ts +2 -2
  51. package/dist-web/index.js +221 -272
  52. package/dist-web/index.js.map +1 -1
  53. package/package.json +18 -25
  54. package/dist-src/hooks/useEcom.js +0 -18
  55. package/dist-types/hooks/useEcom.d.ts +0 -3
package/dist-web/index.js CHANGED
@@ -679,14 +679,15 @@ const getTranslatedSortOptionDisplayName = (str) => {
679
679
  };
680
680
 
681
681
  const Result = ({ children }) => {
682
- var _a;
683
682
  const { loading, response, documents, queryFilter, onLoadMore, onFilterUpdate } = useSearch();
684
683
  const onSortOptionChange = useCallback((e) => onFilterUpdate(e.currentTarget.value), []);
685
- const numberOfDocuments = (documents === null || documents === void 0 ? void 0 : documents.length) || 0;
686
- const numberOfHits = (response === null || response === void 0 ? void 0 : response.documentList.numberOfHits) || 0;
687
- const useSkeletons = !!(queryFilter === null || queryFilter === void 0 ? void 0 : queryFilter.concatResult);
688
- const selectedSortOption = (_a = response === null || response === void 0 ? void 0 : response.documentList.sortOptions.find((x) => x.selected)) === null || _a === void 0 ? void 0 : _a.query;
689
- const sortOptions = response === null || response === void 0 ? void 0 : response.documentList.sortOptions.filter((x) => x.displayName !== 'relevance').map((so) => ({
684
+ const numberOfDocuments = documents?.length || 0;
685
+ const numberOfHits = response?.documentList.numberOfHits || 0;
686
+ const useSkeletons = !!queryFilter?.concatResult;
687
+ const selectedSortOption = response?.documentList.sortOptions.find((x) => x.selected)?.query;
688
+ const sortOptions = response?.documentList.sortOptions
689
+ .filter((x) => x.displayName !== 'relevance')
690
+ .map((so) => ({
690
691
  value: so.query,
691
692
  displayName: getTranslatedSortOptionDisplayName(so.displayName),
692
693
  }));
@@ -1196,7 +1197,7 @@ const ChecklistItem = ({ label, onClick, active, radio }) => (React__default.cre
1196
1197
  active && React__default.createElement(ActionIcon, null, radio ? React__default.createElement(IconRadio, { block: true }) : React__default.createElement(IconCheck, { block: true })),
1197
1198
  React__default.createElement(ActionLabel, { className: active ? 'wayke__theme wayke__font--bold wayke__color--primary-text' : '' }, label))));
1198
1199
  const Checklist = ({ items, radio }) => {
1199
- if (!(items === null || items === void 0 ? void 0 : items.length)) {
1200
+ if (!items?.length) {
1200
1201
  return null;
1201
1202
  }
1202
1203
  return (React__default.createElement(List$2, null, items.map((item) => (React__default.createElement(ChecklistItem, { key: item.label, label: item.label, onClick: item.onClick, active: item.active, radio: radio })))));
@@ -1231,7 +1232,7 @@ const ChecklistFacet = ({ facet }) => {
1231
1232
  .map((f) => ({
1232
1233
  label: f.displayName,
1233
1234
  onClick: () => onClick(f),
1234
- active: (selected === null || selected === void 0 ? void 0 : selected[f.displayName]) !== undefined ? selected[f.displayName] : f.selected,
1235
+ active: selected?.[f.displayName] !== undefined ? selected[f.displayName] : f.selected,
1235
1236
  })) })));
1236
1237
  };
1237
1238
 
@@ -1369,7 +1370,7 @@ const ColorSelectFacet = ({ facet }) => {
1369
1370
  .map((f) => ({
1370
1371
  label: f.displayName,
1371
1372
  onClick: () => onClick(f),
1372
- active: (selected === null || selected === void 0 ? void 0 : selected[f.displayName]) !== undefined ? selected[f.displayName] : f.selected,
1373
+ active: selected?.[f.displayName] !== undefined ? selected[f.displayName] : f.selected,
1373
1374
  hex: [getHexColorFromDisplayName(f.displayName)],
1374
1375
  })) }));
1375
1376
  };
@@ -1514,9 +1515,9 @@ const RangeSlider = ({ loading, values, domain, steps, unit, formatValues, maxPr
1514
1515
 
1515
1516
  const getInitialValues = (domain, facet, searchParams) => {
1516
1517
  const facetMin = domain[0]; //parseInt(facet.filters[0].displayName, 10);
1517
- const _queryMin = (searchParams === null || searchParams === void 0 ? void 0 : searchParams.get(`${facet.id}.min`)) || null;
1518
+ const _queryMin = searchParams?.get(`${facet.id}.min`) || null;
1518
1519
  const facetMax = domain[domain.length - 1]; //parseInt(facet.filters[facet.filters.length - 1].displayName, 10);
1519
- const _queryMax = (searchParams === null || searchParams === void 0 ? void 0 : searchParams.get(`${facet.id}.max`)) || null;
1520
+ const _queryMax = searchParams?.get(`${facet.id}.max`) || null;
1520
1521
  const queryMin = parseInt(_queryMin === null ? `${facetMin}` : _queryMin, 10);
1521
1522
  const min = facetMin > queryMin ? facetMin : queryMin;
1522
1523
  const queryMax = parseInt(_queryMax === null ? `${facetMax}` : _queryMax, 10);
@@ -1538,41 +1539,39 @@ const getSteps$1 = (initialAllValues) => {
1538
1539
  return initialAllValues;
1539
1540
  };
1540
1541
  const RangeFacet = ({ facet, unit, formatValues }) => {
1541
- var _a, _b, _c;
1542
1542
  const { loading, queryFilter, initialFacets, onFilterUpdate } = useSearch();
1543
- const initialFacet = initialFacets === null || initialFacets === void 0 ? void 0 : initialFacets.find((x) => x.id === facet.id);
1544
- const maxPrefix = (_b = (_a = initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.filters[(initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.filters.length) - 1]) === null || _a === void 0 ? void 0 : _a.displayName) === null || _b === void 0 ? void 0 : _b.includes('+');
1543
+ const initialFacet = initialFacets?.find((x) => x.id === facet.id);
1544
+ const maxPrefix = initialFacet?.filters[initialFacet?.filters.length - 1]?.displayName?.includes('+');
1545
1545
  const [state, setValues] = useState(undefined);
1546
1546
  useEffect(() => {
1547
- const _initialAllValues = (initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.filters.map((f) => parseInt(f.displayName.replace(/[\<\>+-]+/g, ''), 10))) || [1, 2];
1547
+ const _initialAllValues = initialFacet?.filters.map((f) => parseInt(f.displayName.replace(/[\<\>+-]+/g, ''), 10)) || [1, 2];
1548
1548
  const _steps = getSteps$1(_initialAllValues);
1549
1549
  const domain = [_steps[0], _steps[_steps.length - 1]];
1550
1550
  setValues({
1551
- id: initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.id,
1551
+ id: initialFacet?.id,
1552
1552
  steps: _steps,
1553
1553
  domain: [_steps[0], _steps[_steps.length - 1]],
1554
- values: (initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.filters.length)
1554
+ values: initialFacet?.filters.length
1555
1555
  ? getInitialValues(domain, initialFacet, queryFilter.searchParams)
1556
1556
  : [0, 0],
1557
1557
  });
1558
- }, [initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.id]);
1558
+ }, [initialFacet?.id]);
1559
1559
  useEffect(() => {
1560
- var _a, _b;
1561
- if (state === null || state === void 0 ? void 0 : state.id) {
1562
- const init = (initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.filters.length)
1560
+ if (state?.id) {
1561
+ const init = initialFacet?.filters.length
1563
1562
  ? getInitialValues(state.domain, initialFacet, queryFilter.searchParams)
1564
1563
  : [0, 0];
1565
- const minStr = (_a = queryFilter.searchParams) === null || _a === void 0 ? void 0 : _a.get(`${facet.id}.min`);
1566
- const maxStr = (_b = queryFilter.searchParams) === null || _b === void 0 ? void 0 : _b.get(`${facet.id}.max`);
1564
+ const minStr = queryFilter.searchParams?.get(`${facet.id}.min`);
1565
+ const maxStr = queryFilter.searchParams?.get(`${facet.id}.max`);
1567
1566
  const min = minStr ? parseFloat(minStr) : init[0];
1568
1567
  const max = maxStr ? parseFloat(maxStr) : init[1];
1569
1568
  if (min !== state.values[0] || max !== state.values[1]) {
1570
1569
  onChange([min, max]);
1571
1570
  }
1572
1571
  }
1573
- }, [(_c = queryFilter.searchParams) === null || _c === void 0 ? void 0 : _c.toString()]);
1572
+ }, [queryFilter.searchParams?.toString()]);
1574
1573
  const onChange = useCallback((nextValues) => {
1575
- if (state === null || state === void 0 ? void 0 : state.id) {
1574
+ if (state?.id) {
1576
1575
  if (state.values[0] !== nextValues[0] || state.values[1] !== nextValues[1]) {
1577
1576
  setValues({ ...state, values: nextValues.slice() });
1578
1577
  const query = new URLSearchParams(queryFilter.searchParams);
@@ -1631,7 +1630,7 @@ const FilterPanel = ({ facet, filteredFacets, numberOfHits, loading, onFilterUpd
1631
1630
  React__default.createElement(ButtonContent, null, `Visa ${numberOfHits} ${numberOfHits === 1 ? 'bil' : 'bilar'}`))))) },
1632
1631
  React__default.createElement(Accordion, null, filteredFacets
1633
1632
  .filter((x) => x.filters.length)
1634
- .map((f) => (React__default.createElement(AccordionItem, { key: f.displayName, heading: f.displayName, isActive: f.id === (facet === null || facet === void 0 ? void 0 : facet.id) },
1633
+ .map((f) => (React__default.createElement(AccordionItem, { key: f.displayName, heading: f.displayName, isActive: f.id === facet?.id },
1635
1634
  React__default.createElement(Repeat, null,
1636
1635
  React__default.createElement(FacetSelector, { facet: f }))))))));
1637
1636
  };
@@ -1647,9 +1646,8 @@ const isSelected = (f, searchParams) => {
1647
1646
  }
1648
1647
  };
1649
1648
  const Filter = ({ filterList }) => {
1650
- var _a;
1651
1649
  const { queryFilter, initialFacets, loading, response, onFilterUpdate } = useSearch();
1652
- const facets = response === null || response === void 0 ? void 0 : response.facets;
1650
+ const facets = response?.facets;
1653
1651
  const [facet, setFacet] = useState();
1654
1652
  const onSelectFacet = useCallback((nextFacet) => setFacet(nextFacet), []);
1655
1653
  const onClose = useCallback(() => setFacet(undefined), []);
@@ -1657,12 +1655,16 @@ const Filter = ({ filterList }) => {
1657
1655
  return null;
1658
1656
  }
1659
1657
  const filterNames = filterList ? filterList.map((x) => x.filterName) : undefined;
1660
- const filteredFacets = (_a = facets === null || facets === void 0 ? void 0 : facets.filter((x) => x.id !== 'segment')) === null || _a === void 0 ? void 0 : _a.filter((f) => (filterNames ? filterNames.includes(f.id) : true)).sort((a, b) => filterNames
1658
+ const filteredFacets = facets
1659
+ ?.filter((x) => x.id !== 'segment')
1660
+ ?.filter((f) => (filterNames ? filterNames.includes(f.id) : true))
1661
+ .sort((a, b) => filterNames
1661
1662
  ? filterNames.indexOf(a.id) -
1662
1663
  filterNames.indexOf(b.id)
1663
- : 0).map((x) => {
1664
- const match = filterList === null || filterList === void 0 ? void 0 : filterList.find((y) => y.filterName === x.id);
1665
- if (match === null || match === void 0 ? void 0 : match.displayName) {
1664
+ : 0)
1665
+ .map((x) => {
1666
+ const match = filterList?.find((y) => y.filterName === x.id);
1667
+ if (match?.displayName) {
1666
1668
  return {
1667
1669
  ...x,
1668
1670
  displayName: match.displayName,
@@ -1674,7 +1676,7 @@ const Filter = ({ filterList }) => {
1674
1676
  };
1675
1677
  });
1676
1678
  return (React__default.createElement(React__default.Fragment, null,
1677
- initialFacets && facet && (React__default.createElement(FilterPanel, { filterList: filterList, facet: facet, loading: loading, filteredFacets: filteredFacets, numberOfHits: (response === null || response === void 0 ? void 0 : response.documentList.numberOfHits) || 0, onFilterUpdate: onFilterUpdate, onClose: onClose })),
1679
+ initialFacets && facet && (React__default.createElement(FilterPanel, { filterList: filterList, facet: facet, loading: loading, filteredFacets: filteredFacets, numberOfHits: response?.documentList.numberOfHits || 0, onFilterUpdate: onFilterUpdate, onClose: onClose })),
1678
1680
  React__default.createElement(List, null, filteredFacets
1679
1681
  .filter((x) => x.filters.length)
1680
1682
  .map((f) => {
@@ -1983,8 +1985,7 @@ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, desc
1983
1985
  };
1984
1986
 
1985
1987
  const resolveImage = (document) => {
1986
- var _a, _b, _c;
1987
- const img = (_c = (_b = (_a = document.featuredImage) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.url;
1988
+ const img = document.featuredImage?.files?.[0]?.url;
1988
1989
  if (img) {
1989
1990
  return `${img}?w=567&q=72`;
1990
1991
  }
@@ -1996,7 +1997,7 @@ const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, onClickItem }
1996
1997
  }
1997
1998
  return (React__default.createElement(Wrapper$7, null,
1998
1999
  React__default.createElement(List$4, null, documents.map((document) => {
1999
- const _path = pathRoute === null || pathRoute === void 0 ? void 0 : pathRoute.replace(/^\/|\/$/g, '');
2000
+ const _path = pathRoute?.replace(/^\/|\/$/g, '');
2000
2001
  const prefix = _path ? `/${_path}/` : '/';
2001
2002
  const pathRouteUrl = window.location.pathname === '/'
2002
2003
  ? `${prefix}${document._id}`
@@ -2668,7 +2669,7 @@ const ExtendContent = ({ children, actionTitle, onClick }) => {
2668
2669
  }
2669
2670
  }, []);
2670
2671
  const onRef = (ref) => {
2671
- const refHeight = (ref === null || ref === void 0 ? void 0 : ref.clientHeight) || 0;
2672
+ const refHeight = ref?.clientHeight || 0;
2672
2673
  if (refHeight < 207) {
2673
2674
  setExtend(true);
2674
2675
  }
@@ -3082,7 +3083,7 @@ const getYoutubeThumbnail = (url) => {
3082
3083
  };
3083
3084
  };
3084
3085
  const onImageLoad = (e, thumbnail) => {
3085
- if ((thumbnail === null || thumbnail === void 0 ? void 0 : thumbnail.length) === 2 &&
3086
+ if (thumbnail?.length === 2 &&
3086
3087
  e.currentTarget.src === thumbnail[0] &&
3087
3088
  e.currentTarget.naturalWidth === 120 &&
3088
3089
  e.currentTarget.naturalHeight === 90) {
@@ -3090,7 +3091,7 @@ const onImageLoad = (e, thumbnail) => {
3090
3091
  }
3091
3092
  };
3092
3093
  const onImageError = (e, thumbnail) => {
3093
- if ((thumbnail === null || thumbnail === void 0 ? void 0 : thumbnail.length) === 2) {
3094
+ if (thumbnail?.length === 2) {
3094
3095
  e.currentTarget.src = thumbnail[1];
3095
3096
  }
3096
3097
  };
@@ -3570,7 +3571,7 @@ const Lightbox = ({ index, media, onClose }) => {
3570
3571
  onClose();
3571
3572
  }
3572
3573
  };
3573
- return (React__default.createElement(Wrapper$h, { ref: (ref) => ref === null || ref === void 0 ? void 0 : ref.focus(), onKeyDown: onKeyDown, tabIndex: 0 },
3574
+ return (React__default.createElement(Wrapper$h, { ref: (ref) => ref?.focus(), onKeyDown: onKeyDown, tabIndex: 0 },
3574
3575
  React__default.createElement(UiBlock$1, { onClick: onClose, "aria-hidden": true }),
3575
3576
  media.map((m, i) => (React__default.createElement(Item$8, { key: i, ref: index === i ? onRef : undefined },
3576
3577
  m.type === 'image' && (React__default.createElement(Img$1, { id: `lightbox-image-${i}`, src: m.files[0].url, alt: `Bild ${i + 1}` })),
@@ -3582,7 +3583,7 @@ const Lightbox = ({ index, media, onClose }) => {
3582
3583
  };
3583
3584
 
3584
3585
  const cache = {};
3585
- const getCachedResult = (key) => (cache === null || cache === void 0 ? void 0 : cache[key]) || undefined;
3586
+ const getCachedResult = (key) => cache?.[key] || undefined;
3586
3587
  const setCachedResult = (key, value) => {
3587
3588
  cache[key] = value;
3588
3589
  };
@@ -3653,7 +3654,7 @@ const useVimeoThumbnail = (id, small) => {
3653
3654
  const [thumbnail, setThumbnail] = useState();
3654
3655
  const { data } = useFetch(`http://vimeo.com/api/v2/video/${id}.json`, {}, !id || !!thumbnail, true);
3655
3656
  useEffect(() => {
3656
- if (data === null || data === void 0 ? void 0 : data[0]) {
3657
+ if (data?.[0]) {
3657
3658
  if (small && data[0].thumbnail_small) {
3658
3659
  setThumbnail(data[0].thumbnail_small);
3659
3660
  }
@@ -3666,7 +3667,7 @@ const useVimeoThumbnail = (id, small) => {
3666
3667
  };
3667
3668
 
3668
3669
  const useThumbnail = (url, small) => {
3669
- if (url === null || url === void 0 ? void 0 : url.toLowerCase().endsWith('.mp4'))
3670
+ if (url?.toLowerCase().endsWith('.mp4'))
3670
3671
  return;
3671
3672
  const [thumbnail, setThumbnail] = useState();
3672
3673
  const vimeoId = url ? getVimeoId(url) : undefined;
@@ -3825,7 +3826,7 @@ const GalleryEmbed = ({ src, index }) => {
3825
3826
  const onError = useCallback((e) => onImageError(e, thumbnail), [thumbnail]);
3826
3827
  const onLoad = useCallback((e) => onImageLoad(e, thumbnail), [thumbnail]);
3827
3828
  const customVideo = src.toLowerCase().endsWith('.mp4');
3828
- if ((thumbnail === null || thumbnail === void 0 ? void 0 : thumbnail.length) && !customVideo) {
3829
+ if (thumbnail?.length && !customVideo) {
3829
3830
  return (React__default.createElement(React__default.Fragment, null,
3830
3831
  React__default.createElement(ImageFull, { onLoad: onLoad, src: thumbnail[0], onError: onError, alt: `Bild ${index + 1}` }),
3831
3832
  React__default.createElement(MediaButton, { text: "Spela video", onClick: onClick }),
@@ -3845,8 +3846,8 @@ const QuickNavEmbeded = ({ src, index }) => {
3845
3846
  const thumbnail = useThumbnail(src);
3846
3847
  const onError = useCallback((e) => onImageError(e, thumbnail), [thumbnail]);
3847
3848
  const onLoad = useCallback((e) => onImageLoad(e, thumbnail), [thumbnail]);
3848
- const customVideo = src === null || src === void 0 ? void 0 : src.toLowerCase().endsWith('.mp4');
3849
- if ((thumbnail === null || thumbnail === void 0 ? void 0 : thumbnail.length) && !customVideo)
3849
+ const customVideo = src?.toLowerCase().endsWith('.mp4');
3850
+ if (thumbnail?.length && !customVideo)
3850
3851
  return (React__default.createElement(QuickNavImg, { onLoad: onLoad, src: thumbnail[0], onError: onError, alt: `Bild ${index + 1}` }));
3851
3852
  if (customVideo)
3852
3853
  return React__default.createElement(CustomPlayer, { key: index, url: src, ratio: "66.66%" });
@@ -3907,8 +3908,7 @@ const Gallery = ({ media, placeholderImage }) => {
3907
3908
  const [lightbox, setLightbox] = useState(false);
3908
3909
  const [navigationDisabled, setNavigationDisabled] = useState(false);
3909
3910
  const beforeChange = useCallback((_, newIndex) => {
3910
- var _a, _b;
3911
- const element = (_b = (_a = quickNavRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('li')) === null || _b === void 0 ? void 0 : _b[newIndex];
3911
+ const element = quickNavRef.current?.querySelectorAll('li')?.[newIndex];
3912
3912
  if (element) {
3913
3913
  scrollIntoView(element, { scrollMode: 'if-needed', block: 'nearest', inline: 'nearest' });
3914
3914
  }
@@ -3926,7 +3926,7 @@ const Gallery = ({ media, placeholderImage }) => {
3926
3926
  }, []);
3927
3927
  const onClick = useCallback(() => {
3928
3928
  PubSub.publish('ImagesClick');
3929
- if (!isDragging.current && !lightbox && !!(media === null || media === void 0 ? void 0 : media.length)) {
3929
+ if (!isDragging.current && !lightbox && !!media?.length) {
3930
3930
  setLightbox(true);
3931
3931
  }
3932
3932
  }, [lightbox, media]);
@@ -3961,20 +3961,17 @@ const Gallery = ({ media, placeholderImage }) => {
3961
3961
  setNavigationDisabled(false);
3962
3962
  };
3963
3963
  const onToggleLightbox = useCallback(() => setLightbox(!lightbox), [lightbox]);
3964
- const mediaLength = (media === null || media === void 0 ? void 0 : media.length) || 0;
3964
+ const mediaLength = media?.length || 0;
3965
3965
  const placeholder = useMemo(() => placeholderImage || DEFAULT_PLACEHOLDER_IMAGE, [placeholderImage]);
3966
3966
  return (React__default.createElement(React__default.Fragment, null,
3967
3967
  React__default.createElement(Wrapper$g, null,
3968
3968
  React__default.createElement(Main, null,
3969
3969
  React__default.createElement(SliderWrapper, { onMouseDown: onMouseDown, onMouseMove: onMouseMove, onClick: onClick },
3970
- React__default.createElement(Slider$2, { ...sliderSettings, swipe: !navigationDisabled, touchMove: !navigationDisabled, swipeToSlide: !navigationDisabled, ref: slider, beforeChange: beforeChange }, !!(media === null || media === void 0 ? void 0 : media.length) ? (media.map((m, i) => {
3971
- var _a;
3972
- return (React__default.createElement(Item$7, { key: m.files[0].url || i },
3973
- m.type === 'image' && (React__default.createElement(Image$1, { src: (_a = m.files[0].formats.filter(notEmpty).find((x) => x.format === '1170x')) === null || _a === void 0 ? void 0 : _a.url, alt: `Bild ${i + 1}` })),
3974
- m.type === 'threesixty' && (React__default.createElement(ThreeSixty, { urls: m.files.map((x) => x.url), visible: i === index, onDisableNavigation: onDisableNavigation, navigationDisabled: navigationDisabled })),
3975
- m.type === 'embedded' && React__default.createElement(GalleryEmbed, { src: m.files[0].url, index: i + 1 }),
3976
- m.type === 'sphere' && (React__default.createElement(Sphere, { visible: i === index, url: m.files[0].url, preview: m.files[0].url, onDisableNavigation: onDisableNavigation, navigationDisabled: navigationDisabled }))));
3977
- })) : (React__default.createElement(Item$7, { key: placeholder },
3970
+ React__default.createElement(Slider$2, { ...sliderSettings, swipe: !navigationDisabled, touchMove: !navigationDisabled, swipeToSlide: !navigationDisabled, ref: slider, beforeChange: beforeChange }, !!media?.length ? (media.map((m, i) => (React__default.createElement(Item$7, { key: m.files[0].url || i },
3971
+ m.type === 'image' && (React__default.createElement(Image$1, { src: m.files[0].formats.filter(notEmpty).find((x) => x.format === '1170x')?.url, alt: `Bild ${i + 1}` })),
3972
+ m.type === 'threesixty' && (React__default.createElement(ThreeSixty, { urls: m.files.map((x) => x.url), visible: i === index, onDisableNavigation: onDisableNavigation, navigationDisabled: navigationDisabled })),
3973
+ m.type === 'embedded' && React__default.createElement(GalleryEmbed, { src: m.files[0].url, index: i + 1 }),
3974
+ m.type === 'sphere' && (React__default.createElement(Sphere, { visible: i === index, url: m.files[0].url, preview: m.files[0].url, onDisableNavigation: onDisableNavigation, navigationDisabled: navigationDisabled })))))) : (React__default.createElement(Item$7, { key: placeholder },
3978
3975
  React__default.createElement(Image$1, { src: placeholder, alt: `Bild 1` })))),
3979
3976
  navigationDisabled && mediaLength > 1 && (React__default.createElement(EnableNavigationButton, null,
3980
3977
  React__default.createElement(ButtonSecondary, { onClick: onEnableNavigation, title: "St\u00E4ng" },
@@ -3985,9 +3982,8 @@ const Gallery = ({ media, placeholderImage }) => {
3985
3982
  React__default.createElement(ArrowRight, { onClick: nextImage, title: "N\u00E4sta bild" },
3986
3983
  React__default.createElement(IconChevronRight, { block: true }))))),
3987
3984
  React__default.createElement(Alt, null,
3988
- React__default.createElement(QuickNav, { ref: quickNavRef }, !!(media === null || media === void 0 ? void 0 : media.length) ? (media.map((m, i) => {
3989
- var _a;
3990
- const src = ((_a = m.files[0].formats.filter(notEmpty).find((x) => x.format === '225x150')) === null || _a === void 0 ? void 0 : _a.url) ||
3985
+ React__default.createElement(QuickNav, { ref: quickNavRef }, !!media?.length ? (media.map((m, i) => {
3986
+ const src = m.files[0].formats.filter(notEmpty).find((x) => x.format === '225x150')?.url ||
3991
3987
  m.files[0].url;
3992
3988
  return (React__default.createElement(QuickNavItem, { key: src || i, active: index === i },
3993
3989
  React__default.createElement(QuickNavBtn, { onClick: () => goTo(i), title: `Gå till bild ${i + 1}` },
@@ -3998,7 +3994,7 @@ const Gallery = ({ media, placeholderImage }) => {
3998
3994
  })) : (React__default.createElement(QuickNavItem, { key: placeholder, active: true },
3999
3995
  React__default.createElement(QuickNavBtn, { onClick: () => goTo(0), title: `Gå till bild 0` },
4000
3996
  React__default.createElement(QuickNavImg, { src: placeholder, alt: `Bild 1` }))))))),
4001
- lightbox && !!(media === null || media === void 0 ? void 0 : media.length) && (React__default.createElement(Lightbox, { media: media, index: index, onClose: onToggleLightbox }))));
3997
+ lightbox && !!media?.length && (React__default.createElement(Lightbox, { media: media, index: index, onClose: onToggleLightbox }))));
4002
3998
  };
4003
3999
 
4004
4000
  const ProductPage = styled.div `
@@ -4418,11 +4414,11 @@ const Leasing = ({ financialOption }) => {
4418
4414
  },
4419
4415
  {
4420
4416
  label: 'Bindningstid',
4421
- value: `${duration === null || duration === void 0 ? void 0 : duration.current} månader`,
4417
+ value: `${duration?.current} månader`,
4422
4418
  },
4423
4419
  {
4424
4420
  label: 'Årlig körsträcka',
4425
- value: `${numberSeparator((mileage === null || mileage === void 0 ? void 0 : mileage.current) || 0)} mil/år`,
4421
+ value: `${numberSeparator(mileage?.current || 0)} mil/år`,
4426
4422
  },
4427
4423
  ] }))))),
4428
4424
  React__default.createElement(OptionBox, null,
@@ -4431,14 +4427,14 @@ const Leasing = ({ financialOption }) => {
4431
4427
  React__default.createElement("p", null,
4432
4428
  "Privatleasing",
4433
4429
  ' ',
4434
- (mileage === null || mileage === void 0 ? void 0 : mileage.current) && (duration === null || duration === void 0 ? void 0 : duration.current) && (React__default.createElement(React__default.Fragment, null,
4430
+ mileage?.current && duration?.current && (React__default.createElement(React__default.Fragment, null,
4435
4431
  React__default.createElement(UtilityTextPrimary, null,
4436
- numberSeparator(mileage === null || mileage === void 0 ? void 0 : mileage.current),
4432
+ numberSeparator(mileage?.current),
4437
4433
  " mil/\u00E5r"),
4438
4434
  ' ',
4439
4435
  "i ",
4440
- React__default.createElement(UtilityTextPrimary, null, duration === null || duration === void 0 ? void 0 :
4441
- duration.current,
4436
+ React__default.createElement(UtilityTextPrimary, null,
4437
+ duration?.current,
4442
4438
  " m\u00E5n"),
4443
4439
  ".",
4444
4440
  ' '))),
@@ -4569,7 +4565,7 @@ const SliderWithLabel = ({ label, values, domain, steps, loading, unit, formatVa
4569
4565
  }, [loading]);
4570
4566
  return (React__default.createElement(React__default.Fragment, null,
4571
4567
  React__default.createElement(RepeatTiny, null,
4572
- React__default.createElement(RangeSliderLabel, { label: label, value: `${numberSeparator((local === null || local === void 0 ? void 0 : local[0]) || values[0])}${unit ? ` ${unit}` : ''}` })),
4568
+ React__default.createElement(RangeSliderLabel, { label: label, value: `${numberSeparator(local?.[0] || values[0])}${unit ? ` ${unit}` : ''}` })),
4573
4569
  React__default.createElement(RepeatTiny, null,
4574
4570
  React__default.createElement(RangeSliderSimple, { loading: loading, values: values, domain: domain, steps: steps, onChange: onChange, onUpdate: onUpdate, unit: unit, formatValues: formatValues }))));
4575
4571
  };
@@ -4585,7 +4581,6 @@ const stepGenerator = (step, max, steps = [], current) => {
4585
4581
  return stepGenerator(step, max, steps, nextCurrent);
4586
4582
  };
4587
4583
  const LoanModal = ({ id, financialOption, onClose }) => {
4588
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
4589
4584
  const [tmp, setTmp] = useState();
4590
4585
  const [extend, setExtend] = React__default.useState(false);
4591
4586
  const onToggleExtend = React__default.useCallback(() => {
@@ -4595,60 +4590,59 @@ const LoanModal = ({ id, financialOption, onClose }) => {
4595
4590
  setExtend(!extend);
4596
4591
  }, [extend]);
4597
4592
  const [variables, setVariables] = useState({
4598
- duration: (_a = financialOption.duration) === null || _a === void 0 ? void 0 : _a.current,
4599
- downPayment: (_b = financialOption.downPayment) === null || _b === void 0 ? void 0 : _b.current,
4600
- residual: (_c = financialOption.residual) === null || _c === void 0 ? void 0 : _c.current,
4593
+ duration: financialOption.duration?.current,
4594
+ downPayment: financialOption.downPayment?.current,
4595
+ residual: financialOption.residual?.current,
4601
4596
  });
4602
4597
  const { duration, downPayment, residual } = variables;
4603
4598
  const { loading, data } = useLoanCalculation(id, duration, downPayment, residual);
4604
4599
  useEffect(() => {
4605
- var _a, _b, _c, _d, _e, _f;
4606
4600
  if (data) {
4607
4601
  setTmp(data);
4608
4602
  setVariables({
4609
- duration: ((_b = (_a = data === null || data === void 0 ? void 0 : data.loan) === null || _a === void 0 ? void 0 : _a.duration) === null || _b === void 0 ? void 0 : _b.current) || 0,
4610
- downPayment: ((_d = (_c = data === null || data === void 0 ? void 0 : data.loan) === null || _c === void 0 ? void 0 : _c.downPayment) === null || _d === void 0 ? void 0 : _d.current) || 0,
4611
- residual: ((_f = (_e = data === null || data === void 0 ? void 0 : data.loan) === null || _e === void 0 ? void 0 : _e.residual) === null || _f === void 0 ? void 0 : _f.current) || 0,
4603
+ duration: data?.loan?.duration?.current || 0,
4604
+ downPayment: data?.loan?.downPayment?.current || 0,
4605
+ residual: data?.loan?.residual?.current || 0,
4612
4606
  });
4613
4607
  }
4614
4608
  }, [data]);
4615
- const loan = (data === null || data === void 0 ? void 0 : data.loan) || (tmp === null || tmp === void 0 ? void 0 : tmp.loan);
4616
- const downPaymentCurrent = ((_d = loan === null || loan === void 0 ? void 0 : loan.downPayment) === null || _d === void 0 ? void 0 : _d.current) || 0;
4617
- const downPaymentMin = ((_e = loan === null || loan === void 0 ? void 0 : loan.downPayment) === null || _e === void 0 ? void 0 : _e.min) || 0;
4618
- const downPaymentMax = ((_f = loan === null || loan === void 0 ? void 0 : loan.downPayment) === null || _f === void 0 ? void 0 : _f.max) || 0;
4619
- const downPaymentStep = ((_g = loan === null || loan === void 0 ? void 0 : loan.downPayment) === null || _g === void 0 ? void 0 : _g.step) || 0;
4609
+ const loan = data?.loan || tmp?.loan;
4610
+ const downPaymentCurrent = loan?.downPayment?.current || 0;
4611
+ const downPaymentMin = loan?.downPayment?.min || 0;
4612
+ const downPaymentMax = loan?.downPayment?.max || 0;
4613
+ const downPaymentStep = loan?.downPayment?.step || 0;
4620
4614
  const downPaymentSteps = stepGenerator(downPaymentStep, downPaymentMax);
4621
4615
  const onDownPaymentChange = useCallback((values) => {
4622
4616
  PubSub.publish('FinanceInterest');
4623
4617
  setVariables({ ...variables, downPayment: values[0] });
4624
4618
  }, [variables]);
4625
- const durationCurrent = ((_h = loan === null || loan === void 0 ? void 0 : loan.duration) === null || _h === void 0 ? void 0 : _h.current) || 0;
4626
- const durationMin = ((_j = loan === null || loan === void 0 ? void 0 : loan.duration) === null || _j === void 0 ? void 0 : _j.min) || 0;
4627
- const durationMax = ((_k = loan === null || loan === void 0 ? void 0 : loan.duration) === null || _k === void 0 ? void 0 : _k.max) || 0;
4628
- const durationStep = ((_l = loan === null || loan === void 0 ? void 0 : loan.duration) === null || _l === void 0 ? void 0 : _l.step) || 0;
4619
+ const durationCurrent = loan?.duration?.current || 0;
4620
+ const durationMin = loan?.duration?.min || 0;
4621
+ const durationMax = loan?.duration?.max || 0;
4622
+ const durationStep = loan?.duration?.step || 0;
4629
4623
  const durationSteps = stepGenerator(durationStep, durationMax);
4630
4624
  const onDurationChange = useCallback((values) => {
4631
4625
  PubSub.publish('FinanceInterest');
4632
4626
  setVariables({ ...variables, duration: values[0] });
4633
4627
  }, [variables]);
4634
- const residualCurrent = (((_m = loan === null || loan === void 0 ? void 0 : loan.residual) === null || _m === void 0 ? void 0 : _m.current) || 0) * 100 || 0;
4635
- const residualMin = (((_o = loan === null || loan === void 0 ? void 0 : loan.residual) === null || _o === void 0 ? void 0 : _o.min) || 0) * 100 || 0;
4636
- const residualMax = (((_p = loan === null || loan === void 0 ? void 0 : loan.residual) === null || _p === void 0 ? void 0 : _p.max) || 0) * 100 || 0;
4637
- const residualStep = (((_q = loan === null || loan === void 0 ? void 0 : loan.residual) === null || _q === void 0 ? void 0 : _q.step) || 0) * 100 || 0;
4628
+ const residualCurrent = (loan?.residual?.current || 0) * 100 || 0;
4629
+ const residualMin = (loan?.residual?.min || 0) * 100 || 0;
4630
+ const residualMax = (loan?.residual?.max || 0) * 100 || 0;
4631
+ const residualStep = (loan?.residual?.step || 0) * 100 || 0;
4638
4632
  const residualSteps = stepGenerator(residualStep, residualMax);
4639
4633
  const onResidualChange = useCallback((values) => {
4640
4634
  PubSub.publish('FinanceInterest');
4641
4635
  setVariables({ ...variables, residual: values[0] / 100 });
4642
4636
  }, [variables]);
4643
- const interestText = (((loan === null || loan === void 0 ? void 0 : loan.interest) || 0) * 100).toFixed(2);
4644
- const effectiveInterestText = (((loan === null || loan === void 0 ? void 0 : loan.effectiveInterest) || 0) * 100).toFixed(2);
4637
+ const interestText = ((loan?.interest || 0) * 100).toFixed(2);
4638
+ const effectiveInterestText = ((loan?.effectiveInterest || 0) * 100).toFixed(2);
4645
4639
  return (React__default.createElement(Modal, { title: "L\u00E5nealternativ", onClose: onClose },
4646
4640
  React__default.createElement(Repeat, null,
4647
4641
  React__default.createElement(ContentLogo, null,
4648
- (financialOption === null || financialOption === void 0 ? void 0 : financialOption.description) && (React__default.createElement(ContentLogoText, null,
4642
+ financialOption?.description && (React__default.createElement(ContentLogoText, null,
4649
4643
  React__default.createElement(Content$2, null,
4650
4644
  React__default.createElement("p", null, financialOption.description)))),
4651
- (financialOption === null || financialOption === void 0 ? void 0 : financialOption.image) && (React__default.createElement(ContentLogoMedia, null,
4645
+ financialOption?.image && (React__default.createElement(ContentLogoMedia, null,
4652
4646
  React__default.createElement(LogoBox, { logo: financialOption.image, alt: financialOption.name || 'Logotyp', wide: true }))))),
4653
4647
  React__default.createElement(Repeat, null,
4654
4648
  React__default.createElement(RepeatSmall, null,
@@ -4660,7 +4654,7 @@ const LoanModal = ({ id, financialOption, onClose }) => {
4660
4654
  React__default.createElement(RepeatSmall, null,
4661
4655
  React__default.createElement(RepeatTiny, null,
4662
4656
  React__default.createElement(Content$2, { small: true },
4663
- React__default.createElement("p", null, `*Beräknat på ${interestText} % ränta (effektivt ${effectiveInterestText} %)${(loan === null || loan === void 0 ? void 0 : loan.mileage) !== null ? `och en årlig körsträcka om ${loan === null || loan === void 0 ? void 0 : loan.mileage} mil.` : ''}`)))),
4657
+ React__default.createElement("p", null, `*Beräknat på ${interestText} % ränta (effektivt ${effectiveInterestText} %)${loan?.mileage !== null ? `och en årlig körsträcka om ${loan?.mileage} mil.` : ''}`)))),
4664
4658
  React__default.createElement(RepeatSmall, null,
4665
4659
  React__default.createElement(ButtonClear, { onClick: onToggleExtend, title: extend ? 'Visa mindre information' : 'Visa mer information' },
4666
4660
  React__default.createElement(ButtonContent, null, extend ? 'Mindre information' : 'Mer information'))),
@@ -4677,28 +4671,27 @@ const LoanModal = ({ id, financialOption, onClose }) => {
4677
4671
  },
4678
4672
  {
4679
4673
  label: 'Uppläggningskostnad',
4680
- value: `${numberSeparator((financialOption === null || financialOption === void 0 ? void 0 : financialOption.setupFee) || 0)} kr`,
4674
+ value: `${numberSeparator(financialOption?.setupFee || 0)} kr`,
4681
4675
  },
4682
4676
  {
4683
4677
  label: 'Administrativa avgifter',
4684
- value: `${numberSeparator((financialOption === null || financialOption === void 0 ? void 0 : financialOption.administrationFee) || 0)} kr/mån`,
4678
+ value: `${numberSeparator(financialOption?.administrationFee || 0)} kr/mån`,
4685
4679
  },
4686
4680
  {
4687
4681
  label: 'Total kreditkostnad',
4688
- value: `${numberSeparator((loan === null || loan === void 0 ? void 0 : loan.totalCreditCost) || 0)} kr`,
4682
+ value: `${numberSeparator(loan?.totalCreditCost || 0)} kr`,
4689
4683
  },
4690
4684
  ] }))))))));
4691
4685
  };
4692
4686
 
4693
4687
  const Loan = ({ id, financialOption }) => {
4694
- var _a, _b, _c, _d, _e, _f, _g;
4695
4688
  const [modal, setModal] = useState(false);
4696
4689
  const toggleModal = useCallback(() => setModal(!modal), [modal]);
4697
- const { data } = useLoanCalculation(id, (_a = financialOption.duration) === null || _a === void 0 ? void 0 : _a.current, (_b = financialOption.downPayment) === null || _b === void 0 ? void 0 : _b.current, (_c = financialOption.residual) === null || _c === void 0 ? void 0 : _c.current);
4698
- const interest = (_d = data === null || data === void 0 ? void 0 : data.loan) === null || _d === void 0 ? void 0 : _d.interest;
4699
- const duration = (_f = (_e = data === null || data === void 0 ? void 0 : data.loan) === null || _e === void 0 ? void 0 : _e.duration) === null || _f === void 0 ? void 0 : _f.current;
4700
- const monthlyCost = (_g = data === null || data === void 0 ? void 0 : data.loan) === null || _g === void 0 ? void 0 : _g.monthlyCost;
4701
- const logo = (financialOption === null || financialOption === void 0 ? void 0 : financialOption.logotype) || 'https://placehold.it/67x10';
4690
+ const { data } = useLoanCalculation(id, financialOption.duration?.current, financialOption.downPayment?.current, financialOption.residual?.current);
4691
+ const interest = data?.loan?.interest;
4692
+ const duration = data?.loan?.duration?.current;
4693
+ const monthlyCost = data?.loan?.monthlyCost;
4694
+ const logo = financialOption?.logotype || 'https://placehold.it/67x10';
4702
4695
  // Skeleton?
4703
4696
  if (financialOption.loanAmount === undefined ||
4704
4697
  financialOption.loanAmount === null ||
@@ -5044,7 +5037,7 @@ const Icon$4 = styled.div `
5044
5037
  `;
5045
5038
 
5046
5039
  const InputSelect = ({ value, options, onChange, unit, title }) => (React__default.createElement(Wrapper$s, null,
5047
- React__default.createElement(Select$1, { value: value, onChange: onChange, title: title, "aria-label": title }, options === null || options === void 0 ? void 0 : options.map((option) => (React__default.createElement(Option$1, { key: option.value, value: option.value },
5040
+ React__default.createElement(Select$1, { value: value, onChange: onChange, title: title, "aria-label": title }, options?.map((option) => (React__default.createElement(Option$1, { key: option.value, value: option.value },
5048
5041
  option.displayName || option.value,
5049
5042
  unit ? ` ${unit}` : '')))),
5050
5043
  React__default.createElement(Icon$4, null,
@@ -5159,7 +5152,7 @@ const InsuranceModal = ({ id, branch, onClose, insuranceOptions }) => {
5159
5152
  drivingDistance: DrivingDistance.Between0And1000,
5160
5153
  });
5161
5154
  const [payload, setPayload] = useState();
5162
- const { loading, data, error } = useInsuranceCalculation(id, (branch === null || branch === void 0 ? void 0 : branch.id) ? branch === null || branch === void 0 ? void 0 : branch.id : undefined, ssnIsValid(payload === null || payload === void 0 ? void 0 : payload.ssn) ? payload === null || payload === void 0 ? void 0 : payload.ssn : undefined, payload === null || payload === void 0 ? void 0 : payload.drivingDistance);
5155
+ const { loading, data, error } = useInsuranceCalculation(id, branch?.id ? branch?.id : undefined, ssnIsValid(payload?.ssn) ? payload?.ssn : undefined, payload?.drivingDistance);
5163
5156
  const onChangeSsn = useCallback((e) => setForm({ ...form, ssn: e.currentTarget.value }), [form]);
5164
5157
  const onChangeDrivingDistance = useCallback((e) => setForm({ ...form, drivingDistance: e.currentTarget.value }), [form]);
5165
5158
  const onShowInsurances = useCallback(() => {
@@ -5179,7 +5172,7 @@ const InsuranceModal = ({ id, branch, onClose, insuranceOptions }) => {
5179
5172
  { value: DrivingDistance.Over2500, displayName: '2500+' },
5180
5173
  ];
5181
5174
  return (React__default.createElement(Modal, { title: "F\u00F6rs\u00E4kring", onClose: onClose },
5182
- ((insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.description) || (insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.logotype)) && (React__default.createElement(Repeat, null,
5175
+ (insuranceOptions?.description || insuranceOptions?.logotype) && (React__default.createElement(Repeat, null,
5183
5176
  React__default.createElement(ContentLogo, null,
5184
5177
  insuranceOptions.description && (React__default.createElement(ContentLogoText, null,
5185
5178
  React__default.createElement(Content$2, null,
@@ -5207,7 +5200,7 @@ const InsuranceModal = ({ id, branch, onClose, insuranceOptions }) => {
5207
5200
  React__default.createElement(Loader, null))),
5208
5201
  error && (React__default.createElement(Repeat, null,
5209
5202
  React__default.createElement(Snackbar, { severity: "error", icon: true, heading: "Ett fel har intr\u00E4ffat" }, "Kunde inte h\u00E4mta f\u00F6rs\u00E4kringar. V\u00E4nligen f\u00F6rs\u00F6k igen."))),
5210
- React__default.createElement(React__default.Fragment, null, (data === null || data === void 0 ? void 0 : data.insurances) && (React__default.createElement(Repeat, null, data === null || data === void 0 ? void 0 : data.insurances.map((insurance) => (React__default.createElement(Repeat, { key: insurance.name },
5203
+ React__default.createElement(React__default.Fragment, null, data?.insurances && (React__default.createElement(Repeat, null, data?.insurances.map((insurance) => (React__default.createElement(Repeat, { key: insurance.name },
5211
5204
  React__default.createElement(DetailBox, { heading: `${numberSeparator(insurance.price)} ${insurance.unit}`, description: insurance.name },
5212
5205
  React__default.createElement(Repeat, null,
5213
5206
  React__default.createElement(React__default.Fragment, null, insurance.description && (React__default.createElement(RepeatTiny, null,
@@ -5253,20 +5246,18 @@ const Insurance = ({ id, branch, insuranceOptions }) => {
5253
5246
  };
5254
5247
 
5255
5248
  const InsuranceFreeModal = ({ onClose, insuranceOptions }) => {
5256
- var _a;
5257
- return (React__default.createElement(Modal, { title: (_a = insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.insuranceHeader) !== null && _a !== void 0 ? _a : 'Försäkring', onClose: onClose },
5258
- (insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.longDescription) && (React__default.createElement(Repeat, null,
5249
+ return (React__default.createElement(Modal, { title: insuranceOptions?.insuranceHeader ?? 'Försäkring', onClose: onClose },
5250
+ insuranceOptions?.longDescription && (React__default.createElement(Repeat, null,
5259
5251
  React__default.createElement(Content$2, { dangerouslySetInnerHTML: {
5260
5252
  __html: marked(insuranceOptions.longDescription),
5261
5253
  } }))),
5262
- (insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.url) && (React__default.createElement(Repeat, null,
5254
+ insuranceOptions?.url && (React__default.createElement(Repeat, null,
5263
5255
  React__default.createElement(ButtonInline, { as: "a", href: insuranceOptions.url, target: "_blank", rel: "noopener noreferrer" }, "L\u00E4s mer om f\u00F6rs\u00E4kringen (\u00D6ppnas i ett nytt f\u00F6nster)"))),
5264
- (insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.logotype) && (React__default.createElement(Repeat, null,
5256
+ insuranceOptions?.logotype && (React__default.createElement(Repeat, null,
5265
5257
  React__default.createElement(LogoBox, { logo: insuranceOptions.logotype, alt: insuranceOptions.name || 'Logotyp', wide: true })))));
5266
5258
  };
5267
5259
 
5268
5260
  const Insurance$1 = ({ insuranceOptions }) => {
5269
- var _a, _b;
5270
5261
  const [modal, setModal] = useState(false);
5271
5262
  const toggleModal = useCallback(() => setModal(!modal), [modal]);
5272
5263
  if (!insuranceOptions.length) {
@@ -5276,7 +5267,7 @@ const Insurance$1 = ({ insuranceOptions }) => {
5276
5267
  modal && React__default.createElement(InsuranceFreeModal, { onClose: toggleModal, insuranceOptions: insuranceOptions[0] }),
5277
5268
  React__default.createElement(Repeat, null,
5278
5269
  React__default.createElement(RepeatTiny, null,
5279
- React__default.createElement(VisualHeading, null, (_b = (_a = insuranceOptions[0]) === null || _a === void 0 ? void 0 : _a.insuranceHeader) !== null && _b !== void 0 ? _b : 'Försäkring')),
5270
+ React__default.createElement(VisualHeading, null, insuranceOptions[0]?.insuranceHeader ?? 'Försäkring')),
5280
5271
  React__default.createElement(RepeatTiny, null,
5281
5272
  React__default.createElement(React__default.Fragment, null, insuranceOptions.map((insuranceOption, index) => (React__default.createElement(OptionBox, { key: `${insuranceOption.url}-${index}`, logo: insuranceOption.logotype || undefined, logoAlt: insuranceOption.name || 'Logotyp' },
5282
5273
  insuranceOption.description && (React__default.createElement(Content$2, { dangerouslySetInnerHTML: {
@@ -5300,7 +5291,6 @@ const InsuranceOptions = ({ id, branch, insuranceOptions }) => {
5300
5291
  };
5301
5292
 
5302
5293
  const ManufacturerPackageOption = ({ packageOption }) => {
5303
- var _a;
5304
5294
  if (!packageOption) {
5305
5295
  return null;
5306
5296
  }
@@ -5309,7 +5299,7 @@ const ManufacturerPackageOption = ({ packageOption }) => {
5309
5299
  React__default.createElement(H2, { noMargin: true }, packageOption.title)),
5310
5300
  packageOption.description && (React__default.createElement(Repeat, null,
5311
5301
  React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5312
- ((_a = packageOption.link) === null || _a === void 0 ? void 0 : _a.url) && (React__default.createElement(Repeat, null,
5302
+ packageOption.link?.url && (React__default.createElement(Repeat, null,
5313
5303
  React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.url, target: "_blank", rel: "noopener noreferrer" }, packageOption.link.title
5314
5304
  ? packageOption.link.title
5315
5305
  : 'Läs mer (Öppnas i ett nytt fönster)'))),
@@ -5431,7 +5421,7 @@ const typedMetadata = Metadata;
5431
5421
  const formatPhonenumber = (text) => {
5432
5422
  try {
5433
5423
  const parsed = parsePhoneNumberFromString(text.replace('-', '').replace(/ /g, ''), typedMetadata);
5434
- return (parsed === null || parsed === void 0 ? void 0 : parsed.formatNational()) || text;
5424
+ return parsed?.formatNational() || text;
5435
5425
  }
5436
5426
  catch (e) {
5437
5427
  return text;
@@ -5439,9 +5429,8 @@ const formatPhonenumber = (text) => {
5439
5429
  };
5440
5430
 
5441
5431
  const ActionList = ({ contact, branch }) => {
5442
- var _a, _b;
5443
- const email = (contact === null || contact === void 0 ? void 0 : contact.email) || ((_a = branch === null || branch === void 0 ? void 0 : branch.contact) === null || _a === void 0 ? void 0 : _a.email);
5444
- const phonenumber = (contact === null || contact === void 0 ? void 0 : contact.phonenumber) || ((_b = branch === null || branch === void 0 ? void 0 : branch.contact) === null || _b === void 0 ? void 0 : _b.phonenumber);
5432
+ const email = contact?.email || branch?.contact?.email;
5433
+ const phonenumber = contact?.phonenumber || branch?.contact?.phonenumber;
5445
5434
  const onClickMailVisible = useCallback(() => PubSub.publish('MailVisible'), []);
5446
5435
  const onClickPhoneVisible = useCallback(() => PubSub.publish('PhonenumberVisible'), []);
5447
5436
  const onClickPhoneValue = useCallback(() => PubSub.publish('PhonenumberCall'), []);
@@ -5594,7 +5583,7 @@ const BranchModal = ({ loading, connections, onClose }) => {
5594
5583
  React__default.createElement("p", null, "V\u00E4lj den anl\u00E4ggning du vill visa kontaktuppgifter f\u00F6r."))),
5595
5584
  React__default.createElement(RepeatTiny, null,
5596
5585
  React__default.createElement(InputLabel, null, "V\u00E4lj anl\u00E4ggning"),
5597
- React__default.createElement(InputSelect, { value: localValue, onChange: onChange, options: connections === null || connections === void 0 ? void 0 : connections.map((x) => ({
5586
+ React__default.createElement(InputSelect, { value: localValue, onChange: onChange, options: connections?.map((x) => ({
5598
5587
  value: x.id,
5599
5588
  displayName: x.name,
5600
5589
  })), title: "V\u00E4lj anl\u00E4ggning" }))),
@@ -5603,16 +5592,13 @@ const BranchModal = ({ loading, connections, onClose }) => {
5603
5592
  React__default.createElement(ButtonContent, null, "V\u00E4lj")))));
5604
5593
  };
5605
5594
 
5606
- const PackageOptionModal = ({ packageOption, onClose }) => {
5607
- var _a;
5608
- return (React__default.createElement(Modal, { title: packageOption.title || '', onClose: onClose },
5609
- packageOption.image && (React__default.createElement(Repeat, null,
5610
- React__default.createElement(LogoBox, { logo: packageOption.image, alt: packageOption.title || undefined, wide: true }))),
5611
- packageOption.description && (React__default.createElement(Repeat, null,
5612
- React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5613
- ((_a = packageOption.link) === null || _a === void 0 ? void 0 : _a.href) && packageOption.link.title && (React__default.createElement(Repeat, null,
5614
- React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.href, target: "_blank", rel: "noopener noreferrer nofollow" }, packageOption.link.title)))));
5615
- };
5595
+ const PackageOptionModal = ({ packageOption, onClose }) => (React__default.createElement(Modal, { title: packageOption.title || '', onClose: onClose },
5596
+ packageOption.image && (React__default.createElement(Repeat, null,
5597
+ React__default.createElement(LogoBox, { logo: packageOption.image, alt: packageOption.title || undefined, wide: true }))),
5598
+ packageOption.description && (React__default.createElement(Repeat, null,
5599
+ React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5600
+ packageOption.link?.href && packageOption.link.title && (React__default.createElement(Repeat, null,
5601
+ React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.href, target: "_blank", rel: "noopener noreferrer nofollow" }, packageOption.link.title)))));
5616
5602
 
5617
5603
  const CheckList = ({ manufacturer, packageOptions, ecommerce, branch, contact, toggleEcomModal, loadingCentralStorageVehicle, }) => {
5618
5604
  const [modalBranch, setModalBranch] = useState(false);
@@ -5626,45 +5612,45 @@ const CheckList = ({ manufacturer, packageOptions, ecommerce, branch, contact, t
5626
5612
  setModalBranch(false);
5627
5613
  }
5628
5614
  }, [branch, contact]);
5629
- const packageOption = manufacturer === null || manufacturer === void 0 ? void 0 : manufacturer.packageOption;
5615
+ const packageOption = manufacturer?.packageOption;
5630
5616
  return (React__default.createElement(React__default.Fragment, null,
5631
- modalBranch && (React__default.createElement(BranchModal, { loading: loadingCentralStorageVehicle, connections: branch === null || branch === void 0 ? void 0 : branch.connections, onClose: closeModalBranch })),
5617
+ modalBranch && (React__default.createElement(BranchModal, { loading: loadingCentralStorageVehicle, connections: branch?.connections, onClose: closeModalBranch })),
5632
5618
  modal && React__default.createElement(PackageOptionModal, { packageOption: modal, onClose: onClose }),
5633
5619
  React__default.createElement(Repeat, null,
5634
5620
  React__default.createElement(CheckMarkList, null,
5635
- (packageOption === null || packageOption === void 0 ? void 0 : packageOption.title) && (React__default.createElement(CheckMarkListItem, null,
5621
+ packageOption?.title && (React__default.createElement(CheckMarkListItem, null,
5636
5622
  React__default.createElement(React__default.Fragment, null,
5637
5623
  "Inkl.",
5638
5624
  ' ',
5639
5625
  React__default.createElement(ButtonInline, { onClick: () => onOpen({
5640
- title: packageOption === null || packageOption === void 0 ? void 0 : packageOption.title,
5641
- image: packageOption === null || packageOption === void 0 ? void 0 : packageOption.image,
5642
- description: packageOption === null || packageOption === void 0 ? void 0 : packageOption.description,
5643
- link: packageOption === null || packageOption === void 0 ? void 0 : packageOption.link,
5626
+ title: packageOption?.title,
5627
+ image: packageOption?.image,
5628
+ description: packageOption?.description,
5629
+ link: packageOption?.link,
5644
5630
  }) }, packageOption.title),
5645
5631
  ' ',
5646
- "begagnatgaranti"))), packageOptions === null || packageOptions === void 0 ? void 0 :
5647
- packageOptions.map((packageOption, index) => (React__default.createElement(CheckMarkListItem, { key: packageOption.title || index },
5632
+ "begagnatgaranti"))),
5633
+ packageOptions?.map((packageOption, index) => (React__default.createElement(CheckMarkListItem, { key: packageOption.title || index },
5648
5634
  React__default.createElement(React__default.Fragment, null,
5649
5635
  "Inkl.",
5650
5636
  ' ',
5651
5637
  React__default.createElement(ButtonInline, { onClick: () => onOpen({
5652
- title: packageOption === null || packageOption === void 0 ? void 0 : packageOption.title,
5653
- image: packageOption === null || packageOption === void 0 ? void 0 : packageOption.image,
5654
- description: packageOption === null || packageOption === void 0 ? void 0 : packageOption.description,
5655
- link: packageOption === null || packageOption === void 0 ? void 0 : packageOption.link,
5638
+ title: packageOption?.title,
5639
+ image: packageOption?.image,
5640
+ description: packageOption?.description,
5641
+ link: packageOption?.link,
5656
5642
  }) }, packageOption.title))))),
5657
- (ecommerce === null || ecommerce === void 0 ? void 0 : ecommerce.withHomeDelivery) && React__default.createElement(CheckMarkListItem, null, "Hemleverans"))),
5643
+ ecommerce?.withHomeDelivery && React__default.createElement(CheckMarkListItem, null, "Hemleverans"))),
5658
5644
  React__default.createElement(Repeat, null,
5659
5645
  ecommerce && ecommerce.enabled && (React__default.createElement(RepeatTiny, null,
5660
5646
  React__default.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, fullWidth: true, onClick: toggleEcomModal },
5661
5647
  React__default.createElement(ButtonContent, null, "K\u00F6p bilen online")))),
5662
- (ecommerce === null || ecommerce === void 0 ? void 0 : ecommerce.reserved) && (React__default.createElement(RepeatTiny, null,
5648
+ ecommerce?.reserved && (React__default.createElement(RepeatTiny, null,
5663
5649
  React__default.createElement(SwitchBar, { title: "Bilen \u00E4r reserverad", body: "Denna bil \u00E4r reserverad av en annan k\u00F6pare." },
5664
5650
  React__default.createElement(Content$2, null,
5665
5651
  React__default.createElement("p", null, "Denna bil \u00E4r reserverad av en annan k\u00F6pare."))))),
5666
5652
  React__default.createElement(ActionList, { branch: branch, contact: contact })),
5667
- ((branch === null || branch === void 0 ? void 0 : branch.connections.length) || 0) > 1 && (React__default.createElement(Repeat, null,
5653
+ (branch?.connections.length || 0) > 1 && (React__default.createElement(Repeat, null,
5668
5654
  React__default.createElement(SwitchBar, { title: "Centrallagerbil", actionTitle: "Byt anl\u00E4ggning", onClick: openModalBranch },
5669
5655
  React__default.createElement(Content$2, null,
5670
5656
  React__default.createElement("p", null, "Denna bil tillh\u00F6r ett centrallager och g\u00E5r att k\u00F6pa genom flera anl\u00E4ggningar. Byt anl\u00E4ggning f\u00F6r att visa kontaktuppgifter till just den anl\u00E4ggningen.")))))));
@@ -5791,7 +5777,7 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
5791
5777
  onClickSearchItem(id);
5792
5778
  }
5793
5779
  }, []);
5794
- if (!(response === null || response === void 0 ? void 0 : response.documentList.documents.length) || (response === null || response === void 0 ? void 0 : response.documentList.documents.length) === 0) {
5780
+ if (!response?.documentList.documents.length || response?.documentList.documents.length === 0) {
5795
5781
  return null;
5796
5782
  }
5797
5783
  if (loading) {
@@ -5806,8 +5792,7 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
5806
5792
  React__default.createElement(H2, { noMargin: true }, "Senast inkomna")))),
5807
5793
  React__default.createElement(Repeat, null,
5808
5794
  React__default.createElement(OverflowGrid, null,
5809
- React__default.createElement(OverflowGridList, null, response === null || response === void 0 ? void 0 : response.documentList.documents.map((document) => {
5810
- var _a, _b, _c;
5795
+ React__default.createElement(OverflowGridList, null, response?.documentList.documents.map((document) => {
5811
5796
  const prefix = pathRoute ? `/${pathRoute}` : '/';
5812
5797
  const r = regexPathGuid(pathRoute);
5813
5798
  const pathRouteUrl = window.location.pathname === '/'
@@ -5816,7 +5801,7 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
5816
5801
  ? window.location.pathname.replace(r, `${pathRoute}${document._id}`)
5817
5802
  : `${window.location.pathname}${prefix}${document._id}`;
5818
5803
  return (React__default.createElement(OverflowGridItem, { key: document._id },
5819
- React__default.createElement(ProductCard, { id: document._id, onClick: onItemClicked, title: document.title, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: (_c = (_b = (_a = document.featuredImage) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.url, description: document.shortDescription, uspList: [
5804
+ React__default.createElement(ProductCard, { id: document._id, onClick: onItemClicked, title: document.title, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: document.featuredImage?.files?.[0]?.url, description: document.shortDescription, uspList: [
5820
5805
  {
5821
5806
  title: document.modelYear,
5822
5807
  },
@@ -5839,20 +5824,17 @@ const PackageOptions = ({ packageOptions }) => {
5839
5824
  if (!packageOptions) {
5840
5825
  return null;
5841
5826
  }
5842
- return (React__default.createElement(React__default.Fragment, null, packageOptions.map((packageOption, index) => {
5843
- var _a;
5844
- return (React__default.createElement(ProductPageMainSection, { key: packageOption.title || index },
5845
- React__default.createElement(Repeat, null,
5846
- React__default.createElement(H2, { noMargin: true }, packageOption.title)),
5847
- packageOption.description && (React__default.createElement(Repeat, null,
5848
- React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5849
- ((_a = packageOption.link) === null || _a === void 0 ? void 0 : _a.url) && (React__default.createElement(Repeat, null,
5850
- React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.url, target: "_blank", rel: "noopener noreferrer" }, packageOption.link.title
5851
- ? packageOption.link.title
5852
- : 'Läs mer (Öppnas i ett nytt fönster)'))),
5853
- packageOption.image && (React__default.createElement(Repeat, null,
5854
- React__default.createElement(LogoBox, { logo: packageOption.image, alt: "Logotyp", wide: true })))));
5855
- })));
5827
+ return (React__default.createElement(React__default.Fragment, null, packageOptions.map((packageOption, index) => (React__default.createElement(ProductPageMainSection, { key: packageOption.title || index },
5828
+ React__default.createElement(Repeat, null,
5829
+ React__default.createElement(H2, { noMargin: true }, packageOption.title)),
5830
+ packageOption.description && (React__default.createElement(Repeat, null,
5831
+ React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5832
+ packageOption.link?.url && (React__default.createElement(Repeat, null,
5833
+ React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.url, target: "_blank", rel: "noopener noreferrer" }, packageOption.link.title
5834
+ ? packageOption.link.title
5835
+ : 'Läs mer (Öppnas i ett nytt fönster)'))),
5836
+ packageOption.image && (React__default.createElement(Repeat, null,
5837
+ React__default.createElement(LogoBox, { logo: packageOption.image, alt: "Logotyp", wide: true }))))))));
5856
5838
  };
5857
5839
 
5858
5840
  const TableColumn = styled.div `
@@ -5923,15 +5905,15 @@ const arr = [];
5923
5905
  const GetOpeningHours = (o) => KeyOrder.reduce((prev, current) => {
5924
5906
  const title = TranslateWeekDays(current);
5925
5907
  const item = o[current];
5926
- const previous = prev === null || prev === void 0 ? void 0 : prev[prev.length - 1];
5927
- if (previous && previous.from == (item === null || item === void 0 ? void 0 : item.from) && previous.until === (item === null || item === void 0 ? void 0 : item.until)) {
5908
+ const previous = prev?.[prev.length - 1];
5909
+ if (previous && previous.from == item?.from && previous.until === item?.until) {
5928
5910
  prev[prev.length - 1].titleTo = title;
5929
5911
  }
5930
5912
  else {
5931
5913
  prev.push({
5932
5914
  titleFrom: title,
5933
- from: item === null || item === void 0 ? void 0 : item.from,
5934
- until: item === null || item === void 0 ? void 0 : item.until,
5915
+ from: item?.from,
5916
+ until: item?.until,
5935
5917
  });
5936
5918
  }
5937
5919
  return prev;
@@ -5942,8 +5924,8 @@ const GetOpeningHoursToday = (o) => {
5942
5924
  const current = o[day];
5943
5925
  return {
5944
5926
  title: current ? 'Öppetider idag' : 'Stängt idag',
5945
- from: current === null || current === void 0 ? void 0 : current.from,
5946
- until: current === null || current === void 0 ? void 0 : current.until,
5927
+ from: current?.from,
5928
+ until: current?.until,
5947
5929
  };
5948
5930
  };
5949
5931
  const valuOfDateString = (s) => {
@@ -5954,7 +5936,7 @@ const OpeningHours = ({ openingHours }) => {
5954
5936
  const today = useMemo(() => (openingHours ? GetOpeningHoursToday(openingHours) : null), [openingHours]);
5955
5937
  const currentlyOpen = useMemo(() => {
5956
5938
  try {
5957
- if ((today === null || today === void 0 ? void 0 : today.from) && (today === null || today === void 0 ? void 0 : today.until)) {
5939
+ if (today?.from && today?.until) {
5958
5940
  const currentDate = new Date().valueOf();
5959
5941
  const from = valuOfDateString(today.from);
5960
5942
  const until = valuOfDateString(today.until);
@@ -5976,9 +5958,9 @@ const OpeningHours = ({ openingHours }) => {
5976
5958
  React__default.createElement(TableColumn, null,
5977
5959
  React__default.createElement(TableColumnRow, null,
5978
5960
  React__default.createElement(TableColumnCell, null,
5979
- React__default.createElement(UtilityTextBold, null, today === null || today === void 0 ? void 0 : today.title)),
5961
+ React__default.createElement(UtilityTextBold, null, today?.title)),
5980
5962
  React__default.createElement(TableColumnCell, null,
5981
- React__default.createElement(UtilityTextBold, null, (today === null || today === void 0 ? void 0 : today.from) ? `${today.from}-${today.until}` : 'Stängt'))),
5963
+ React__default.createElement(UtilityTextBold, null, today?.from ? `${today.from}-${today.until}` : 'Stängt'))),
5982
5964
  oh.map((o) => (React__default.createElement(TableColumnRow, { key: o.titleFrom },
5983
5965
  React__default.createElement(TableColumnCell, null, o.titleTo ? `${o.titleFrom}-${o.titleTo}` : o.titleFrom),
5984
5966
  React__default.createElement(TableColumnCell, null, o.from ? `${o.from}-${o.until}` : 'Stängt'))))))));
@@ -6047,7 +6029,6 @@ const StaticMap = ({ position }) => {
6047
6029
  };
6048
6030
 
6049
6031
  const Branch = ({ branch, loading }) => {
6050
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6051
6032
  const [modal, setModal] = useState(false);
6052
6033
  const openModal = useCallback(() => setModal(true), []);
6053
6034
  const closeModal = useCallback(() => setModal(false), []);
@@ -6060,14 +6041,14 @@ const Branch = ({ branch, loading }) => {
6060
6041
  return null;
6061
6042
  }
6062
6043
  return (React__default.createElement(React__default.Fragment, null,
6063
- modal && (React__default.createElement(BranchModal, { loading: loading, connections: branch === null || branch === void 0 ? void 0 : branch.connections, onClose: closeModal })),
6044
+ modal && (React__default.createElement(BranchModal, { loading: loading, connections: branch?.connections, onClose: closeModal })),
6064
6045
  React__default.createElement(Repeat, null,
6065
- React__default.createElement(H2, { noMargin: true }, ((_a = branch === null || branch === void 0 ? void 0 : branch.location) === null || _a === void 0 ? void 0 : _a.city)
6066
- ? `Den här bilen finns på vår anläggning i ${(_b = branch === null || branch === void 0 ? void 0 : branch.location) === null || _b === void 0 ? void 0 : _b.city}`
6046
+ React__default.createElement(H2, { noMargin: true }, branch?.location?.city
6047
+ ? `Den här bilen finns på vår anläggning i ${branch?.location?.city}`
6067
6048
  : 'Kontakt')),
6068
6049
  React__default.createElement(Repeat, null,
6069
- React__default.createElement(StaticMap, { position: (_c = branch === null || branch === void 0 ? void 0 : branch.location) === null || _c === void 0 ? void 0 : _c.position })),
6070
- (((_d = branch === null || branch === void 0 ? void 0 : branch.connections) === null || _d === void 0 ? void 0 : _d.length) || 0) > 1 && (React__default.createElement(Repeat, null,
6050
+ React__default.createElement(StaticMap, { position: branch?.location?.position })),
6051
+ (branch?.connections?.length || 0) > 1 && (React__default.createElement(Repeat, null,
6071
6052
  React__default.createElement(Content$2, null,
6072
6053
  React__default.createElement("p", null,
6073
6054
  "Denna bil tillh\u00F6r ett centrallager och g\u00E5r att k\u00F6pa genom flera anl\u00E4ggningar.",
@@ -6078,13 +6059,13 @@ const Branch = ({ branch, loading }) => {
6078
6059
  React__default.createElement(ProductPageContentLimit, null,
6079
6060
  React__default.createElement(Repeat, null,
6080
6061
  React__default.createElement(TableColumn, null,
6081
- ((_e = branch === null || branch === void 0 ? void 0 : branch.location) === null || _e === void 0 ? void 0 : _e.streetAddress) && ((_f = branch === null || branch === void 0 ? void 0 : branch.location) === null || _f === void 0 ? void 0 : _f.city) && (React__default.createElement(TableColumnRow, null,
6062
+ branch?.location?.streetAddress && branch?.location?.city && (React__default.createElement(TableColumnRow, null,
6082
6063
  React__default.createElement(TableColumnCell, null, "Adress"),
6083
6064
  React__default.createElement(TableColumnCell, null,
6084
6065
  React__default.createElement(ButtonInlineBold, null,
6085
- React__default.createElement(ButtonContent, null, `${(_g = branch === null || branch === void 0 ? void 0 : branch.location) === null || _g === void 0 ? void 0 : _g.streetAddress}, ${(_h = branch === null || branch === void 0 ? void 0 : branch.location) === null || _h === void 0 ? void 0 : _h.city}`))))),
6086
- ((_j = branch === null || branch === void 0 ? void 0 : branch.contact) === null || _j === void 0 ? void 0 : _j.phonenumber) && (React__default.createElement(PhoneNumber, { phoneNumber: formatPhonenumber(branch.contact.phonenumber) })))),
6087
- (branch === null || branch === void 0 ? void 0 : branch.openingHours) && (React__default.createElement(Repeat, null,
6066
+ React__default.createElement(ButtonContent, null, `${branch?.location?.streetAddress}, ${branch?.location?.city}`))))),
6067
+ branch?.contact?.phonenumber && (React__default.createElement(PhoneNumber, { phoneNumber: formatPhonenumber(branch.contact.phonenumber) })))),
6068
+ branch?.openingHours && (React__default.createElement(Repeat, null,
6088
6069
  React__default.createElement(OpeningHours, { openingHours: branch.openingHours })))))));
6089
6070
  };
6090
6071
 
@@ -6210,20 +6191,19 @@ const useSearchItemBranch = (id, branch) => useQuery(SEARCH_ITEM_BRANCH_QUERY, {
6210
6191
  });
6211
6192
 
6212
6193
  const useCentralStorage = (vehicle) => {
6213
- var _a, _b;
6214
6194
  const { centralStorageId, setCentralStorageId } = useContext(CentralStorageContext);
6215
- const connections = (_a = vehicle === null || vehicle === void 0 ? void 0 : vehicle.branch) === null || _a === void 0 ? void 0 : _a.connections;
6195
+ const connections = vehicle?.branch?.connections;
6216
6196
  const branchId = centralStorageId
6217
- ? (_b = connections === null || connections === void 0 ? void 0 : connections.find((x) => x.id === centralStorageId)) === null || _b === void 0 ? void 0 : _b.id
6197
+ ? connections?.find((x) => x.id === centralStorageId)?.id
6218
6198
  : undefined;
6219
- const { data, loading } = useSearchItemBranch(vehicle === null || vehicle === void 0 ? void 0 : vehicle.id, branchId);
6199
+ const { data, loading } = useSearchItemBranch(vehicle?.id, branchId);
6220
6200
  useEffect(() => {
6221
- if (((connections === null || connections === void 0 ? void 0 : connections.length) || 0) > 0) {
6201
+ if ((connections?.length || 0) > 0) {
6222
6202
  const match = centralStorageId
6223
- ? connections === null || connections === void 0 ? void 0 : connections.find((x) => x.id === centralStorageId)
6203
+ ? connections?.find((x) => x.id === centralStorageId)
6224
6204
  : undefined;
6225
6205
  if (!match) {
6226
- const first = connections === null || connections === void 0 ? void 0 : connections[0];
6206
+ const first = connections?.[0];
6227
6207
  if (first) {
6228
6208
  setCentralStorageId(first.id);
6229
6209
  }
@@ -6231,7 +6211,7 @@ const useCentralStorage = (vehicle) => {
6231
6211
  }
6232
6212
  }, [connections]);
6233
6213
  return {
6234
- vehicle: ((connections === null || connections === void 0 ? void 0 : connections.length) || 0) > 0 ? data === null || data === void 0 ? void 0 : data.vehicle : vehicle,
6214
+ vehicle: (connections?.length || 0) > 0 ? data?.vehicle : vehicle,
6235
6215
  loading,
6236
6216
  };
6237
6217
  };
@@ -6248,14 +6228,14 @@ const PageLoading = () => (React__default.createElement(Page, null,
6248
6228
 
6249
6229
  class PropertyTreeCreator {
6250
6230
  constructor(properties) {
6251
- this.propertiesWithCategory = (propertyKey) => { var _a; return !!((_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.id); };
6231
+ this.propertiesWithCategory = (propertyKey) => !!this.properties[propertyKey].category?.id;
6252
6232
  this.propertiesWithoutCategory = (propertyKey) => !this.propertiesWithCategory(propertyKey);
6253
6233
  this.isList = (property) => property.type === PropertyTreeCreator.TEXT_LIST_TYPE;
6254
6234
  this.isNonList = (property) => !this.isList(property);
6255
- this.hasCategoryWithId = (propertyKey, categoryId) => { var _a; return ((_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.id) === categoryId; };
6256
- this.propertiesWithSubCategory = (propertyKey) => { var _a, _b; return !!((_b = (_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.subCategory) === null || _b === void 0 ? void 0 : _b.id); };
6235
+ this.hasCategoryWithId = (propertyKey, categoryId) => this.properties[propertyKey].category?.id === categoryId;
6236
+ this.propertiesWithSubCategory = (propertyKey) => !!this.properties[propertyKey].category?.subCategory?.id;
6257
6237
  this.propertiesWithoutSubCategory = (propertyKey) => !this.propertiesWithSubCategory(propertyKey);
6258
- this.hasSubCategoryWithId = (propertyKey, categoryId) => { var _a, _b; return ((_b = (_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.subCategory) === null || _b === void 0 ? void 0 : _b.id) === categoryId; };
6238
+ this.hasSubCategoryWithId = (propertyKey, categoryId) => this.properties[propertyKey].category?.subCategory?.id === categoryId;
6259
6239
  this.properties = properties;
6260
6240
  }
6261
6241
  create() {
@@ -6322,7 +6302,7 @@ class PropertyTreeCreator {
6322
6302
  const categories = Object.keys(this.properties)
6323
6303
  .filter((key) => this.hasCategoryWithId(key, id))
6324
6304
  .filter(this.propertiesWithSubCategory)
6325
- .map((key) => { var _a; return (_a = this.properties[key].category) === null || _a === void 0 ? void 0 : _a.subCategory; })
6305
+ .map((key) => this.properties[key].category?.subCategory)
6326
6306
  .filter(PropertyTreeCreator.distinctCategories);
6327
6307
  return categories;
6328
6308
  }
@@ -6951,7 +6931,6 @@ const MetadataCategory = ({ properties, subCategories }) => (React__default.crea
6951
6931
  !!subCategories.length &&
6952
6932
  subCategories.map((subCategory, index) => (React__default.createElement(MetadataSubCategory, { name: subCategory.name, properties: subCategory.properties, key: `${subCategory.name}-${index}` })))));
6953
6933
  const PropertySet = ({ propertySet, vehicleData }) => {
6954
- var _a, _b;
6955
6934
  const [activeCategoryId, setActiveCategoryId] = useState(-1);
6956
6935
  const mappedProperties = useMemo(() => {
6957
6936
  if (!propertySet) {
@@ -6965,20 +6944,19 @@ const PropertySet = ({ propertySet, vehicleData }) => {
6965
6944
  return tree;
6966
6945
  }, [propertySet]);
6967
6946
  useEffect(() => {
6968
- var _a;
6969
- const categories = ((_a = mappedProperties === null || mappedProperties === void 0 ? void 0 : mappedProperties.categories) === null || _a === void 0 ? void 0 : _a.length) !== undefined ? mappedProperties === null || mappedProperties === void 0 ? void 0 : mappedProperties.categories : undefined;
6947
+ const categories = mappedProperties?.categories?.length !== undefined ? mappedProperties?.categories : undefined;
6970
6948
  if (activeCategoryId < 0 && categories !== undefined && categories.length > 0) {
6971
6949
  setActiveCategoryId(categories[0].id);
6972
6950
  }
6973
6951
  }, [mappedProperties]);
6974
6952
  const onTab = useCallback((id) => setActiveCategoryId(parseInt(id, 10)), []);
6975
- const activeCategory = (_a = mappedProperties === null || mappedProperties === void 0 ? void 0 : mappedProperties.categories) === null || _a === void 0 ? void 0 : _a.find((category) => category.id === activeCategoryId);
6953
+ const activeCategory = mappedProperties?.categories?.find((category) => category.id === activeCategoryId);
6976
6954
  return (React__default.createElement(React__default.Fragment, null,
6977
6955
  React__default.createElement(Repeat, null,
6978
- React__default.createElement(Tabs, { tabs: ((_b = mappedProperties === null || mappedProperties === void 0 ? void 0 : mappedProperties.categories) === null || _b === void 0 ? void 0 : _b.map((category) => ({
6956
+ React__default.createElement(Tabs, { tabs: mappedProperties?.categories?.map((category) => ({
6979
6957
  name: `${category.id}`,
6980
6958
  displayName: category.name,
6981
- }))) || [], active: `${activeCategoryId}`, onClick: onTab })),
6959
+ })) || [], active: `${activeCategoryId}`, onClick: onTab })),
6982
6960
  activeCategory && (React__default.createElement(Repeat, null,
6983
6961
  React__default.createElement(MetadataCategory, { properties: activeCategory.properties, subCategories: activeCategory.subCategories })))));
6984
6962
  };
@@ -7047,11 +7025,10 @@ const PdfDownloadItem = ({ document }) => (React__default.createElement(PdfListI
7047
7025
  const PdfDownloadContainer = ({ documents }) => (React__default.createElement(PdfContainer, null, documents.map((document, i) => (React__default.createElement(PdfDownloadItem, { key: `${document.url}-${i}`, document: document })))));
7048
7026
 
7049
7027
  const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, onClickSearchItem, }) => {
7050
- var _a, _b, _c;
7051
7028
  const { ecomSettings } = useSettings();
7052
7029
  const ecomContext = useRef();
7053
7030
  const { loading, data: result } = useSearchItem(id);
7054
- const { vehicle: centralStorageVehicle, loading: loadingCentralStorageVehicle } = useCentralStorage(result === null || result === void 0 ? void 0 : result.vehicle);
7031
+ const { vehicle: centralStorageVehicle, loading: loadingCentralStorageVehicle } = useCentralStorage(result?.vehicle);
7055
7032
  useEffect(() => {
7056
7033
  if (ecomSettings) {
7057
7034
  ecomContext.current = new WaykeEcomWeb({
@@ -7060,7 +7037,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7060
7037
  api: {
7061
7038
  address: ecomSettings.url,
7062
7039
  },
7063
- bankIdThumbprint: ecomSettings === null || ecomSettings === void 0 ? void 0 : ecomSettings.bankIdThumbprint,
7040
+ bankIdThumbprint: ecomSettings?.bankIdThumbprint,
7064
7041
  },
7065
7042
  logo: ecomSettings.serviceLogotypeUrl,
7066
7043
  logoX2: ecomSettings.serviceLogotypeUrl,
@@ -7081,26 +7058,25 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7081
7058
  }
7082
7059
  }, []);
7083
7060
  useEffect(() => {
7084
- var _a;
7085
- if (((_a = result === null || result === void 0 ? void 0 : result.vehicle) === null || _a === void 0 ? void 0 : _a.data) && modifyDocumentTitleItem) {
7061
+ if (result?.vehicle?.data && modifyDocumentTitleItem) {
7086
7062
  const { vehicle } = result;
7087
7063
  const { registrationNumber } = vehicle.data;
7088
7064
  document.title = `${registrationNumber} | ${vehicle.title} | ${vehicle.shortDescription}`;
7089
7065
  }
7090
7066
  }, [result]);
7091
- const options = useMemo(() => { var _a, _b, _c; return (_c = (_b = (_a = result === null || result === void 0 ? void 0 : result.vehicle) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.filter(notEmpty).map((opt) => ({ title: opt })); }, [(_b = (_a = result === null || result === void 0 ? void 0 : result.vehicle) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.options]);
7067
+ const options = useMemo(() => result?.vehicle?.data?.options?.filter(notEmpty).map((opt) => ({ title: opt })), [result?.vehicle?.data?.options]);
7092
7068
  const onShowMoreOptionsClick = useCallback(() => PubSub.publish('OptionsClick'), []);
7093
7069
  if (loading) {
7094
7070
  return React__default.createElement(PageLoading, null);
7095
7071
  }
7096
- if (!((_c = result === null || result === void 0 ? void 0 : result.vehicle) === null || _c === void 0 ? void 0 : _c.data)) {
7072
+ if (!result?.vehicle?.data) {
7097
7073
  return React__default.createElement(Page404, null);
7098
7074
  }
7099
7075
  const { vehicle } = result;
7100
- const contact = centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.contact;
7101
- const branch = centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch;
7076
+ const contact = centralStorageVehicle?.contact;
7077
+ const branch = centralStorageVehicle?.branch;
7102
7078
  const { title, shortDescription, media, description, price, financialOptions, manufacturer, ecommerce, packageOptions, publishedAt, documents, } = vehicle;
7103
- const insuranceOptions = (centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.insuranceOptions)
7079
+ const insuranceOptions = centralStorageVehicle?.insuranceOptions
7104
7080
  ? centralStorageVehicle.insuranceOptions
7105
7081
  : vehicle.insuranceOptions;
7106
7082
  const { fuelType, mileage, gearbox, modelYear, propertySet } = vehicle.data;
@@ -7131,7 +7107,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7131
7107
  React__default.createElement(ButtonContent, null,
7132
7108
  React__default.createElement(IconChevronLeft, { block: true })),
7133
7109
  React__default.createElement(ButtonContent, null, "Tillbaka till bils\u00F6k"))))) : null,
7134
- (manufacturer === null || manufacturer === void 0 ? void 0 : manufacturer.logotype) && (React__default.createElement(Repeat, null,
7110
+ manufacturer?.logotype && (React__default.createElement(Repeat, null,
7135
7111
  React__default.createElement(LogoBox, { logo: manufacturer.logotype, alt: manufacturer.name }))),
7136
7112
  React__default.createElement(Repeat, null,
7137
7113
  React__default.createElement(RepeatSmall, null,
@@ -7144,9 +7120,9 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7144
7120
  React__default.createElement(PriceTable, { price: price })),
7145
7121
  (financialOptions.length > 0 || insuranceOptions.length > 0) && (React__default.createElement(ProductPageAsideSection, { mobileOrder: 4 },
7146
7122
  financialOptions.length > 0 && (React__default.createElement(FinancialOptions, { id: id, financialOptions: financialOptions })),
7147
- insuranceOptions.length > 0 && (React__default.createElement(InsuranceOptions, { id: id, branch: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch, insuranceOptions: insuranceOptions })))),
7123
+ insuranceOptions.length > 0 && (React__default.createElement(InsuranceOptions, { id: id, branch: centralStorageVehicle?.branch, insuranceOptions: insuranceOptions })))),
7148
7124
  React__default.createElement(ProductPageAsideSection, { mobileOrder: 5 },
7149
- React__default.createElement(CheckList, { manufacturer: manufacturer, packageOptions: packageOptions, ecommerce: ecommerce, branch: branch, contact: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.contact, loadingCentralStorageVehicle: loadingCentralStorageVehicle, toggleEcomModal: () => { var _a; return (_a = ecomContext.current) === null || _a === void 0 ? void 0 : _a.start(); } }))),
7125
+ React__default.createElement(CheckList, { manufacturer: manufacturer, packageOptions: packageOptions, ecommerce: ecommerce, branch: branch, contact: centralStorageVehicle?.contact, loadingCentralStorageVehicle: loadingCentralStorageVehicle, toggleEcomModal: () => ecomContext.current?.start() }))),
7150
7126
  React__default.createElement(ProductPageMain, null,
7151
7127
  React__default.createElement(ProductPageAsideSection, { mobileOrder: 3 },
7152
7128
  React__default.createElement(Gallery, { media: media, placeholderImage: placeholderImage })),
@@ -7161,8 +7137,8 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7161
7137
  description && (React__default.createElement(ProductPageMainSection, null,
7162
7138
  React__default.createElement(Blockquote, { author: contact && contact.name ? contact.name : null, date: publishedAt
7163
7139
  ? dateTimeFormat.format(publishedAt, dateTimeFormat.DayMonth)
7164
- : undefined, avatar: (contact === null || contact === void 0 ? void 0 : contact.avatar) || undefined }, !!description && React__default.createElement("p", null, description)))),
7165
- ((options === null || options === void 0 ? void 0 : options.length) || 0) > 0 && (React__default.createElement(ProductPageMainSection, null,
7140
+ : undefined, avatar: contact?.avatar || undefined }, !!description && React__default.createElement("p", null, description)))),
7141
+ (options?.length || 0) > 0 && (React__default.createElement(ProductPageMainSection, null,
7166
7142
  React__default.createElement(Repeat, null,
7167
7143
  React__default.createElement(H2, { noMargin: true }, "Utrustning")),
7168
7144
  React__default.createElement(Repeat, null,
@@ -7182,9 +7158,9 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7182
7158
  React__default.createElement(ProductPageMainSection, null,
7183
7159
  React__default.createElement(Branch, { branch: branch, loading: loadingCentralStorageVehicle }),
7184
7160
  ecommerce && ecommerce.enabled && (React__default.createElement(Repeat, null,
7185
- React__default.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, title: "K\u00F6p bilen online", onClick: () => { var _a; return (_a = ecomContext.current) === null || _a === void 0 ? void 0 : _a.start(); } }, "K\u00F6p bilen online")))),
7161
+ React__default.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, title: "K\u00F6p bilen online", onClick: () => ecomContext.current?.start() }, "K\u00F6p bilen online")))),
7186
7162
  React__default.createElement(PackageOptions, { packageOptions: packageOptions }),
7187
- React__default.createElement(ManufacturerPackageOption, { packageOption: manufacturer === null || manufacturer === void 0 ? void 0 : manufacturer.packageOption }))))),
7163
+ React__default.createElement(ManufacturerPackageOption, { packageOption: manufacturer?.packageOption }))))),
7188
7164
  React__default.createElement(Related, { id: id, hashRoute: hashRoute, pathRoute: pathRoute, onClickSearchItem: onClickSearchItem })),
7189
7165
  false ,
7190
7166
  React__default.createElement(PortalElement, { id: DefaultPortal })));
@@ -7224,7 +7200,7 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7224
7200
  'x-api-key': apiKey,
7225
7201
  }
7226
7202
  : {},
7227
- }, !initialize || !!(queryFilter === null || queryFilter === void 0 ? void 0 : queryFilter.block));
7203
+ }, !initialize || !!queryFilter?.block);
7228
7204
  const popStateEvent = (event) => {
7229
7205
  const { currentTarget } = event;
7230
7206
  if (currentTarget) {
@@ -7267,7 +7243,7 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7267
7243
  const nextSearch = nextSearchParams.toString() ? `?${nextSearchParams}` : '';
7268
7244
  if (initialize) {
7269
7245
  if (window.location.search.localeCompare(nextSearch) !== 0) {
7270
- const _path = pathRoute === null || pathRoute === void 0 ? void 0 : pathRoute.replace(/^\/|\/$/g, '');
7246
+ const _path = pathRoute?.replace(/^\/|\/$/g, '');
7271
7247
  const prefix = _path ? `/${_path}/` : '/';
7272
7248
  const index = _path ? window.location.pathname.indexOf(prefix) : -1;
7273
7249
  let pathname = window.location.pathname;
@@ -7280,12 +7256,11 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7280
7256
  }
7281
7257
  }, [queryFilter, initialize, useQueryParamsFromUrl]);
7282
7258
  useEffect(() => {
7283
- var _a;
7284
7259
  if (response) {
7285
7260
  if (!initialFacets && !useQueryParamsFromUrl) {
7286
7261
  setInitialFacets(response.facets);
7287
7262
  }
7288
- if (useQueryParamsFromUrl && ((_a = response.query) === null || _a === void 0 ? void 0 : _a.parameters)) {
7263
+ if (useQueryParamsFromUrl && response.query?.parameters) {
7289
7264
  const nextSearchParams = new URLSearchParams(response.query.parameters);
7290
7265
  nextSearchParams.delete('hits');
7291
7266
  nextSearchParams.delete('offset');
@@ -7298,7 +7273,7 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7298
7273
  });
7299
7274
  }
7300
7275
  }
7301
- if (queryFilter === null || queryFilter === void 0 ? void 0 : queryFilter.concatResult) {
7276
+ if (queryFilter?.concatResult) {
7302
7277
  setDocuments([...(documents || []), ...(response.documentList.documents || [])]);
7303
7278
  }
7304
7279
  else {
@@ -7317,10 +7292,9 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7317
7292
  }
7318
7293
  }, [initialize]);
7319
7294
  const onLoadMore = useCallback(() => {
7320
- var _a;
7321
7295
  if (response) {
7322
7296
  setQueryFilter({
7323
- searchParams: new URLSearchParams((_a = response === null || response === void 0 ? void 0 : response.documentList.pagination.nextPage) === null || _a === void 0 ? void 0 : _a.query),
7297
+ searchParams: new URLSearchParams(response?.documentList.pagination.nextPage?.query),
7324
7298
  concatResult: true,
7325
7299
  });
7326
7300
  }
@@ -7333,9 +7307,8 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7333
7307
  : _initialQueryParams;
7334
7308
  if (useQueryParamsFromUrl && _initialQueryParams) {
7335
7309
  _initialQueryParams.forEach((value, key) => {
7336
- var _a;
7337
- if (!((_a = initialQueryParams === null || initialQueryParams === void 0 ? void 0 : initialQueryParams.getAll(key)) === null || _a === void 0 ? void 0 : _a.some((v) => v === value))) {
7338
- initialQueryParams === null || initialQueryParams === void 0 ? void 0 : initialQueryParams.append(key, value);
7310
+ if (!initialQueryParams?.getAll(key)?.some((v) => v === value)) {
7311
+ initialQueryParams?.append(key, value);
7339
7312
  }
7340
7313
  });
7341
7314
  }
@@ -7393,29 +7366,11 @@ const Root = styled.div.attrs(() => ({
7393
7366
  }
7394
7367
  `;
7395
7368
 
7396
- const useEcom = (ecomSettings) => {
7397
- if (ecomSettings === null || ecomSettings === void 0 ? void 0 : ecomSettings.url) {
7398
- import('@wayke-se/ecom').then(({ config }) => {
7399
- config.bind({
7400
- api: {
7401
- address: ecomSettings.url,
7402
- },
7403
- /** Specifying an origin is optional **/
7404
- origin: {
7405
- topic: 'Wayke',
7406
- channel: 'wayke.se',
7407
- },
7408
- bankIdThumbprint: ecomSettings.bankIdThumbprint,
7409
- });
7410
- });
7411
- }
7412
- };
7413
-
7414
7369
  const SettingsProvider = ({ googleMapsApiKey, googleMapsMarker, ecomSettings, children, }) => (React__default.createElement(SettingsContext.Provider, { value: { ecomSettings, googleMapsApiKey, googleMapsMarker } }, children));
7415
7370
 
7416
7371
  const RelatedSearchProvider = ({ url, urlMlt, apiKey, children }) => {
7417
7372
  const [queryFilter, setQueryFilter] = useState();
7418
- const query = queryFilter === null || queryFilter === void 0 ? void 0 : queryFilter.searchParams.toString();
7373
+ const query = queryFilter?.searchParams.toString();
7419
7374
  const { loading, data: response, error, } = useFetch(`${urlMlt || url}${query ? `?${query}` : ''}`, {
7420
7375
  headers: apiKey
7421
7376
  ? {
@@ -7520,7 +7475,7 @@ const PathProvider = ({ children }) => {
7520
7475
  }
7521
7476
  dispatch({ type: SET_PATH, path });
7522
7477
  }, []);
7523
- const id = useMemo(() => { var _a; return (_a = state.path.match(regexGuidAnyWhere)) === null || _a === void 0 ? void 0 : _a.pop(); }, [state.path]);
7478
+ const id = useMemo(() => state.path.match(regexGuidAnyWhere)?.pop(), [state.path]);
7524
7479
  const value = useMemo(() => ({
7525
7480
  ...state,
7526
7481
  previousPath,
@@ -7531,17 +7486,14 @@ const PathProvider = ({ children }) => {
7531
7486
  return React__default.createElement(PathContext.Provider, { value: value }, children);
7532
7487
  };
7533
7488
 
7534
- const WaykeProvider = ({ url, urlMlt, apiKey, ecomSettings, graphQlUrl, googleMapsApiKey, googleMapsMarker, useQueryParamsFromUrl, pathRoute, children, }) => {
7535
- useEcom(ecomSettings);
7536
- return (React__default.createElement(PathProvider, null,
7537
- React__default.createElement(SettingsProvider, { googleMapsApiKey: googleMapsApiKey, googleMapsMarker: googleMapsMarker, ecomSettings: ecomSettings },
7538
- React__default.createElement(CentralStorageProvider, null,
7539
- React__default.createElement(GraphqlProvider, { uri: graphQlUrl },
7540
- React__default.createElement(SearchProvider, { url: url, apiKey: apiKey, useQueryParamsFromUrl: useQueryParamsFromUrl, pathRoute: pathRoute },
7541
- React__default.createElement(RelatedSearchProvider, { url: url, urlMlt: urlMlt, apiKey: apiKey },
7542
- React__default.createElement(ThemeProvider, null,
7543
- React__default.createElement(Root, null, children)))))))));
7544
- };
7489
+ const WaykeProvider = ({ url, urlMlt, apiKey, ecomSettings, graphQlUrl, googleMapsApiKey, googleMapsMarker, useQueryParamsFromUrl, pathRoute, children, }) => (React__default.createElement(PathProvider, null,
7490
+ React__default.createElement(SettingsProvider, { googleMapsApiKey: googleMapsApiKey, googleMapsMarker: googleMapsMarker, ecomSettings: ecomSettings },
7491
+ React__default.createElement(CentralStorageProvider, null,
7492
+ React__default.createElement(GraphqlProvider, { uri: graphQlUrl },
7493
+ React__default.createElement(SearchProvider, { url: url, apiKey: apiKey, useQueryParamsFromUrl: useQueryParamsFromUrl, pathRoute: pathRoute },
7494
+ React__default.createElement(RelatedSearchProvider, { url: url, urlMlt: urlMlt, apiKey: apiKey },
7495
+ React__default.createElement(ThemeProvider, null,
7496
+ React__default.createElement(Root, null, children)))))))));
7545
7497
 
7546
7498
  const regexGuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
7547
7499
  const HASH_CHANGE = 'hashchange';
@@ -7590,16 +7542,13 @@ const WaykeComposite = ({ filterList, initialQueryParams, removeSearchBar, remov
7590
7542
  const WaykeCompositeWithProvider = ({ provider, composite }) => (React__default.createElement(WaykeProvider, { ...provider },
7591
7543
  React__default.createElement(WaykeComposite, { ...composite })));
7592
7544
 
7593
- const WaykeItemProvider = ({ url, urlMlt, apiKey, ecomSettings, graphQlUrl, googleMapsApiKey, googleMapsMarker, children, }) => {
7594
- useEcom(ecomSettings);
7595
- return (React__default.createElement(PathProvider, null,
7596
- React__default.createElement(SettingsProvider, { googleMapsApiKey: googleMapsApiKey, googleMapsMarker: googleMapsMarker, ecomSettings: ecomSettings },
7597
- React__default.createElement(CentralStorageProvider, null,
7598
- React__default.createElement(GraphqlProvider, { uri: graphQlUrl },
7599
- React__default.createElement(RelatedSearchProvider, { url: url, urlMlt: urlMlt, apiKey: apiKey },
7600
- React__default.createElement(ThemeProvider, null,
7601
- React__default.createElement(Root, null, children))))))));
7602
- };
7545
+ const WaykeItemProvider = ({ url, urlMlt, apiKey, ecomSettings, graphQlUrl, googleMapsApiKey, googleMapsMarker, children, }) => (React__default.createElement(PathProvider, null,
7546
+ React__default.createElement(SettingsProvider, { googleMapsApiKey: googleMapsApiKey, googleMapsMarker: googleMapsMarker, ecomSettings: ecomSettings },
7547
+ React__default.createElement(CentralStorageProvider, null,
7548
+ React__default.createElement(GraphqlProvider, { uri: graphQlUrl },
7549
+ React__default.createElement(RelatedSearchProvider, { url: url, urlMlt: urlMlt, apiKey: apiKey },
7550
+ React__default.createElement(ThemeProvider, null,
7551
+ React__default.createElement(Root, null, children))))))));
7603
7552
 
7604
7553
  export default WaykeCompositeWithProvider;
7605
7554
  export { SearchBar, WaykeItemProvider, WaykeProvider, PubSub as WaykePubSub, WaykeSearch, WaykeSearchItem, ThemeProvider as WaykeThemeProvider };