@tracktor/map 1.8.3 → 1.8.5
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/components/Markers/Markers.d.ts +2 -1
- package/dist/main.js +95 -93
- package/dist/main.umd.cjs +2 -2
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ interface MarkerProps {
|
|
|
13
13
|
variant?: string | keyof typeof variantMarkerColor;
|
|
14
14
|
color?: ThemeColor;
|
|
15
15
|
size?: number;
|
|
16
|
+
type?: string;
|
|
16
17
|
}
|
|
17
|
-
declare const Markers: ({ color, variant, size }: MarkerProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
declare const Markers: ({ color, variant, type, size }: MarkerProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
19
|
export default Markers;
|
package/dist/main.js
CHANGED
|
@@ -106,11 +106,11 @@ function Ve() {
|
|
|
106
106
|
}
|
|
107
107
|
if (c) {
|
|
108
108
|
c = console;
|
|
109
|
-
var y = c.error,
|
|
109
|
+
var y = c.error, m = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
|
|
110
110
|
return y.call(
|
|
111
111
|
c,
|
|
112
112
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
113
|
-
|
|
113
|
+
m
|
|
114
114
|
), t(r);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -157,14 +157,14 @@ function Ve() {
|
|
|
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
|
-
function
|
|
160
|
+
function g(r, c, y, m, i, v) {
|
|
161
161
|
var h = y.ref;
|
|
162
162
|
return r = {
|
|
163
163
|
$$typeof: E,
|
|
164
164
|
type: r,
|
|
165
165
|
key: c,
|
|
166
166
|
props: y,
|
|
167
|
-
_owner:
|
|
167
|
+
_owner: m
|
|
168
168
|
}, (h !== void 0 ? h : null) !== null ? Object.defineProperty(r, "ref", {
|
|
169
169
|
enumerable: !1,
|
|
170
170
|
get: d
|
|
@@ -190,13 +190,13 @@ function Ve() {
|
|
|
190
190
|
value: v
|
|
191
191
|
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function p(r, c, y, m, i, v) {
|
|
194
194
|
var h = c.children;
|
|
195
195
|
if (h !== void 0)
|
|
196
|
-
if (
|
|
196
|
+
if (m)
|
|
197
197
|
if (I(h)) {
|
|
198
|
-
for (
|
|
199
|
-
_(h[
|
|
198
|
+
for (m = 0; m < h.length; m++)
|
|
199
|
+
_(h[m]);
|
|
200
200
|
Object.freeze && Object.freeze(h);
|
|
201
201
|
} else
|
|
202
202
|
console.error(
|
|
@@ -208,18 +208,18 @@ function Ve() {
|
|
|
208
208
|
var j = Object.keys(c).filter(function(k) {
|
|
209
209
|
return k !== "key";
|
|
210
210
|
});
|
|
211
|
-
|
|
211
|
+
m = 0 < j.length ? "{key: someKey, " + j.join(": ..., ") + ": ...}" : "{key: someKey}", X[h + m] || (j = 0 < j.length ? "{" + j.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
212
212
|
`A props object containing a "key" prop is being spread into JSX:
|
|
213
213
|
let props = %s;
|
|
214
214
|
<%s {...props} />
|
|
215
215
|
React keys must be passed directly to JSX without using spread:
|
|
216
216
|
let props = %s;
|
|
217
217
|
<%s key={someKey} {...props} />`,
|
|
218
|
-
|
|
218
|
+
m,
|
|
219
219
|
h,
|
|
220
220
|
j,
|
|
221
221
|
h
|
|
222
|
-
), X[h +
|
|
222
|
+
), X[h + m] = !0);
|
|
223
223
|
}
|
|
224
224
|
if (h = null, y !== void 0 && (n(y), h = "" + y), s(c) && (n(c.key), h = "" + c.key), "key" in c) {
|
|
225
225
|
y = {};
|
|
@@ -229,7 +229,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
229
229
|
return h && u(
|
|
230
230
|
y,
|
|
231
231
|
typeof r == "function" ? r.displayName || r.name || "Unknown" : r
|
|
232
|
-
),
|
|
232
|
+
), g(
|
|
233
233
|
r,
|
|
234
234
|
h,
|
|
235
235
|
y,
|
|
@@ -257,24 +257,24 @@ React keys must be passed directly to JSX without using spread:
|
|
|
257
257
|
l
|
|
258
258
|
)(), J = $(a(l)), X = {};
|
|
259
259
|
B.Fragment = C, B.jsx = function(r, c, y) {
|
|
260
|
-
var
|
|
261
|
-
return
|
|
260
|
+
var m = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
261
|
+
return p(
|
|
262
262
|
r,
|
|
263
263
|
c,
|
|
264
264
|
y,
|
|
265
265
|
!1,
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
m ? Error("react-stack-top-frame") : z,
|
|
267
|
+
m ? $(a(r)) : J
|
|
268
268
|
);
|
|
269
269
|
}, B.jsxs = function(r, c, y) {
|
|
270
|
-
var
|
|
271
|
-
return
|
|
270
|
+
var m = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
271
|
+
return p(
|
|
272
272
|
r,
|
|
273
273
|
c,
|
|
274
274
|
y,
|
|
275
275
|
!0,
|
|
276
|
-
|
|
277
|
-
|
|
276
|
+
m ? Error("react-stack-top-frame") : z,
|
|
277
|
+
m ? $(a(r)) : J
|
|
278
278
|
);
|
|
279
279
|
};
|
|
280
280
|
})()), B;
|
|
@@ -283,7 +283,7 @@ var ye;
|
|
|
283
283
|
function We() {
|
|
284
284
|
return ye || (ye = 1, process.env.NODE_ENV === "production" ? Z.exports = Be() : Z.exports = Ve()), Z.exports;
|
|
285
285
|
}
|
|
286
|
-
var
|
|
286
|
+
var f = We();
|
|
287
287
|
const Ge = Ie({
|
|
288
288
|
licenceMapbox: "",
|
|
289
289
|
licenseMuiX: ""
|
|
@@ -298,7 +298,7 @@ const Ge = Ie({
|
|
|
298
298
|
}),
|
|
299
299
|
[t, n]
|
|
300
300
|
);
|
|
301
|
-
return n && (be.accessToken = n), /* @__PURE__ */
|
|
301
|
+
return n && (be.accessToken = n), /* @__PURE__ */ f.jsx(Ge.Provider, { value: a, children: e });
|
|
302
302
|
}, qe = (e) => e?.type === "LineString" || e?.type === "MultiLineString", ze = (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;
|
|
@@ -311,14 +311,14 @@ const Ge = Ie({
|
|
|
311
311
|
if (!qe(n))
|
|
312
312
|
return null;
|
|
313
313
|
const a = n.coordinates, [o, l] = ze(a);
|
|
314
|
-
return /* @__PURE__ */
|
|
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)
|
|
317
317
|
return null;
|
|
318
318
|
const a = Xe(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");
|
|
319
|
-
return /* @__PURE__ */
|
|
319
|
+
return /* @__PURE__ */ f.jsxs(f.Fragment, { children: [
|
|
320
320
|
o.length > 0 && // biome-ignore lint/correctness/useUniqueElementIds: <ID must stay stable for map layer>
|
|
321
|
-
/* @__PURE__ */
|
|
321
|
+
/* @__PURE__ */ f.jsx(fe, { id: "features-polygon", type: "geojson", data: { features: o, type: "FeatureCollection" }, children: /* @__PURE__ */ f.jsx(
|
|
322
322
|
pe,
|
|
323
323
|
{
|
|
324
324
|
id: "polygon-fill",
|
|
@@ -329,8 +329,8 @@ const Ge = Ie({
|
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
) }),
|
|
332
|
-
l.length > 0 && /* @__PURE__ */
|
|
333
|
-
/* @__PURE__ */
|
|
332
|
+
l.length > 0 && /* @__PURE__ */ f.jsxs(f.Fragment, { children: [
|
|
333
|
+
/* @__PURE__ */ f.jsx(fe, { id: "features-line", type: "geojson", data: { features: l, type: "FeatureCollection" }, children: /* @__PURE__ */ f.jsx(
|
|
334
334
|
pe,
|
|
335
335
|
{
|
|
336
336
|
id: "line-stroke",
|
|
@@ -342,7 +342,7 @@ const Ge = Ie({
|
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
) }),
|
|
345
|
-
t && l.map((s, u) => /* @__PURE__ */
|
|
345
|
+
t && l.map((s, u) => /* @__PURE__ */ f.jsx(Je, { route: s, children: t }, `label-${u}`))
|
|
346
346
|
] })
|
|
347
347
|
] });
|
|
348
348
|
}, Ze = "#000000", He = "#FFFFFF", se = {
|
|
@@ -351,32 +351,34 @@ const Ge = Ie({
|
|
|
351
351
|
secondary: "#9C27B0",
|
|
352
352
|
success: "#4CAF50",
|
|
353
353
|
warning: "#FF9800"
|
|
354
|
-
}, Qe = (e) => e in se, Ke = ({ color: e, variant: t,
|
|
355
|
-
const
|
|
354
|
+
}, Qe = (e) => e in se, Ke = ({ color: e, variant: t, type: n, size: a = 28 }) => {
|
|
355
|
+
const o = xe(), l = o.palette.mode === "dark" ? Ze : He, s = Math.max(3, Math.round(a * 0.25)), u = (() => {
|
|
356
|
+
if (n === "dropOff")
|
|
357
|
+
return "#4e85e1";
|
|
356
358
|
if (t && Qe(t))
|
|
357
359
|
return se[t];
|
|
358
360
|
if (!e)
|
|
359
361
|
return se.default;
|
|
360
362
|
if (typeof e == "function")
|
|
361
|
-
return e(
|
|
363
|
+
return e(o);
|
|
362
364
|
if (ie(e) && e.includes(".")) {
|
|
363
|
-
const [
|
|
364
|
-
if (
|
|
365
|
-
return
|
|
365
|
+
const [d, g] = e.split("."), p = o.palette[d];
|
|
366
|
+
if (p && typeof p == "object" && g in p)
|
|
367
|
+
return p[g];
|
|
366
368
|
}
|
|
367
369
|
return e;
|
|
368
370
|
})();
|
|
369
|
-
return /* @__PURE__ */
|
|
371
|
+
return /* @__PURE__ */ f.jsx(
|
|
370
372
|
H,
|
|
371
373
|
{
|
|
372
374
|
component: "div",
|
|
373
375
|
style: {
|
|
374
|
-
backgroundColor:
|
|
375
|
-
border: `${
|
|
376
|
+
backgroundColor: l,
|
|
377
|
+
border: `${s}px solid ${u}`,
|
|
376
378
|
borderRadius: "50%",
|
|
377
379
|
boxShadow: "0 0 4px rgba(0,0,0,0.3)",
|
|
378
|
-
height:
|
|
379
|
-
width:
|
|
380
|
+
height: a,
|
|
381
|
+
width: a
|
|
380
382
|
}
|
|
381
383
|
}
|
|
382
384
|
);
|
|
@@ -433,26 +435,26 @@ const Ge = Ie({
|
|
|
433
435
|
animationKey: s,
|
|
434
436
|
openPopup: u
|
|
435
437
|
}) => {
|
|
436
|
-
const { current: d } = Ue(),
|
|
437
|
-
const x = [...
|
|
438
|
+
const { current: d } = Ue(), g = ae(""), p = M(() => e.filter(Se), [e]), _ = M(() => tt(t), [t]), b = M(() => {
|
|
439
|
+
const x = [...p.map((E) => [E.lng, E.lat]), ..._];
|
|
438
440
|
return x.length === 0 ? null : x.reduce((E, [R, C]) => E.extend([R, C]), new be.LngLatBounds());
|
|
439
|
-
}, [
|
|
441
|
+
}, [p, _]);
|
|
440
442
|
return w(() => {
|
|
441
443
|
if (u) {
|
|
442
|
-
|
|
444
|
+
g.current = s !== void 0 ? he(s) : "__initial_skip__";
|
|
443
445
|
return;
|
|
444
446
|
}
|
|
445
447
|
if (d && l && b) {
|
|
446
448
|
if (s !== void 0) {
|
|
447
449
|
const x = he(s);
|
|
448
|
-
if (
|
|
450
|
+
if (g.current === x)
|
|
449
451
|
return;
|
|
450
|
-
|
|
451
|
-
} else if (
|
|
452
|
+
g.current = x;
|
|
453
|
+
} else if (g.current === "__initial_skip__")
|
|
452
454
|
return;
|
|
453
455
|
if (!b.isEmpty()) {
|
|
454
|
-
if (
|
|
455
|
-
const x =
|
|
456
|
+
if (p.length === 1 && _.length === 0) {
|
|
457
|
+
const x = p[0];
|
|
456
458
|
d.flyTo({
|
|
457
459
|
center: [x.lng, x.lat],
|
|
458
460
|
duration: o ? 0 : a,
|
|
@@ -466,7 +468,7 @@ const Ge = Ie({
|
|
|
466
468
|
});
|
|
467
469
|
}
|
|
468
470
|
}
|
|
469
|
-
}, [d, b, n, a, o, s, l,
|
|
471
|
+
}, [d, b, n, a, o, s, l, p, _, u]), null;
|
|
470
472
|
}, Te = (e, t) => {
|
|
471
473
|
if (t <= 0)
|
|
472
474
|
throw new Error("chunkSize must be greater than 0");
|
|
@@ -488,8 +490,8 @@ const Ge = Ie({
|
|
|
488
490
|
};
|
|
489
491
|
function je(e, t, n) {
|
|
490
492
|
return async (a, o, l, s) => {
|
|
491
|
-
const u = nt(a, o), d = e(u, l),
|
|
492
|
-
return
|
|
493
|
+
const u = nt(a, o), d = e(u, l), g = await t(d), p = g ? n(g)?.[0] : void 0;
|
|
494
|
+
return p?.length ? ot(o, p, s) : { all: [], nearest: null };
|
|
493
495
|
};
|
|
494
496
|
}
|
|
495
497
|
const ke = async (e, t, n) => {
|
|
@@ -564,7 +566,7 @@ const ke = async (e, t, n) => {
|
|
|
564
566
|
})(), () => {
|
|
565
567
|
s = !0;
|
|
566
568
|
};
|
|
567
|
-
}, [e, t, n, a]), o ? /* @__PURE__ */
|
|
569
|
+
}, [e, t, n, a]), o ? /* @__PURE__ */ f.jsx(ee, { features: o }) : null;
|
|
568
570
|
}, mt = le(gt), yt = {
|
|
569
571
|
cycling: "routed-bike",
|
|
570
572
|
driving: "routed-car",
|
|
@@ -615,15 +617,15 @@ const ke = async (e, t, n) => {
|
|
|
615
617
|
findNearest: Et,
|
|
616
618
|
getItinerary: Rt
|
|
617
619
|
}, Oe = ({ from: e, to: t, profile: n, engine: a, itineraryLineStyle: o, initialRoute: l, onRouteComputed: s, itineraryLabel: u }) => {
|
|
618
|
-
const [d,
|
|
620
|
+
const [d, g] = V(l ?? null);
|
|
619
621
|
return w(() => {
|
|
620
|
-
l && (
|
|
622
|
+
l && (g(l), s?.(l));
|
|
621
623
|
}, [l, s]), w(() => {
|
|
622
624
|
!(e && t) || l || (async () => {
|
|
623
625
|
const _ = await (a === "OSRM" ? Ae : K).getItinerary(e, t, n);
|
|
624
|
-
|
|
626
|
+
g(_ ?? null), s?.(_ ?? null);
|
|
625
627
|
})();
|
|
626
|
-
}, [e, t, n, a, l, s]), d ? /* @__PURE__ */
|
|
628
|
+
}, [e, t, n, a, l, s]), d ? /* @__PURE__ */ f.jsx(ee, { features: d, lineStyle: o, lineLabel: u }) : null;
|
|
627
629
|
}, St = ({
|
|
628
630
|
origin: e,
|
|
629
631
|
maxDistanceMeters: t,
|
|
@@ -634,28 +636,28 @@ const ke = async (e, t, n) => {
|
|
|
634
636
|
profile: s = "driving",
|
|
635
637
|
engine: u = "OSRM"
|
|
636
638
|
}) => {
|
|
637
|
-
const [d,
|
|
639
|
+
const [d, g] = V(o ?? []), p = ae(null);
|
|
638
640
|
w(() => {
|
|
639
|
-
o &&
|
|
641
|
+
o && g(o);
|
|
640
642
|
}, [o]), w(() => {
|
|
641
643
|
const b = new AbortController();
|
|
642
644
|
if (o?.length) return;
|
|
643
645
|
if (!e || e.length !== 2 || !n?.length) {
|
|
644
|
-
|
|
646
|
+
g([]);
|
|
645
647
|
return;
|
|
646
648
|
}
|
|
647
|
-
|
|
649
|
+
g([]);
|
|
648
650
|
const x = n.map((R) => ({
|
|
649
651
|
coords: [R.lng, R.lat],
|
|
650
652
|
id: R.id
|
|
651
653
|
}));
|
|
652
|
-
return (u === "OSRM" ? Ae : K).findNearest(e, x, s, t).then((R) =>
|
|
654
|
+
return (u === "OSRM" ? Ae : K).findNearest(e, x, s, t).then((R) => g(R ?? [])).catch(() => g([])), () => b.abort();
|
|
653
655
|
}, [e, t, n, s, u, o?.length]), w(() => {
|
|
654
|
-
const b =
|
|
655
|
-
(!b || b.length !== d.length || b.some((E, R) => E.id !== d[R]?.id || E.distance !== d[R]?.distance)) && (a?.(d),
|
|
656
|
+
const b = p.current;
|
|
657
|
+
(!b || b.length !== d.length || b.some((E, R) => E.id !== d[R]?.id || E.distance !== d[R]?.distance)) && (a?.(d), p.current = d);
|
|
656
658
|
}, [d, a]);
|
|
657
659
|
const _ = d[0];
|
|
658
|
-
return _ ? _.routeFeature ? /* @__PURE__ */
|
|
660
|
+
return _ ? _.routeFeature ? /* @__PURE__ */ f.jsx(ee, { features: _.routeFeature }) : /* @__PURE__ */ f.jsx(Oe, { from: e, to: _.point, profile: s, engine: u, itineraryLineStyle: l }) : null;
|
|
659
661
|
}, Tt = le(St), oe = {
|
|
660
662
|
satellite: "mapbox://styles/mapbox/satellite-streets-v12",
|
|
661
663
|
street: {
|
|
@@ -691,8 +693,8 @@ const ke = async (e, t, n) => {
|
|
|
691
693
|
zoom: s = 5,
|
|
692
694
|
popupMaxWidth: u,
|
|
693
695
|
openPopup: d,
|
|
694
|
-
openPopupOnHover:
|
|
695
|
-
markers:
|
|
696
|
+
openPopupOnHover: g,
|
|
697
|
+
markers: p = [],
|
|
696
698
|
fitBounds: _ = !0,
|
|
697
699
|
fitBoundsPadding: b,
|
|
698
700
|
fitBoundDuration: x,
|
|
@@ -727,17 +729,17 @@ const ke = async (e, t, n) => {
|
|
|
727
729
|
mapStyle: z,
|
|
728
730
|
theme: N ?? U.palette.mode
|
|
729
731
|
}), c = (i, v) => {
|
|
730
|
-
!
|
|
732
|
+
!g && v && I(i);
|
|
731
733
|
}, y = (i, v) => {
|
|
732
|
-
|
|
734
|
+
g && I(v ? i : null);
|
|
733
735
|
};
|
|
734
736
|
w(() => {
|
|
735
737
|
I(d ?? null);
|
|
736
738
|
}, [d]);
|
|
737
|
-
const
|
|
738
|
-
return /* @__PURE__ */
|
|
739
|
-
/* @__PURE__ */
|
|
740
|
-
n && /* @__PURE__ */
|
|
739
|
+
const m = M(() => L ? p?.find((i) => i.id === L) ?? null : null, [L, p]);
|
|
740
|
+
return /* @__PURE__ */ f.jsxs(H, { "data-testid": "mapbox-container", sx: { height: a, position: "relative", width: o, ...e }, children: [
|
|
741
|
+
/* @__PURE__ */ f.jsx(Fe, { styles: et }),
|
|
742
|
+
n && /* @__PURE__ */ f.jsx(
|
|
741
743
|
Ne,
|
|
742
744
|
{
|
|
743
745
|
"data-testid": "skeleton-loader",
|
|
@@ -751,7 +753,7 @@ const ke = async (e, t, n) => {
|
|
|
751
753
|
}
|
|
752
754
|
}
|
|
753
755
|
),
|
|
754
|
-
!n && /* @__PURE__ */
|
|
756
|
+
!n && /* @__PURE__ */ f.jsxs(
|
|
755
757
|
De,
|
|
756
758
|
{
|
|
757
759
|
ref: P,
|
|
@@ -766,36 +768,36 @@ const ke = async (e, t, n) => {
|
|
|
766
768
|
style: { height: "100%", width: "100%" },
|
|
767
769
|
mapboxAccessToken: void 0,
|
|
768
770
|
onClick: (i) => {
|
|
769
|
-
const v =
|
|
771
|
+
const v = p.find((h) => {
|
|
770
772
|
const { lng: j, lat: O } = i.lngLat, k = Math.abs(Number(h.lng ?? 0) - j), Pe = Math.abs(Number(h.lat ?? 0) - O);
|
|
771
773
|
return k < 0.01 && Pe < 0.01;
|
|
772
774
|
});
|
|
773
775
|
W?.(i.lngLat.lng, i.lngLat.lat, v ?? null);
|
|
774
776
|
},
|
|
775
777
|
children: [
|
|
776
|
-
$ &&
|
|
778
|
+
$ && p.filter(Se).map((i) => {
|
|
777
779
|
const v = typeof i.size == "number" ? i.size : void 0, h = (() => {
|
|
778
780
|
if (!i.IconComponent)
|
|
779
781
|
return null;
|
|
780
782
|
const k = { ...i.iconProps };
|
|
781
|
-
return v && (k.width = v, k.height = v), /* @__PURE__ */
|
|
782
|
-
})(), j = i.IconComponent ? null : /* @__PURE__ */
|
|
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 = {
|
|
783
785
|
alignItems: "center",
|
|
784
786
|
cursor: i.Tooltip ? "pointer" : "default",
|
|
785
787
|
display: "inline-flex",
|
|
786
788
|
justifyContent: "center",
|
|
787
789
|
...i.IconComponent && !v ? {} : v ? { height: v, width: v } : {}
|
|
788
790
|
};
|
|
789
|
-
return /* @__PURE__ */
|
|
791
|
+
return /* @__PURE__ */ f.jsx(
|
|
790
792
|
ve,
|
|
791
793
|
{
|
|
792
794
|
longitude: i.lng,
|
|
793
795
|
latitude: i.lat,
|
|
794
|
-
anchor: "
|
|
796
|
+
anchor: "center",
|
|
795
797
|
onClick: (k) => {
|
|
796
798
|
k.originalEvent.stopPropagation(), i.id && c(i.id, !!i.Tooltip), W?.(i.lng, i.lat, i);
|
|
797
799
|
},
|
|
798
|
-
children: /* @__PURE__ */
|
|
800
|
+
children: /* @__PURE__ */ f.jsx(
|
|
799
801
|
H,
|
|
800
802
|
{
|
|
801
803
|
component: "div",
|
|
@@ -809,20 +811,20 @@ const ke = async (e, t, n) => {
|
|
|
809
811
|
i.id
|
|
810
812
|
);
|
|
811
813
|
}),
|
|
812
|
-
$ &&
|
|
814
|
+
$ && m?.Tooltip && /* @__PURE__ */ f.jsx(
|
|
813
815
|
Ye,
|
|
814
816
|
{
|
|
815
|
-
longitude: Q(
|
|
816
|
-
latitude: Q(
|
|
817
|
+
longitude: Q(m.lng) ? m.lng : 0,
|
|
818
|
+
latitude: Q(m.lat) ? m.lat : 0,
|
|
817
819
|
anchor: "top",
|
|
818
820
|
onClose: () => I(null),
|
|
819
821
|
maxWidth: u,
|
|
820
822
|
closeOnClick: !0,
|
|
821
823
|
closeOnMove: !1,
|
|
822
|
-
children: /* @__PURE__ */
|
|
824
|
+
children: /* @__PURE__ */ f.jsx(H, { component: "div", sx: { minHeight: 60, minWidth: 240 }, children: m.Tooltip })
|
|
823
825
|
}
|
|
824
826
|
),
|
|
825
|
-
T && /* @__PURE__ */
|
|
827
|
+
T && /* @__PURE__ */ f.jsx(
|
|
826
828
|
Oe,
|
|
827
829
|
{
|
|
828
830
|
from: T.from,
|
|
@@ -835,7 +837,7 @@ const ke = async (e, t, n) => {
|
|
|
835
837
|
itineraryLabel: T.itineraryLabel
|
|
836
838
|
}
|
|
837
839
|
),
|
|
838
|
-
S && /* @__PURE__ */
|
|
840
|
+
S && /* @__PURE__ */ f.jsx(
|
|
839
841
|
Tt,
|
|
840
842
|
{
|
|
841
843
|
origin: S.origin,
|
|
@@ -848,7 +850,7 @@ const ke = async (e, t, n) => {
|
|
|
848
850
|
itineraryLineStyle: S.itineraryLineStyle
|
|
849
851
|
}
|
|
850
852
|
),
|
|
851
|
-
A && /* @__PURE__ */
|
|
853
|
+
A && /* @__PURE__ */ f.jsx(
|
|
852
854
|
mt,
|
|
853
855
|
{
|
|
854
856
|
origin: A.origin,
|
|
@@ -857,11 +859,11 @@ const ke = async (e, t, n) => {
|
|
|
857
859
|
intervals: A.intervals
|
|
858
860
|
}
|
|
859
861
|
),
|
|
860
|
-
D && /* @__PURE__ */
|
|
861
|
-
_ && /* @__PURE__ */
|
|
862
|
+
D && /* @__PURE__ */ f.jsx(ee, { features: D }),
|
|
863
|
+
_ && /* @__PURE__ */ f.jsx(
|
|
862
864
|
rt,
|
|
863
865
|
{
|
|
864
|
-
markers:
|
|
866
|
+
markers: p,
|
|
865
867
|
features: D,
|
|
866
868
|
padding: b,
|
|
867
869
|
duration: R ? 0 : x,
|
|
@@ -875,11 +877,11 @@ const ke = async (e, t, n) => {
|
|
|
875
877
|
] });
|
|
876
878
|
}, Nt = le(kt), Dt = ["OSRM", "Mapbox"], Ut = ["driving", "walking", "cycling"], Yt = (e, t) => {
|
|
877
879
|
const n = "geometry" in t ? t.geometry : t, [a, o] = e, l = (s) => s.map(
|
|
878
|
-
(u) => u.reduce((d, [
|
|
880
|
+
(u) => u.reduce((d, [g, p], _, b) => {
|
|
879
881
|
const [x, E] = b[(_ - 1 + b.length) % b.length];
|
|
880
|
-
return
|
|
882
|
+
return p > o != E > o && a < (x - g) * (o - p) / (E - p) + g ? !d : d;
|
|
881
883
|
}, !1)
|
|
882
|
-
).reduce((u, d,
|
|
884
|
+
).reduce((u, d, g) => g === 0 ? d : u && !d, !1);
|
|
883
885
|
return n.type === "Polygon" ? l(n.coordinates) : n.type === "MultiPolygon" ? n.coordinates.some((s) => l(s)) : !1;
|
|
884
886
|
};
|
|
885
887
|
export {
|
package/dist/main.umd.cjs
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
*
|
|
16
16
|
* This source code is licensed under the MIT license found in the
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/var pe;function je(){return pe||(pe=1,process.env.NODE_ENV!=="production"&&(function(){function e(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===J?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case P:return"Fragment";case V:return"Profiler";case H:return"StrictMode";case G:return"Suspense";case W:return"SuspenseList";case M:return"Activity"}if(typeof n=="object")switch(typeof n.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),n.$$typeof){case T:return"Portal";case ie:return n.displayName||"Context";case ce:return(n._context.displayName||"Context")+".Consumer";case ue:var c=n.render;return n=n.displayName,n||(n=c.displayName||c.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case j:return c=n.displayName||null,c!==null?c:e(n.type)||"Memo";case k:c=n._payload,n=n._init;try{return e(n(c))}catch{}}return null}function t(n){return""+n}function r(n){try{t(n);var c=!1}catch{c=!0}if(c){c=console;var h=c.error,
|
|
18
|
+
*/var pe;function je(){return pe||(pe=1,process.env.NODE_ENV!=="production"&&(function(){function e(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===J?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case P:return"Fragment";case V:return"Profiler";case H:return"StrictMode";case G:return"Suspense";case W:return"SuspenseList";case M:return"Activity"}if(typeof n=="object")switch(typeof n.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),n.$$typeof){case T:return"Portal";case ie:return n.displayName||"Context";case ce:return(n._context.displayName||"Context")+".Consumer";case ue:var c=n.render;return n=n.displayName,n||(n=c.displayName||c.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case j:return c=n.displayName||null,c!==null?c:e(n.type)||"Memo";case k:c=n._payload,n=n._init;try{return e(n(c))}catch{}}return null}function t(n){return""+n}function r(n){try{t(n);var c=!1}catch{c=!0}if(c){c=console;var h=c.error,y=typeof Symbol=="function"&&Symbol.toStringTag&&n[Symbol.toStringTag]||n.constructor.name||"Object";return h.call(c,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",y),t(n)}}function a(n){if(n===P)return"<>";if(typeof n=="object"&&n!==null&&n.$$typeof===k)return"<...>";try{var c=e(n);return c?"<"+c+">":"<...>"}catch{return"<...>"}}function o(){var n=I.A;return n===null?null:n.getOwner()}function l(){return Error("react-stack-top-frame")}function s(n){if(F.call(n,"key")){var c=Object.getOwnPropertyDescriptor(n,"key").get;if(c&&c.isReactWarning)return!1}return n.key!==void 0}function u(n,c){function h(){Q||(Q=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",c))}h.isReactWarning=!0,Object.defineProperty(n,"key",{get:h,configurable:!0})}function f(){var n=e(this.type);return K[n]||(K[n]=!0,console.error("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.")),n=this.props.ref,n!==void 0?n:null}function m(n,c,h,y,i,v){var b=h.ref;return n={$$typeof:S,type:n,key:c,props:h,_owner:y},(b!==void 0?b:null)!==null?Object.defineProperty(n,"ref",{enumerable:!1,get:f}):Object.defineProperty(n,"ref",{enumerable:!1,value:null}),n._store={},Object.defineProperty(n._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(n,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(n,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(n,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:v}),Object.freeze&&(Object.freeze(n.props),Object.freeze(n)),n}function g(n,c,h,y,i,v){var b=c.children;if(b!==void 0)if(y)if(D(b)){for(y=0;y<b.length;y++)x(b[y]);Object.freeze&&Object.freeze(b)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else x(b);if(F.call(c,"key")){b=e(n);var w=Object.keys(c).filter(function(L){return L!=="key"});y=0<w.length?"{key: someKey, "+w.join(": ..., ")+": ...}":"{key: someKey}",ee[b+y]||(w=0<w.length?"{"+w.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
19
19
|
let props = %s;
|
|
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} />`,m,b,w,b),ee[b+m]=!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),g(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 m=1e4>I.recentlyCreatedOwnerStacks++;return y(n,c,h,!1,m?Error("react-stack-top-frame"):$,m?U(a(n)):q)},B.jsxs=function(n,c,h){var m=1e4>I.recentlyCreatedOwnerStacks++;return y(n,c,h,!0,m?Error("react-stack-top-frame"):$,m?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,size:r=28})=>{const a=O.useTheme(),o=a.palette.mode==="dark"?Ne:Ie,l=Math.max(3,Math.round(r*.25)),s=(()=>{if(t&&Fe(t))return te[t];if(!e)return te.default;if(typeof e=="function")return e(a);if(A.isString(e)&&e.includes(".")){const[u,f]=e.split("."),g=a.palette[u];if(g&&typeof g=="object"&&f in g)return g[f]}return e})();return p.jsx(O.Box,{component:"div",style:{backgroundColor:o,border:`${l}px solid ${s}`,borderRadius:"50%",boxShadow:"0 0 4px rgba(0,0,0,0.3)",height:r,width:r}})},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(),g=d.useRef(""),y=d.useMemo(()=>e.filter(oe),[e]),x=d.useMemo(()=>Be(t),[t]),_=d.useMemo(()=>{const R=[...y.map(S=>[S.lng,S.lat]),...x];return R.length===0?null:R.reduce((S,[T,P])=>S.extend([T,P]),new fe.LngLatBounds)},[y,x]);return d.useEffect(()=>{if(u){g.current=s!==void 0?ye(s):"__initial_skip__";return}if(f&&l&&_){if(s!==void 0){const R=ye(s);if(g.current===R)return;g.current=R}else if(g.current==="__initial_skip__")return;if(!_.isEmpty()){if(y.length===1&&x.length===0){const R=y[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,y,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),g=await t(f),y=g?r(g)?.[0]:void 0;return y?.length?We(o,y,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,g]=d.useState(l??null);return d.useEffect(()=>{l&&(g(l),s?.(l))},[l,s]),d.useEffect(()=>{!(e&&t)||l||(async()=>{const x=await(a==="OSRM"?ve:Z).getItinerary(e,t,r);g(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,g]=d.useState(o??[]),y=d.useRef(null);d.useEffect(()=>{o&&g(o)},[o]),d.useEffect(()=>{const _=new AbortController;if(o?.length)return;if(!e||e.length!==2||!r?.length){g([]);return}g([]);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=>g(T??[])).catch(()=>g([])),()=>_.abort()},[e,t,r,s,u,o?.length]),d.useEffect(()=>{const _=y.current;(!_||_.length!==f.length||_.some((S,T)=>S.id!==f[T]?.id||S.distance!==f[T]?.distance))&&(a?.(f),y.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:g,markers:y=[],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)=>{!g&&v&&D(i)},h=(i,v)=>{g&&D(v?i:null)};d.useEffect(()=>{D(f??null)},[f]);const m=d.useMemo(()=>F?y?.find(i=>i.id===F)??null:null,[F,y]);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=y.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&&y.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}),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:"bottom",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&&m?.Tooltip&&p.jsx(C.Popup,{longitude:A.isNumber(m.lng)?m.lng:0,latitude:A.isNumber(m.lat)?m.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:m.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:y,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,[g,y],x,_)=>{const[R,S]=_[(x-1+_.length)%_.length];return y>o!=S>o&&a<(R-g)*(o-y)/(S-y)+g?!f:f},!1)).reduce((u,f,g)=>g===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:{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"})}));
|
package/package.json
CHANGED