import{a as o}from"./rolldown-runtime-C_ttsnZz.js";import{St as e,q as t}from"./index-BT8Vuu3B.js";import{n as r}from"./context-BrD4AniQ-_nW8oMsv.js";import{i,t as a}from"./constants-DOpa8YMW-CAHGepUD.js";import{n}from"./esm-Be30MpcN-ls4GMpDI.js";import{t as l}from"./esm-k7KI3vER-DWALg7MX.js";import{o as s,r as m,s as c}from"./mapbox-jb8Zev6T-wBzax2Lb.js";var u=o(e(),1),p=t(),g={en:{"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},fr:{"AttributionControl.ToggleAttribution":"Afficher/Masquer l’attribution","FullscreenControl.Enter":"Passer en plein écran","FullscreenControl.Exit":"Quitter le plein écran","GeolocateControl.FindMyLocation":"Trouver ma position","GeolocateControl.LocationNotAvailable":"Position non disponible","LogoControl.Title":"Page d’accueil Mapbox","Map.Title":"Carte","NavigationControl.ResetBearing":"Réinitialiser l’orientation au nord","NavigationControl.ZoomIn":"Zoomer","NavigationControl.ZoomOut":"Dézoomer","ScrollZoomBlocker.CtrlMessage":"Utilisez ctrl + défilement pour zoomer sur la carte","ScrollZoomBlocker.CmdMessage":"Utilisez ⌘ + défilement pour zoomer sur la carte","TouchPanBlocker.Message":"Utilisez deux doigts pour déplacer la carte"}},d=()=>{let{current:o}=s(),{centerPinMarkerPoints:e,markerPoints:t,locationBoundary:i,setZoom:a,mapPadding:m}=r(),[c,p]=(0,u.useState)(void 0),g=(0,u.useRef)(void 0),d=(0,u.useCallback)(()=>{o&&a(o.getZoom())},[o,a]);return(0,u.useEffect)(()=>(d(),o?.on("zoom",d),()=>{o?.off("zoom",d)}),[o,d]),(0,u.useEffect)(()=>{if(!o)return;let r=[];if(void 0!==i&&i.length>0?r.push(...i):void 0!==t&&t.length>0?(r.push(...t),e&&r.push(e)):void 0!==e&&r.push(e),0===r.length)return;let a=l(n(r));(!g.current||!a.every((o,e)=>o===g.current?.[e]))&&(g.current=a,p(a))},[o,t,i,e]),(0,u.useEffect)(()=>{if(!o||void 0===c)return;let[e,t,r,i]=c,a=.1*(r-e)||.001,n=.1*(i-t)||.001;o.fitBounds([[e-a,t-n],[r+a,i+n]],{retainPadding:!1,padding:m,maxZoom:17,duration:700})},[o,c,m]),null};function f({children:o}){let{mapProvider:e,locale:t,center:n,zoom:l=a.zoom,minZoom:s,maxZoom:u,pitch:f=a.pitch,bearing:v=a.bearing,cooperativeGestures:b=a.cooperativeGestures,zoomPosition:C}=r();return"mapbox"===e.name?(0,p.jsxs)(c,{mapboxAccessToken:e.apiKey,initialViewState:{...n,zoom:l,pitch:f,bearing:v},cooperativeGestures:b,minZoom:s,maxZoom:u,mapStyle:`mapbox://styles/${e.theme||i.mapbox}`,interactiveLayerIds:["road-label","waterway-label"],locale:g[t],children:[(0,p.jsx)(d,{}),C&&(0,p.jsx)(m,{position:C}),o]}):null}export{f as default};
//# sourceMappingURL=Mapbox-CIislOVu-DAN86RTH.js.map