1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8267],{27253:function(e,t,r){"use strict";r.r(t);var o=r(85893),n=r(67294),l=r(24613),a=r.n(l),i=r(1307),s=r.n(i),c=r(44183),u=r(68291),d=r(28379),p=r(35358),g=r(80883),m=r(28906),f=r(33576),h=r(86612),w=r(42276),y=r(95115),v=r(46083),C=r(19425),b=r(37561),x=r(14687),k=r(12878),M=r(11163),L=r(35863);let D={type:"FeatureCollection",features:[]},P=()=>(0,n.useMemo)(()=>{let e=e=>{var t;return null!==(t=null==e?void 0:e.originalEvent)&&void 0!==t?t:e},t=t=>{var r,o;let n=e(t);null==n||null===(r=n.preventDefault)||void 0===r||r.call(n),null==n||null===(o=n.stopPropagation)||void 0===o||o.call(n)},r=(e,t,r)=>{(null==e?void 0:e.polygon)&&t&&r&&[[t[0],t[1]],[r[0],t[1]],[r[0],r[1]],[t[0],r[1]],[t[0],t[1]]].forEach((t,r)=>{e.polygon.updateCoordinate("0.".concat(r),t[0],t[1])})},o=function(e){(null==e?void 0:e.isDragging)&&(e.isDragging=!1,e.startPoint=null,this.changeMode("simple_select"))};return{...s().modes.draw_polygon,onSetup:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];let o=s().modes.draw_polygon.onSetup.apply(this,t);return o.isDragging=!1,o.startPoint=null,o},onClick:function(){return!0},onMouseDown:function(e,o){t(o),e.startPoint=[o.lngLat.lng,o.lngLat.lat],e.isDragging=!0,r(e,e.startPoint,e.startPoint)},onDrag:function(e,o){if(!e.isDragging)return;t(o);let n=[o.lngLat.lng,o.lngLat.lat];r(e,e.startPoint,n)},onMouseMove:function(e,o){if(!e.isDragging)return;t(o);let n=[o.lngLat.lng,o.lngLat.lat];r(e,e.startPoint,n)},onMouseUp:function(e,n){if(!e.isDragging)return;t(n);let l=[n.lngLat.lng,n.lngLat.lat];r(e,e.startPoint,l),o.call(this,e)},onTouchStart:function(e,t){this.onMouseDown(e,t)},onTouchMove:function(e,t){this.onMouseMove(e,t)},onTouchEnd:function(e,t){this.onMouseUp(e,t)},onStop:function(e){return e.isDragging=!1,e.startPoint=null,s().modes.draw_polygon.onStop.call(this,e)},onKeyUp:function(e,t){27===t.keyCode&&(e.isDragging=!1,this.deleteFeature(e.polygon.id,{silent:!0}),this.changeMode("simple_select"))}}},[]),T=()=>{let[e,t]=(0,n.useState)({mapLoaded:!1,showRecenterButton:!1,isDrawingMode:!1,isCircleMode:!1,showDrawOptions:!1,showCircleOptions:!1,activeDrawTool:null,squarePolygon:null,styleLoaded:!1});return[e,(0,n.useCallback)(e=>{t(t=>({...t,...e}))},[])]},E=e=>(0,n.useCallback)((t,r)=>{if(!(null==e?void 0:e.type)||!(null==e?void 0:e.coordinates))return!0;try{let o=(0,g.xm)([t,r]);return(0,m.F)(o,e)}catch(e){return console.warn("Error checking point within boundary:",e),!1}},[e]),N=(0,n.memo)(e=>{let{isDrawingMode:t,isCircleMode:r,showDrawOptions:n,showCircleOptions:l,activeDrawTool:a,hasActiveFilter:i,onToggleDrawing:s,onStartAreaDrawing:c,onToggleCircleOptions:u,onStartCircleDrawing:d,onRemoveDrawing:p,translations:g}=e;return(0,o.jsxs)("div",{className:"draw-controls",children:[(0,o.jsx)("button",{title:g("search:areaTools"),className:"draw-button",onClick:s,children:t||r?(0,o.jsx)(C.Z,{size:20,color:"#ec6328"}):(0,o.jsx)(C.Z,{size:20,color:"#aaa"})}),n&&(0,o.jsxs)("div",{className:"draw-options",children:[(0,o.jsx)("button",{title:g("search:polyArea"),className:"draw-button ".concat("area"===a?"active":""),onClick:c,children:(0,o.jsx)(b.Z,{size:20,color:"area"===a?"#ec6328":"#aaa"})}),(0,o.jsx)("button",{title:g("search:circleArea:title"),className:"draw-button ".concat("circle"===a?"active":""),onClick:u,children:(0,o.jsx)(x.Z,{size:20,color:"circle"===a?"#ec6328":"#aaa"})})]}),l&&(0,o.jsxs)("div",{className:"draw-options",children:[(0,o.jsx)("button",{title:g("search:circleArea:0"),className:"draw-radius",onClick:()=>d(.5),children:"0.5 km"}),(0,o.jsx)("button",{title:g("search:circleArea:1"),className:"draw-radius",onClick:()=>d(1),children:"1 km"}),(0,o.jsx)("button",{title:g("search:circleArea:2"),className:"draw-radius",onClick:()=>d(2),children:"2 km"})]}),i&&(0,o.jsx)("button",{title:g("search:cancelArea"),className:"draw-remove-button",onClick:p,children:(0,o.jsx)(k.Z,{size:20,color:"#aaa"})})]})});N.displayName="DrawingControls",t.default=(0,n.memo)(function(e){let{config:t,height:r,markers:i,actions:g,actionProps:m,searchParams:C,setSearchParams:b,pois:x,translations:k,mutate:j}=e,O=(0,M.useRouter)(),F=(null==t?void 0:t.center)||[0,0],A=(null==t?void 0:t.zoom)||10,_=(null==t?void 0:t.zoomLimit)||10,R=(null==t?void 0:t.boundary)||[],[z,S]=T(),B=P(),I=E(R),Z=(0,n.useRef)(null),K=(0,n.useRef)(null),q=(0,n.useRef)(null),H=(0,n.useRef)(null),U=(0,n.useRef)({radiu
1sInKm:null,enabled:!1}),X=(0,n.useRef)(null),G=(0,n.useCallback)(()=>{Z.current&&X.current&&(Z.current.off("mousedown",X.current),X.current=null)},[]),V=(0,n.useCallback)(e=>{let t=Z.current;if(!t)return;let r=t.getSource("circle-preview");r&&r.setData(e?{type:"FeatureCollection",features:[e]}:{type:"FeatureCollection",features:[]})},[]),Y=(0,n.useCallback)(()=>{U.current.enabled=!1,U.current.radiusInKm=null,G(),V(null)},[G,V]),$=(0,n.useCallback)(e=>{if(!U.current.enabled||!U.current.radiusInKm||!e){V(null);return}V((0,f.X)(e,U.current.radiusInKm,{steps:64,units:"kilometers"}))},[V]),J=(0,n.useCallback)(e=>{if(U.current.radiusInKm=e,U.current.enabled=!0,V(null),G(),Z.current){let e=()=>{G(),Y()};X.current=e,Z.current.on("mousedown",e)}},[Y,G,V]),Q=(0,n.useCallback)(()=>{if(H.current&&(H.current.remove(),H.current=null),Z.current)try{Z.current.stop()}catch(e){console.warn("Error stopping map:",e)}Y()},[Y]);(0,n.useEffect)(()=>{if(!(0,y._)()||!t)return Q;let e=!0;return(async()=>{try{if(Z.current)try{Z.current.remove()}catch(e){console.warn("Error removing map:",e)}let r=new(a()).Map({container:K.current,attributionControl:!1,style:{version:8,sources:{protomaps:{type:"vector",tiles:[t.tiles],minzoom:9,maxzoom:15,attribution:"\xa9 Cercoalloggio"}},layers:u.LY,glyphs:"/fonts/{fontstack}/{range}.pbf",sprite:"/sprites/v3/light"},center:[F[1],F[0]],zoom:A,maxZoom:15,minZoom:_,interactive:!0});Z.current=r,r.on("style.load",async()=>{if(e){S({styleLoaded:!0});try{await W(r),S({mapLoaded:!0});let e=document.getElementById("loading-overlay");e&&(e.style.display="none")}catch(e){console.error("Error setting up map features:",e)}}}),r.on("error",e=>{console.error("Map error:",e)})}catch(e){console.error("Error initializing map:",e)}})(),()=>{if(e=!1,Q(),Z.current){if(q.current)try{Z.current.removeControl(q.current)}catch(e){console.warn("Error removing draw control:",e)}Z.current.remove()}Z.current=null,q.current=null}},[t,A,_,F,Q]);let W=(0,n.useCallback)(async e=>{if(await new Promise(e=>setTimeout(e,100)),(null==R?void 0:R.type)==="Polygon"&&R.coordinates){let t=R.coordinates[0];if(Array.isArray(t)&&t.length>3){let r=t.reduce((e,t)=>e.extend(t),new(a()).LngLatBounds(t[0],t[0]));e.setMaxBounds(r)}}e.addControl(new l.NavigationControl,"top-left"),s().constants.classes.CONTROL_BASE="maplibregl-ctrl",s().constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",s().constants.classes.CONTROL_GROUP="maplibregl-ctrl-group",q.current=new(s())({displayControlsDefault:!1,controls:{polygon:!1,trash:!1},modes:{...s().modes,draw_circle:c.CircleMode,drag_circle:c.DragCircleMode,direct_select:c.DirectMode,simple_select:c.SimpleSelectMode,draw_rectangle:B},styles:u.H}),e.addControl(q.current),e.getSource("circle-preview")||e.addSource("circle-preview",{type:"geojson",data:D}),e.getLayer("circle-preview-fill")||e.addLayer({id:"circle-preview-fill",type:"fill",source:"circle-preview",paint:{"fill-color":"#9ca3af","fill-opacity":.2}}),e.getLayer("circle-preview-outline")||e.addLayer({id:"circle-preview-outline",type:"line",source:"circle-preview",paint:{"line-color":"#9ca3af","line-width":2,"line-dasharray":[2,2]}}),e.on("draw.create",er),e.on("draw.delete",er),e.on("draw.update",er);try{if(!e.hasImage("custom-marker")){let t=await e.loadImage("/images/marker.png");e.addImage("custom-marker",t.data,{pixelRatio:1.25})}}catch(e){console.warn("Error loading marker image:",e)}(null==x?void 0:x.length)>0&&await ee(e),H.current=new(a()).Popup({closeButton:!1,closeOnClick:!1,anchor:"top",offset:30}),et(e),C.bbox?await eo(e,C.bbox):C.circle&&await en(e,C.circle)},[R,x,C.bbox,C.circle]),ee=(0,n.useCallback)(async e=>{try{e.addSource("poi-source",{type:"geojson",data:{type:"FeatureCollection",features:x.map((e,t)=>({type:"Feature",id:t,properties:{description:e.name||""},geometry:{type:"Point",coordinates:[parseFloat(e.lon),parseFloat(e.lat)]}}))}}),e.addLayer(u.$b),e.on("click","poi-background",t=>{if(t.features.length>0){let r=t.features[0],{description:o}=r.properties,[n,l]=r.geometry.coordinates;new(a()).Popup({closeButton:!1,closeOnClick:!0,anchor:"top",offset:8}).setLngLat([n,l]).setHTML('<div class="popup-gl-poi"><img src="/images/university.png" width="24" height="24" /><span>'.concat(o,"</span></div>")).addTo(e),e.flyTo({center:[n,l],zoom:13,essential:!0})}}),e.on("mouseenter","poi-background",()=>{z.isDrawingMode||z.isCircleMode||(e.getCanvas().style.cursor="pointer")}),e.on("mouseleave","poi-background",()=>{z.isDrawingMode||z.isCircleMode||(e.getCanvas().style.cursor="")}
1)}catch(e){console.warn("Error setting up POIs:",e)}},[x,z.isDrawingMode,z.isCircleMode]),et=(0,n.useCallback)(e=>{e.on("click","places",e=>{if(e.features.length>0){let{unid:t}=e.features[0].properties;(null==g?void 0:g.includes("lift_property_id"))&&m.setCurrentProperty(t),m.setCurrentHoveredProperty(t)}}),e.on("mouseenter","places",t=>{z.isDrawingMode||z.isCircleMode||(e.getCanvas().style.cursor="pointer");let r=t.features[0].geometry.coordinates.slice(),{unid:o,zone:n,title:l,cover:a}=t.features[0].properties;for(;Math.abs(t.lngLat.lng-r[0])>180;)r[0]+=t.lngLat.lng>r[0]?360:-360;H.current.setLngLat(r).setHTML('<div class="popup-gl-marker">\n <img src="'.concat(a,'" width="90" height="90" alt="').concat(o,'" />\n <div class="title"><small>').concat(n,"</small>\n <span>").concat(o,"</span>").concat(l,"</div>\n </div>")).addTo(e)}),e.on("mouseleave","places",()=>{z.isDrawingMode||z.isCircleMode||(e.getCanvas().style.cursor=""),H.current.remove()})},[g,m,z.isDrawingMode,z.isCircleMode]),er=(0,n.useCallback)(e=>{m.setCurrentProperty(null),m.setCurrentHoveredProperty(null);let t=q.current.getAll();if(t.features.length>0){let e=t.features[t.features.length-1];if(e.properties.isCircle){Y();let{center:t,radiusInKm:r}=e.properties,[o,n]=t;b(e=>{let t={...e};return delete t.suggestions,delete t.zone,delete t.poi,delete t.bbox,{...t,circle:"".concat(n,",").concat(o,",").concat(r),p:1}})}else{let t=(0,h.V)(e),r=t.join(",");b(e=>{let t={...e};return delete t.suggestions,delete t.zone,delete t.poi,delete t.circle,{...t,bbox:r,p:1}}),S({squarePolygon:(0,w.b)(t)})}q.current&&(q.current.deleteAll(),q.current.add(e),S({isDrawingMode:!1,isCircleMode:!1}),Z.current&&(Z.current.getCanvas().style.cursor=""))}else b(e=>{let t={...e};return delete t.bbox,delete t.circle,t}),Y();es()},[m,b,S,Y]),eo=(0,n.useCallback)(async(e,t)=>{let r=t.split(",").map(Number),o=(0,w.b)(r);q.current&&(q.current.deleteAll(),q.current.add(o),e.fitBounds(r,{padding:{top:25,bottom:25,left:25,right:25}}))},[]),en=(0,n.useCallback)(async(e,t)=>{let[r,o,n]=t.split(",").map(Number),l=(0,f.X)([o,r],n,{steps:64,units:"kilometers"});if(l.properties={isCircle:!0,center:[o,r],radiusInKm:n},q.current){q.current.deleteAll(),q.current.add(l);let t=(0,h.V)(l);e.fitBounds(t,{padding:{top:25,bottom:25,left:25,right:25}})}},[]);(0,n.useEffect)(()=>{if(!z.mapLoaded||!z.styleLoaded||!(null==i?void 0:i.length))return;let e=setTimeout(()=>{el(),es()},200);return()=>clearTimeout(e)},[z.mapLoaded,z.styleLoaded,i]),(0,n.useEffect)(()=>{q.current&&z.squarePolygon&&(q.current.deleteAll(),q.current.add(z.squarePolygon),es())},[z.squarePolygon]),(0,n.useEffect)(()=>{if(!z.mapLoaded||!Z.current)return;let e=Z.current,t=e=>{z.isCircleMode&&U.current.enabled&&$([e.lngLat.lng,e.lngLat.lat])},r=()=>{U.current.enabled&&V(null)};return e.on("mousemove",t),e.on("mouseleave",r),()=>{e.off("mousemove",t),e.off("mouseleave",r)}},[z.mapLoaded,z.isCircleMode,V,$]),(0,n.useEffect)(()=>{if(!Z.current)return;let e=Z.current;z.isDrawingMode||z.isCircleMode?e.getCanvas().style.cursor="crosshair":e.getCanvas().style.cursor=""},[z.isDrawingMode,z.isCircleMode]);let el=(0,n.useCallback)(()=>{if(Z.current&&z.mapLoaded&&z.styleLoaded)try{if(!Z.current.isStyleLoaded()){setTimeout(el,100);return}if(q.current&&!C.bbox&&!C.circle)try{q.current.deleteAll()}catch(e){console.warn("Error clearing drawings:",e)}let e=i.map(e=>{var t,r;return{type:"Feature",id:e.unid,properties:{unid:e.unid,zone:e.zone,title:e.title,cover:(0,p.cq)(e.slider[0]),minCost:((null==e?void 0:null===(t=e.details)||void 0===t?void 0:t.wholeRent)?null==e?void 0:null===(r=e.details)||void 0===r?void 0:r.wholeRentCost:e.minCost)||0},geometry:{type:"Point",coordinates:[parseFloat(e.lon),parseFloat(e.lat)]}}});Z.current.getSource("results-markers")?Z.current.getSource("results-markers").setData({type:"FeatureCollection",features:e}):(Z.current.addSource("results-markers",{type:"geojson",data:{type:"FeatureCollection",features:e}}),Z.current.getLayer("places")||Z.current.addLayer({...u.sp,layout:{...u.sp.layout,visibility:"visible"}}),ea(Z.current)),ei()}catch(e){console.warn("Error in addMarkersToMap, will retry:",e),setTimeout(el,100)}},[i,C.bbox,C.circle]),ea=(0,n.useCallback)(e=>{e.getLayer("minCost-labels")||e.addLayer({id:"minCost-labels",type:"symbol",source:"results-markers",layout:{"text-field":["concat",["to-string",["get","minCost"]],"â¬"],"text-font":["Noto Sans Regular"],"text-size":12,"text-anchor":"top","text-offset":[0,1.2],"text-allow-overlap":!1,"text-ignore-placement":!1},paint:{"text-color":"#333","text-halo-color":"#fff","text-halo-width":1}}),e.getLayer("hovered-minCost-labels")||e.addLayer({id:"hovered-minCost-labels",type:"symbol",source:"results-markers",layout:{"text-field":["concat",["to-string",["get","minCost"]],"â¬"],"text-font":["Noto Sans Medium"],"text-size":14,"text-anchor":"top","text-offset":[0,1],"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#fff","text-halo-color":"#db4812","text-halo-width":4},filter:["==",["get","unid"],""]}
1)},[]),ei=(0,n.useCallback)(()=>{if(!Z.current||!z.mapLoaded||!(null==i?void 0:i.length)||!Z.current.getLayer("hovered-minCost-labels"))return;let e=m.currentHoveredProperty;try{if(e){Z.current.setFilter("hovered-minCost-labels",["==",["get","unid"],e]);let t=i.find(t=>t.unid===e);if(t){let e=parseFloat(t.lon),r=parseFloat(t.lat);if(!isNaN(e)&&!isNaN(r)&&I(e,r)){let t=Z.current.getZoom(),o=Math.min(Z.current.getMaxZoom(),t+Math.max(.5,(14-t)*.2));requestAnimationFrame(()=>{var t;null===(t=Z.current)||void 0===t||t.flyTo({center:[e,r],zoom:o,duration:1750,easing:e=>e*(2-e)})})}}}else Z.current.setFilter("hovered-minCost-labels",["==",["get","unid"],""])}catch(e){console.warn("Error in hover update:",e)}},[m.currentHoveredProperty,i,z.mapLoaded,I]);(0,n.useEffect)(()=>{if(!z.mapLoaded||!Z.current)return;let e=requestAnimationFrame(()=>{ei()});return()=>{var t;cancelAnimationFrame(e),null===(t=Z.current)||void 0===t||t.stop()}},[ei,z.mapLoaded]);let es=(0,n.useCallback)(()=>{if(!Z.current||!(null==i?void 0:i.length))return;let e=new(a()).LngLatBounds,t=(0,d.d)(i,[F[1],F[0]],5e4);t.forEach(t=>{e.extend([parseFloat(t.lon),parseFloat(t.lat)])}),!e.isEmpty()&&t.length>0&&Z.current.fitBounds(e,{padding:{top:50,bottom:50,left:50,right:50}})},[i,F]),ec=(0,n.useCallback)(()=>{Z.current&&Z.current.flyTo({center:[F[1],F[0]],zoom:A,duration:1500})},[F,A]),eu=(0,n.useCallback)(()=>{if(Y(),S({showDrawOptions:!z.showDrawOptions,showCircleOptions:!1,isDrawingMode:!1,isCircleMode:!1,activeDrawTool:null}),Z.current){var e;Z.current.dragPan.enable(),Z.current.boxZoom.enable(),null===(e=q.current)||void 0===e||e.changeMode("simple_select"),Z.current.getCanvas().style.cursor=""}},[z.showDrawOptions,S,Y]),ed=(0,n.useCallback)(()=>{if(Y(),S({isDrawingMode:!0,isCircleMode:!1,showDrawOptions:!1,activeDrawTool:"area"}),Z.current){var e,t;Z.current.dragPan.disable(),Z.current.boxZoom.disable(),null===(e=q.current)||void 0===e||e.deleteAll(),null===(t=q.current)||void 0===t||t.changeMode("draw_rectangle"),Z.current.getCanvas().style.cursor="crosshair"}},[S,Y]),ep=(0,n.useCallback)(()=>{S({showCircleOptions:!z.showCircleOptions})},[z.showCircleOptions,S]),eg=(0,n.useCallback)(e=>{if(S({isCircleMode:!0,isDrawingMode:!1,showCircleOptions:!1,activeDrawTool:"circle"}),Z.current){var t,r;Z.current.dragPan.disable(),Z.current.boxZoom.disable(),null===(t=q.current)||void 0===t||t.deleteAll(),null===(r=q.current)||void 0===r||r.changeMode("draw_circle",{initialRadiusInKm:e}),Z.current.getCanvas().style.cursor="crosshair"}J(e)},[S,J]),em=(0,n.useCallback)(()=>{q.current&&q.current.deleteAll(),Y();let e={...C};delete e.bbox,delete e.circle,b(e);let t=(0,L.CK)(e);O.replace({pathname:O.pathname,query:(0,L.CK)(e,"router")},void 0,{shallow:!0}),j("/api/search?".concat(t)),S({activeDrawTool:null,isDrawingMode:!1,isCircleMode:!1}),Z.current&&(Z.current.getCanvas().style.cursor="")},[C,O,b,j,S,Y]);return(0,o.jsxs)("div",{style:{position:"relative",width:"100%",height:"".concat(r,"px")},children:[(0,o.jsx)("div",{id:"loading-overlay",children:(0,o.jsx)("img",{src:v.B.logo,width:160,height:"auto",alt:"Logo",id:"loading-logo"})}),(0,o.jsx)("div",{ref:K,style:{width:"100%",height:"100%"},className:"map-container BG-white",id:"map"}),z.showRecenterButton&&(0,o.jsx)("button",{style:{position:"absolute",bottom:"14px",left:"10px",zIndex:1,padding:"8px",backgroundColor:"white",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.3s ease"},className:"recenter-button",onClick:ec,title:k("search:recenter"),children:(0,o.jsx)("img",{src:"/images/recenter.png",height:"18",width:"18",alt:"Recenter"})}),(0,o.jsx)(N,{isDrawingMode:z.isDrawingMode,isCircleMode:z.isCircleMode,showDrawOptions:z.showDrawOptions,showCircleOptions:z.showCircleOptions,activeDrawTool:z.activeDrawTool,hasActiveFilter:!!C.bbox||!!C.circle,onToggleDrawing:eu,onStartAreaDrawing:ed,onToggleCircleOptions:ep,onStartCircleDrawing:eg,onRemoveDrawing:em,translations:k})]})})},28379:function(e,t,r){"use strict";r.d(t,{d:function(){return l}});var o=r(80883),n=r(52882);let l=(e,t,r)=>{let l=(0,o.xm)(t);return e.filter(e=>{let t=(0,o.xm)([e.lon,e.lat]);return(0,n.Z)(l,t,{units:"kilometers"})<=r/1e3})}},24654:function(){}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.