@wayke-se/components-react 2.16.0 → 3.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +33 -2
  2. package/dist-node/index.js +3254 -1142
  3. package/dist-node/index.js.map +1 -1
  4. package/dist-src/State/CentralStorage/useCentralStorage.js +7 -8
  5. package/dist-src/State/Path/PathProvider.js +1 -1
  6. package/dist-src/State/RelatedSearch/RelatedSearchProvider.js +1 -1
  7. package/dist-src/State/Search/SearchProvider.js +7 -10
  8. package/dist-src/components/ActionList/index.js +2 -3
  9. package/dist-src/components/Checklist/index.js +1 -1
  10. package/dist-src/components/ExtendContent/index.js +1 -1
  11. package/dist-src/components/Filter/index.js +10 -7
  12. package/dist-src/components/FilterPanel/checkListFacet.js +1 -1
  13. package/dist-src/components/FilterPanel/colorFacet.js +1 -1
  14. package/dist-src/components/FilterPanel/index.js +1 -1
  15. package/dist-src/components/FilterPanel/rangeFacet.js +14 -16
  16. package/dist-src/components/FinancialOptions/LoanModal.js +27 -29
  17. package/dist-src/components/FinancialOptions/leasing.js +6 -6
  18. package/dist-src/components/FinancialOptions/loan.js +5 -6
  19. package/dist-src/components/Gallery/index.js +11 -16
  20. package/dist-src/components/Grid/index.js +2 -3
  21. package/dist-src/components/InputSelect/index.js +1 -1
  22. package/dist-src/components/InsuranceOptions/InsuranceFree.js +1 -2
  23. package/dist-src/components/InsuranceOptions/InsuranceFreeModal.js +4 -5
  24. package/dist-src/components/InsuranceOptions/InsuranceModal.js +3 -3
  25. package/dist-src/components/Lightbox/index.js +1 -1
  26. package/dist-src/components/OpeningHours/index.js +9 -9
  27. package/dist-src/components/RangeSlider/SliderWithLabel.js +1 -1
  28. package/dist-src/components/Result/index.js +7 -6
  29. package/dist-src/components/Video/EmbededVideo.js +1 -1
  30. package/dist-src/components/Video/QuickNavEmbeded.js +2 -2
  31. package/dist-src/components/Video/useThumbnail.js +1 -1
  32. package/dist-src/components/Video/utils.js +2 -2
  33. package/dist-src/hooks/useFetch.js +1 -1
  34. package/dist-src/hooks/useVimeoThumbnail.js +1 -1
  35. package/dist-src/layouts/searchItem/Branch.js +9 -10
  36. package/dist-src/layouts/searchItem/BranchModal.js +1 -1
  37. package/dist-src/layouts/searchItem/CheckList.js +16 -16
  38. package/dist-src/layouts/searchItem/ManufacturerPackagesOption.js +1 -2
  39. package/dist-src/layouts/searchItem/PackageOptionModal.js +7 -10
  40. package/dist-src/layouts/searchItem/PackageOptions.js +11 -14
  41. package/dist-src/layouts/searchItem/Property.js +4 -6
  42. package/dist-src/layouts/searchItem/Related.js +3 -4
  43. package/dist-src/layouts/searchItem/index.js +42 -21
  44. package/dist-src/providers/WaykeItemProvidet.js +7 -11
  45. package/dist-src/providers/WaykeProvider.js +8 -12
  46. package/dist-src/utils/phonenumbers.js +1 -1
  47. package/dist-src/utils/specification.js +9 -13
  48. package/dist-src/utils/vehicle-properties/property-tree-creator.js +5 -5
  49. package/dist-types/State/CentralStorage/useCentralStorage.d.ts +1 -1
  50. package/dist-types/State/Settings/SettingsContext.d.ts +1 -0
  51. package/dist-types/components/InputSearch/index.d.ts +5 -3
  52. package/dist-types/components/RangeSlider/handle.d.ts +2 -2
  53. package/dist-types/components/RangeSlider/track.d.ts +2 -2
  54. package/dist-types/components/Video/useThumbnail.d.ts +1 -1
  55. package/dist-types/components/Video/utils.d.ts +2 -2
  56. package/dist-types/hooks/useFetch.d.ts +1 -1
  57. package/dist-types/hooks/useInsurance.d.ts +1 -1
  58. package/dist-types/hooks/useLoan.d.ts +1 -1
  59. package/dist-types/hooks/useSearchItem.d.ts +1 -1
  60. package/dist-types/hooks/useSearchItemBranch.d.ts +1 -1
  61. package/dist-types/hooks/useVimeoThumbnail.d.ts +1 -1
  62. package/dist-types/utils/regex.d.ts +1 -1
  63. package/dist-types/utils/ssn.d.ts +1 -1
  64. package/dist-web/index.js +250 -323
  65. package/dist-web/index.js.map +1 -1
  66. package/package.json +18 -26
  67. package/dist-src/components/Ecom/index.js +0 -48
  68. package/dist-src/hooks/useEcom.js +0 -18
  69. package/dist-types/components/Ecom/index.d.ts +0 -10
  70. package/dist-types/hooks/useEcom.d.ts +0 -3
package/dist-web/index.js CHANGED
@@ -5,11 +5,11 @@ import { sv } from 'date-fns/locale';
5
5
  import ReactDOM from 'react-dom';
6
6
  import { Slider as Slider$1, Rail, Handles, Tracks } from 'react-compound-slider';
7
7
  import LazyLoad from 'react-lazyload';
8
+ import WaykeEcomWeb from '@wayke-se/ecom-web';
8
9
  import Slider$2 from 'react-slick';
9
10
  import scrollIntoView from 'scroll-into-view-if-needed';
10
11
  import { gql, useQuery, ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
11
12
  import { marked } from 'marked';
12
- import EcomBase from '@wayke-se/ecom-react';
13
13
  import { parsePhoneNumberFromString } from 'libphonenumber-js/core';
14
14
 
15
15
  const _colors = {
@@ -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: {
@@ -5299,56 +5290,7 @@ const InsuranceOptions = ({ id, branch, insuranceOptions }) => {
5299
5290
  return null;
5300
5291
  };
5301
5292
 
5302
- const SettingsContext = createContext({});
5303
-
5304
- const useSettings = () => useContext(SettingsContext);
5305
-
5306
- const Ecom = ({ vehicle, manufacturer, onExit, onUserEvent }) => {
5307
- var _a, _b, _c;
5308
- const { ecomSettings } = useSettings();
5309
- useEffect(() => {
5310
- PubSub.publish('EcomOnInit');
5311
- }, []);
5312
- const onUserEventLocal = useCallback((userEvent, currentStep) => {
5313
- PubSub.publish('EcomOnUserEvent', userEvent, currentStep);
5314
- if (onUserEvent) {
5315
- onUserEvent(userEvent, currentStep);
5316
- }
5317
- }, []);
5318
- const onExitLocal = useCallback(() => {
5319
- PubSub.publish('EcomOnExit');
5320
- if (onExit) {
5321
- onExit();
5322
- }
5323
- }, []);
5324
- const { id, title, shortDescription, price, data, media } = vehicle;
5325
- const { modelYear, mileage, gearbox, fuelType } = data;
5326
- const imageUrl = (_c = (_b = (_a = media === null || media === void 0 ? void 0 : media[0]) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.url;
5327
- const ecomData = {
5328
- vehicle: {
5329
- id,
5330
- title,
5331
- shortDescription: shortDescription || '',
5332
- price,
5333
- imageUrl,
5334
- modelYear,
5335
- milage: `${mileage}`,
5336
- gearBox: gearbox || '',
5337
- fuelType: fuelType || '',
5338
- },
5339
- serviceLogotypeUrl: (ecomSettings === null || ecomSettings === void 0 ? void 0 : ecomSettings.serviceLogotypeUrl) ||
5340
- (manufacturer === null || manufacturer === void 0 ? void 0 : manufacturer.logotype) ||
5341
- 'https://cdn.wayke.se/wui/images/ecom/wayke-logo.svg',
5342
- onExit: onExitLocal,
5343
- onUserEvent: onUserEventLocal,
5344
- useBankId: ecomSettings === null || ecomSettings === void 0 ? void 0 : ecomSettings.useBankId,
5345
- displayBankIdAlert: ecomSettings === null || ecomSettings === void 0 ? void 0 : ecomSettings.displayBankIdAlert,
5346
- };
5347
- return React__default.createElement(EcomBase, { ...ecomData });
5348
- };
5349
-
5350
5293
  const ManufacturerPackageOption = ({ packageOption }) => {
5351
- var _a;
5352
5294
  if (!packageOption) {
5353
5295
  return null;
5354
5296
  }
@@ -5357,7 +5299,7 @@ const ManufacturerPackageOption = ({ packageOption }) => {
5357
5299
  React__default.createElement(H2, { noMargin: true }, packageOption.title)),
5358
5300
  packageOption.description && (React__default.createElement(Repeat, null,
5359
5301
  React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5360
- ((_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,
5361
5303
  React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.url, target: "_blank", rel: "noopener noreferrer" }, packageOption.link.title
5362
5304
  ? packageOption.link.title
5363
5305
  : 'Läs mer (Öppnas i ett nytt fönster)'))),
@@ -5479,7 +5421,7 @@ const typedMetadata = Metadata;
5479
5421
  const formatPhonenumber = (text) => {
5480
5422
  try {
5481
5423
  const parsed = parsePhoneNumberFromString(text.replace('-', '').replace(/ /g, ''), typedMetadata);
5482
- return (parsed === null || parsed === void 0 ? void 0 : parsed.formatNational()) || text;
5424
+ return parsed?.formatNational() || text;
5483
5425
  }
5484
5426
  catch (e) {
5485
5427
  return text;
@@ -5487,9 +5429,8 @@ const formatPhonenumber = (text) => {
5487
5429
  };
5488
5430
 
5489
5431
  const ActionList = ({ contact, branch }) => {
5490
- var _a, _b;
5491
- 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);
5492
- 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;
5493
5434
  const onClickMailVisible = useCallback(() => PubSub.publish('MailVisible'), []);
5494
5435
  const onClickPhoneVisible = useCallback(() => PubSub.publish('PhonenumberVisible'), []);
5495
5436
  const onClickPhoneValue = useCallback(() => PubSub.publish('PhonenumberCall'), []);
@@ -5642,7 +5583,7 @@ const BranchModal = ({ loading, connections, onClose }) => {
5642
5583
  React__default.createElement("p", null, "V\u00E4lj den anl\u00E4ggning du vill visa kontaktuppgifter f\u00F6r."))),
5643
5584
  React__default.createElement(RepeatTiny, null,
5644
5585
  React__default.createElement(InputLabel, null, "V\u00E4lj anl\u00E4ggning"),
5645
- 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) => ({
5646
5587
  value: x.id,
5647
5588
  displayName: x.name,
5648
5589
  })), title: "V\u00E4lj anl\u00E4ggning" }))),
@@ -5651,16 +5592,13 @@ const BranchModal = ({ loading, connections, onClose }) => {
5651
5592
  React__default.createElement(ButtonContent, null, "V\u00E4lj")))));
5652
5593
  };
5653
5594
 
5654
- const PackageOptionModal = ({ packageOption, onClose }) => {
5655
- var _a;
5656
- return (React__default.createElement(Modal, { title: packageOption.title || '', onClose: onClose },
5657
- packageOption.image && (React__default.createElement(Repeat, null,
5658
- React__default.createElement(LogoBox, { logo: packageOption.image, alt: packageOption.title || undefined, wide: true }))),
5659
- packageOption.description && (React__default.createElement(Repeat, null,
5660
- React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5661
- ((_a = packageOption.link) === null || _a === void 0 ? void 0 : _a.href) && packageOption.link.title && (React__default.createElement(Repeat, null,
5662
- React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.href, target: "_blank", rel: "noopener noreferrer nofollow" }, packageOption.link.title)))));
5663
- };
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)))));
5664
5602
 
5665
5603
  const CheckList = ({ manufacturer, packageOptions, ecommerce, branch, contact, toggleEcomModal, loadingCentralStorageVehicle, }) => {
5666
5604
  const [modalBranch, setModalBranch] = useState(false);
@@ -5674,45 +5612,45 @@ const CheckList = ({ manufacturer, packageOptions, ecommerce, branch, contact, t
5674
5612
  setModalBranch(false);
5675
5613
  }
5676
5614
  }, [branch, contact]);
5677
- const packageOption = manufacturer === null || manufacturer === void 0 ? void 0 : manufacturer.packageOption;
5615
+ const packageOption = manufacturer?.packageOption;
5678
5616
  return (React__default.createElement(React__default.Fragment, null,
5679
- 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 })),
5680
5618
  modal && React__default.createElement(PackageOptionModal, { packageOption: modal, onClose: onClose }),
5681
5619
  React__default.createElement(Repeat, null,
5682
5620
  React__default.createElement(CheckMarkList, null,
5683
- (packageOption === null || packageOption === void 0 ? void 0 : packageOption.title) && (React__default.createElement(CheckMarkListItem, null,
5621
+ packageOption?.title && (React__default.createElement(CheckMarkListItem, null,
5684
5622
  React__default.createElement(React__default.Fragment, null,
5685
5623
  "Inkl.",
5686
5624
  ' ',
5687
5625
  React__default.createElement(ButtonInline, { onClick: () => onOpen({
5688
- title: packageOption === null || packageOption === void 0 ? void 0 : packageOption.title,
5689
- image: packageOption === null || packageOption === void 0 ? void 0 : packageOption.image,
5690
- description: packageOption === null || packageOption === void 0 ? void 0 : packageOption.description,
5691
- 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,
5692
5630
  }) }, packageOption.title),
5693
5631
  ' ',
5694
- "begagnatgaranti"))), packageOptions === null || packageOptions === void 0 ? void 0 :
5695
- 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 },
5696
5634
  React__default.createElement(React__default.Fragment, null,
5697
5635
  "Inkl.",
5698
5636
  ' ',
5699
5637
  React__default.createElement(ButtonInline, { onClick: () => onOpen({
5700
- title: packageOption === null || packageOption === void 0 ? void 0 : packageOption.title,
5701
- image: packageOption === null || packageOption === void 0 ? void 0 : packageOption.image,
5702
- description: packageOption === null || packageOption === void 0 ? void 0 : packageOption.description,
5703
- 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,
5704
5642
  }) }, packageOption.title))))),
5705
- (ecommerce === null || ecommerce === void 0 ? void 0 : ecommerce.withHomeDelivery) && React__default.createElement(CheckMarkListItem, null, "Hemleverans"))),
5643
+ ecommerce?.withHomeDelivery && React__default.createElement(CheckMarkListItem, null, "Hemleverans"))),
5706
5644
  React__default.createElement(Repeat, null,
5707
5645
  ecommerce && ecommerce.enabled && (React__default.createElement(RepeatTiny, null,
5708
5646
  React__default.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, fullWidth: true, onClick: toggleEcomModal },
5709
5647
  React__default.createElement(ButtonContent, null, "K\u00F6p bilen online")))),
5710
- (ecommerce === null || ecommerce === void 0 ? void 0 : ecommerce.reserved) && (React__default.createElement(RepeatTiny, null,
5648
+ ecommerce?.reserved && (React__default.createElement(RepeatTiny, null,
5711
5649
  React__default.createElement(SwitchBar, { title: "Bilen \u00E4r reserverad", body: "Denna bil \u00E4r reserverad av en annan k\u00F6pare." },
5712
5650
  React__default.createElement(Content$2, null,
5713
5651
  React__default.createElement("p", null, "Denna bil \u00E4r reserverad av en annan k\u00F6pare."))))),
5714
5652
  React__default.createElement(ActionList, { branch: branch, contact: contact })),
5715
- ((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,
5716
5654
  React__default.createElement(SwitchBar, { title: "Centrallagerbil", actionTitle: "Byt anl\u00E4ggning", onClick: openModalBranch },
5717
5655
  React__default.createElement(Content$2, null,
5718
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.")))))));
@@ -5839,7 +5777,7 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
5839
5777
  onClickSearchItem(id);
5840
5778
  }
5841
5779
  }, []);
5842
- 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) {
5843
5781
  return null;
5844
5782
  }
5845
5783
  if (loading) {
@@ -5854,8 +5792,7 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
5854
5792
  React__default.createElement(H2, { noMargin: true }, "Senast inkomna")))),
5855
5793
  React__default.createElement(Repeat, null,
5856
5794
  React__default.createElement(OverflowGrid, null,
5857
- React__default.createElement(OverflowGridList, null, response === null || response === void 0 ? void 0 : response.documentList.documents.map((document) => {
5858
- var _a, _b, _c;
5795
+ React__default.createElement(OverflowGridList, null, response?.documentList.documents.map((document) => {
5859
5796
  const prefix = pathRoute ? `/${pathRoute}` : '/';
5860
5797
  const r = regexPathGuid(pathRoute);
5861
5798
  const pathRouteUrl = window.location.pathname === '/'
@@ -5864,7 +5801,7 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
5864
5801
  ? window.location.pathname.replace(r, `${pathRoute}${document._id}`)
5865
5802
  : `${window.location.pathname}${prefix}${document._id}`;
5866
5803
  return (React__default.createElement(OverflowGridItem, { key: document._id },
5867
- 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: [
5868
5805
  {
5869
5806
  title: document.modelYear,
5870
5807
  },
@@ -5887,20 +5824,17 @@ const PackageOptions = ({ packageOptions }) => {
5887
5824
  if (!packageOptions) {
5888
5825
  return null;
5889
5826
  }
5890
- return (React__default.createElement(React__default.Fragment, null, packageOptions.map((packageOption, index) => {
5891
- var _a;
5892
- return (React__default.createElement(ProductPageMainSection, { key: packageOption.title || index },
5893
- React__default.createElement(Repeat, null,
5894
- React__default.createElement(H2, { noMargin: true }, packageOption.title)),
5895
- packageOption.description && (React__default.createElement(Repeat, null,
5896
- React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5897
- ((_a = packageOption.link) === null || _a === void 0 ? void 0 : _a.url) && (React__default.createElement(Repeat, null,
5898
- React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.url, target: "_blank", rel: "noopener noreferrer" }, packageOption.link.title
5899
- ? packageOption.link.title
5900
- : 'Läs mer (Öppnas i ett nytt fönster)'))),
5901
- packageOption.image && (React__default.createElement(Repeat, null,
5902
- React__default.createElement(LogoBox, { logo: packageOption.image, alt: "Logotyp", wide: true })))));
5903
- })));
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 }))))))));
5904
5838
  };
5905
5839
 
5906
5840
  const TableColumn = styled.div `
@@ -5971,15 +5905,15 @@ const arr = [];
5971
5905
  const GetOpeningHours = (o) => KeyOrder.reduce((prev, current) => {
5972
5906
  const title = TranslateWeekDays(current);
5973
5907
  const item = o[current];
5974
- const previous = prev === null || prev === void 0 ? void 0 : prev[prev.length - 1];
5975
- 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) {
5976
5910
  prev[prev.length - 1].titleTo = title;
5977
5911
  }
5978
5912
  else {
5979
5913
  prev.push({
5980
5914
  titleFrom: title,
5981
- from: item === null || item === void 0 ? void 0 : item.from,
5982
- until: item === null || item === void 0 ? void 0 : item.until,
5915
+ from: item?.from,
5916
+ until: item?.until,
5983
5917
  });
5984
5918
  }
5985
5919
  return prev;
@@ -5990,8 +5924,8 @@ const GetOpeningHoursToday = (o) => {
5990
5924
  const current = o[day];
5991
5925
  return {
5992
5926
  title: current ? 'Öppetider idag' : 'Stängt idag',
5993
- from: current === null || current === void 0 ? void 0 : current.from,
5994
- until: current === null || current === void 0 ? void 0 : current.until,
5927
+ from: current?.from,
5928
+ until: current?.until,
5995
5929
  };
5996
5930
  };
5997
5931
  const valuOfDateString = (s) => {
@@ -6002,7 +5936,7 @@ const OpeningHours = ({ openingHours }) => {
6002
5936
  const today = useMemo(() => (openingHours ? GetOpeningHoursToday(openingHours) : null), [openingHours]);
6003
5937
  const currentlyOpen = useMemo(() => {
6004
5938
  try {
6005
- 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) {
6006
5940
  const currentDate = new Date().valueOf();
6007
5941
  const from = valuOfDateString(today.from);
6008
5942
  const until = valuOfDateString(today.until);
@@ -6024,9 +5958,9 @@ const OpeningHours = ({ openingHours }) => {
6024
5958
  React__default.createElement(TableColumn, null,
6025
5959
  React__default.createElement(TableColumnRow, null,
6026
5960
  React__default.createElement(TableColumnCell, null,
6027
- React__default.createElement(UtilityTextBold, null, today === null || today === void 0 ? void 0 : today.title)),
5961
+ React__default.createElement(UtilityTextBold, null, today?.title)),
6028
5962
  React__default.createElement(TableColumnCell, null,
6029
- 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'))),
6030
5964
  oh.map((o) => (React__default.createElement(TableColumnRow, { key: o.titleFrom },
6031
5965
  React__default.createElement(TableColumnCell, null, o.titleTo ? `${o.titleFrom}-${o.titleTo}` : o.titleFrom),
6032
5966
  React__default.createElement(TableColumnCell, null, o.from ? `${o.from}-${o.until}` : 'Stängt'))))))));
@@ -6042,6 +5976,10 @@ const PhoneNumber = ({ phoneNumber }) => {
6042
5976
  React__default.createElement(ButtonContent, null, "Visa telefonnummer"))))));
6043
5977
  };
6044
5978
 
5979
+ const SettingsContext = createContext({});
5980
+
5981
+ const useSettings = () => useContext(SettingsContext);
5982
+
6045
5983
  const Wrapper$w = styled.a `
6046
5984
  display: block;
6047
5985
  `;
@@ -6091,7 +6029,6 @@ const StaticMap = ({ position }) => {
6091
6029
  };
6092
6030
 
6093
6031
  const Branch = ({ branch, loading }) => {
6094
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6095
6032
  const [modal, setModal] = useState(false);
6096
6033
  const openModal = useCallback(() => setModal(true), []);
6097
6034
  const closeModal = useCallback(() => setModal(false), []);
@@ -6104,14 +6041,14 @@ const Branch = ({ branch, loading }) => {
6104
6041
  return null;
6105
6042
  }
6106
6043
  return (React__default.createElement(React__default.Fragment, null,
6107
- 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 })),
6108
6045
  React__default.createElement(Repeat, null,
6109
- React__default.createElement(H2, { noMargin: true }, ((_a = branch === null || branch === void 0 ? void 0 : branch.location) === null || _a === void 0 ? void 0 : _a.city)
6110
- ? `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}`
6111
6048
  : 'Kontakt')),
6112
6049
  React__default.createElement(Repeat, null,
6113
- React__default.createElement(StaticMap, { position: (_c = branch === null || branch === void 0 ? void 0 : branch.location) === null || _c === void 0 ? void 0 : _c.position })),
6114
- (((_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,
6115
6052
  React__default.createElement(Content$2, null,
6116
6053
  React__default.createElement("p", null,
6117
6054
  "Denna bil tillh\u00F6r ett centrallager och g\u00E5r att k\u00F6pa genom flera anl\u00E4ggningar.",
@@ -6122,13 +6059,13 @@ const Branch = ({ branch, loading }) => {
6122
6059
  React__default.createElement(ProductPageContentLimit, null,
6123
6060
  React__default.createElement(Repeat, null,
6124
6061
  React__default.createElement(TableColumn, null,
6125
- ((_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,
6126
6063
  React__default.createElement(TableColumnCell, null, "Adress"),
6127
6064
  React__default.createElement(TableColumnCell, null,
6128
6065
  React__default.createElement(ButtonInlineBold, null,
6129
- 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}`))))),
6130
- ((_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) })))),
6131
- (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,
6132
6069
  React__default.createElement(OpeningHours, { openingHours: branch.openingHours })))))));
6133
6070
  };
6134
6071
 
@@ -6254,20 +6191,19 @@ const useSearchItemBranch = (id, branch) => useQuery(SEARCH_ITEM_BRANCH_QUERY, {
6254
6191
  });
6255
6192
 
6256
6193
  const useCentralStorage = (vehicle) => {
6257
- var _a, _b;
6258
6194
  const { centralStorageId, setCentralStorageId } = useContext(CentralStorageContext);
6259
- 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;
6260
6196
  const branchId = centralStorageId
6261
- ? (_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
6262
6198
  : undefined;
6263
- const { data, loading } = useSearchItemBranch(vehicle === null || vehicle === void 0 ? void 0 : vehicle.id, branchId);
6199
+ const { data, loading } = useSearchItemBranch(vehicle?.id, branchId);
6264
6200
  useEffect(() => {
6265
- if (((connections === null || connections === void 0 ? void 0 : connections.length) || 0) > 0) {
6201
+ if ((connections?.length || 0) > 0) {
6266
6202
  const match = centralStorageId
6267
- ? connections === null || connections === void 0 ? void 0 : connections.find((x) => x.id === centralStorageId)
6203
+ ? connections?.find((x) => x.id === centralStorageId)
6268
6204
  : undefined;
6269
6205
  if (!match) {
6270
- const first = connections === null || connections === void 0 ? void 0 : connections[0];
6206
+ const first = connections?.[0];
6271
6207
  if (first) {
6272
6208
  setCentralStorageId(first.id);
6273
6209
  }
@@ -6275,7 +6211,7 @@ const useCentralStorage = (vehicle) => {
6275
6211
  }
6276
6212
  }, [connections]);
6277
6213
  return {
6278
- 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,
6279
6215
  loading,
6280
6216
  };
6281
6217
  };
@@ -6292,14 +6228,14 @@ const PageLoading = () => (React__default.createElement(Page, null,
6292
6228
 
6293
6229
  class PropertyTreeCreator {
6294
6230
  constructor(properties) {
6295
- 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;
6296
6232
  this.propertiesWithoutCategory = (propertyKey) => !this.propertiesWithCategory(propertyKey);
6297
6233
  this.isList = (property) => property.type === PropertyTreeCreator.TEXT_LIST_TYPE;
6298
6234
  this.isNonList = (property) => !this.isList(property);
6299
- this.hasCategoryWithId = (propertyKey, categoryId) => { var _a; return ((_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.id) === categoryId; };
6300
- 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;
6301
6237
  this.propertiesWithoutSubCategory = (propertyKey) => !this.propertiesWithSubCategory(propertyKey);
6302
- 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;
6303
6239
  this.properties = properties;
6304
6240
  }
6305
6241
  create() {
@@ -6366,7 +6302,7 @@ class PropertyTreeCreator {
6366
6302
  const categories = Object.keys(this.properties)
6367
6303
  .filter((key) => this.hasCategoryWithId(key, id))
6368
6304
  .filter(this.propertiesWithSubCategory)
6369
- .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)
6370
6306
  .filter(PropertyTreeCreator.distinctCategories);
6371
6307
  return categories;
6372
6308
  }
@@ -6995,7 +6931,6 @@ const MetadataCategory = ({ properties, subCategories }) => (React__default.crea
6995
6931
  !!subCategories.length &&
6996
6932
  subCategories.map((subCategory, index) => (React__default.createElement(MetadataSubCategory, { name: subCategory.name, properties: subCategory.properties, key: `${subCategory.name}-${index}` })))));
6997
6933
  const PropertySet = ({ propertySet, vehicleData }) => {
6998
- var _a, _b;
6999
6934
  const [activeCategoryId, setActiveCategoryId] = useState(-1);
7000
6935
  const mappedProperties = useMemo(() => {
7001
6936
  if (!propertySet) {
@@ -7009,20 +6944,19 @@ const PropertySet = ({ propertySet, vehicleData }) => {
7009
6944
  return tree;
7010
6945
  }, [propertySet]);
7011
6946
  useEffect(() => {
7012
- var _a;
7013
- 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;
7014
6948
  if (activeCategoryId < 0 && categories !== undefined && categories.length > 0) {
7015
6949
  setActiveCategoryId(categories[0].id);
7016
6950
  }
7017
6951
  }, [mappedProperties]);
7018
6952
  const onTab = useCallback((id) => setActiveCategoryId(parseInt(id, 10)), []);
7019
- 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);
7020
6954
  return (React__default.createElement(React__default.Fragment, null,
7021
6955
  React__default.createElement(Repeat, null,
7022
- 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) => ({
7023
6957
  name: `${category.id}`,
7024
6958
  displayName: category.name,
7025
- }))) || [], active: `${activeCategoryId}`, onClick: onTab })),
6959
+ })) || [], active: `${activeCategoryId}`, onClick: onTab })),
7026
6960
  activeCategory && (React__default.createElement(Repeat, null,
7027
6961
  React__default.createElement(MetadataCategory, { properties: activeCategory.properties, subCategories: activeCategory.subCategories })))));
7028
6962
  };
@@ -7091,37 +7025,58 @@ const PdfDownloadItem = ({ document }) => (React__default.createElement(PdfListI
7091
7025
  const PdfDownloadContainer = ({ documents }) => (React__default.createElement(PdfContainer, null, documents.map((document, i) => (React__default.createElement(PdfDownloadItem, { key: `${document.url}-${i}`, document: document })))));
7092
7026
 
7093
7027
  const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, onClickSearchItem, }) => {
7094
- var _a, _b, _c;
7095
- const [ecomModal, setEcomModal] = useState(false);
7028
+ const { ecomSettings } = useSettings();
7029
+ const ecomContext = useRef();
7096
7030
  const { loading, data: result } = useSearchItem(id);
7097
- const toggleEcomModal = useCallback(() => setEcomModal(!ecomModal), [ecomModal]);
7098
- const { vehicle: centralStorageVehicle, loading: loadingCentralStorageVehicle } = useCentralStorage(result === null || result === void 0 ? void 0 : result.vehicle);
7031
+ const { vehicle: centralStorageVehicle, loading: loadingCentralStorageVehicle } = useCentralStorage(result?.vehicle);
7032
+ useEffect(() => {
7033
+ if (ecomSettings) {
7034
+ ecomContext.current = new WaykeEcomWeb({
7035
+ id,
7036
+ ecomSdkConfig: {
7037
+ api: {
7038
+ address: ecomSettings.url,
7039
+ },
7040
+ bankIdThumbprint: ecomSettings?.bankIdThumbprint,
7041
+ },
7042
+ logo: ecomSettings.serviceLogotypeUrl,
7043
+ logoX2: ecomSettings.serviceLogotypeUrl,
7044
+ onEvent(view, event, currentStep, data) {
7045
+ PubSub.publish('EcomOnUserEvent', view, event, currentStep, data);
7046
+ },
7047
+ });
7048
+ }
7049
+ return () => {
7050
+ if (ecomContext.current) {
7051
+ ecomContext.current.destroy();
7052
+ }
7053
+ };
7054
+ }, []);
7099
7055
  useEffect(() => {
7100
7056
  if (!disableResetScrollOnInit) {
7101
7057
  window.scrollTo(0, 0);
7102
7058
  }
7103
7059
  }, []);
7104
7060
  useEffect(() => {
7105
- var _a;
7106
- 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) {
7107
7062
  const { vehicle } = result;
7108
7063
  const { registrationNumber } = vehicle.data;
7109
7064
  document.title = `${registrationNumber} | ${vehicle.title} | ${vehicle.shortDescription}`;
7110
7065
  }
7111
7066
  }, [result]);
7112
- 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]);
7113
7068
  const onShowMoreOptionsClick = useCallback(() => PubSub.publish('OptionsClick'), []);
7114
7069
  if (loading) {
7115
7070
  return React__default.createElement(PageLoading, null);
7116
7071
  }
7117
- if (!((_c = result === null || result === void 0 ? void 0 : result.vehicle) === null || _c === void 0 ? void 0 : _c.data)) {
7072
+ if (!result?.vehicle?.data) {
7118
7073
  return React__default.createElement(Page404, null);
7119
7074
  }
7120
7075
  const { vehicle } = result;
7121
- const contact = centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.contact;
7122
- const branch = centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch;
7076
+ const contact = centralStorageVehicle?.contact;
7077
+ const branch = centralStorageVehicle?.branch;
7123
7078
  const { title, shortDescription, media, description, price, financialOptions, manufacturer, ecommerce, packageOptions, publishedAt, documents, } = vehicle;
7124
- const insuranceOptions = (centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.insuranceOptions)
7079
+ const insuranceOptions = centralStorageVehicle?.insuranceOptions
7125
7080
  ? centralStorageVehicle.insuranceOptions
7126
7081
  : vehicle.insuranceOptions;
7127
7082
  const { fuelType, mileage, gearbox, modelYear, propertySet } = vehicle.data;
@@ -7140,7 +7095,6 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7140
7095
  uspList.push({ title: fuelType });
7141
7096
  }
7142
7097
  return (React__default.createElement(React__default.Fragment, null,
7143
- ecomModal && React__default.createElement(Ecom, { vehicle: vehicle, manufacturer: manufacturer, onExit: toggleEcomModal }),
7144
7098
  React__default.createElement(Page, null,
7145
7099
  React__default.createElement(PageSection, { large: true },
7146
7100
  React__default.createElement(Container, null,
@@ -7153,7 +7107,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7153
7107
  React__default.createElement(ButtonContent, null,
7154
7108
  React__default.createElement(IconChevronLeft, { block: true })),
7155
7109
  React__default.createElement(ButtonContent, null, "Tillbaka till bils\u00F6k"))))) : null,
7156
- (manufacturer === null || manufacturer === void 0 ? void 0 : manufacturer.logotype) && (React__default.createElement(Repeat, null,
7110
+ manufacturer?.logotype && (React__default.createElement(Repeat, null,
7157
7111
  React__default.createElement(LogoBox, { logo: manufacturer.logotype, alt: manufacturer.name }))),
7158
7112
  React__default.createElement(Repeat, null,
7159
7113
  React__default.createElement(RepeatSmall, null,
@@ -7166,9 +7120,9 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7166
7120
  React__default.createElement(PriceTable, { price: price })),
7167
7121
  (financialOptions.length > 0 || insuranceOptions.length > 0) && (React__default.createElement(ProductPageAsideSection, { mobileOrder: 4 },
7168
7122
  financialOptions.length > 0 && (React__default.createElement(FinancialOptions, { id: id, financialOptions: financialOptions })),
7169
- 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 })))),
7170
7124
  React__default.createElement(ProductPageAsideSection, { mobileOrder: 5 },
7171
- 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: toggleEcomModal }))),
7125
+ React__default.createElement(CheckList, { manufacturer: manufacturer, packageOptions: packageOptions, ecommerce: ecommerce, branch: branch, contact: centralStorageVehicle?.contact, loadingCentralStorageVehicle: loadingCentralStorageVehicle, toggleEcomModal: () => ecomContext.current?.start() }))),
7172
7126
  React__default.createElement(ProductPageMain, null,
7173
7127
  React__default.createElement(ProductPageAsideSection, { mobileOrder: 3 },
7174
7128
  React__default.createElement(Gallery, { media: media, placeholderImage: placeholderImage })),
@@ -7183,8 +7137,8 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7183
7137
  description && (React__default.createElement(ProductPageMainSection, null,
7184
7138
  React__default.createElement(Blockquote, { author: contact && contact.name ? contact.name : null, date: publishedAt
7185
7139
  ? dateTimeFormat.format(publishedAt, dateTimeFormat.DayMonth)
7186
- : undefined, avatar: (contact === null || contact === void 0 ? void 0 : contact.avatar) || undefined }, !!description && React__default.createElement("p", null, description)))),
7187
- ((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,
7188
7142
  React__default.createElement(Repeat, null,
7189
7143
  React__default.createElement(H2, { noMargin: true }, "Utrustning")),
7190
7144
  React__default.createElement(Repeat, null,
@@ -7204,9 +7158,9 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7204
7158
  React__default.createElement(ProductPageMainSection, null,
7205
7159
  React__default.createElement(Branch, { branch: branch, loading: loadingCentralStorageVehicle }),
7206
7160
  ecommerce && ecommerce.enabled && (React__default.createElement(Repeat, null,
7207
- React__default.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, title: "K\u00F6p bilen online", onClick: toggleEcomModal }, "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")))),
7208
7162
  React__default.createElement(PackageOptions, { packageOptions: packageOptions }),
7209
- React__default.createElement(ManufacturerPackageOption, { packageOption: manufacturer === null || manufacturer === void 0 ? void 0 : manufacturer.packageOption }))))),
7163
+ React__default.createElement(ManufacturerPackageOption, { packageOption: manufacturer?.packageOption }))))),
7210
7164
  React__default.createElement(Related, { id: id, hashRoute: hashRoute, pathRoute: pathRoute, onClickSearchItem: onClickSearchItem })),
7211
7165
  false ,
7212
7166
  React__default.createElement(PortalElement, { id: DefaultPortal })));
@@ -7246,7 +7200,7 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7246
7200
  'x-api-key': apiKey,
7247
7201
  }
7248
7202
  : {},
7249
- }, !initialize || !!(queryFilter === null || queryFilter === void 0 ? void 0 : queryFilter.block));
7203
+ }, !initialize || !!queryFilter?.block);
7250
7204
  const popStateEvent = (event) => {
7251
7205
  const { currentTarget } = event;
7252
7206
  if (currentTarget) {
@@ -7289,7 +7243,7 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7289
7243
  const nextSearch = nextSearchParams.toString() ? `?${nextSearchParams}` : '';
7290
7244
  if (initialize) {
7291
7245
  if (window.location.search.localeCompare(nextSearch) !== 0) {
7292
- const _path = pathRoute === null || pathRoute === void 0 ? void 0 : pathRoute.replace(/^\/|\/$/g, '');
7246
+ const _path = pathRoute?.replace(/^\/|\/$/g, '');
7293
7247
  const prefix = _path ? `/${_path}/` : '/';
7294
7248
  const index = _path ? window.location.pathname.indexOf(prefix) : -1;
7295
7249
  let pathname = window.location.pathname;
@@ -7302,12 +7256,11 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7302
7256
  }
7303
7257
  }, [queryFilter, initialize, useQueryParamsFromUrl]);
7304
7258
  useEffect(() => {
7305
- var _a;
7306
7259
  if (response) {
7307
7260
  if (!initialFacets && !useQueryParamsFromUrl) {
7308
7261
  setInitialFacets(response.facets);
7309
7262
  }
7310
- if (useQueryParamsFromUrl && ((_a = response.query) === null || _a === void 0 ? void 0 : _a.parameters)) {
7263
+ if (useQueryParamsFromUrl && response.query?.parameters) {
7311
7264
  const nextSearchParams = new URLSearchParams(response.query.parameters);
7312
7265
  nextSearchParams.delete('hits');
7313
7266
  nextSearchParams.delete('offset');
@@ -7320,7 +7273,7 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7320
7273
  });
7321
7274
  }
7322
7275
  }
7323
- if (queryFilter === null || queryFilter === void 0 ? void 0 : queryFilter.concatResult) {
7276
+ if (queryFilter?.concatResult) {
7324
7277
  setDocuments([...(documents || []), ...(response.documentList.documents || [])]);
7325
7278
  }
7326
7279
  else {
@@ -7339,10 +7292,9 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7339
7292
  }
7340
7293
  }, [initialize]);
7341
7294
  const onLoadMore = useCallback(() => {
7342
- var _a;
7343
7295
  if (response) {
7344
7296
  setQueryFilter({
7345
- 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),
7346
7298
  concatResult: true,
7347
7299
  });
7348
7300
  }
@@ -7355,9 +7307,8 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7355
7307
  : _initialQueryParams;
7356
7308
  if (useQueryParamsFromUrl && _initialQueryParams) {
7357
7309
  _initialQueryParams.forEach((value, key) => {
7358
- var _a;
7359
- if (!((_a = initialQueryParams === null || initialQueryParams === void 0 ? void 0 : initialQueryParams.getAll(key)) === null || _a === void 0 ? void 0 : _a.some((v) => v === value))) {
7360
- 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);
7361
7312
  }
7362
7313
  });
7363
7314
  }
@@ -7415,29 +7366,11 @@ const Root = styled.div.attrs(() => ({
7415
7366
  }
7416
7367
  `;
7417
7368
 
7418
- const useEcom = (ecomSettings) => {
7419
- if (ecomSettings === null || ecomSettings === void 0 ? void 0 : ecomSettings.url) {
7420
- import('@wayke-se/ecom').then(({ config }) => {
7421
- config.bind({
7422
- api: {
7423
- address: ecomSettings.url,
7424
- },
7425
- /** Specifying an origin is optional **/
7426
- origin: {
7427
- topic: 'Wayke',
7428
- channel: 'wayke.se',
7429
- },
7430
- bankIdThumbprint: ecomSettings.bankIdThumbprint,
7431
- });
7432
- });
7433
- }
7434
- };
7435
-
7436
7369
  const SettingsProvider = ({ googleMapsApiKey, googleMapsMarker, ecomSettings, children, }) => (React__default.createElement(SettingsContext.Provider, { value: { ecomSettings, googleMapsApiKey, googleMapsMarker } }, children));
7437
7370
 
7438
7371
  const RelatedSearchProvider = ({ url, urlMlt, apiKey, children }) => {
7439
7372
  const [queryFilter, setQueryFilter] = useState();
7440
- const query = queryFilter === null || queryFilter === void 0 ? void 0 : queryFilter.searchParams.toString();
7373
+ const query = queryFilter?.searchParams.toString();
7441
7374
  const { loading, data: response, error, } = useFetch(`${urlMlt || url}${query ? `?${query}` : ''}`, {
7442
7375
  headers: apiKey
7443
7376
  ? {
@@ -7542,7 +7475,7 @@ const PathProvider = ({ children }) => {
7542
7475
  }
7543
7476
  dispatch({ type: SET_PATH, path });
7544
7477
  }, []);
7545
- 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]);
7546
7479
  const value = useMemo(() => ({
7547
7480
  ...state,
7548
7481
  previousPath,
@@ -7553,17 +7486,14 @@ const PathProvider = ({ children }) => {
7553
7486
  return React__default.createElement(PathContext.Provider, { value: value }, children);
7554
7487
  };
7555
7488
 
7556
- const WaykeProvider = ({ url, urlMlt, apiKey, ecomSettings, graphQlUrl, googleMapsApiKey, googleMapsMarker, useQueryParamsFromUrl, pathRoute, children, }) => {
7557
- useEcom(ecomSettings);
7558
- return (React__default.createElement(PathProvider, null,
7559
- React__default.createElement(SettingsProvider, { googleMapsApiKey: googleMapsApiKey, googleMapsMarker: googleMapsMarker, ecomSettings: ecomSettings },
7560
- React__default.createElement(CentralStorageProvider, null,
7561
- React__default.createElement(GraphqlProvider, { uri: graphQlUrl },
7562
- React__default.createElement(SearchProvider, { url: url, apiKey: apiKey, useQueryParamsFromUrl: useQueryParamsFromUrl, pathRoute: pathRoute },
7563
- React__default.createElement(RelatedSearchProvider, { url: url, urlMlt: urlMlt, apiKey: apiKey },
7564
- React__default.createElement(ThemeProvider, null,
7565
- React__default.createElement(Root, null, children)))))))));
7566
- };
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)))))))));
7567
7497
 
7568
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;
7569
7499
  const HASH_CHANGE = 'hashchange';
@@ -7612,16 +7542,13 @@ const WaykeComposite = ({ filterList, initialQueryParams, removeSearchBar, remov
7612
7542
  const WaykeCompositeWithProvider = ({ provider, composite }) => (React__default.createElement(WaykeProvider, { ...provider },
7613
7543
  React__default.createElement(WaykeComposite, { ...composite })));
7614
7544
 
7615
- const WaykeItemProvider = ({ url, urlMlt, apiKey, ecomSettings, graphQlUrl, googleMapsApiKey, googleMapsMarker, children, }) => {
7616
- useEcom(ecomSettings);
7617
- return (React__default.createElement(PathProvider, null,
7618
- React__default.createElement(SettingsProvider, { googleMapsApiKey: googleMapsApiKey, googleMapsMarker: googleMapsMarker, ecomSettings: ecomSettings },
7619
- React__default.createElement(CentralStorageProvider, null,
7620
- React__default.createElement(GraphqlProvider, { uri: graphQlUrl },
7621
- React__default.createElement(RelatedSearchProvider, { url: url, urlMlt: urlMlt, apiKey: apiKey },
7622
- React__default.createElement(ThemeProvider, null,
7623
- React__default.createElement(Root, null, children))))))));
7624
- };
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))))))));
7625
7552
 
7626
7553
  export default WaykeCompositeWithProvider;
7627
7554
  export { SearchBar, WaykeItemProvider, WaykeProvider, PubSub as WaykePubSub, WaykeSearch, WaykeSearchItem, ThemeProvider as WaykeThemeProvider };