@tracktor/map 1.8.4 → 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/components/Markers/Markers.d.ts +2 -1
- package/dist/main.js +250 -241
- 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
|
@@ -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";
|
|
@@ -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
|
}
|
|
@@ -153,18 +153,18 @@ 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
|
-
function
|
|
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,
|
|
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,
|
|
@@ -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,29 +252,29 @@ 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
|
-
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") : J,
|
|
267
|
+
m ? $(a(r)) : q
|
|
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") : J,
|
|
277
|
+
m ? $(a(r)) : q
|
|
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,27 +298,27 @@ const Ge = Ie({
|
|
|
298
298
|
}),
|
|
299
299
|
[t, n]
|
|
300
300
|
);
|
|
301
|
-
return n && (be.accessToken = n), /* @__PURE__ */
|
|
302
|
-
},
|
|
301
|
+
return n && (be.accessToken = n), /* @__PURE__ */ f.jsx(Ge.Provider, { value: a, children: e });
|
|
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] =
|
|
314
|
-
return /* @__PURE__ */
|
|
313
|
+
const a = n.coordinates, [o, l] = Je(a);
|
|
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(qe, { 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
|
);
|
|
@@ -403,17 +405,17 @@ const Ge = Ie({
|
|
|
403
405
|
return Number.isFinite(t) ? t : null;
|
|
404
406
|
}
|
|
405
407
|
return null;
|
|
406
|
-
},
|
|
408
|
+
}, Re = (e) => {
|
|
407
409
|
const t = _e(e);
|
|
408
410
|
return t !== null && t >= -90 && t <= 90;
|
|
409
|
-
},
|
|
411
|
+
}, Ee = (e) => {
|
|
410
412
|
const t = _e(e);
|
|
411
413
|
return t !== null && t >= -180 && t <= 180;
|
|
412
|
-
}, 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) => {
|
|
413
415
|
if (typeof e != "object" || e === null)
|
|
414
416
|
return !1;
|
|
415
417
|
const t = e;
|
|
416
|
-
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);
|
|
417
419
|
}, he = (e) => ie(e) || Q(e) ? String(e) : JSON.stringify(e), tt = (e) => {
|
|
418
420
|
if (!e)
|
|
419
421
|
return [];
|
|
@@ -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
|
-
return x.length === 0 ? null : x.reduce((
|
|
439
|
-
}, [
|
|
438
|
+
const { current: d } = Ue(), g = ae(""), p = M(() => e.filter(Se), [e]), _ = M(() => tt(t), [t]), b = M(() => {
|
|
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
|
+
}, [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",
|
|
@@ -586,7 +588,7 @@ const ke = async (e, t, n) => {
|
|
|
586
588
|
vt,
|
|
587
589
|
Ce,
|
|
588
590
|
(e) => e.distances ?? void 0
|
|
589
|
-
),
|
|
591
|
+
), Rt = async (e, t, n = "driving", a) => {
|
|
590
592
|
if (!t.length)
|
|
591
593
|
return [];
|
|
592
594
|
const o = Te(t, bt - 1);
|
|
@@ -595,7 +597,7 @@ const ke = async (e, t, n) => {
|
|
|
595
597
|
xt,
|
|
596
598
|
(s) => _t(e, s, n, a)
|
|
597
599
|
)).flatMap((s) => s.all).sort((s, u) => s.distance - u.distance);
|
|
598
|
-
},
|
|
600
|
+
}, Et = async (e, t, n = "driving") => {
|
|
599
601
|
const a = `${e.join(",")};${t.join(",")}`, o = we("route", n, a, {
|
|
600
602
|
geometries: "geojson",
|
|
601
603
|
overview: "full"
|
|
@@ -612,18 +614,18 @@ const ke = async (e, t, n) => {
|
|
|
612
614
|
type: "Feature"
|
|
613
615
|
};
|
|
614
616
|
}, Ae = {
|
|
615
|
-
findNearest:
|
|
616
|
-
getItinerary:
|
|
617
|
+
findNearest: Rt,
|
|
618
|
+
getItinerary: Et
|
|
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
|
-
|
|
648
|
-
const x = n.map((
|
|
649
|
-
coords: [
|
|
650
|
-
id:
|
|
649
|
+
g([]);
|
|
650
|
+
const x = n.map((E) => ({
|
|
651
|
+
coords: [E.lng, E.lat],
|
|
652
|
+
id: E.id
|
|
651
653
|
}));
|
|
652
|
-
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();
|
|
653
655
|
}, [e, t, n, s, u, o?.length]), w(() => {
|
|
654
|
-
const b =
|
|
655
|
-
(!b || b.length !== d.length || b.some((
|
|
656
|
+
const b = p.current;
|
|
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);
|
|
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,13 +693,13 @@ 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,
|
|
699
|
-
fitBoundsAnimationKey:
|
|
700
|
-
disableAnimation:
|
|
701
|
+
fitBoundsAnimationKey: R,
|
|
702
|
+
disableAnimation: E,
|
|
701
703
|
mapStyle: C,
|
|
702
704
|
onMapClick: W,
|
|
703
705
|
baseMapView: F,
|
|
@@ -710,176 +712,183 @@ const ke = async (e, t, n) => {
|
|
|
710
712
|
findNearestMarker: S,
|
|
711
713
|
isochrone: A
|
|
712
714
|
}) => {
|
|
713
|
-
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(() => {
|
|
714
716
|
const [i = 2.3522, v = 48.8566] = ce(l) ? l : [];
|
|
715
717
|
return { latitude: v, longitude: i, zoom: s };
|
|
716
|
-
}, [l, s]),
|
|
718
|
+
}, [l, s]), J = M(
|
|
717
719
|
() => C || Me(F, N ?? U.palette.mode),
|
|
718
720
|
[F, C, N, U.palette.mode]
|
|
719
721
|
), {
|
|
720
|
-
style:
|
|
722
|
+
style: q,
|
|
721
723
|
cooperativeGestures: X,
|
|
722
724
|
doubleClickZoom: r
|
|
723
725
|
} = jt({
|
|
724
726
|
baseMapView: F,
|
|
725
727
|
cooperativeGestures: te,
|
|
726
728
|
doubleClickZoom: re,
|
|
727
|
-
mapStyle:
|
|
729
|
+
mapStyle: J,
|
|
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
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
{
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
{
|
|
757
|
-
ref: P,
|
|
758
|
-
cooperativeGestures: X,
|
|
759
|
-
doubleClickZoom: r,
|
|
760
|
-
mapStyle: J,
|
|
761
|
-
projection: ne,
|
|
762
|
-
onLoad: () => {
|
|
763
|
-
G(!0), P.current?.resize();
|
|
764
|
-
},
|
|
765
|
-
initialViewState: q,
|
|
766
|
-
style: { height: "100%", width: "100%" },
|
|
767
|
-
mapboxAccessToken: void 0,
|
|
768
|
-
onClick: (i) => {
|
|
769
|
-
const v = m.find((h) => {
|
|
770
|
-
const { lng: j, lat: O } = i.lngLat, k = Math.abs(Number(h.lng ?? 0) - j), Pe = Math.abs(Number(h.lat ?? 0) - O);
|
|
771
|
-
return k < 0.01 && Pe < 0.01;
|
|
772
|
-
});
|
|
773
|
-
W?.(i.lngLat.lng, i.lngLat.lat, v ?? null);
|
|
774
|
-
},
|
|
775
|
-
children: [
|
|
776
|
-
$ && m.filter(Se).map((i) => {
|
|
777
|
-
const v = typeof i.size == "number" ? i.size : void 0, h = (() => {
|
|
778
|
-
if (!i.IconComponent)
|
|
779
|
-
return null;
|
|
780
|
-
const k = { ...i.iconProps };
|
|
781
|
-
return v && (k.width = v, k.height = v), /* @__PURE__ */ p.jsx(i.IconComponent, { ...k });
|
|
782
|
-
})(), j = i.IconComponent ? null : /* @__PURE__ */ p.jsx(Ke, { color: i.color, variant: i.variant, size: v }), O = {
|
|
783
|
-
alignItems: "center",
|
|
784
|
-
cursor: i.Tooltip ? "pointer" : "default",
|
|
785
|
-
display: "inline-flex",
|
|
786
|
-
justifyContent: "center",
|
|
787
|
-
...i.IconComponent && !v ? {} : v ? { height: v, width: v } : {}
|
|
788
|
-
};
|
|
789
|
-
return /* @__PURE__ */ p.jsx(
|
|
790
|
-
ve,
|
|
791
|
-
{
|
|
792
|
-
longitude: i.lng,
|
|
793
|
-
latitude: i.lat,
|
|
794
|
-
anchor: "center",
|
|
795
|
-
onClick: (k) => {
|
|
796
|
-
k.originalEvent.stopPropagation(), i.id && c(i.id, !!i.Tooltip), W?.(i.lng, i.lat, i);
|
|
797
|
-
},
|
|
798
|
-
children: /* @__PURE__ */ p.jsx(
|
|
799
|
-
H,
|
|
800
|
-
{
|
|
801
|
-
component: "div",
|
|
802
|
-
onMouseEnter: () => i.id && y(i.id, !!i.Tooltip),
|
|
803
|
-
onMouseLeave: () => y(null),
|
|
804
|
-
style: O,
|
|
805
|
-
children: h || j
|
|
806
|
-
}
|
|
807
|
-
)
|
|
808
|
-
},
|
|
809
|
-
i.id
|
|
810
|
-
);
|
|
811
|
-
}),
|
|
812
|
-
$ && g?.Tooltip && /* @__PURE__ */ p.jsx(
|
|
813
|
-
Ye,
|
|
814
|
-
{
|
|
815
|
-
longitude: Q(g.lng) ? g.lng : 0,
|
|
816
|
-
latitude: Q(g.lat) ? g.lat : 0,
|
|
817
|
-
anchor: "top",
|
|
818
|
-
onClose: () => I(null),
|
|
819
|
-
maxWidth: u,
|
|
820
|
-
closeOnClick: !0,
|
|
821
|
-
closeOnMove: !1,
|
|
822
|
-
children: /* @__PURE__ */ p.jsx(H, { component: "div", sx: { minHeight: 60, minWidth: 240 }, children: g.Tooltip })
|
|
823
|
-
}
|
|
824
|
-
),
|
|
825
|
-
T && /* @__PURE__ */ p.jsx(
|
|
826
|
-
Oe,
|
|
827
|
-
{
|
|
828
|
-
from: T.from,
|
|
829
|
-
to: T.to,
|
|
830
|
-
profile: T.profile,
|
|
831
|
-
engine: T.engine,
|
|
832
|
-
itineraryLineStyle: T.itineraryLineStyle,
|
|
833
|
-
initialRoute: T.initialRoute,
|
|
834
|
-
onRouteComputed: T.onRouteComputed,
|
|
835
|
-
itineraryLabel: T.itineraryLabel
|
|
836
|
-
}
|
|
837
|
-
),
|
|
838
|
-
S && /* @__PURE__ */ p.jsx(
|
|
839
|
-
Tt,
|
|
840
|
-
{
|
|
841
|
-
origin: S.origin,
|
|
842
|
-
destinations: S.destinations,
|
|
843
|
-
onNearestFound: S.onNearestFound,
|
|
844
|
-
maxDistanceMeters: S.maxDistanceMeters,
|
|
845
|
-
engine: S.engine,
|
|
846
|
-
profile: S.profile,
|
|
847
|
-
initialNearestResults: S.initialNearestResults,
|
|
848
|
-
itineraryLineStyle: S.itineraryLineStyle
|
|
849
|
-
}
|
|
850
|
-
),
|
|
851
|
-
A && /* @__PURE__ */ p.jsx(
|
|
852
|
-
mt,
|
|
853
|
-
{
|
|
854
|
-
origin: A.origin,
|
|
855
|
-
profile: A.profile,
|
|
856
|
-
onIsochroneLoaded: A.onIsochroneLoaded,
|
|
857
|
-
intervals: A.intervals
|
|
858
|
-
}
|
|
859
|
-
),
|
|
860
|
-
D && /* @__PURE__ */ p.jsx(ee, { features: D }),
|
|
861
|
-
_ && /* @__PURE__ */ p.jsx(
|
|
862
|
-
rt,
|
|
863
|
-
{
|
|
864
|
-
markers: m,
|
|
865
|
-
features: D,
|
|
866
|
-
padding: b,
|
|
867
|
-
duration: R ? 0 : x,
|
|
868
|
-
animationKey: E,
|
|
869
|
-
openPopup: !!d
|
|
739
|
+
const m = M(() => L ? p?.find((i) => i.id === L) ?? null : null, [L, p]);
|
|
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
|
|
870
758
|
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
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
|
+
);
|
|
876
885
|
}, Nt = le(kt), Dt = ["OSRM", "Mapbox"], Ut = ["driving", "walking", "cycling"], Yt = (e, t) => {
|
|
877
886
|
const n = "geometry" in t ? t.geometry : t, [a, o] = e, l = (s) => s.map(
|
|
878
|
-
(u) => u.reduce((d, [
|
|
879
|
-
const [x,
|
|
880
|
-
return
|
|
887
|
+
(u) => u.reduce((d, [g, p], _, b) => {
|
|
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;
|
|
881
890
|
}, !1)
|
|
882
|
-
).reduce((u, d,
|
|
891
|
+
).reduce((u, d, g) => g === 0 ? d : u && !d, !1);
|
|
883
892
|
return n.type === "Polygon" ? l(n.coordinates) : n.type === "MultiPolygon" ? n.coordinates.some((s) => l(s)) : !1;
|
|
884
893
|
};
|
|
885
894
|
export {
|
|
@@ -890,8 +899,8 @@ export {
|
|
|
890
899
|
Dt as engines,
|
|
891
900
|
Yt as isPointInGeoJSON,
|
|
892
901
|
Ft as isValidLatLngTuple,
|
|
893
|
-
|
|
894
|
-
|
|
902
|
+
Re as isValidLatitude,
|
|
903
|
+
Ee as isValidLongitude,
|
|
895
904
|
Se as isValidMarker,
|
|
896
905
|
Ut as profiles
|
|
897
906
|
};
|
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:"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&&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:{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