{"ast":null,"code":"import { 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\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\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 const CityItem = ({\n  className,\n  city,\n  highlight,\n  onMouseEvent,\n  light\n}) => {\n  const accommodationsCount = city.houses.reduce((acc, curr) => acc + curr.accommodationsCount, 0);\n  const availableCount = city.houses.reduce((acc, curr) => acc + curr.availableCount, 0);\n  const locale = useLocale();\n  const accommodationsCountHtml = locale(`houses-count`, accommodationsCount).replace('#', `<span class='bold'>${accommodationsCount}</span>`);\n  const availableCountHtml = availableCount == 0 ? `${locale(`all-houses-full`)}` : locale(`available-accommodations`, availableCount).replace('#', `<span class='bold'>${availableCount}</span>`);\n  const openingDateStr = useLocaleDate(city.openingDate);\n  const 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};\nconst defaultShowMobile = 4;\n\nconst CitiesList = ({\n  cities,\n  highlightCity,\n  handleMouseEvent,\n  placeholder,\n  loadMore\n}) => {\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: city => /*#__PURE__*/_jsx(CityItem, {\n      city: city,\n      highlight: city.slug == highlightCity,\n      onMouseEvent: handleMouseEvent && (event => handleMouseEvent(event.type, city.slug))\n    }, city._id),\n    searchFilter: (city, input) => city.title.toLowerCase().includes(input) || city.department && city.department.toLowerCase().includes(input) || city.areas && city.areas.toLowerCase().includes(input),\n    limit: defaultShowMobile,\n    placeholder: placeholder,\n    loadMore: loadMore\n  });\n};\n\nexport default CitiesList;","map":null,"metadata":{},"sourceType":"module"}