{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport { Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nimport React from \"react\";\nimport cn from 'classnames';\nimport { ArrowWithLine } from 'components/gui/Arrow';\nimport BoxButton from 'components/gui/BoxButton';\nimport List from 'components/list/List';\nimport useLocale from 'contexts/useLocale';\nimport useLocaleDate from 'contexts/useLocaleDate';\nimport { useIsDesktop } from 'hooks/useIsDevice';\nimport HTMLReactParser from 'html-react-parser';\nimport Link from 'next/link';\n\nvar AccommodationsCountSVG = function AccommodationsCountSVG(props) {\n  return /*#__PURE__*/_jsxs(\"svg\", _objectSpread(_objectSpread({}, props), {}, {\n    children: [/*#__PURE__*/_jsx(\"path\", {\n      fill: \"#000\",\n      d: \"M0 11h20v10H0zM10 0l10 11H0L10 0z\"\n    }), /*#__PURE__*/_jsx(\"circle\", {\n      cx: \"19.5\",\n      cy: \"7.5\",\n      r: \"7.5\",\n      fill: \"#fff\"\n    })]\n  }));\n};\n\nAccommodationsCountSVG.defaultProps = {\n  width: \"28\",\n  height: \"21\",\n  viewBox: \"0 0 28 21\",\n  fill: \"none\",\n  xmlns: \"http://www.w3.org/2000/svg\"\n};\nimport styles from './CitiesList.module.scss';\nexport var CityItem = function CityItem(_ref) {\n  var className = _ref.className,\n      city = _ref.city,\n      highlight = _ref.highlight,\n      onMouseEvent = _ref.onMouseEvent,\n      light = _ref.light;\n  var accommodationsCount = city.houses.reduce(function (acc, curr) {\n    return acc + curr.accommodationsCount;\n  }, 0);\n  var availableCount = city.houses.reduce(function (acc, curr) {\n    return acc + curr.availableCount;\n  }, 0);\n  var locale = useLocale();\n  var accommodationsCountHtml = locale(\"houses-count\", accommodationsCount).replace('#', \"<span class='bold'>\".concat(accommodationsCount, \"</span>\"));\n  var availableCountHtml = availableCount == 0 ? \"\".concat(locale(\"all-houses-full\")) : locale(\"available-accommodations\", availableCount).replace('#', \"<span class='bold'>\".concat(availableCount, \"</span>\"));\n  var openingDateStr = useLocaleDate(city.openingDate);\n  var isDesktop = useIsDesktop();\n  return (\n    /*#__PURE__*/\n    // <Link href={city.url}>\n    _jsx(\"li\", {\n      onMouseOver: onMouseEvent,\n      onMouseOut: onMouseEvent,\n      className: cn(styles.listItem, city.open ? styles.opened : styles.notOpened, highlight && styles.highlight, light && styles.light, className),\n      children: isDesktop ? /*#__PURE__*/_jsx(\"div\", {\n        className: cn(styles.itemInner),\n        children: /*#__PURE__*/_jsxs(\"div\", {\n          className: cn(styles.grid),\n          children: [/*#__PURE__*/_jsxs(\"div\", {\n            className: cn(styles.nameContainer),\n            children: [/*#__PURE__*/_jsx(\"h3\", {\n              className: cn('h--2'),\n              children: city.title\n            }), city.areas && /*#__PURE__*/_jsx(\"p\", {\n              className: cn('p--m'),\n              children: city.areas\n            }), !city.open && /*#__PURE__*/_jsx(\"p\", {\n              className: cn('p--m'),\n              children: openingDateStr ? locale('opening-on-date').replace('{date}', openingDateStr) : locale('opening-unknown-date')\n            })]\n          }), city.open && /*#__PURE__*/_jsx(_Fragment, {\n            children: /*#__PURE__*/_jsxs(\"div\", {\n              className: cn(styles.infosContainer),\n              children: [/*#__PURE__*/_jsxs(\"div\", {\n                className: cn(styles.infosRollOut),\n                children: [/*#__PURE__*/_jsxs(\"div\", {\n                  className: cn(styles.infosHalf),\n                  children: [/*#__PURE__*/_jsx(\"h3\", {\n                    className: cn('h--2'),\n                    children: accommodationsCount\n                  }), /*#__PURE__*/_jsx(\"p\", {\n                    className: cn('p--m'),\n                    children: \"Habitations\"\n                  }), /*#__PURE__*/_jsx(\"p\", {\n                    className: cn('p--m'),\n                    children: \"compose.\"\n                  })]\n                }), /*#__PURE__*/_jsxs(\"div\", {\n                  className: cn(styles.infosHalf),\n                  children: [/*#__PURE__*/_jsx(\"h3\", {\n                    className: cn('h--2'),\n                    children: availableCount\n                  }), /*#__PURE__*/_jsx(\"p\", {\n                    className: cn('p--m'),\n                    children: \"Appartements\"\n                  }), /*#__PURE__*/_jsx(\"p\", {\n                    className: cn('p--m'),\n                    children: \"disponibles.\"\n                  })]\n                })]\n              }), /*#__PURE__*/_jsx(\"div\", {\n                className: cn(styles.infosRollOver),\n                children: /*#__PURE__*/_jsx(BoxButton, {\n                  href: city.url,\n                  label: locale('discover'),\n                  fullWidth: true,\n                  icon: \"right\"\n                })\n              })]\n            })\n          })]\n        })\n      }) : /*#__PURE__*/_jsxs(_Fragment, {\n        children: [/*#__PURE__*/_jsx(\"h3\", {\n          className: cn('h--3'),\n          children: city.title\n        }), /*#__PURE__*/_jsxs(\"div\", {\n          className: cn(styles.grid),\n          children: [/*#__PURE__*/_jsxs(\"div\", {\n            className: cn(styles.nameContainer),\n            children: [city.areas && /*#__PURE__*/_jsx(\"p\", {\n              className: cn('p--m'),\n              children: city.areas\n            }), !city.open && /*#__PURE__*/_jsx(\"p\", {\n              className: cn('p--m'),\n              children: openingDateStr ? locale('opening-on-date').replace('{date}', openingDateStr) : locale('opening-unknown-date')\n            })]\n          }), city.open && /*#__PURE__*/_jsxs(\"div\", {\n            className: cn(styles.infosContainer),\n            children: [/*#__PURE__*/_jsx(\"p\", {\n              className: cn('p--m'),\n              children: HTMLReactParser(accommodationsCountHtml)\n            }), availableCountHtml && /*#__PURE__*/_jsx(\"p\", {\n              className: cn('p--m'),\n              children: HTMLReactParser(availableCountHtml)\n            })]\n          })]\n        }), city.open && /*#__PURE__*/_jsx(\"div\", {\n          className: cn(styles.buttonCont),\n          children: /*#__PURE__*/_jsx(BoxButton, {\n            href: city.url,\n            label: locale('discover'),\n            fullWidth: true,\n            icon: \"right\"\n          })\n        })]\n      })\n    }, city._id) // </Link>\n\n  );\n};\nvar defaultShowMobile = 4;\n\nvar CitiesList = function CitiesList(_ref2) {\n  var cities = _ref2.cities,\n      highlightCity = _ref2.highlightCity,\n      handleMouseEvent = _ref2.handleMouseEvent,\n      placeholder = _ref2.placeholder,\n      loadMore = _ref2.loadMore;\n  return /*#__PURE__*/_jsx(List, {\n    classNameList: cn(styles.list),\n    classNameSearch: cn(styles.searchBox),\n    items: cities //.flatMap(city => [city, { ...city, id: city.id + '-2' }])}\n    ,\n    renderItem: function renderItem(city) {\n      return /*#__PURE__*/_jsx(CityItem, {\n        city: city,\n        highlight: city.slug == highlightCity,\n        onMouseEvent: handleMouseEvent && function (event) {\n          return handleMouseEvent(event.type, city.slug);\n        }\n      }, city._id);\n    },\n    searchFilter: function searchFilter(city, input) {\n      return city.title.toLowerCase().includes(input) || city.department && city.department.toLowerCase().includes(input) || city.areas && city.areas.toLowerCase().includes(input);\n    },\n    limit: defaultShowMobile,\n    placeholder: placeholder,\n    loadMore: loadMore\n  });\n};\n\nexport default CitiesList;","map":null,"metadata":{},"sourceType":"module"}