react-route-profile 0.1.19 → 0.1.21

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.
package/dist/index.cjs CHANGED
@@ -2,5 +2,5 @@
2
2
  <path stroke-linecap="round" stroke-linejoin="round" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"></path>
3
3
  <path fill="white" stroke-linecap="round" stroke-linejoin="round" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"></path>
4
4
  </svg>
5
- `;var wt=(e,r,o)=>{let t=0;return e.replace(/fill="[^"]*"/g,n=>(t+=1,t===1?`fill="${r}"`:t===2?`fill="${o}"`:n))},P=(e,r)=>{let o=wt(ye,e,r).trim();return `data:image/svg+xml,${encodeURIComponent(o).replace(/'/g,"%27").replace(/"/g,"%22")}`};var we=e=>{let{cx:r,cy:o,fill:t,name:n}=e,i=h(),s=i.markerShape,a=s.size,c=k.useMemo(()=>P(i.marker.outer,i.marker.inner),[i.marker.inner,i.marker.outer]);if(r===void 0||o===void 0)return null;let m=typeof n=="string"?n.split(/\s+/).map(l=>l.trim()).filter(Boolean):[];return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx(ie,{cx:r,cy:o}),jsxRuntime.jsx("image",{x:r-a/2,y:o-a/2-s.lift,width:a,height:a,href:c}),n?jsxRuntime.jsx(Et,{words:m,cx:r,cy:o,fill:t}):null]})},Et=({words:e,cx:r,cy:o,fill:t})=>{let i=h().markerShape.text;return jsxRuntime.jsx("text",{y:o-e.length*i.startLiftPerWord,fill:t||"#fff",fontSize:i.fontSize,fontWeight:i.fontWeight,letterSpacing:i.letterSpacing,style:{userSelect:"none"},children:e.map((s,a)=>jsxRuntime.jsx(Rt,{word:s,index:a,cx:r},s))})},Rt=({word:e,index:r,cx:o})=>{let n=h().markerShape.text,i=k.useId();return jsxRuntime.jsx("tspan",{x:o+n.xOffset,dy:r===0?0:n.lineHeight,children:e},i)};var be=({route:e,maxDistance:r,belowHeight:o=0,xAxisMap:t,offset:n})=>{let i=e.routes??[];if(!i.length)return null;let s=t?Object.values(t)[0]:void 0,a=s?.scale,c=s?.x??n?.left??0,m=s?.width??n?.width??0,l=s?.y??(n?.top??0)+(n?.height??0),d=16,u=l-o-d;return !a||m<=0?null:jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:c,y:u,width:m,height:d,fill:"none"}),i.map((v,p)=>{let[x,y]=v.segment,f=Math.max(0,Math.min(x,r)),w=Math.max(0,Math.min(y,r)),b=Math.min(f,w),R=Math.max(f,w);if(R<=b)return null;let C=a(b),z=a(R),D=Math.min(C,z),N=Math.max(0,Math.abs(z-C));return N<=0?null:jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:D,y:u,width:N,height:d,fill:v.color}),jsxRuntime.jsx("text",{x:D+N/2,y:u+d/2,fill:"#000000",fontSize:10,fontWeight:600,textAnchor:"middle",dominantBaseline:"middle",children:v.id})]},`${v.id}-${p}`)})]})};function Re(e){let[r,o]=k.useState(null),t=k.useMemo(()=>r!=null?e[r]:null,[r,e]),n=k.useCallback(()=>{o(null);},[]),i=k.useCallback(s=>{if(!e.length)return;let a=0,c=e.length-1;for(;a<c;){let l=Math.floor((a+c)/2);e[l].distance<s?a=l+1:c=l;}let m=a;if(a>0){let l=e[a-1],d=e[a];Math.abs(l.distance-s)<Math.abs(d.distance-s)&&(m=a-1);}o(m);},[e]);return {activeIndex:r,activePoint:t,triggerByXValue:i,clearActiveIndex:n}}var ke=e=>e.length?e[e.length-1].distance:0,Te=(e,r=2e3)=>{let o=[];for(let t=0;t<=e;t+=r)o.push(t);return o[o.length-1]<e&&o.push(e),o},Ce=e=>[...e.geoJson?.features?.find(n=>n?.geometry?.type==="LineString"&&n?.properties?.elevationProfile?.points)?.properties?.elevationProfile?.points||[]].sort((n,i)=>(n?.distance??0)-(i?.distance??0)),Me=e=>(e.geoJson?.features?.find(t=>t?.geometry?.type==="LineString"&&t?.geometry?.coordinates)).geometry.coordinates,Pe=e=>{if(!e.length)return [0,0];let r=e.map(i=>i.elevation),o=Math.min(...r),t=Math.max(...r),n=Math.max(10,(t-o)*.05);return [Math.floor(o-n),Math.ceil(t+n)]},Le=(e,r=false)=>{let[o,t]=e,n=(t-o)*1.2,i=Math.max(10,Math.round(n/6/10)*10||50),s=r?-20:0,a=Math.floor((o-(n-(t-o))/2)/i)*i+s,c=Math.ceil((t+(n-(t-o))/2)/i)*i+s,m=[];for(let l=a;l<=c+i/2;l+=i)m.push(l);return [a,c,m]},De=(e,r)=>{if(!e?.length)return [];let t=(r?.features??[]).filter(i=>i?.geometry?.type==="Point"),n=[];return t.forEach(i=>{let s=i?.geometry?.coordinates;if(!Array.isArray(s)||s.length<2)return;let[a,c]=s;if(!Number.isFinite(c)||!Number.isFinite(a))return;let m=e.reduce((l,d)=>{let u=Math.pow(d.lat-c,2)+Math.pow(d.lng-a,2);return u<l.dist?{point:d,dist:u}:l},{point:null,dist:Number.POSITIVE_INFINITY});if(m.point){if(m.point.distance===0)return;n.push({distance:m.point.distance,elevation:m.point.elevation,name:i?.properties?.name});}}),n.sort((i,s)=>(i.distance??0)-(s.distance??0))},Ie=(e,r)=>{if(!e.length)return null;let o=null,t=Number.POSITIVE_INFINITY;return e.forEach(([n,i])=>{let s=(i-r.lat)**2+(n-r.lng)**2;s<t&&(t=s,o={lat:i,lng:n});}),o},Ae=(e,r)=>{if(!e.length)return null;let o=null,t=Number.POSITIVE_INFINITY;return e.forEach(n=>{let i=(n.lat-r[0])**2+(n.lng-r[1])**2;i<t&&(t=i,o=n);}),o};var ze=(e,r,o=1e3)=>r&&Math.abs((r.distance??0)-(e.distance??0))<o;var _=({route:e})=>{let{hover:r,setHover:o}=H(),t=h(),n=k.useMemo(()=>Ce(e),[e]),i=k.useMemo(()=>De(n,e.geoJson),[n,e.geoJson]),s=ke(n),a=Te(s),[c,m]=Pe(n),[l,d,u]=k.useMemo(()=>Le([c,m],!!e.surface?.length),[c,m,e.surface?.length]),{activeIndex:v,activePoint:p,triggerByXValue:x,clearActiveIndex:y}=Re(n);return k.useEffect(()=>{if(r.source==="chart"||!r.lat||!r.lng)return;let f=Ae(n,[r.lat,r.lng]);f&&x(f.distance);},[r,n,x]),n.length?jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",style:{userSelect:"none"},children:jsxRuntime.jsxs(recharts.ComposedChart,{data:n,margin:t.chart.margin,onMouseMove:({activePayload:f})=>{v&&y();let w=f?.[0];if(!w)return;let{lat:b,lng:R}=w.payload;o({lat:b,lng:R,source:"chart"});},onMouseEnter:()=>y(),children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"elevationGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:t.colors.primary,stopOpacity:t.chart.gradientStartOpacity}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:t.colors.primaryMuted,stopOpacity:t.chart.gradientEndOpacity})]})}),jsxRuntime.jsx(recharts.CartesianGrid,{stroke:t.chart.gridStroke,strokeDasharray:t.chart.gridDasharray}),jsxRuntime.jsx(recharts.Customized,{component:jsxRuntime.jsx(be,{route:e,maxDistance:s,belowHeight:A})}),jsxRuntime.jsx(recharts.Customized,{component:jsxRuntime.jsx(ge,{route:e,maxDistance:s})}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"distance",type:"number",domain:[0,s],ticks:a,tick:jsxRuntime.jsx(K,{}),stroke:t.chart.axisStroke}),jsxRuntime.jsx(recharts.YAxis,{dataKey:"elevation",tick:jsxRuntime.jsx(ae,{}),domain:[l,d],ticks:u,stroke:t.chart.axisStroke,width:t.chart.yAxisWidth}),jsxRuntime.jsx(recharts.Tooltip,{cursor:{stroke:t.chart.cursorStroke,strokeWidth:t.chart.cursorStrokeWidth},content:jsxRuntime.jsx(ve,{accent:t.colors.accent,primary:t.colors.primary,markers:i,surfaces:e.surface,routes:e.routes})}),jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:"elevation",stroke:t.colors.primary,strokeWidth:t.chart.lineStrokeWidth,dot:f=>{let{cx:w,cy:b,index:R}=f;if(R===v&&p)return jsxRuntime.jsx(oe,{cx:w,cy:b},`dot-${w}-${b}`)},activeDot:{r:t.chart.activeDotRadius,fill:t.dots.chartActive,strokeWidth:0},fill:"url(#elevationGradient)",isAnimationActive:false}),i.length>0&&i.map((f,w)=>{let b=ze(i[w],i[w+1]);return jsxRuntime.jsx(recharts.ReferenceDot,{x:f.distance,y:f.elevation,r:t.chart.referenceDotRadius,shape:R=>jsxRuntime.jsx(we,{...R,name:b?void 0:f.name,fill:t.colors.accent})},`${f.distance}-${w}`)}),p&&jsxRuntime.jsx(recharts.ReferenceLine,{x:p.distance,opacity:t.chart.referenceLineOpacity})]})}):null};var Ne={lat:48.9325937,lng:20.3452306},Fe=13,Ue=12;var Xe={};var Ge=({route:e,height:r,isHorizontal:o})=>{let t=h(),{hover:n,setHover:i}=H(),s=k.useRef(null),a=k.useRef(null),c=k.useRef(null),m=k.useMemo(()=>Me(e),[e]),l=k.useMemo(()=>({default:P(t.marker.outer,t.marker.inner),start:P(t.marker.outer,t.marker.startInner),finish:P(t.marker.outer,t.marker.finishInner)}),[t.marker]);return k.useEffect(()=>{if(!s.current||!window.google?.maps)return;let d=o&&(e.zoomHorizontal||Fe)||e.zoomVertical||Ue,u=new window.google.maps.Map(s.current,{center:e.center||Ne,zoom:d,mapTypeId:window.google.maps.MapTypeId.SATELLITE,streetViewControl:false});c.current=u,u.data.setStyle(p=>{let x=p.getProperty("name"),y=p.getProperty("first"),f=p.getProperty("last");return {strokeColor:t.colors.primaryMuted,strokeWeight:t.map.strokeWeight,icon:{url:y?l.start:f?l.finish:l.default,scaledSize:new window.google.maps.Size(t.map.markerSize,t.map.markerSize),optimized:false,zIndex:y||f?100:10,collisionBehavior:window.google?.maps?.CollisionBehavior?.REQUIRED_AND_HIDES_OPTIONAL},label:{className:"rrpMarkerLabel",fontSize:`${t.map.markerLabelFontSize}px`,fontWeight:t.map.markerLabelFontWeight,color:t.colors.accent,text:x}}}),u.data.addGeoJson(e.geoJson);let v=u.addListener("mousemove",p=>{let x=p.latLng;if(!x)return;let y=Ie(m,{lat:x.lat(),lng:x.lng()});y&&i({lat:y.lat,lng:y.lng,source:"map"});});return ()=>{v.remove(),u.data.forEach(p=>{u.data.remove(p);}),c.current=null;}},[e,o,t,m,i,l]),k.useEffect(()=>{if(!s.current||!window.google?.maps)return;let d=c.current;if(!d)return;if(!n.lat||!n.lng){a.current&&(a.current.setMap(null),a.current=null);return}let u={path:window.google.maps.SymbolPath.CIRCLE,scale:t.map.hoverMarkerScale,fillColor:t.dots.mapActive,fillOpacity:1,strokeWeight:0};a.current?a.current.setIcon(u):a.current=new window.google.maps.Marker({map:d,icon:u}),a.current.setPosition({lat:n.lat,lng:n.lng}),a.current.setMap(d);},[n,t]),jsxRuntime.jsx("div",{ref:s,className:Xe.rrpMapCanvas,style:{height:r}})};var Q={};var Gt={apiKey:"Oops! Cannot display the map: Google Maps API key missing",[reactWrapper.Status.FAILURE]:"Unable to load Google Maps API. Check your API key or network.",[reactWrapper.Status.LOADING]:void 0,[reactWrapper.Status.SUCCESS]:void 0},Qe=({type:e,height:r})=>jsxRuntime.jsx("div",{style:{height:r},children:jsxRuntime.jsx(j,{message:Gt[e],height:r})}),Qt=(e,r)=>jsxRuntime.jsx(Qe,{type:e,height:r}),Ye=({apiKey:e,route:r,height:o="100dvh",className:t,style:n,theme:i=S})=>{let{isHorizontal:s}=B();if(!e)return jsxRuntime.jsx(O,{theme:i,children:jsxRuntime.jsx(Qe,{type:"apiKey",height:o})});let a={height:o,width:"100%",...n};return jsxRuntime.jsx(O,{theme:i,children:jsxRuntime.jsx(re,{children:jsxRuntime.jsxs("div",{className:t,style:a,children:[jsxRuntime.jsx(reactWrapper.Wrapper,{apiKey:e,render:c=>Qt(c,o),children:jsxRuntime.jsx(Ge,{route:r,height:o,isHorizontal:s})}),jsxRuntime.jsx("div",{className:Q.rrpChartLayer,children:jsxRuntime.jsx("div",{className:Q.rrpChartBody,children:jsxRuntime.jsx(_,{route:r})})})]})})})};function $(){let[e,r]=k__namespace.useState({width:null,height:null}),o=k__namespace.useRef(null);return [k__namespace.useCallback(n=>{if(o.current&&(o.current.disconnect(),o.current=null),n?.nodeType===Node.ELEMENT_NODE){let i=new ResizeObserver(([s])=>{if(s&&s.borderBoxSize){let{inlineSize:a,blockSize:c}=s.borderBoxSize[0];r({width:a,height:c});}});i.observe(n),o.current=i;}},[]),e]}var $t=()=>{let[e,{height:r}]=$(),[o,{height:t}]=$(),n=!!r,s=n?`calc(${t}px - ${r}px)`:"0px";return {refHeader:e,refContainer:o,isHeaderReady:n,mapHeight:s}};exports.RouteMap=Ye;exports.SurfaceType=pe;exports.ThemeProvider=O;exports.theme=S;exports.useMapHeader=$t;exports.useTheme=h;//# sourceMappingURL=index.cjs.map
5
+ `;var wt=(e,r,o)=>{let t=0;return e.replace(/fill="[^"]*"/g,n=>(t+=1,t===1?`fill="${r}"`:t===2?`fill="${o}"`:n))},P=(e,r)=>{let o=wt(ye,e,r).trim();return `data:image/svg+xml,${encodeURIComponent(o).replace(/'/g,"%27").replace(/"/g,"%22")}`};var we=e=>{let{cx:r,cy:o,fill:t,name:n}=e,i=h(),s=i.markerShape,a=s.size,c=k.useMemo(()=>P(i.marker.outer,i.marker.inner),[i.marker.inner,i.marker.outer]);if(r===void 0||o===void 0)return null;let m=typeof n=="string"?n.split(/\s+/).map(l=>l.trim()).filter(Boolean):[];return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx(ie,{cx:r,cy:o}),jsxRuntime.jsx("image",{x:r-a/2,y:o-a/2-s.lift,width:a,height:a,href:c}),n?jsxRuntime.jsx(Et,{words:m,cx:r,cy:o,fill:t}):null]})},Et=({words:e,cx:r,cy:o,fill:t})=>{let i=h().markerShape.text;return jsxRuntime.jsx("text",{y:o-e.length*i.startLiftPerWord,fill:t||"#fff",fontSize:i.fontSize,fontWeight:i.fontWeight,letterSpacing:i.letterSpacing,style:{userSelect:"none"},children:e.map((s,a)=>jsxRuntime.jsx(Rt,{word:s,index:a,cx:r},s))})},Rt=({word:e,index:r,cx:o})=>{let n=h().markerShape.text,i=k.useId();return jsxRuntime.jsx("tspan",{x:o+n.xOffset,dy:r===0?0:n.lineHeight,children:e},i)};var be=({route:e,maxDistance:r,belowHeight:o=0,xAxisMap:t,offset:n})=>{let i=e.routes??[];if(!i.length)return null;let s=t?Object.values(t)[0]:void 0,a=s?.scale,c=s?.x??n?.left??0,m=s?.width??n?.width??0,l=s?.y??(n?.top??0)+(n?.height??0),d=16,u=l-o-d;return !a||m<=0?null:jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:c,y:u,width:m,height:d,fill:"none"}),i.map((v,p)=>{let[x,y]=v.segment,f=Math.max(0,Math.min(x,r)),w=Math.max(0,Math.min(y,r)),b=Math.min(f,w),R=Math.max(f,w);if(R<=b)return null;let C=a(b),z=a(R),D=Math.min(C,z),N=Math.max(0,Math.abs(z-C));return N<=0?null:jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:D,y:u,width:N,height:d,fill:v.color}),jsxRuntime.jsx("text",{x:D+N/2,y:u+d/2,fill:"#000000",fontSize:10,fontWeight:600,textAnchor:"middle",dominantBaseline:"middle",children:v.id})]},`${v.id}-${p}`)})]})};function Re(e){let[r,o]=k.useState(null),t=k.useMemo(()=>r!=null?e[r]:null,[r,e]),n=k.useCallback(()=>{o(null);},[]),i=k.useCallback(s=>{if(!e.length)return;let a=0,c=e.length-1;for(;a<c;){let l=Math.floor((a+c)/2);e[l].distance<s?a=l+1:c=l;}let m=a;if(a>0){let l=e[a-1],d=e[a];Math.abs(l.distance-s)<Math.abs(d.distance-s)&&(m=a-1);}o(m);},[e]);return {activeIndex:r,activePoint:t,triggerByXValue:i,clearActiveIndex:n}}var ke=e=>e.length?e[e.length-1].distance:0,Te=(e,r=2e3)=>{let o=[];for(let t=0;t<=e;t+=r)o.push(t);return o[o.length-1]<e&&o.push(e),o},Ce=e=>[...e.geoJson?.features?.find(n=>n?.geometry?.type==="LineString"&&n?.properties?.elevationProfile?.points)?.properties?.elevationProfile?.points||[]].sort((n,i)=>(n?.distance??0)-(i?.distance??0)),Me=e=>(e.geoJson?.features?.find(t=>t?.geometry?.type==="LineString"&&t?.geometry?.coordinates)).geometry.coordinates,Pe=e=>{if(!e.length)return [0,0];let r=e.map(i=>i.elevation),o=Math.min(...r),t=Math.max(...r),n=Math.max(10,(t-o)*.05);return [Math.floor(o-n),Math.ceil(t+n)]},Le=(e,r=false)=>{let[o,t]=e,n=(t-o)*1.2,i=Math.max(10,Math.round(n/6/10)*10||50),s=r?-20:0,a=Math.floor((o-(n-(t-o))/2)/i)*i+s,c=Math.ceil((t+(n-(t-o))/2)/i)*i+s,m=[];for(let l=a;l<=c+i/2;l+=i)m.push(l);return [a,c,m]},De=(e,r)=>{if(!e?.length)return [];let t=(r?.features??[]).filter(i=>i?.geometry?.type==="Point"),n=[];return t.forEach(i=>{let s=i?.geometry?.coordinates;if(!Array.isArray(s)||s.length<2)return;let[a,c]=s;if(!Number.isFinite(c)||!Number.isFinite(a))return;let m=e.reduce((l,d)=>{let u=Math.pow(d.lat-c,2)+Math.pow(d.lng-a,2);return u<l.dist?{point:d,dist:u}:l},{point:null,dist:Number.POSITIVE_INFINITY});if(m.point){if(m.point.distance===0)return;n.push({distance:m.point.distance,elevation:m.point.elevation,name:i?.properties?.name});}}),n.sort((i,s)=>(i.distance??0)-(s.distance??0))},Ie=(e,r)=>{if(!e.length)return null;let o=null,t=Number.POSITIVE_INFINITY;return e.forEach(([n,i])=>{let s=(i-r.lat)**2+(n-r.lng)**2;s<t&&(t=s,o={lat:i,lng:n});}),o},Ae=(e,r)=>{if(!e.length)return null;let o=null,t=Number.POSITIVE_INFINITY;return e.forEach(n=>{let i=(n.lat-r[0])**2+(n.lng-r[1])**2;i<t&&(t=i,o=n);}),o};var ze=(e,r,o=1e3)=>r&&Math.abs((r.distance??0)-(e.distance??0))<o;var _=({route:e})=>{let{hover:r,setHover:o}=H(),t=h(),n=k.useMemo(()=>Ce(e),[e]),i=k.useMemo(()=>De(n,e.geoJson),[n,e.geoJson]),s=ke(n),a=Te(s),[c,m]=Pe(n),[l,d,u]=k.useMemo(()=>Le([c,m],!!e.surface?.length),[c,m,e.surface?.length]),{activeIndex:v,activePoint:p,triggerByXValue:x,clearActiveIndex:y}=Re(n);return k.useEffect(()=>{if(r.source==="chart"||!r.lat||!r.lng)return;let f=Ae(n,[r.lat,r.lng]);f&&x(f.distance);},[r,n,x]),n.length?jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",style:{userSelect:"none"},children:jsxRuntime.jsxs(recharts.ComposedChart,{data:n,margin:t.chart.margin,onMouseMove:({activePayload:f})=>{v&&y();let w=f?.[0];if(!w)return;let{lat:b,lng:R}=w.payload;o({lat:b,lng:R,source:"chart"});},onMouseEnter:()=>y(),children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"elevationGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:t.colors.primary,stopOpacity:t.chart.gradientStartOpacity}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:t.colors.primaryMuted,stopOpacity:t.chart.gradientEndOpacity})]})}),jsxRuntime.jsx(recharts.CartesianGrid,{stroke:t.chart.gridStroke,strokeDasharray:t.chart.gridDasharray}),jsxRuntime.jsx(recharts.Customized,{component:jsxRuntime.jsx(be,{route:e,maxDistance:s,belowHeight:A})}),jsxRuntime.jsx(recharts.Customized,{component:jsxRuntime.jsx(ge,{route:e,maxDistance:s})}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"distance",type:"number",domain:[0,s],ticks:a,tick:jsxRuntime.jsx(K,{}),stroke:t.chart.axisStroke}),jsxRuntime.jsx(recharts.YAxis,{dataKey:"elevation",tick:jsxRuntime.jsx(ae,{}),domain:[l,d],ticks:u,stroke:t.chart.axisStroke,width:t.chart.yAxisWidth}),jsxRuntime.jsx(recharts.Tooltip,{cursor:{stroke:t.chart.cursorStroke,strokeWidth:t.chart.cursorStrokeWidth},content:jsxRuntime.jsx(ve,{accent:t.colors.accent,primary:t.colors.primary,markers:i,surfaces:e.surface,routes:e.routes})}),jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:"elevation",stroke:t.colors.primary,strokeWidth:t.chart.lineStrokeWidth,dot:f=>{let{cx:w,cy:b,index:R}=f;if(R===v&&p)return jsxRuntime.jsx(oe,{cx:w,cy:b},`dot-${w}-${b}`)},activeDot:{r:t.chart.activeDotRadius,fill:t.dots.chartActive,strokeWidth:0},fill:"url(#elevationGradient)",isAnimationActive:false}),i.length>0&&i.map((f,w)=>{let b=ze(i[w],i[w+1]);return jsxRuntime.jsx(recharts.ReferenceDot,{x:f.distance,y:f.elevation,r:t.chart.referenceDotRadius,shape:R=>jsxRuntime.jsx(we,{...R,name:b?void 0:f.name,fill:t.colors.accent})},`${f.distance}-${w}`)}),p&&jsxRuntime.jsx(recharts.ReferenceLine,{x:p.distance,opacity:t.chart.referenceLineOpacity})]})}):null};var Ne={lat:48.9325937,lng:20.3452306},Fe=13,Ue=12;var Xe={};var Ge=({route:e,height:r,isHorizontal:o})=>{let t=h(),{hover:n,setHover:i}=H(),s=k.useRef(null),a=k.useRef(null),c=k.useRef(null),m=k.useMemo(()=>Me(e),[e]),l=k.useMemo(()=>({default:P(t.marker.outer,t.marker.inner),start:P(t.marker.outer,t.marker.startInner),finish:P(t.marker.outer,t.marker.finishInner)}),[t.marker]);return k.useEffect(()=>{if(!s.current||!window.google?.maps)return;let d=o&&(e.zoomHorizontal||Fe)||e.zoomVertical||Ue,u=new window.google.maps.Map(s.current,{center:e.center||Ne,zoom:d,mapTypeId:window.google.maps.MapTypeId.SATELLITE,streetViewControl:false});c.current=u,u.data.setStyle(p=>{let x=p.getProperty("name"),y=p.getProperty("first"),f=p.getProperty("last");return {strokeColor:t.colors.primaryMuted,strokeWeight:t.map.strokeWeight,icon:{url:y?l.start:f?l.finish:l.default,scaledSize:new window.google.maps.Size(t.map.markerSize,t.map.markerSize),optimized:false,zIndex:y||f?100:10,collisionBehavior:window.google?.maps?.CollisionBehavior?.REQUIRED_AND_HIDES_OPTIONAL},label:{className:"rrpMarkerLabel",fontSize:`${t.map.markerLabelFontSize}px`,fontWeight:t.map.markerLabelFontWeight,color:t.colors.accent,text:x}}}),u.data.addGeoJson(e.geoJson);let v=u.addListener("mousemove",p=>{let x=p.latLng;if(!x)return;let y=Ie(m,{lat:x.lat(),lng:x.lng()});y&&i({lat:y.lat,lng:y.lng,source:"map"});});return ()=>{v.remove(),u.data.forEach(p=>{u.data.remove(p);}),c.current=null;}},[e,o,t,m,i,l]),k.useEffect(()=>{if(!s.current||!window.google?.maps)return;let d=c.current;if(!d)return;if(!n.lat||!n.lng){a.current&&(a.current.setMap(null),a.current=null);return}let u={path:window.google.maps.SymbolPath.CIRCLE,scale:t.map.hoverMarkerScale,fillColor:t.dots.mapActive,fillOpacity:1,strokeWeight:0};a.current?a.current.setIcon(u):a.current=new window.google.maps.Marker({map:d,icon:u}),a.current.setPosition({lat:n.lat,lng:n.lng}),a.current.setMap(d);},[n,t]),jsxRuntime.jsx("div",{ref:s,className:Xe.rrpMapCanvas,style:{height:r}})};var Q={};var Gt={apiKey:"Oops! Cannot display the map: Google Maps API key missing",[reactWrapper.Status.FAILURE]:"Unable to load Google Maps API. Check your API key or network.",[reactWrapper.Status.LOADING]:void 0,[reactWrapper.Status.SUCCESS]:void 0},Qe=({type:e,height:r})=>jsxRuntime.jsx("div",{style:{height:r},children:jsxRuntime.jsx(j,{message:Gt[e],height:r})}),Qt=(e,r)=>jsxRuntime.jsx(Qe,{type:e,height:r}),Ye=({apiKey:e,route:r,height:o="100dvh",className:t,style:n,theme:i=S})=>{let{isHorizontal:s}=B();if(!e)return jsxRuntime.jsx(O,{theme:i,children:jsxRuntime.jsx(Qe,{type:"apiKey",height:o})});let a={height:o,width:"100%",...n};return jsxRuntime.jsx(O,{theme:i,children:jsxRuntime.jsx(re,{children:jsxRuntime.jsxs("div",{className:t,style:a,children:[jsxRuntime.jsx(reactWrapper.Wrapper,{apiKey:e,render:c=>Qt(c,o),children:jsxRuntime.jsx(Ge,{route:r,height:o,isHorizontal:s})}),jsxRuntime.jsx("div",{className:Q.rrpChartLayer,children:jsxRuntime.jsx("div",{className:Q.rrpChartBody,children:jsxRuntime.jsx(_,{route:r})})})]})})})};function $(){let[e,r]=k__namespace.useState({width:null,height:null}),o=k__namespace.useRef(null);return [k__namespace.useCallback(n=>{if(o.current&&(o.current.disconnect(),o.current=null),n?.nodeType===Node.ELEMENT_NODE){let i=new ResizeObserver(([s])=>{if(s&&s.borderBoxSize){let{inlineSize:a,blockSize:c}=s.borderBoxSize[0];r({width:a,height:c});}});i.observe(n),o.current=i;}},[]),e]}var $t=()=>{let[e,{height:r}]=$(),[o,{height:t}]=$(),n=!!r,i=n?`calc(${t}px - ${r}px)`:"0px";return {refHeader:e,refContainer:o,isHeaderReady:n,headerHeight:r,mapHeight:i}};exports.RouteMap=Ye;exports.SurfaceType=pe;exports.ThemeProvider=O;exports.theme=S;exports.useMapHeader=$t;exports.useTheme=h;//# sourceMappingURL=index.cjs.map
6
6
  //# sourceMappingURL=index.cjs.map