@tracktor/map 1.8.5 → 1.8.6
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/main.js +185 -178
- package/dist/main.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -74,7 +74,7 @@ function Ve() {
|
|
|
74
74
|
switch (typeof r.tag == "number" && console.error(
|
|
75
75
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
76
76
|
), r.$$typeof) {
|
|
77
|
-
case
|
|
77
|
+
case E:
|
|
78
78
|
return "Portal";
|
|
79
79
|
case re:
|
|
80
80
|
return r.displayName || "Context";
|
|
@@ -153,14 +153,14 @@ function Ve() {
|
|
|
153
153
|
}
|
|
154
154
|
function d() {
|
|
155
155
|
var r = e(this.type);
|
|
156
|
-
return
|
|
156
|
+
return z[r] || (z[r] = !0, console.error(
|
|
157
157
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
158
158
|
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
159
159
|
}
|
|
160
160
|
function g(r, c, y, m, i, v) {
|
|
161
161
|
var h = y.ref;
|
|
162
162
|
return r = {
|
|
163
|
-
$$typeof:
|
|
163
|
+
$$typeof: R,
|
|
164
164
|
type: r,
|
|
165
165
|
key: c,
|
|
166
166
|
props: y,
|
|
@@ -242,9 +242,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
242
242
|
b(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === S && (r._payload.status === "fulfilled" ? b(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
|
|
243
243
|
}
|
|
244
244
|
function b(r) {
|
|
245
|
-
return typeof r == "object" && r !== null && r.$$typeof ===
|
|
245
|
+
return typeof r == "object" && r !== null && r.$$typeof === R;
|
|
246
246
|
}
|
|
247
|
-
var x = Le,
|
|
247
|
+
var x = Le, R = Symbol.for("react.transitional.element"), E = Symbol.for("react.portal"), C = Symbol.for("react.fragment"), W = Symbol.for("react.strict_mode"), F = Symbol.for("react.profiler"), te = Symbol.for("react.consumer"), re = Symbol.for("react.context"), ne = Symbol.for("react.forward_ref"), N = Symbol.for("react.suspense"), D = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), S = Symbol.for("react.lazy"), A = Symbol.for("react.activity"), U = Symbol.for("react.client.reference"), P = x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, L = Object.prototype.hasOwnProperty, I = Array.isArray, $ = console.createTask ? console.createTask : function() {
|
|
248
248
|
return null;
|
|
249
249
|
};
|
|
250
250
|
x = {
|
|
@@ -252,10 +252,10 @@ React keys must be passed directly to JSX without using spread:
|
|
|
252
252
|
return r();
|
|
253
253
|
}
|
|
254
254
|
};
|
|
255
|
-
var G,
|
|
255
|
+
var G, z = {}, J = x.react_stack_bottom_frame.bind(
|
|
256
256
|
x,
|
|
257
257
|
l
|
|
258
|
-
)(),
|
|
258
|
+
)(), q = $(a(l)), X = {};
|
|
259
259
|
B.Fragment = C, B.jsx = function(r, c, y) {
|
|
260
260
|
var m = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
261
261
|
return p(
|
|
@@ -263,8 +263,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
263
263
|
c,
|
|
264
264
|
y,
|
|
265
265
|
!1,
|
|
266
|
-
m ? Error("react-stack-top-frame") :
|
|
267
|
-
m ? $(a(r)) :
|
|
266
|
+
m ? Error("react-stack-top-frame") : J,
|
|
267
|
+
m ? $(a(r)) : q
|
|
268
268
|
);
|
|
269
269
|
}, B.jsxs = function(r, c, y) {
|
|
270
270
|
var m = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
@@ -273,8 +273,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
273
273
|
c,
|
|
274
274
|
y,
|
|
275
275
|
!0,
|
|
276
|
-
m ? Error("react-stack-top-frame") :
|
|
277
|
-
m ? $(a(r)) :
|
|
276
|
+
m ? Error("react-stack-top-frame") : J,
|
|
277
|
+
m ? $(a(r)) : q
|
|
278
278
|
);
|
|
279
279
|
};
|
|
280
280
|
})()), B;
|
|
@@ -299,18 +299,18 @@ const Ge = Ie({
|
|
|
299
299
|
[t, n]
|
|
300
300
|
);
|
|
301
301
|
return n && (be.accessToken = n), /* @__PURE__ */ f.jsx(Ge.Provider, { value: a, children: e });
|
|
302
|
-
},
|
|
302
|
+
}, ze = (e) => e?.type === "LineString" || e?.type === "MultiLineString", Je = (e) => {
|
|
303
303
|
let t;
|
|
304
304
|
Array.isArray(e[0][0]) ? t = e.reduce((o, l) => l.length > o.length ? l : o) : t = e;
|
|
305
305
|
const n = Math.floor(t.length / 2);
|
|
306
306
|
return [t[n][0], t[n][1]];
|
|
307
|
-
},
|
|
307
|
+
}, qe = ({ route: e, children: t }) => {
|
|
308
308
|
if (!(e && t))
|
|
309
309
|
return null;
|
|
310
310
|
const n = e.geometry;
|
|
311
|
-
if (!
|
|
311
|
+
if (!ze(n))
|
|
312
312
|
return null;
|
|
313
|
-
const a = n.coordinates, [o, l] =
|
|
313
|
+
const a = n.coordinates, [o, l] = Je(a);
|
|
314
314
|
return /* @__PURE__ */ f.jsx(ve, { longitude: o, latitude: l, children: t });
|
|
315
315
|
}, Xe = (e) => ce(e) ? { features: e, type: "FeatureCollection" } : e.type === "FeatureCollection" ? e : { features: [e], type: "FeatureCollection" }, ee = ({ features: e, lineLabel: t, lineStyle: n }) => {
|
|
316
316
|
if (!e)
|
|
@@ -342,7 +342,7 @@ const Ge = Ie({
|
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
) }),
|
|
345
|
-
t && l.map((s, u) => /* @__PURE__ */ f.jsx(
|
|
345
|
+
t && l.map((s, u) => /* @__PURE__ */ f.jsx(qe, { route: s, children: t }, `label-${u}`))
|
|
346
346
|
] })
|
|
347
347
|
] });
|
|
348
348
|
}, Ze = "#000000", He = "#FFFFFF", se = {
|
|
@@ -405,17 +405,17 @@ const Ge = Ie({
|
|
|
405
405
|
return Number.isFinite(t) ? t : null;
|
|
406
406
|
}
|
|
407
407
|
return null;
|
|
408
|
-
},
|
|
408
|
+
}, Re = (e) => {
|
|
409
409
|
const t = _e(e);
|
|
410
410
|
return t !== null && t >= -90 && t <= 90;
|
|
411
|
-
},
|
|
411
|
+
}, Ee = (e) => {
|
|
412
412
|
const t = _e(e);
|
|
413
413
|
return t !== null && t >= -180 && t <= 180;
|
|
414
|
-
}, Ft = (e) => Array.isArray(e) && e.length === 2 &&
|
|
414
|
+
}, Ft = (e) => Array.isArray(e) && e.length === 2 && Re(e[0]) && Ee(e[1]), Se = (e) => {
|
|
415
415
|
if (typeof e != "object" || e === null)
|
|
416
416
|
return !1;
|
|
417
417
|
const t = e;
|
|
418
|
-
return (typeof t.id == "string" || typeof t.id == "number" || t.id === void 0) &&
|
|
418
|
+
return (typeof t.id == "string" || typeof t.id == "number" || t.id === void 0) && Re(t.lat) && Ee(t.lng);
|
|
419
419
|
}, he = (e) => ie(e) || Q(e) ? String(e) : JSON.stringify(e), tt = (e) => {
|
|
420
420
|
if (!e)
|
|
421
421
|
return [];
|
|
@@ -436,8 +436,8 @@ const Ge = Ie({
|
|
|
436
436
|
openPopup: u
|
|
437
437
|
}) => {
|
|
438
438
|
const { current: d } = Ue(), g = ae(""), p = M(() => e.filter(Se), [e]), _ = M(() => tt(t), [t]), b = M(() => {
|
|
439
|
-
const x = [...p.map((
|
|
440
|
-
return x.length === 0 ? null : x.reduce((
|
|
439
|
+
const x = [...p.map((R) => [R.lng, R.lat]), ..._];
|
|
440
|
+
return x.length === 0 ? null : x.reduce((R, [E, C]) => R.extend([E, C]), new be.LngLatBounds());
|
|
441
441
|
}, [p, _]);
|
|
442
442
|
return w(() => {
|
|
443
443
|
if (u) {
|
|
@@ -588,7 +588,7 @@ const ke = async (e, t, n) => {
|
|
|
588
588
|
vt,
|
|
589
589
|
Ce,
|
|
590
590
|
(e) => e.distances ?? void 0
|
|
591
|
-
),
|
|
591
|
+
), Rt = async (e, t, n = "driving", a) => {
|
|
592
592
|
if (!t.length)
|
|
593
593
|
return [];
|
|
594
594
|
const o = Te(t, bt - 1);
|
|
@@ -597,7 +597,7 @@ const ke = async (e, t, n) => {
|
|
|
597
597
|
xt,
|
|
598
598
|
(s) => _t(e, s, n, a)
|
|
599
599
|
)).flatMap((s) => s.all).sort((s, u) => s.distance - u.distance);
|
|
600
|
-
},
|
|
600
|
+
}, Et = async (e, t, n = "driving") => {
|
|
601
601
|
const a = `${e.join(",")};${t.join(",")}`, o = we("route", n, a, {
|
|
602
602
|
geometries: "geojson",
|
|
603
603
|
overview: "full"
|
|
@@ -614,8 +614,8 @@ const ke = async (e, t, n) => {
|
|
|
614
614
|
type: "Feature"
|
|
615
615
|
};
|
|
616
616
|
}, Ae = {
|
|
617
|
-
findNearest:
|
|
618
|
-
getItinerary:
|
|
617
|
+
findNearest: Rt,
|
|
618
|
+
getItinerary: Et
|
|
619
619
|
}, Oe = ({ from: e, to: t, profile: n, engine: a, itineraryLineStyle: o, initialRoute: l, onRouteComputed: s, itineraryLabel: u }) => {
|
|
620
620
|
const [d, g] = V(l ?? null);
|
|
621
621
|
return w(() => {
|
|
@@ -647,14 +647,14 @@ const ke = async (e, t, n) => {
|
|
|
647
647
|
return;
|
|
648
648
|
}
|
|
649
649
|
g([]);
|
|
650
|
-
const x = n.map((
|
|
651
|
-
coords: [
|
|
652
|
-
id:
|
|
650
|
+
const x = n.map((E) => ({
|
|
651
|
+
coords: [E.lng, E.lat],
|
|
652
|
+
id: E.id
|
|
653
653
|
}));
|
|
654
|
-
return (u === "OSRM" ? Ae : K).findNearest(e, x, s, t).then((
|
|
654
|
+
return (u === "OSRM" ? Ae : K).findNearest(e, x, s, t).then((E) => g(E ?? [])).catch(() => g([])), () => b.abort();
|
|
655
655
|
}, [e, t, n, s, u, o?.length]), w(() => {
|
|
656
656
|
const b = p.current;
|
|
657
|
-
(!b || b.length !== d.length || b.some((
|
|
657
|
+
(!b || b.length !== d.length || b.some((R, E) => R.id !== d[E]?.id || R.distance !== d[E]?.distance)) && (a?.(d), p.current = d);
|
|
658
658
|
}, [d, a]);
|
|
659
659
|
const _ = d[0];
|
|
660
660
|
return _ ? _.routeFeature ? /* @__PURE__ */ f.jsx(ee, { features: _.routeFeature }) : /* @__PURE__ */ f.jsx(Oe, { from: e, to: _.point, profile: s, engine: u, itineraryLineStyle: l }) : null;
|
|
@@ -698,8 +698,8 @@ const ke = async (e, t, n) => {
|
|
|
698
698
|
fitBounds: _ = !0,
|
|
699
699
|
fitBoundsPadding: b,
|
|
700
700
|
fitBoundDuration: x,
|
|
701
|
-
fitBoundsAnimationKey:
|
|
702
|
-
disableAnimation:
|
|
701
|
+
fitBoundsAnimationKey: R,
|
|
702
|
+
disableAnimation: E,
|
|
703
703
|
mapStyle: C,
|
|
704
704
|
onMapClick: W,
|
|
705
705
|
baseMapView: F,
|
|
@@ -712,21 +712,21 @@ const ke = async (e, t, n) => {
|
|
|
712
712
|
findNearestMarker: S,
|
|
713
713
|
isochrone: A
|
|
714
714
|
}) => {
|
|
715
|
-
const U = xe(), P = ae(null), [L, I] = V(d ?? null), [$, G] = V(!1),
|
|
715
|
+
const U = xe(), P = ae(null), [L, I] = V(d ?? null), [$, G] = V(!1), z = M(() => {
|
|
716
716
|
const [i = 2.3522, v = 48.8566] = ce(l) ? l : [];
|
|
717
717
|
return { latitude: v, longitude: i, zoom: s };
|
|
718
|
-
}, [l, s]),
|
|
718
|
+
}, [l, s]), J = M(
|
|
719
719
|
() => C || Me(F, N ?? U.palette.mode),
|
|
720
720
|
[F, C, N, U.palette.mode]
|
|
721
721
|
), {
|
|
722
|
-
style:
|
|
722
|
+
style: q,
|
|
723
723
|
cooperativeGestures: X,
|
|
724
724
|
doubleClickZoom: r
|
|
725
725
|
} = jt({
|
|
726
726
|
baseMapView: F,
|
|
727
727
|
cooperativeGestures: te,
|
|
728
728
|
doubleClickZoom: re,
|
|
729
|
-
mapStyle:
|
|
729
|
+
mapStyle: J,
|
|
730
730
|
theme: N ?? U.palette.mode
|
|
731
731
|
}), c = (i, v) => {
|
|
732
732
|
!g && v && I(i);
|
|
@@ -737,149 +737,156 @@ const ke = async (e, t, n) => {
|
|
|
737
737
|
I(d ?? null);
|
|
738
738
|
}, [d]);
|
|
739
739
|
const m = M(() => L ? p?.find((i) => i.id === L) ?? null : null, [L, p]);
|
|
740
|
-
return /* @__PURE__ */ f.jsxs(
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
{
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
{
|
|
759
|
-
ref: P,
|
|
760
|
-
cooperativeGestures: X,
|
|
761
|
-
doubleClickZoom: r,
|
|
762
|
-
mapStyle: J,
|
|
763
|
-
projection: ne,
|
|
764
|
-
onLoad: () => {
|
|
765
|
-
G(!0), P.current?.resize();
|
|
766
|
-
},
|
|
767
|
-
initialViewState: q,
|
|
768
|
-
style: { height: "100%", width: "100%" },
|
|
769
|
-
mapboxAccessToken: void 0,
|
|
770
|
-
onClick: (i) => {
|
|
771
|
-
const v = p.find((h) => {
|
|
772
|
-
const { lng: j, lat: O } = i.lngLat, k = Math.abs(Number(h.lng ?? 0) - j), Pe = Math.abs(Number(h.lat ?? 0) - O);
|
|
773
|
-
return k < 0.01 && Pe < 0.01;
|
|
774
|
-
});
|
|
775
|
-
W?.(i.lngLat.lng, i.lngLat.lat, v ?? null);
|
|
776
|
-
},
|
|
777
|
-
children: [
|
|
778
|
-
$ && p.filter(Se).map((i) => {
|
|
779
|
-
const v = typeof i.size == "number" ? i.size : void 0, h = (() => {
|
|
780
|
-
if (!i.IconComponent)
|
|
781
|
-
return null;
|
|
782
|
-
const k = { ...i.iconProps };
|
|
783
|
-
return v && (k.width = v, k.height = v), /* @__PURE__ */ f.jsx(i.IconComponent, { ...k });
|
|
784
|
-
})(), j = i.IconComponent ? null : /* @__PURE__ */ f.jsx(Ke, { color: i.color, variant: i.variant, size: v, type: i.type }), O = {
|
|
785
|
-
alignItems: "center",
|
|
786
|
-
cursor: i.Tooltip ? "pointer" : "default",
|
|
787
|
-
display: "inline-flex",
|
|
788
|
-
justifyContent: "center",
|
|
789
|
-
...i.IconComponent && !v ? {} : v ? { height: v, width: v } : {}
|
|
790
|
-
};
|
|
791
|
-
return /* @__PURE__ */ f.jsx(
|
|
792
|
-
ve,
|
|
793
|
-
{
|
|
794
|
-
longitude: i.lng,
|
|
795
|
-
latitude: i.lat,
|
|
796
|
-
anchor: "center",
|
|
797
|
-
onClick: (k) => {
|
|
798
|
-
k.originalEvent.stopPropagation(), i.id && c(i.id, !!i.Tooltip), W?.(i.lng, i.lat, i);
|
|
799
|
-
},
|
|
800
|
-
children: /* @__PURE__ */ f.jsx(
|
|
801
|
-
H,
|
|
802
|
-
{
|
|
803
|
-
component: "div",
|
|
804
|
-
onMouseEnter: () => i.id && y(i.id, !!i.Tooltip),
|
|
805
|
-
onMouseLeave: () => y(null),
|
|
806
|
-
style: O,
|
|
807
|
-
children: h || j
|
|
808
|
-
}
|
|
809
|
-
)
|
|
810
|
-
},
|
|
811
|
-
i.id
|
|
812
|
-
);
|
|
813
|
-
}),
|
|
814
|
-
$ && m?.Tooltip && /* @__PURE__ */ f.jsx(
|
|
815
|
-
Ye,
|
|
816
|
-
{
|
|
817
|
-
longitude: Q(m.lng) ? m.lng : 0,
|
|
818
|
-
latitude: Q(m.lat) ? m.lat : 0,
|
|
819
|
-
anchor: "top",
|
|
820
|
-
onClose: () => I(null),
|
|
821
|
-
maxWidth: u,
|
|
822
|
-
closeOnClick: !0,
|
|
823
|
-
closeOnMove: !1,
|
|
824
|
-
children: /* @__PURE__ */ f.jsx(H, { component: "div", sx: { minHeight: 60, minWidth: 240 }, children: m.Tooltip })
|
|
825
|
-
}
|
|
826
|
-
),
|
|
827
|
-
T && /* @__PURE__ */ f.jsx(
|
|
828
|
-
Oe,
|
|
829
|
-
{
|
|
830
|
-
from: T.from,
|
|
831
|
-
to: T.to,
|
|
832
|
-
profile: T.profile,
|
|
833
|
-
engine: T.engine,
|
|
834
|
-
itineraryLineStyle: T.itineraryLineStyle,
|
|
835
|
-
initialRoute: T.initialRoute,
|
|
836
|
-
onRouteComputed: T.onRouteComputed,
|
|
837
|
-
itineraryLabel: T.itineraryLabel
|
|
838
|
-
}
|
|
839
|
-
),
|
|
840
|
-
S && /* @__PURE__ */ f.jsx(
|
|
841
|
-
Tt,
|
|
842
|
-
{
|
|
843
|
-
origin: S.origin,
|
|
844
|
-
destinations: S.destinations,
|
|
845
|
-
onNearestFound: S.onNearestFound,
|
|
846
|
-
maxDistanceMeters: S.maxDistanceMeters,
|
|
847
|
-
engine: S.engine,
|
|
848
|
-
profile: S.profile,
|
|
849
|
-
initialNearestResults: S.initialNearestResults,
|
|
850
|
-
itineraryLineStyle: S.itineraryLineStyle
|
|
851
|
-
}
|
|
852
|
-
),
|
|
853
|
-
A && /* @__PURE__ */ f.jsx(
|
|
854
|
-
mt,
|
|
855
|
-
{
|
|
856
|
-
origin: A.origin,
|
|
857
|
-
profile: A.profile,
|
|
858
|
-
onIsochroneLoaded: A.onIsochroneLoaded,
|
|
859
|
-
intervals: A.intervals
|
|
860
|
-
}
|
|
861
|
-
),
|
|
862
|
-
D && /* @__PURE__ */ f.jsx(ee, { features: D }),
|
|
863
|
-
_ && /* @__PURE__ */ f.jsx(
|
|
864
|
-
rt,
|
|
865
|
-
{
|
|
866
|
-
markers: p,
|
|
867
|
-
features: D,
|
|
868
|
-
padding: b,
|
|
869
|
-
duration: R ? 0 : x,
|
|
870
|
-
animationKey: E,
|
|
871
|
-
openPopup: !!d
|
|
740
|
+
return /* @__PURE__ */ f.jsxs(
|
|
741
|
+
H,
|
|
742
|
+
{
|
|
743
|
+
"data-testid": "mapbox-container",
|
|
744
|
+
sx: { borderRadius: t ? 0 : 6, height: a, overflow: "hidden", position: "relative", width: o, ...e },
|
|
745
|
+
children: [
|
|
746
|
+
/* @__PURE__ */ f.jsx(Fe, { styles: et }),
|
|
747
|
+
n && /* @__PURE__ */ f.jsx(
|
|
748
|
+
Ne,
|
|
749
|
+
{
|
|
750
|
+
"data-testid": "skeleton-loader",
|
|
751
|
+
width: o,
|
|
752
|
+
height: a,
|
|
753
|
+
variant: t ? "rectangular" : "rounded",
|
|
754
|
+
sx: {
|
|
755
|
+
inset: 0,
|
|
756
|
+
position: "absolute",
|
|
757
|
+
zIndex: 2
|
|
872
758
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
759
|
+
}
|
|
760
|
+
),
|
|
761
|
+
!n && /* @__PURE__ */ f.jsxs(
|
|
762
|
+
De,
|
|
763
|
+
{
|
|
764
|
+
ref: P,
|
|
765
|
+
cooperativeGestures: X,
|
|
766
|
+
doubleClickZoom: r,
|
|
767
|
+
mapStyle: q,
|
|
768
|
+
projection: ne,
|
|
769
|
+
onLoad: () => {
|
|
770
|
+
G(!0), P.current?.resize();
|
|
771
|
+
},
|
|
772
|
+
initialViewState: z,
|
|
773
|
+
style: { height: "100%", width: "100%" },
|
|
774
|
+
mapboxAccessToken: void 0,
|
|
775
|
+
onClick: (i) => {
|
|
776
|
+
const v = p.find((h) => {
|
|
777
|
+
const { lng: j, lat: O } = i.lngLat, k = Math.abs(Number(h.lng ?? 0) - j), Pe = Math.abs(Number(h.lat ?? 0) - O);
|
|
778
|
+
return k < 0.01 && Pe < 0.01;
|
|
779
|
+
});
|
|
780
|
+
W?.(i.lngLat.lng, i.lngLat.lat, v ?? null);
|
|
781
|
+
},
|
|
782
|
+
children: [
|
|
783
|
+
$ && p.filter(Se).map((i) => {
|
|
784
|
+
const v = typeof i.size == "number" ? i.size : void 0, h = (() => {
|
|
785
|
+
if (!i.IconComponent)
|
|
786
|
+
return null;
|
|
787
|
+
const k = { ...i.iconProps };
|
|
788
|
+
return v && (k.width = v, k.height = v), /* @__PURE__ */ f.jsx(i.IconComponent, { ...k });
|
|
789
|
+
})(), j = i.IconComponent ? null : /* @__PURE__ */ f.jsx(Ke, { color: i.color, variant: i.variant, size: v, type: i.type }), O = {
|
|
790
|
+
alignItems: "center",
|
|
791
|
+
cursor: i.Tooltip ? "pointer" : "default",
|
|
792
|
+
display: "inline-flex",
|
|
793
|
+
justifyContent: "center",
|
|
794
|
+
...i.IconComponent && !v ? {} : v ? { height: v, width: v } : {}
|
|
795
|
+
};
|
|
796
|
+
return /* @__PURE__ */ f.jsx(
|
|
797
|
+
ve,
|
|
798
|
+
{
|
|
799
|
+
longitude: i.lng,
|
|
800
|
+
latitude: i.lat,
|
|
801
|
+
anchor: "center",
|
|
802
|
+
onClick: (k) => {
|
|
803
|
+
k.originalEvent.stopPropagation(), i.id && c(i.id, !!i.Tooltip), W?.(i.lng, i.lat, i);
|
|
804
|
+
},
|
|
805
|
+
children: /* @__PURE__ */ f.jsx(
|
|
806
|
+
H,
|
|
807
|
+
{
|
|
808
|
+
component: "div",
|
|
809
|
+
onMouseEnter: () => i.id && y(i.id, !!i.Tooltip),
|
|
810
|
+
onMouseLeave: () => y(null),
|
|
811
|
+
style: O,
|
|
812
|
+
children: h || j
|
|
813
|
+
}
|
|
814
|
+
)
|
|
815
|
+
},
|
|
816
|
+
i.id
|
|
817
|
+
);
|
|
818
|
+
}),
|
|
819
|
+
$ && m?.Tooltip && /* @__PURE__ */ f.jsx(
|
|
820
|
+
Ye,
|
|
821
|
+
{
|
|
822
|
+
longitude: Q(m.lng) ? m.lng : 0,
|
|
823
|
+
latitude: Q(m.lat) ? m.lat : 0,
|
|
824
|
+
anchor: "top",
|
|
825
|
+
onClose: () => I(null),
|
|
826
|
+
maxWidth: u,
|
|
827
|
+
closeOnClick: !0,
|
|
828
|
+
closeOnMove: !1,
|
|
829
|
+
children: /* @__PURE__ */ f.jsx(H, { component: "div", sx: { minHeight: 60, minWidth: 240 }, children: m.Tooltip })
|
|
830
|
+
}
|
|
831
|
+
),
|
|
832
|
+
T && /* @__PURE__ */ f.jsx(
|
|
833
|
+
Oe,
|
|
834
|
+
{
|
|
835
|
+
from: T.from,
|
|
836
|
+
to: T.to,
|
|
837
|
+
profile: T.profile,
|
|
838
|
+
engine: T.engine,
|
|
839
|
+
itineraryLineStyle: T.itineraryLineStyle,
|
|
840
|
+
initialRoute: T.initialRoute,
|
|
841
|
+
onRouteComputed: T.onRouteComputed,
|
|
842
|
+
itineraryLabel: T.itineraryLabel
|
|
843
|
+
}
|
|
844
|
+
),
|
|
845
|
+
S && /* @__PURE__ */ f.jsx(
|
|
846
|
+
Tt,
|
|
847
|
+
{
|
|
848
|
+
origin: S.origin,
|
|
849
|
+
destinations: S.destinations,
|
|
850
|
+
onNearestFound: S.onNearestFound,
|
|
851
|
+
maxDistanceMeters: S.maxDistanceMeters,
|
|
852
|
+
engine: S.engine,
|
|
853
|
+
profile: S.profile,
|
|
854
|
+
initialNearestResults: S.initialNearestResults,
|
|
855
|
+
itineraryLineStyle: S.itineraryLineStyle
|
|
856
|
+
}
|
|
857
|
+
),
|
|
858
|
+
A && /* @__PURE__ */ f.jsx(
|
|
859
|
+
mt,
|
|
860
|
+
{
|
|
861
|
+
origin: A.origin,
|
|
862
|
+
profile: A.profile,
|
|
863
|
+
onIsochroneLoaded: A.onIsochroneLoaded,
|
|
864
|
+
intervals: A.intervals
|
|
865
|
+
}
|
|
866
|
+
),
|
|
867
|
+
D && /* @__PURE__ */ f.jsx(ee, { features: D }),
|
|
868
|
+
_ && /* @__PURE__ */ f.jsx(
|
|
869
|
+
rt,
|
|
870
|
+
{
|
|
871
|
+
markers: p,
|
|
872
|
+
features: D,
|
|
873
|
+
padding: b,
|
|
874
|
+
duration: E ? 0 : x,
|
|
875
|
+
animationKey: R,
|
|
876
|
+
openPopup: !!d
|
|
877
|
+
}
|
|
878
|
+
)
|
|
879
|
+
]
|
|
880
|
+
}
|
|
881
|
+
)
|
|
882
|
+
]
|
|
883
|
+
}
|
|
884
|
+
);
|
|
878
885
|
}, Nt = le(kt), Dt = ["OSRM", "Mapbox"], Ut = ["driving", "walking", "cycling"], Yt = (e, t) => {
|
|
879
886
|
const n = "geometry" in t ? t.geometry : t, [a, o] = e, l = (s) => s.map(
|
|
880
887
|
(u) => u.reduce((d, [g, p], _, b) => {
|
|
881
|
-
const [x,
|
|
882
|
-
return p > o !=
|
|
888
|
+
const [x, R] = b[(_ - 1 + b.length) % b.length];
|
|
889
|
+
return p > o != R > o && a < (x - g) * (o - p) / (R - p) + g ? !d : d;
|
|
883
890
|
}, !1)
|
|
884
891
|
).reduce((u, d, g) => g === 0 ? d : u && !d, !1);
|
|
885
892
|
return n.type === "Polygon" ? l(n.coordinates) : n.type === "MultiPolygon" ? n.coordinates.some((s) => l(s)) : !1;
|
|
@@ -892,8 +899,8 @@ export {
|
|
|
892
899
|
Dt as engines,
|
|
893
900
|
Yt as isPointInGeoJSON,
|
|
894
901
|
Ft as isValidLatLngTuple,
|
|
895
|
-
|
|
896
|
-
|
|
902
|
+
Re as isValidLatitude,
|
|
903
|
+
Ee as isValidLongitude,
|
|
897
904
|
Se as isValidMarker,
|
|
898
905
|
Ut as profiles
|
|
899
906
|
};
|
package/dist/main.umd.cjs
CHANGED
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
<%s {...props} />
|
|
21
21
|
React keys must be passed directly to JSX without using spread:
|
|
22
22
|
let props = %s;
|
|
23
|
-
<%s key={someKey} {...props} />`,y,b,w,b),ee[b+y]=!0)}if(b=null,h!==void 0&&(r(h),b=""+h),s(c)&&(r(c.key),b=""+c.key),"key"in c){h={};for(var N in c)N!=="key"&&(h[N]=c[N])}else h=c;return b&&u(h,typeof n=="function"?n.displayName||n.name||"Unknown":n),m(n,b,h,o(),i,v)}function x(n){_(n)?n._store&&(n._store.validated=1):typeof n=="object"&&n!==null&&n.$$typeof===k&&(n._payload.status==="fulfilled"?_(n._payload.value)&&n._payload.value._store&&(n._payload.value._store.validated=1):n._store&&(n._store.validated=1))}function _(n){return typeof n=="object"&&n!==null&&n.$$typeof===S}var R=d,S=Symbol.for("react.transitional.element"),T=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),H=Symbol.for("react.strict_mode"),V=Symbol.for("react.profiler"),ce=Symbol.for("react.consumer"),ie=Symbol.for("react.context"),ue=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),J=Symbol.for("react.client.reference"),I=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,D=Array.isArray,U=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(n){return n()}};var Q,K={},$=R.react_stack_bottom_frame.bind(R,l)(),q=U(a(l)),ee={};B.Fragment=P,B.jsx=function(n,c,h){var y=1e4>I.recentlyCreatedOwnerStacks++;return g(n,c,h,!1,y?Error("react-stack-top-frame"):$,y?U(a(n)):q)},B.jsxs=function(n,c,h){var y=1e4>I.recentlyCreatedOwnerStacks++;return g(n,c,h,!0,y?Error("react-stack-top-frame"):$,y?U(a(n)):q)}})()),B}var ge;function Ae(){return ge||(ge=1,process.env.NODE_ENV==="production"?z.exports=ke():z.exports=je()),z.exports}var p=Ae();const we=d.createContext({licenceMapbox:"",licenseMuiX:""}),Ce=({children:e,licenseMuiX:t,licenceMapbox:r})=>{d.useEffect(()=>{t&&Te.LicenseInfo.setLicenseKey(t)},[t]);const a=d.useMemo(()=>({licenceMapbox:r,licenseMuiX:t}),[t,r]);return r&&(fe.accessToken=r),p.jsx(we.Provider,{value:a,children:e})},Le=e=>e?.type==="LineString"||e?.type==="MultiLineString",Oe=e=>{let t;Array.isArray(e[0][0])?t=e.reduce((o,l)=>l.length>o.length?l:o):t=e;const r=Math.floor(t.length/2);return[t[r][0],t[r][1]]},Pe=({route:e,children:t})=>{if(!(e&&t))return null;const r=e.geometry;if(!Le(r))return null;const a=r.coordinates,[o,l]=Oe(a);return p.jsx(C.Marker,{longitude:o,latitude:l,children:t})},Me=e=>A.isArray(e)?{features:e,type:"FeatureCollection"}:e.type==="FeatureCollection"?e:{features:[e],type:"FeatureCollection"},X=({features:e,lineLabel:t,lineStyle:r})=>{if(!e)return null;const a=Me(e),o=a.features.filter(s=>s.geometry.type==="Polygon"||s.geometry.type==="MultiPolygon"),l=a.features.filter(s=>s.geometry.type==="LineString"||s.geometry.type==="MultiLineString");return p.jsxs(p.Fragment,{children:[o.length>0&&p.jsx(C.Source,{id:"features-polygon",type:"geojson",data:{features:o,type:"FeatureCollection"},children:p.jsx(C.Layer,{id:"polygon-fill",type:"fill",paint:{"fill-color":["coalesce",["get","color"],"#4ADE80"],"fill-opacity":["coalesce",["get","opacity"],.4]}})}),l.length>0&&p.jsxs(p.Fragment,{children:[p.jsx(C.Source,{id:"features-line",type:"geojson",data:{features:l,type:"FeatureCollection"},children:p.jsx(C.Layer,{id:"line-stroke",type:"line",paint:{"line-color":r?.color??["coalesce",["get","color"],"#3B82F6"],"line-opacity":r?.opacity??["coalesce",["get","opacity"],.9],"line-width":r?.width??["coalesce",["get","width"],3]}})}),t&&l.map((s,u)=>p.jsx(Pe,{route:s,children:t},`label-${u}`))]})]})},Ne="#000000",Ie="#FFFFFF",te={default:"#009ba6",primary:"#3F83F8",secondary:"#9C27B0",success:"#4CAF50",warning:"#FF9800"},Fe=e=>e in te,De=({color:e,variant:t,type:r,size:a=28})=>{const o=O.useTheme(),l=o.palette.mode==="dark"?Ne:Ie,s=Math.max(3,Math.round(a*.25)),u=(()=>{if(r==="dropOff")return"#4e85e1";if(t&&Fe(t))return te[t];if(!e)return te.default;if(typeof e=="function")return e(o);if(A.isString(e)&&e.includes(".")){const[f,m]=e.split("."),g=o.palette[f];if(g&&typeof g=="object"&&m in g)return g[m]}return e})();return p.jsx(O.Box,{component:"div",style:{backgroundColor:l,border:`${s}px solid ${u}`,borderRadius:"50%",boxShadow:"0 0 4px rgba(0,0,0,0.3)",height:a,width:a}})},Ue=e=>({".mapboxgl-popup-close-button":{color:e.palette.mode==="dark"?"#fff !important":"#000 !important",fontSize:"20px !important"},".mapboxgl-popup-content":{backgroundColor:"transparent!important",borderRadius:"0px !important",boxShadow:"none!important",padding:"0px 0px!important",width:"fit-content!important"},".mapboxgl-popup-tip":{borderTopColor:`${e.palette.mode==="dark"?"#1e1e1e":"#ffffff"} !important`}}),me=e=>{if(A.isNumber(e))return e;if(A.isString(e)&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null},ne=e=>{const t=me(e);return t!==null&&t>=-90&&t<=90},re=e=>{const t=me(e);return t!==null&&t>=-180&&t<=180},Ye=e=>Array.isArray(e)&&e.length===2&&ne(e[0])&&re(e[1]),oe=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return(typeof t.id=="string"||typeof t.id=="number"||t.id===void 0)&&ne(t.lat)&&re(t.lng)},ye=e=>A.isString(e)||A.isNumber(e)?String(e):JSON.stringify(e),Be=e=>{if(!e)return[];const t=A.isArray(e)?e:e.type==="FeatureCollection"?e.features:[e],r=[];for(const a of t){const o=a.geometry;o.type==="Point"&&r.push(o.coordinates),o.type==="LineString"&&r.push(...o.coordinates),o.type==="Polygon"&&r.push(...o.coordinates[0])}return r},Ve=({markers:e=[],features:t,padding:r=50,duration:a=1e3,disableAnimation:o,fitBounds:l=!0,animationKey:s,openPopup:u})=>{const{current:f}=C.useMap(),m=d.useRef(""),g=d.useMemo(()=>e.filter(oe),[e]),x=d.useMemo(()=>Be(t),[t]),_=d.useMemo(()=>{const R=[...g.map(S=>[S.lng,S.lat]),...x];return R.length===0?null:R.reduce((S,[T,P])=>S.extend([T,P]),new fe.LngLatBounds)},[g,x]);return d.useEffect(()=>{if(u){m.current=s!==void 0?ye(s):"__initial_skip__";return}if(f&&l&&_){if(s!==void 0){const R=ye(s);if(m.current===R)return;m.current=R}else if(m.current==="__initial_skip__")return;if(!_.isEmpty()){if(g.length===1&&x.length===0){const R=g[0];f.flyTo({center:[R.lng,R.lat],duration:o?0:a,zoom:14});return}f.fitBounds([_.getSouthWest().toArray(),_.getNorthEast().toArray()],{duration:o?0:a,padding:r})}}},[f,_,r,a,o,s,l,g,x,u]),null},he=(e,t)=>{if(t<=0)throw new Error("chunkSize must be greater than 0");const r=[];for(let a=0;a<e.length;a+=t)r.push(e.slice(a,a+t));return r},Ge=(e,t)=>[e,...t.map(r=>r.coords)].map(r=>r.join(",")).join(";"),We=(e,t,r)=>{const a=t.map((s,u)=>{if(u===0||s==null)return null;const f=e[u-1];return f?{distance:s,id:f.id,point:f.coords}:null}).filter(s=>s!==null);if(a.length===0)return{all:[],nearest:null};const o=a.sort((s,u)=>s.distance-u.distance),l=o[0];return r&&l.distance>r?{all:o,nearest:null}:{all:o,nearest:l}};function be(e,t,r){return async(a,o,l,s)=>{const u=Ge(a,o),f=e(u,l),m=await t(f),g=m?r(m)?.[0]:void 0;return g?.length?We(o,g,s):{all:[],nearest:null}}}const Ee=async(e,t,r)=>{const a=Array.from({length:Math.ceil(e.length/t)},(l,s)=>e.slice(s*t,(s+1)*t));return(await Promise.all(a.map(async l=>Promise.all(l.map(r))))).flat()},Je="https://api.mapbox.com",se=(e,t,r,a,o={})=>{const l=new URLSearchParams({access_token:"",...o});return`${Je}/${e}/${t}/mapbox/${r}/${a}?${l.toString()}`},ae=async e=>{try{const t=await fetch(e);return t.ok?await t.json():(console.error(`Mapbox API error: ${t.status} ${t.statusText}`),null)}catch(t){return console.error("Mapbox network error:",t),null}},ze=25,Xe=5,Ze=be((e,t)=>se("directions-matrix","v1",t,e,{annotations:"distance",sources:"0"}),ae,e=>e.distances??void 0),Z={findNearest:async(e,t,r="driving",a)=>{if(!t.length)return[];const o=he(t,ze-1);return(await Ee(o,Xe,s=>Ze(e,s,r,a))).flatMap(s=>s.all).sort((s,u)=>s.distance-u.distance)},getIsochrone:async(e,t="driving",r=[5,10,15])=>{const a=`${e[0]},${e[1]}`,o=se("isochrone","v1",t,a,{contours_minutes:r.join(","),polygons:"true"});return await ae(o)},getItinerary:async(e,t,r="driving")=>{const a=`${e.join(",")};${t.join(",")}`,o=se("directions","v5",r,a,{geometries:"geojson",overview:"full"}),l=await ae(o);if(!l?.routes?.length)return null;const s=l.routes[0];return{geometry:s.geometry,properties:{distance:s.distance,duration:s.duration},type:"Feature"}}},He=({origin:e,profile:t="driving",intervals:r=[5,10,15],onIsochroneLoaded:a})=>{const[o,l]=d.useState(null);return d.useEffect(()=>{let s=!1;if(!e||e.length!==2){l(null);return}return(async()=>{if(!Z.getIsochrone){console.warn("⚠️ getIsochrone is not implemented for this provider.");return}const u=await Z.getIsochrone(e,t,r);s||(l(u),a?.(u??null))})(),()=>{s=!0}},[e,t,r,a]),o?p.jsx(X,{features:o}):null},Qe=d.memo(He),Ke={cycling:"routed-bike",driving:"routed-car",walking:"routed-foot"},$e="https://routing.openstreetmap.de",_e=(e,t,r,a)=>{const o=`${$e}/${Ke[t]}/${e}/v1/${t}/${r}`,l=a?`?${new URLSearchParams(a).toString()}`:"";return`${o}${l}`},Re=async e=>{try{const t=await fetch(e);return t.ok?await t.json():(console.error("OSRM API error:",t.status,t.statusText),null)}catch(t){return console.error("Error fetching OSRM API:",t),null}},qe=100,et=5,tt=be((e,t)=>_e("table",t,e,{annotations:"distance",sources:0}),Re,e=>e.distances??void 0),ve={findNearest:async(e,t,r="driving",a)=>{if(!t.length)return[];const o=he(t,qe-1);return(await Ee(o,et,s=>tt(e,s,r,a))).flatMap(s=>s.all).sort((s,u)=>s.distance-u.distance)},getItinerary:async(e,t,r="driving")=>{const a=`${e.join(",")};${t.join(",")}`,o=_e("route",r,a,{geometries:"geojson",overview:"full"}),l=await Re(o);if(!l?.routes?.length)return null;const s=l.routes[0];return{geometry:s.geometry,properties:{distance:s.distance,duration:s.duration},type:"Feature"}}},xe=({from:e,to:t,profile:r,engine:a,itineraryLineStyle:o,initialRoute:l,onRouteComputed:s,itineraryLabel:u})=>{const[f,m]=d.useState(l??null);return d.useEffect(()=>{l&&(m(l),s?.(l))},[l,s]),d.useEffect(()=>{!(e&&t)||l||(async()=>{const x=await(a==="OSRM"?ve:Z).getItinerary(e,t,r);m(x??null),s?.(x??null)})()},[e,t,r,a,l,s]),f?p.jsx(X,{features:f,lineStyle:o,lineLabel:u}):null},nt=({origin:e,maxDistanceMeters:t,destinations:r,onNearestFound:a,initialNearestResults:o,itineraryLineStyle:l,profile:s="driving",engine:u="OSRM"})=>{const[f,m]=d.useState(o??[]),g=d.useRef(null);d.useEffect(()=>{o&&m(o)},[o]),d.useEffect(()=>{const _=new AbortController;if(o?.length)return;if(!e||e.length!==2||!r?.length){m([]);return}m([]);const R=r.map(T=>({coords:[T.lng,T.lat],id:T.id}));return(u==="OSRM"?ve:Z).findNearest(e,R,s,t).then(T=>m(T??[])).catch(()=>m([])),()=>_.abort()},[e,t,r,s,u,o?.length]),d.useEffect(()=>{const _=g.current;(!_||_.length!==f.length||_.some((S,T)=>S.id!==f[T]?.id||S.distance!==f[T]?.distance))&&(a?.(f),g.current=f)},[f,a]);const x=f[0];return x?x.routeFeature?p.jsx(X,{features:x.routeFeature}):p.jsx(xe,{from:e,to:x.point,profile:s,engine:u,itineraryLineStyle:l}):null},rt=d.memo(nt),le={satellite:"mapbox://styles/mapbox/satellite-streets-v12",street:{dark:"mapbox://styles/mapbox/dark-v11",light:"mapbox://styles/mapbox/streets-v12"}},Se=(e,t)=>{const r=t==="dark";switch(e){case"satellite":return le.satellite;default:return r?le.street.dark:le.street.light}},ot=({mapStyle:e,theme:t,baseMapView:r,doubleClickZoom:a,cooperativeGestures:o})=>({cooperativeGestures:o,doubleClickZoom:a,failIfMajorPerformanceCaveat:!1,style:e??Se(r,t)}),st=({containerStyle:e,square:t,loading:r,height:a=300,width:o="100%",center:l=[2.3522,48.8566],zoom:s=5,popupMaxWidth:u,openPopup:f,openPopupOnHover:m,markers:g=[],fitBounds:x=!0,fitBoundsPadding:_,fitBoundDuration:R,fitBoundsAnimationKey:S,disableAnimation:T,mapStyle:P,onMapClick:H,baseMapView:V,cooperativeGestures:ce=!0,doubleClickZoom:ie=!0,projection:ue,theme:G,features:W,itineraryParams:j,findNearestMarker:k,isochrone:M})=>{const J=O.useTheme(),I=d.useRef(null),[F,D]=d.useState(f??null),[U,Q]=d.useState(!1),K=d.useMemo(()=>{const[i=2.3522,v=48.8566]=A.isArray(l)?l:[];return{latitude:v,longitude:i,zoom:s}},[l,s]),$=d.useMemo(()=>P||Se(V,G??J.palette.mode),[V,P,G,J.palette.mode]),{style:q,cooperativeGestures:ee,doubleClickZoom:n}=ot({baseMapView:V,cooperativeGestures:ce,doubleClickZoom:ie,mapStyle:$,theme:G??J.palette.mode}),c=(i,v)=>{!m&&v&&D(i)},h=(i,v)=>{m&&D(v?i:null)};d.useEffect(()=>{D(f??null)},[f]);const y=d.useMemo(()=>F?g?.find(i=>i.id===F)??null:null,[F,g]);return p.jsxs(O.Box,{"data-testid":"mapbox-container",sx:{height:a,position:"relative",width:o,...e},children:[p.jsx(O.GlobalStyles,{styles:Ue}),r&&p.jsx(O.Skeleton,{"data-testid":"skeleton-loader",width:o,height:a,variant:t?"rectangular":"rounded",sx:{inset:0,position:"absolute",zIndex:2}}),!r&&p.jsxs(C,{ref:I,cooperativeGestures:ee,doubleClickZoom:n,mapStyle:q,projection:ue,onLoad:()=>{Q(!0),I.current?.resize()},initialViewState:K,style:{height:"100%",width:"100%"},mapboxAccessToken:void 0,onClick:i=>{const v=g.find(b=>{const{lng:w,lat:N}=i.lngLat,L=Math.abs(Number(b.lng??0)-w),ut=Math.abs(Number(b.lat??0)-N);return L<.01&&ut<.01});H?.(i.lngLat.lng,i.lngLat.lat,v??null)},children:[U&&g.filter(oe).map(i=>{const v=typeof i.size=="number"?i.size:void 0,b=(()=>{if(!i.IconComponent)return null;const L={...i.iconProps};return v&&(L.width=v,L.height=v),p.jsx(i.IconComponent,{...L})})(),w=i.IconComponent?null:p.jsx(De,{color:i.color,variant:i.variant,size:v,type:i.type}),N={alignItems:"center",cursor:i.Tooltip?"pointer":"default",display:"inline-flex",justifyContent:"center",...i.IconComponent&&!v?{}:v?{height:v,width:v}:{}};return p.jsx(C.Marker,{longitude:i.lng,latitude:i.lat,anchor:"center",onClick:L=>{L.originalEvent.stopPropagation(),i.id&&c(i.id,!!i.Tooltip),H?.(i.lng,i.lat,i)},children:p.jsx(O.Box,{component:"div",onMouseEnter:()=>i.id&&h(i.id,!!i.Tooltip),onMouseLeave:()=>h(null),style:N,children:b||w})},i.id)}),U&&y?.Tooltip&&p.jsx(C.Popup,{longitude:A.isNumber(y.lng)?y.lng:0,latitude:A.isNumber(y.lat)?y.lat:0,anchor:"top",onClose:()=>D(null),maxWidth:u,closeOnClick:!0,closeOnMove:!1,children:p.jsx(O.Box,{component:"div",sx:{minHeight:60,minWidth:240},children:y.Tooltip})}),j&&p.jsx(xe,{from:j.from,to:j.to,profile:j.profile,engine:j.engine,itineraryLineStyle:j.itineraryLineStyle,initialRoute:j.initialRoute,onRouteComputed:j.onRouteComputed,itineraryLabel:j.itineraryLabel}),k&&p.jsx(rt,{origin:k.origin,destinations:k.destinations,onNearestFound:k.onNearestFound,maxDistanceMeters:k.maxDistanceMeters,engine:k.engine,profile:k.profile,initialNearestResults:k.initialNearestResults,itineraryLineStyle:k.itineraryLineStyle}),M&&p.jsx(Qe,{origin:M.origin,profile:M.profile,onIsochroneLoaded:M.onIsochroneLoaded,intervals:M.intervals}),W&&p.jsx(X,{features:W}),x&&p.jsx(Ve,{markers:g,features:W,padding:_,duration:T?0:R,animationKey:S,openPopup:!!f})]})]})},at=d.memo(st),lt=["OSRM","Mapbox"],ct=["driving","walking","cycling"],it=(e,t)=>{const r="geometry"in t?t.geometry:t,[a,o]=e,l=s=>s.map(u=>u.reduce((f,[m,g],x,_)=>{const[R,S]=_[(x-1+_.length)%_.length];return g>o!=S>o&&a<(R-m)*(o-g)/(S-g)+m?!f:f},!1)).reduce((u,f,m)=>m===0?f:u&&!f,!1);return r.type==="Polygon"?l(r.coordinates):r.type==="MultiPolygon"?r.coordinates.some(s=>l(s)):!1};E.DEFAULT_CENTER_LAT=46.8677,E.DEFAULT_CENTER_LNG=2.333,E.MapProvider=Ce,E.MapView=at,E.engines=lt,E.isPointInGeoJSON=it,E.isValidLatLngTuple=Ye,E.isValidLatitude=ne,E.isValidLongitude=re,E.isValidMarker=oe,E.profiles=ct,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}));
|
|
23
|
+
<%s key={someKey} {...props} />`,y,b,w,b),ee[b+y]=!0)}if(b=null,h!==void 0&&(r(h),b=""+h),s(c)&&(r(c.key),b=""+c.key),"key"in c){h={};for(var N in c)N!=="key"&&(h[N]=c[N])}else h=c;return b&&u(h,typeof n=="function"?n.displayName||n.name||"Unknown":n),m(n,b,h,o(),i,v)}function x(n){_(n)?n._store&&(n._store.validated=1):typeof n=="object"&&n!==null&&n.$$typeof===k&&(n._payload.status==="fulfilled"?_(n._payload.value)&&n._payload.value._store&&(n._payload.value._store.validated=1):n._store&&(n._store.validated=1))}function _(n){return typeof n=="object"&&n!==null&&n.$$typeof===S}var R=d,S=Symbol.for("react.transitional.element"),T=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),H=Symbol.for("react.strict_mode"),V=Symbol.for("react.profiler"),ce=Symbol.for("react.consumer"),ie=Symbol.for("react.context"),ue=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),J=Symbol.for("react.client.reference"),I=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,D=Array.isArray,U=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(n){return n()}};var Q,K={},$=R.react_stack_bottom_frame.bind(R,l)(),q=U(a(l)),ee={};B.Fragment=P,B.jsx=function(n,c,h){var y=1e4>I.recentlyCreatedOwnerStacks++;return g(n,c,h,!1,y?Error("react-stack-top-frame"):$,y?U(a(n)):q)},B.jsxs=function(n,c,h){var y=1e4>I.recentlyCreatedOwnerStacks++;return g(n,c,h,!0,y?Error("react-stack-top-frame"):$,y?U(a(n)):q)}})()),B}var ge;function Ae(){return ge||(ge=1,process.env.NODE_ENV==="production"?z.exports=ke():z.exports=je()),z.exports}var p=Ae();const we=d.createContext({licenceMapbox:"",licenseMuiX:""}),Ce=({children:e,licenseMuiX:t,licenceMapbox:r})=>{d.useEffect(()=>{t&&Te.LicenseInfo.setLicenseKey(t)},[t]);const a=d.useMemo(()=>({licenceMapbox:r,licenseMuiX:t}),[t,r]);return r&&(fe.accessToken=r),p.jsx(we.Provider,{value:a,children:e})},Le=e=>e?.type==="LineString"||e?.type==="MultiLineString",Oe=e=>{let t;Array.isArray(e[0][0])?t=e.reduce((o,l)=>l.length>o.length?l:o):t=e;const r=Math.floor(t.length/2);return[t[r][0],t[r][1]]},Pe=({route:e,children:t})=>{if(!(e&&t))return null;const r=e.geometry;if(!Le(r))return null;const a=r.coordinates,[o,l]=Oe(a);return p.jsx(C.Marker,{longitude:o,latitude:l,children:t})},Me=e=>A.isArray(e)?{features:e,type:"FeatureCollection"}:e.type==="FeatureCollection"?e:{features:[e],type:"FeatureCollection"},X=({features:e,lineLabel:t,lineStyle:r})=>{if(!e)return null;const a=Me(e),o=a.features.filter(s=>s.geometry.type==="Polygon"||s.geometry.type==="MultiPolygon"),l=a.features.filter(s=>s.geometry.type==="LineString"||s.geometry.type==="MultiLineString");return p.jsxs(p.Fragment,{children:[o.length>0&&p.jsx(C.Source,{id:"features-polygon",type:"geojson",data:{features:o,type:"FeatureCollection"},children:p.jsx(C.Layer,{id:"polygon-fill",type:"fill",paint:{"fill-color":["coalesce",["get","color"],"#4ADE80"],"fill-opacity":["coalesce",["get","opacity"],.4]}})}),l.length>0&&p.jsxs(p.Fragment,{children:[p.jsx(C.Source,{id:"features-line",type:"geojson",data:{features:l,type:"FeatureCollection"},children:p.jsx(C.Layer,{id:"line-stroke",type:"line",paint:{"line-color":r?.color??["coalesce",["get","color"],"#3B82F6"],"line-opacity":r?.opacity??["coalesce",["get","opacity"],.9],"line-width":r?.width??["coalesce",["get","width"],3]}})}),t&&l.map((s,u)=>p.jsx(Pe,{route:s,children:t},`label-${u}`))]})]})},Ne="#000000",Ie="#FFFFFF",te={default:"#009ba6",primary:"#3F83F8",secondary:"#9C27B0",success:"#4CAF50",warning:"#FF9800"},Fe=e=>e in te,De=({color:e,variant:t,type:r,size:a=28})=>{const o=O.useTheme(),l=o.palette.mode==="dark"?Ne:Ie,s=Math.max(3,Math.round(a*.25)),u=(()=>{if(r==="dropOff")return"#4e85e1";if(t&&Fe(t))return te[t];if(!e)return te.default;if(typeof e=="function")return e(o);if(A.isString(e)&&e.includes(".")){const[f,m]=e.split("."),g=o.palette[f];if(g&&typeof g=="object"&&m in g)return g[m]}return e})();return p.jsx(O.Box,{component:"div",style:{backgroundColor:l,border:`${s}px solid ${u}`,borderRadius:"50%",boxShadow:"0 0 4px rgba(0,0,0,0.3)",height:a,width:a}})},Ue=e=>({".mapboxgl-popup-close-button":{color:e.palette.mode==="dark"?"#fff !important":"#000 !important",fontSize:"20px !important"},".mapboxgl-popup-content":{backgroundColor:"transparent!important",borderRadius:"0px !important",boxShadow:"none!important",padding:"0px 0px!important",width:"fit-content!important"},".mapboxgl-popup-tip":{borderTopColor:`${e.palette.mode==="dark"?"#1e1e1e":"#ffffff"} !important`}}),me=e=>{if(A.isNumber(e))return e;if(A.isString(e)&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null},ne=e=>{const t=me(e);return t!==null&&t>=-90&&t<=90},re=e=>{const t=me(e);return t!==null&&t>=-180&&t<=180},Ye=e=>Array.isArray(e)&&e.length===2&&ne(e[0])&&re(e[1]),oe=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return(typeof t.id=="string"||typeof t.id=="number"||t.id===void 0)&&ne(t.lat)&&re(t.lng)},ye=e=>A.isString(e)||A.isNumber(e)?String(e):JSON.stringify(e),Be=e=>{if(!e)return[];const t=A.isArray(e)?e:e.type==="FeatureCollection"?e.features:[e],r=[];for(const a of t){const o=a.geometry;o.type==="Point"&&r.push(o.coordinates),o.type==="LineString"&&r.push(...o.coordinates),o.type==="Polygon"&&r.push(...o.coordinates[0])}return r},Ve=({markers:e=[],features:t,padding:r=50,duration:a=1e3,disableAnimation:o,fitBounds:l=!0,animationKey:s,openPopup:u})=>{const{current:f}=C.useMap(),m=d.useRef(""),g=d.useMemo(()=>e.filter(oe),[e]),x=d.useMemo(()=>Be(t),[t]),_=d.useMemo(()=>{const R=[...g.map(S=>[S.lng,S.lat]),...x];return R.length===0?null:R.reduce((S,[T,P])=>S.extend([T,P]),new fe.LngLatBounds)},[g,x]);return d.useEffect(()=>{if(u){m.current=s!==void 0?ye(s):"__initial_skip__";return}if(f&&l&&_){if(s!==void 0){const R=ye(s);if(m.current===R)return;m.current=R}else if(m.current==="__initial_skip__")return;if(!_.isEmpty()){if(g.length===1&&x.length===0){const R=g[0];f.flyTo({center:[R.lng,R.lat],duration:o?0:a,zoom:14});return}f.fitBounds([_.getSouthWest().toArray(),_.getNorthEast().toArray()],{duration:o?0:a,padding:r})}}},[f,_,r,a,o,s,l,g,x,u]),null},he=(e,t)=>{if(t<=0)throw new Error("chunkSize must be greater than 0");const r=[];for(let a=0;a<e.length;a+=t)r.push(e.slice(a,a+t));return r},Ge=(e,t)=>[e,...t.map(r=>r.coords)].map(r=>r.join(",")).join(";"),We=(e,t,r)=>{const a=t.map((s,u)=>{if(u===0||s==null)return null;const f=e[u-1];return f?{distance:s,id:f.id,point:f.coords}:null}).filter(s=>s!==null);if(a.length===0)return{all:[],nearest:null};const o=a.sort((s,u)=>s.distance-u.distance),l=o[0];return r&&l.distance>r?{all:o,nearest:null}:{all:o,nearest:l}};function be(e,t,r){return async(a,o,l,s)=>{const u=Ge(a,o),f=e(u,l),m=await t(f),g=m?r(m)?.[0]:void 0;return g?.length?We(o,g,s):{all:[],nearest:null}}}const Ee=async(e,t,r)=>{const a=Array.from({length:Math.ceil(e.length/t)},(l,s)=>e.slice(s*t,(s+1)*t));return(await Promise.all(a.map(async l=>Promise.all(l.map(r))))).flat()},Je="https://api.mapbox.com",se=(e,t,r,a,o={})=>{const l=new URLSearchParams({access_token:"",...o});return`${Je}/${e}/${t}/mapbox/${r}/${a}?${l.toString()}`},ae=async e=>{try{const t=await fetch(e);return t.ok?await t.json():(console.error(`Mapbox API error: ${t.status} ${t.statusText}`),null)}catch(t){return console.error("Mapbox network error:",t),null}},ze=25,Xe=5,Ze=be((e,t)=>se("directions-matrix","v1",t,e,{annotations:"distance",sources:"0"}),ae,e=>e.distances??void 0),Z={findNearest:async(e,t,r="driving",a)=>{if(!t.length)return[];const o=he(t,ze-1);return(await Ee(o,Xe,s=>Ze(e,s,r,a))).flatMap(s=>s.all).sort((s,u)=>s.distance-u.distance)},getIsochrone:async(e,t="driving",r=[5,10,15])=>{const a=`${e[0]},${e[1]}`,o=se("isochrone","v1",t,a,{contours_minutes:r.join(","),polygons:"true"});return await ae(o)},getItinerary:async(e,t,r="driving")=>{const a=`${e.join(",")};${t.join(",")}`,o=se("directions","v5",r,a,{geometries:"geojson",overview:"full"}),l=await ae(o);if(!l?.routes?.length)return null;const s=l.routes[0];return{geometry:s.geometry,properties:{distance:s.distance,duration:s.duration},type:"Feature"}}},He=({origin:e,profile:t="driving",intervals:r=[5,10,15],onIsochroneLoaded:a})=>{const[o,l]=d.useState(null);return d.useEffect(()=>{let s=!1;if(!e||e.length!==2){l(null);return}return(async()=>{if(!Z.getIsochrone){console.warn("⚠️ getIsochrone is not implemented for this provider.");return}const u=await Z.getIsochrone(e,t,r);s||(l(u),a?.(u??null))})(),()=>{s=!0}},[e,t,r,a]),o?p.jsx(X,{features:o}):null},Qe=d.memo(He),Ke={cycling:"routed-bike",driving:"routed-car",walking:"routed-foot"},$e="https://routing.openstreetmap.de",_e=(e,t,r,a)=>{const o=`${$e}/${Ke[t]}/${e}/v1/${t}/${r}`,l=a?`?${new URLSearchParams(a).toString()}`:"";return`${o}${l}`},Re=async e=>{try{const t=await fetch(e);return t.ok?await t.json():(console.error("OSRM API error:",t.status,t.statusText),null)}catch(t){return console.error("Error fetching OSRM API:",t),null}},qe=100,et=5,tt=be((e,t)=>_e("table",t,e,{annotations:"distance",sources:0}),Re,e=>e.distances??void 0),ve={findNearest:async(e,t,r="driving",a)=>{if(!t.length)return[];const o=he(t,qe-1);return(await Ee(o,et,s=>tt(e,s,r,a))).flatMap(s=>s.all).sort((s,u)=>s.distance-u.distance)},getItinerary:async(e,t,r="driving")=>{const a=`${e.join(",")};${t.join(",")}`,o=_e("route",r,a,{geometries:"geojson",overview:"full"}),l=await Re(o);if(!l?.routes?.length)return null;const s=l.routes[0];return{geometry:s.geometry,properties:{distance:s.distance,duration:s.duration},type:"Feature"}}},xe=({from:e,to:t,profile:r,engine:a,itineraryLineStyle:o,initialRoute:l,onRouteComputed:s,itineraryLabel:u})=>{const[f,m]=d.useState(l??null);return d.useEffect(()=>{l&&(m(l),s?.(l))},[l,s]),d.useEffect(()=>{!(e&&t)||l||(async()=>{const x=await(a==="OSRM"?ve:Z).getItinerary(e,t,r);m(x??null),s?.(x??null)})()},[e,t,r,a,l,s]),f?p.jsx(X,{features:f,lineStyle:o,lineLabel:u}):null},nt=({origin:e,maxDistanceMeters:t,destinations:r,onNearestFound:a,initialNearestResults:o,itineraryLineStyle:l,profile:s="driving",engine:u="OSRM"})=>{const[f,m]=d.useState(o??[]),g=d.useRef(null);d.useEffect(()=>{o&&m(o)},[o]),d.useEffect(()=>{const _=new AbortController;if(o?.length)return;if(!e||e.length!==2||!r?.length){m([]);return}m([]);const R=r.map(T=>({coords:[T.lng,T.lat],id:T.id}));return(u==="OSRM"?ve:Z).findNearest(e,R,s,t).then(T=>m(T??[])).catch(()=>m([])),()=>_.abort()},[e,t,r,s,u,o?.length]),d.useEffect(()=>{const _=g.current;(!_||_.length!==f.length||_.some((S,T)=>S.id!==f[T]?.id||S.distance!==f[T]?.distance))&&(a?.(f),g.current=f)},[f,a]);const x=f[0];return x?x.routeFeature?p.jsx(X,{features:x.routeFeature}):p.jsx(xe,{from:e,to:x.point,profile:s,engine:u,itineraryLineStyle:l}):null},rt=d.memo(nt),le={satellite:"mapbox://styles/mapbox/satellite-streets-v12",street:{dark:"mapbox://styles/mapbox/dark-v11",light:"mapbox://styles/mapbox/streets-v12"}},Se=(e,t)=>{const r=t==="dark";switch(e){case"satellite":return le.satellite;default:return r?le.street.dark:le.street.light}},ot=({mapStyle:e,theme:t,baseMapView:r,doubleClickZoom:a,cooperativeGestures:o})=>({cooperativeGestures:o,doubleClickZoom:a,failIfMajorPerformanceCaveat:!1,style:e??Se(r,t)}),st=({containerStyle:e,square:t,loading:r,height:a=300,width:o="100%",center:l=[2.3522,48.8566],zoom:s=5,popupMaxWidth:u,openPopup:f,openPopupOnHover:m,markers:g=[],fitBounds:x=!0,fitBoundsPadding:_,fitBoundDuration:R,fitBoundsAnimationKey:S,disableAnimation:T,mapStyle:P,onMapClick:H,baseMapView:V,cooperativeGestures:ce=!0,doubleClickZoom:ie=!0,projection:ue,theme:G,features:W,itineraryParams:j,findNearestMarker:k,isochrone:M})=>{const J=O.useTheme(),I=d.useRef(null),[F,D]=d.useState(f??null),[U,Q]=d.useState(!1),K=d.useMemo(()=>{const[i=2.3522,v=48.8566]=A.isArray(l)?l:[];return{latitude:v,longitude:i,zoom:s}},[l,s]),$=d.useMemo(()=>P||Se(V,G??J.palette.mode),[V,P,G,J.palette.mode]),{style:q,cooperativeGestures:ee,doubleClickZoom:n}=ot({baseMapView:V,cooperativeGestures:ce,doubleClickZoom:ie,mapStyle:$,theme:G??J.palette.mode}),c=(i,v)=>{!m&&v&&D(i)},h=(i,v)=>{m&&D(v?i:null)};d.useEffect(()=>{D(f??null)},[f]);const y=d.useMemo(()=>F?g?.find(i=>i.id===F)??null:null,[F,g]);return p.jsxs(O.Box,{"data-testid":"mapbox-container",sx:{borderRadius:t?0:6,height:a,overflow:"hidden",position:"relative",width:o,...e},children:[p.jsx(O.GlobalStyles,{styles:Ue}),r&&p.jsx(O.Skeleton,{"data-testid":"skeleton-loader",width:o,height:a,variant:t?"rectangular":"rounded",sx:{inset:0,position:"absolute",zIndex:2}}),!r&&p.jsxs(C,{ref:I,cooperativeGestures:ee,doubleClickZoom:n,mapStyle:q,projection:ue,onLoad:()=>{Q(!0),I.current?.resize()},initialViewState:K,style:{height:"100%",width:"100%"},mapboxAccessToken:void 0,onClick:i=>{const v=g.find(b=>{const{lng:w,lat:N}=i.lngLat,L=Math.abs(Number(b.lng??0)-w),ut=Math.abs(Number(b.lat??0)-N);return L<.01&&ut<.01});H?.(i.lngLat.lng,i.lngLat.lat,v??null)},children:[U&&g.filter(oe).map(i=>{const v=typeof i.size=="number"?i.size:void 0,b=(()=>{if(!i.IconComponent)return null;const L={...i.iconProps};return v&&(L.width=v,L.height=v),p.jsx(i.IconComponent,{...L})})(),w=i.IconComponent?null:p.jsx(De,{color:i.color,variant:i.variant,size:v,type:i.type}),N={alignItems:"center",cursor:i.Tooltip?"pointer":"default",display:"inline-flex",justifyContent:"center",...i.IconComponent&&!v?{}:v?{height:v,width:v}:{}};return p.jsx(C.Marker,{longitude:i.lng,latitude:i.lat,anchor:"center",onClick:L=>{L.originalEvent.stopPropagation(),i.id&&c(i.id,!!i.Tooltip),H?.(i.lng,i.lat,i)},children:p.jsx(O.Box,{component:"div",onMouseEnter:()=>i.id&&h(i.id,!!i.Tooltip),onMouseLeave:()=>h(null),style:N,children:b||w})},i.id)}),U&&y?.Tooltip&&p.jsx(C.Popup,{longitude:A.isNumber(y.lng)?y.lng:0,latitude:A.isNumber(y.lat)?y.lat:0,anchor:"top",onClose:()=>D(null),maxWidth:u,closeOnClick:!0,closeOnMove:!1,children:p.jsx(O.Box,{component:"div",sx:{minHeight:60,minWidth:240},children:y.Tooltip})}),j&&p.jsx(xe,{from:j.from,to:j.to,profile:j.profile,engine:j.engine,itineraryLineStyle:j.itineraryLineStyle,initialRoute:j.initialRoute,onRouteComputed:j.onRouteComputed,itineraryLabel:j.itineraryLabel}),k&&p.jsx(rt,{origin:k.origin,destinations:k.destinations,onNearestFound:k.onNearestFound,maxDistanceMeters:k.maxDistanceMeters,engine:k.engine,profile:k.profile,initialNearestResults:k.initialNearestResults,itineraryLineStyle:k.itineraryLineStyle}),M&&p.jsx(Qe,{origin:M.origin,profile:M.profile,onIsochroneLoaded:M.onIsochroneLoaded,intervals:M.intervals}),W&&p.jsx(X,{features:W}),x&&p.jsx(Ve,{markers:g,features:W,padding:_,duration:T?0:R,animationKey:S,openPopup:!!f})]})]})},at=d.memo(st),lt=["OSRM","Mapbox"],ct=["driving","walking","cycling"],it=(e,t)=>{const r="geometry"in t?t.geometry:t,[a,o]=e,l=s=>s.map(u=>u.reduce((f,[m,g],x,_)=>{const[R,S]=_[(x-1+_.length)%_.length];return g>o!=S>o&&a<(R-m)*(o-g)/(S-g)+m?!f:f},!1)).reduce((u,f,m)=>m===0?f:u&&!f,!1);return r.type==="Polygon"?l(r.coordinates):r.type==="MultiPolygon"?r.coordinates.some(s=>l(s)):!1};E.DEFAULT_CENTER_LAT=46.8677,E.DEFAULT_CENTER_LNG=2.333,E.MapProvider=Ce,E.MapView=at,E.engines=lt,E.isPointInGeoJSON=it,E.isValidLatLngTuple=Ye,E.isValidLatitude=ne,E.isValidLongitude=re,E.isValidMarker=oe,E.profiles=ct,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED