efficient-shell 4.137.0 → 4.145.0
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/LICENSE +6 -17
- package/README.md +80 -12
- package/dist/Browser-24YNRTKT.js +43 -0
- package/dist/Calculator-LER6KUQC.js +29 -0
- package/dist/ConfirmDialog-GAYETRMG.js +1 -0
- package/dist/CurrencyConverter-Y35GFDFF.js +21 -0
- package/dist/Documents-7FYX2CGT.js +52 -0
- package/dist/Files-RZOML2N6.js +89 -0
- package/dist/Notepad-VVDCBDUA.js +25 -0
- package/dist/PdfViewer-CvLb2j_l.d.ts +40 -0
- package/dist/PdfViewer-ZCT3PYXU.js +1 -0
- package/dist/PomodoroTimer-VAM3AJOX.js +99 -0
- package/dist/Preview-HZ37D7QJ.js +187 -0
- package/dist/Sidebar-CVF7C6BO.js +23 -0
- package/dist/Spreadsheet-6WX3P6AB.js +37 -0
- package/dist/Stock-AUWI3TUX.js +16 -0
- package/dist/Weather-HU75TH7T.js +60 -0
- package/dist/WorldClock-T64MDRMJ.js +32 -0
- package/dist/apps/index.d.ts +3 -23
- package/dist/apps/index.js +1 -151
- package/dist/brand.css +1 -1
- package/dist/chunk-2RHMSFZV.js +9 -0
- package/dist/chunk-4FS742BM.js +1 -0
- package/dist/chunk-57MIENLJ.js +1 -0
- package/dist/chunk-7DAQ3WVP.js +106 -0
- package/dist/chunk-BR22X7E5.js +1 -0
- package/dist/chunk-BUTSU7FO.js +1 -0
- package/dist/chunk-CVTOZCM3.js +24 -0
- package/dist/chunk-D65T4H6J.js +1 -0
- package/dist/chunk-ESL5TDNA.js +1 -0
- package/dist/chunk-FBDZGO3V.js +1 -0
- package/dist/chunk-FHTLC7HH.js +1 -0
- package/dist/chunk-GDSGXDET.js +34 -0
- package/dist/chunk-I55UMU3R.js +6 -0
- package/dist/chunk-KKOHUQPF.js +1 -0
- package/dist/chunk-L7TEFXIS.js +69 -0
- package/dist/chunk-LVDRBRYU.js +1 -0
- package/dist/chunk-LVFMK5OQ.js +29 -0
- package/dist/chunk-LWLCNQY7.js +1 -0
- package/dist/chunk-MAIHBBWT.js +1 -0
- package/dist/chunk-MU5H2CDL.js +2 -0
- package/dist/chunk-NBBOFQPL.js +947 -0
- package/dist/chunk-NPJH5MD7.js +13 -0
- package/dist/chunk-OCSOMMY2.js +1 -0
- package/dist/chunk-PH3PRIFP.js +5 -0
- package/dist/chunk-RJ4LACFH.js +9 -0
- package/dist/chunk-SLCR26NK.js +4 -0
- package/dist/chunk-TFKB2WEB.js +19 -0
- package/dist/chunk-TR6PLN7W.js +1 -0
- package/dist/chunk-TWV42Q3K.js +1 -0
- package/dist/chunk-UB22J6EF.js +1 -0
- package/dist/chunk-UB4JIOLD.js +2 -0
- package/dist/chunk-V453E4KU.js +11 -0
- package/dist/chunk-VTVSMRFX.js +1 -0
- package/dist/file-intake/index.js +1 -4
- package/dist/{index-DVI9DMSu.d.ts → index-NhR7frRu.d.ts} +189 -17
- package/dist/index.d.ts +2 -2
- package/dist/index.js +639 -7473
- package/dist/map/index.d.ts +266 -13
- package/dist/map/index.js +22 -540
- package/dist/markdown/index.js +6 -184
- package/dist/markup/index.js +1 -135
- package/dist/page-tabs/index.js +21 -709
- package/dist/pdf/index.d.ts +9 -0
- package/dist/pdf/index.js +2 -0
- package/dist/sounds-OMHXVVQ4.js +1 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -19
- package/dist/ui.css +7 -0
- package/package.json +9 -3
- package/dist/Browser-ZNX4WFUH.js +0 -482
- package/dist/Browser-ZNX4WFUH.js.map +0 -1
- package/dist/Calculator-6FGNKOXU.js +0 -192
- package/dist/Calculator-6FGNKOXU.js.map +0 -1
- package/dist/ConfirmDialog-NPQMIGUR.js +0 -4
- package/dist/ConfirmDialog-NPQMIGUR.js.map +0 -1
- package/dist/CurrencyConverter-FF7EXRYL.js +0 -236
- package/dist/CurrencyConverter-FF7EXRYL.js.map +0 -1
- package/dist/Documents-H3R7XSBH.js +0 -441
- package/dist/Documents-H3R7XSBH.js.map +0 -1
- package/dist/Files-ZHJIAUC2.js +0 -805
- package/dist/Files-ZHJIAUC2.js.map +0 -1
- package/dist/Notepad-VE7ISWRQ.js +0 -410
- package/dist/Notepad-VE7ISWRQ.js.map +0 -1
- package/dist/PdfViewer-SQBFYAGW.js +0 -5
- package/dist/PdfViewer-SQBFYAGW.js.map +0 -1
- package/dist/PomodoroTimer-IR3WREED.js +0 -633
- package/dist/PomodoroTimer-IR3WREED.js.map +0 -1
- package/dist/Preview-DAQGRNRM.js +0 -2959
- package/dist/Preview-DAQGRNRM.js.map +0 -1
- package/dist/Sidebar-YW6H4NDJ.js +0 -291
- package/dist/Sidebar-YW6H4NDJ.js.map +0 -1
- package/dist/Spreadsheet-HOCPHJOC.js +0 -519
- package/dist/Spreadsheet-HOCPHJOC.js.map +0 -1
- package/dist/Stock-LVRQPURG.js +0 -158
- package/dist/Stock-LVRQPURG.js.map +0 -1
- package/dist/Weather-LZQGVDJL.js +0 -431
- package/dist/Weather-LZQGVDJL.js.map +0 -1
- package/dist/WorldClock-XPD7WOZT.js +0 -202
- package/dist/WorldClock-XPD7WOZT.js.map +0 -1
- package/dist/apps/index.js.map +0 -1
- package/dist/chunk-5O42JXQE.js +0 -26
- package/dist/chunk-5O42JXQE.js.map +0 -1
- package/dist/chunk-5RPTS3BT.js +0 -70
- package/dist/chunk-5RPTS3BT.js.map +0 -1
- package/dist/chunk-6XJEJWNJ.js +0 -61
- package/dist/chunk-6XJEJWNJ.js.map +0 -1
- package/dist/chunk-7CCHEEYC.js +0 -94
- package/dist/chunk-7CCHEEYC.js.map +0 -1
- package/dist/chunk-BE7FZOFU.js +0 -17
- package/dist/chunk-BE7FZOFU.js.map +0 -1
- package/dist/chunk-COWYSHG2.js +0 -79
- package/dist/chunk-COWYSHG2.js.map +0 -1
- package/dist/chunk-D7PYW2QS.js +0 -265
- package/dist/chunk-D7PYW2QS.js.map +0 -1
- package/dist/chunk-DVZWYWSD.js +0 -26
- package/dist/chunk-DVZWYWSD.js.map +0 -1
- package/dist/chunk-E7TB6WD2.js +0 -153
- package/dist/chunk-E7TB6WD2.js.map +0 -1
- package/dist/chunk-FIHOGVUP.js +0 -416
- package/dist/chunk-FIHOGVUP.js.map +0 -1
- package/dist/chunk-GA35NEND.js +0 -56
- package/dist/chunk-GA35NEND.js.map +0 -1
- package/dist/chunk-HUBJAUGG.js +0 -316
- package/dist/chunk-HUBJAUGG.js.map +0 -1
- package/dist/chunk-I2TAAJHS.js +0 -465
- package/dist/chunk-I2TAAJHS.js.map +0 -1
- package/dist/chunk-ICTRCKUE.js +0 -3710
- package/dist/chunk-ICTRCKUE.js.map +0 -1
- package/dist/chunk-IPXN646P.js +0 -14
- package/dist/chunk-IPXN646P.js.map +0 -1
- package/dist/chunk-IRWSRJ4K.js +0 -48
- package/dist/chunk-IRWSRJ4K.js.map +0 -1
- package/dist/chunk-JOPU6WPY.js +0 -504
- package/dist/chunk-JOPU6WPY.js.map +0 -1
- package/dist/chunk-MGGY74RY.js +0 -14
- package/dist/chunk-MGGY74RY.js.map +0 -1
- package/dist/chunk-PVPPAWVM.js +0 -46
- package/dist/chunk-PVPPAWVM.js.map +0 -1
- package/dist/chunk-R7QGMK6N.js +0 -102
- package/dist/chunk-R7QGMK6N.js.map +0 -1
- package/dist/chunk-RT6DSB5Y.js +0 -143
- package/dist/chunk-RT6DSB5Y.js.map +0 -1
- package/dist/chunk-TRCWINHF.js +0 -105
- package/dist/chunk-TRCWINHF.js.map +0 -1
- package/dist/chunk-TW7LPMVR.js +0 -16
- package/dist/chunk-TW7LPMVR.js.map +0 -1
- package/dist/chunk-UTYKLGGT.js +0 -195
- package/dist/chunk-UTYKLGGT.js.map +0 -1
- package/dist/chunk-VNJJCH5A.js +0 -822
- package/dist/chunk-VNJJCH5A.js.map +0 -1
- package/dist/chunk-XJHZWSKV.js +0 -1103
- package/dist/chunk-XJHZWSKV.js.map +0 -1
- package/dist/chunk-Y3GYJ7YR.js +0 -549
- package/dist/chunk-Y3GYJ7YR.js.map +0 -1
- package/dist/chunk-YA4EE7ST.js +0 -14107
- package/dist/chunk-YA4EE7ST.js.map +0 -1
- package/dist/chunk-YDHXWCCJ.js +0 -145
- package/dist/chunk-YDHXWCCJ.js.map +0 -1
- package/dist/chunk-YE6GUDGP.js +0 -548
- package/dist/chunk-YE6GUDGP.js.map +0 -1
- package/dist/chunk-YNKK7NE3.js +0 -171
- package/dist/chunk-YNKK7NE3.js.map +0 -1
- package/dist/chunk-YPO6RDMX.js +0 -20
- package/dist/chunk-YPO6RDMX.js.map +0 -1
- package/dist/chunk-ZS7PMGUW.js +0 -7
- package/dist/chunk-ZS7PMGUW.js.map +0 -1
- package/dist/file-intake/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/map/index.js.map +0 -1
- package/dist/markdown/index.js.map +0 -1
- package/dist/markup/index.js.map +0 -1
- package/dist/page-tabs/index.js.map +0 -1
- package/dist/sounds-NT4DEZGD.js +0 -3
- package/dist/sounds-NT4DEZGD.js.map +0 -1
- package/dist/ui/index.js.map +0 -1
package/dist/map/index.js
CHANGED
|
@@ -1,541 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Button_default } from '../chunk-RT6DSB5Y.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return () => watcher.disconnect();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// src/map/maplibre.ts
|
|
28
|
-
var MAPLIBRE_WORKER_FILE = "maplibre-gl-worker.mjs";
|
|
29
|
-
var mapLibreWorkerUrl = (version) => `/maplibre-gl/${version}/${MAPLIBRE_WORKER_FILE}`;
|
|
30
|
-
var loading = null;
|
|
31
|
-
function loadMapLibre() {
|
|
32
|
-
loading ??= Promise.all([import('maplibre-gl'), import('maplibre-gl/dist/maplibre-gl.css')]).then(([maplibre]) => {
|
|
33
|
-
maplibre.setWorkerUrl(mapLibreWorkerUrl(maplibre.getVersion()));
|
|
34
|
-
return maplibre;
|
|
35
|
-
}).catch((error) => {
|
|
36
|
-
loading = null;
|
|
37
|
-
throw error;
|
|
38
|
-
});
|
|
39
|
-
return loading;
|
|
40
|
-
}
|
|
41
|
-
function subscribe(onChange) {
|
|
42
|
-
const watcher = new MutationObserver(onChange);
|
|
43
|
-
watcher.observe(document.documentElement, { attributes: true, attributeFilter: ROOT_THEME_ATTRIBUTES });
|
|
44
|
-
return () => watcher.disconnect();
|
|
45
|
-
}
|
|
46
|
-
var isDark = rootIsDark;
|
|
47
|
-
function useDarkTheme() {
|
|
48
|
-
return useSyncExternalStore(subscribe, isDark, () => false);
|
|
49
|
-
}
|
|
50
|
-
var ROUTE_SOURCE = "routes";
|
|
51
|
-
function accentColor() {
|
|
52
|
-
const probe = document.createElement("span");
|
|
53
|
-
probe.className = "text-blue-600";
|
|
54
|
-
probe.style.display = "none";
|
|
55
|
-
document.body.appendChild(probe);
|
|
56
|
-
const color = getComputedStyle(probe).color || "#2563eb";
|
|
57
|
-
probe.remove();
|
|
58
|
-
return toRgb(color);
|
|
59
|
-
}
|
|
60
|
-
function toRgb(css) {
|
|
61
|
-
const ctx = document.createElement("canvas").getContext("2d");
|
|
62
|
-
if (!ctx) return "#2563eb";
|
|
63
|
-
ctx.fillStyle = "#2563eb";
|
|
64
|
-
ctx.fillStyle = css;
|
|
65
|
-
ctx.fillRect(0, 0, 1, 1);
|
|
66
|
-
const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
|
|
67
|
-
return `rgb(${r}, ${g}, ${b})`;
|
|
68
|
-
}
|
|
69
|
-
var STYLES = {
|
|
70
|
-
light: "https://tiles.openfreemap.org/styles/positron",
|
|
71
|
-
dark: "https://tiles.openfreemap.org/styles/dark"
|
|
72
|
-
};
|
|
73
|
-
var WORLD = { center: [30, 20], zoom: 1 };
|
|
74
|
-
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
75
|
-
function iconElement(paths, selected) {
|
|
76
|
-
const svg = document.createElementNS(SVG_NS, "svg");
|
|
77
|
-
svg.setAttribute("viewBox", "0 0 24 24");
|
|
78
|
-
svg.setAttribute("fill", "none");
|
|
79
|
-
svg.setAttribute("stroke", "currentColor");
|
|
80
|
-
svg.setAttribute("stroke-width", "2");
|
|
81
|
-
svg.setAttribute("aria-hidden", "true");
|
|
82
|
-
svg.setAttribute("class", selected ? "h-4 w-4" : "h-3.5 w-3.5");
|
|
83
|
-
for (const d of paths) {
|
|
84
|
-
const path = document.createElementNS(SVG_NS, "path");
|
|
85
|
-
path.setAttribute("stroke-linecap", "round");
|
|
86
|
-
path.setAttribute("stroke-linejoin", "round");
|
|
87
|
-
path.setAttribute("d", d);
|
|
88
|
-
svg.appendChild(path);
|
|
89
|
-
}
|
|
90
|
-
return svg;
|
|
91
|
-
}
|
|
92
|
-
function pinElement(pin, selected) {
|
|
93
|
-
const el = document.createElement("button");
|
|
94
|
-
el.type = "button";
|
|
95
|
-
el.title = pin.approximate ? `${pin.label} (approximate)` : pin.label;
|
|
96
|
-
el.setAttribute("aria-label", pin.approximate ? `${pin.label}, approximate location` : pin.label);
|
|
97
|
-
el.dataset.pin = pin.key;
|
|
98
|
-
el.className = [
|
|
99
|
-
"relative grid place-items-center rounded-full border-2 border-white font-semibold leading-none shadow-md cursor-pointer",
|
|
100
|
-
pin.tone,
|
|
101
|
-
selected ? "h-8 w-8 text-xs ring-2 ring-gray-900 ring-offset-1" : "h-6 w-6 text-[10px]",
|
|
102
|
-
pin.approximate ? "border-dashed opacity-80" : "",
|
|
103
|
-
pin.faded && !selected ? "opacity-40" : ""
|
|
104
|
-
].join(" ");
|
|
105
|
-
if (pin.icon?.length) el.appendChild(iconElement(pin.icon, selected));
|
|
106
|
-
else el.textContent = pin.glyph;
|
|
107
|
-
if (pin.badge) {
|
|
108
|
-
const badge = document.createElement("span");
|
|
109
|
-
badge.setAttribute("aria-hidden", "true");
|
|
110
|
-
badge.className = [
|
|
111
|
-
"absolute -right-2 -top-2 grid h-4 min-w-4 place-items-center rounded-full px-0.5 text-[9px] font-semibold leading-none shadow",
|
|
112
|
-
pin.badgeTone ?? "bg-white text-gray-900"
|
|
113
|
-
].join(" ");
|
|
114
|
-
badge.textContent = pin.badge;
|
|
115
|
-
el.appendChild(badge);
|
|
116
|
-
}
|
|
117
|
-
return el;
|
|
118
|
-
}
|
|
119
|
-
function EntityMap({
|
|
120
|
-
pins,
|
|
121
|
-
selectedKey,
|
|
122
|
-
focus,
|
|
123
|
-
onSelect,
|
|
124
|
-
ariaLabel,
|
|
125
|
-
className = "",
|
|
126
|
-
children,
|
|
127
|
-
routes,
|
|
128
|
-
fitTo,
|
|
129
|
-
attribution
|
|
130
|
-
}) {
|
|
131
|
-
const box = useRef(null);
|
|
132
|
-
const map = useRef(null);
|
|
133
|
-
const lib = useRef(null);
|
|
134
|
-
const markers = useRef([]);
|
|
135
|
-
const fitted = useRef("");
|
|
136
|
-
const [ready, setReady] = useState(false);
|
|
137
|
-
const [failed, setFailed] = useState(false);
|
|
138
|
-
const theme = useDarkTheme() ? "dark" : "light";
|
|
139
|
-
const latest = useRef({ onSelect, pins, selectedKey });
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
latest.current = { onSelect, pins, selectedKey };
|
|
142
|
-
});
|
|
143
|
-
const revealSelected = useCallback(() => {
|
|
144
|
-
const m = map.current;
|
|
145
|
-
const { pins: shown, selectedKey: chosen } = latest.current;
|
|
146
|
-
const pin = chosen ? shown.find((p) => p.key === chosen) : void 0;
|
|
147
|
-
if (!m || !pin || m.getBounds().contains([pin.lng, pin.lat])) return;
|
|
148
|
-
const reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
149
|
-
m.easeTo({ center: [pin.lng, pin.lat], duration: reduced ? 0 : 400 });
|
|
150
|
-
}, []);
|
|
151
|
-
useEffect(() => {
|
|
152
|
-
let cancelled = false;
|
|
153
|
-
let created = null;
|
|
154
|
-
let observer = null;
|
|
155
|
-
let unfoldWatch = () => {
|
|
156
|
-
};
|
|
157
|
-
void (async () => {
|
|
158
|
-
try {
|
|
159
|
-
const maplibre = await loadMapLibre();
|
|
160
|
-
if (cancelled || !box.current) return;
|
|
161
|
-
lib.current = maplibre;
|
|
162
|
-
created = new maplibre.Map({
|
|
163
|
-
container: box.current,
|
|
164
|
-
style: STYLES[theme],
|
|
165
|
-
center: WORLD.center,
|
|
166
|
-
zoom: WORLD.zoom,
|
|
167
|
-
attributionControl: attribution ? { compact: true, customAttribution: attribution } : { compact: true },
|
|
168
|
-
dragRotate: false,
|
|
169
|
-
pitchWithRotate: false,
|
|
170
|
-
touchPitch: false,
|
|
171
|
-
maxPitch: 0
|
|
172
|
-
});
|
|
173
|
-
created.touchZoomRotate.disableRotation();
|
|
174
|
-
created.keyboard.disableRotation();
|
|
175
|
-
created.addControl(new maplibre.NavigationControl({ showCompass: false }), "top-right");
|
|
176
|
-
created.on("error", (event) => console.warn("[map]", event.error?.message));
|
|
177
|
-
unfoldWatch = foldAttributionOnce(box.current.querySelector(".maplibregl-ctrl-attrib"));
|
|
178
|
-
const current = created;
|
|
179
|
-
observer = new ResizeObserver(() => {
|
|
180
|
-
current.resize();
|
|
181
|
-
revealSelected();
|
|
182
|
-
});
|
|
183
|
-
observer.observe(box.current);
|
|
184
|
-
map.current = created;
|
|
185
|
-
setReady(true);
|
|
186
|
-
} catch (error) {
|
|
187
|
-
console.error("[map] could not start", error);
|
|
188
|
-
if (!cancelled) setFailed(true);
|
|
189
|
-
}
|
|
190
|
-
})();
|
|
191
|
-
return () => {
|
|
192
|
-
cancelled = true;
|
|
193
|
-
observer?.disconnect();
|
|
194
|
-
unfoldWatch();
|
|
195
|
-
markers.current.forEach((m) => m.remove());
|
|
196
|
-
markers.current = [];
|
|
197
|
-
created?.remove();
|
|
198
|
-
map.current = null;
|
|
199
|
-
};
|
|
200
|
-
}, []);
|
|
201
|
-
const shownTheme = useRef(theme);
|
|
202
|
-
useEffect(() => {
|
|
203
|
-
if (!ready || !map.current || shownTheme.current === theme) return;
|
|
204
|
-
shownTheme.current = theme;
|
|
205
|
-
map.current.setStyle(STYLES[theme]);
|
|
206
|
-
}, [ready, theme]);
|
|
207
|
-
useEffect(() => {
|
|
208
|
-
const m = map.current;
|
|
209
|
-
const maplibre = lib.current;
|
|
210
|
-
if (!ready || !m || !maplibre) return;
|
|
211
|
-
markers.current.forEach((marker) => marker.remove());
|
|
212
|
-
markers.current = [];
|
|
213
|
-
const ordered = [...pins].sort((a, b) => Number(a.key === selectedKey) - Number(b.key === selectedKey));
|
|
214
|
-
for (const pin of ordered) {
|
|
215
|
-
const el = pinElement(pin, pin.key === selectedKey);
|
|
216
|
-
el.addEventListener("click", (event) => {
|
|
217
|
-
event.stopPropagation();
|
|
218
|
-
latest.current.onSelect(pin.key);
|
|
219
|
-
});
|
|
220
|
-
markers.current.push(new maplibre.Marker({ element: el, anchor: "center" }).setLngLat([pin.lng, pin.lat]).addTo(m));
|
|
221
|
-
}
|
|
222
|
-
}, [ready, pins, selectedKey]);
|
|
223
|
-
useEffect(() => {
|
|
224
|
-
if (!ready || !selectedKey) return;
|
|
225
|
-
const frame = requestAnimationFrame(revealSelected);
|
|
226
|
-
return () => cancelAnimationFrame(frame);
|
|
227
|
-
}, [ready, selectedKey, revealSelected]);
|
|
228
|
-
useEffect(() => {
|
|
229
|
-
const m = map.current;
|
|
230
|
-
const maplibre = lib.current;
|
|
231
|
-
const target = fitTo ? pins.filter((p) => fitTo.includes(p.key)) : pins;
|
|
232
|
-
if (!ready || !m || !maplibre || target.length === 0) return;
|
|
233
|
-
const key = target.map((p) => `${p.key}@${p.lat},${p.lng}`).sort().join("|");
|
|
234
|
-
if (fitted.current === key) return;
|
|
235
|
-
const first = fitted.current === "";
|
|
236
|
-
fitted.current = key;
|
|
237
|
-
if (target.length === 1) {
|
|
238
|
-
m.jumpTo({ center: [target[0].lng, target[0].lat], zoom: 13 });
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
const bounds = new maplibre.LngLatBounds([target[0].lng, target[0].lat], [target[0].lng, target[0].lat]);
|
|
242
|
-
for (const p of target) bounds.extend([p.lng, p.lat]);
|
|
243
|
-
m.fitBounds(bounds, { padding: 48, maxZoom: 14, animate: !first });
|
|
244
|
-
}, [ready, pins, fitTo]);
|
|
245
|
-
useEffect(() => {
|
|
246
|
-
const m = map.current;
|
|
247
|
-
if (!ready || !m) return;
|
|
248
|
-
const data = {
|
|
249
|
-
type: "FeatureCollection",
|
|
250
|
-
features: (routes ?? []).filter((r) => r.coordinates.length >= 2).map((r) => ({
|
|
251
|
-
type: "Feature",
|
|
252
|
-
properties: { key: r.key, estimate: r.estimate, faded: !!r.faded },
|
|
253
|
-
geometry: { type: "LineString", coordinates: r.coordinates }
|
|
254
|
-
}))
|
|
255
|
-
};
|
|
256
|
-
const draw = () => {
|
|
257
|
-
const color = accentColor();
|
|
258
|
-
const opacity = ["case", ["get", "faded"], 0.25, 0.85];
|
|
259
|
-
const source = m.getSource(ROUTE_SOURCE);
|
|
260
|
-
if (source) source.setData(data);
|
|
261
|
-
else m.addSource(ROUTE_SOURCE, { type: "geojson", data });
|
|
262
|
-
if (m.getLayer("routes-road")) m.setPaintProperty("routes-road", "line-color", color);
|
|
263
|
-
else m.addLayer({
|
|
264
|
-
id: "routes-road",
|
|
265
|
-
type: "line",
|
|
266
|
-
source: ROUTE_SOURCE,
|
|
267
|
-
filter: ["!", ["get", "estimate"]],
|
|
268
|
-
layout: { "line-join": "round", "line-cap": "round" },
|
|
269
|
-
paint: { "line-color": color, "line-width": 4, "line-opacity": opacity }
|
|
270
|
-
});
|
|
271
|
-
if (m.getLayer("routes-estimate")) m.setPaintProperty("routes-estimate", "line-color", color);
|
|
272
|
-
else m.addLayer({
|
|
273
|
-
id: "routes-estimate",
|
|
274
|
-
type: "line",
|
|
275
|
-
source: ROUTE_SOURCE,
|
|
276
|
-
filter: ["get", "estimate"],
|
|
277
|
-
layout: { "line-join": "round", "line-cap": "round" },
|
|
278
|
-
paint: { "line-color": color, "line-width": 3, "line-dasharray": [1.5, 1.5], "line-opacity": opacity }
|
|
279
|
-
});
|
|
280
|
-
};
|
|
281
|
-
const tryDraw = () => {
|
|
282
|
-
try {
|
|
283
|
-
draw();
|
|
284
|
-
} catch (error) {
|
|
285
|
-
console.debug("[map] routes wait for the style", error);
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
tryDraw();
|
|
289
|
-
m.on("style.load", tryDraw);
|
|
290
|
-
m.once("idle", tryDraw);
|
|
291
|
-
return () => {
|
|
292
|
-
m.off("style.load", tryDraw);
|
|
293
|
-
m.off("idle", tryDraw);
|
|
294
|
-
};
|
|
295
|
-
}, [ready, routes, theme]);
|
|
296
|
-
useEffect(() => {
|
|
297
|
-
const m = map.current;
|
|
298
|
-
if (!ready || !m || !focus) return;
|
|
299
|
-
const pin = pins.find((p) => p.key === focus.key);
|
|
300
|
-
if (!pin) return;
|
|
301
|
-
const to = { center: [pin.lng, pin.lat], zoom: Math.max(m.getZoom(), 13) };
|
|
302
|
-
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) m.jumpTo(to);
|
|
303
|
-
else m.flyTo({ ...to, duration: 600 });
|
|
304
|
-
}, [ready, focus?.n]);
|
|
305
|
-
return /* @__PURE__ */ jsxs("div", { className: `relative min-h-72 overflow-hidden rounded-lg border border-gray-200 bg-gray-100 ${className}`, children: [
|
|
306
|
-
/* @__PURE__ */ jsx("div", { className: "absolute inset-0", children: /* @__PURE__ */ jsx("div", { ref: box, className: "h-full w-full", role: "region", "aria-label": ariaLabel }) }),
|
|
307
|
-
failed && /* @__PURE__ */ jsx("p", { className: "absolute inset-0 grid place-items-center p-6 text-center text-sm text-gray-500", children: "The map could not be drawn here. The list has everything it shows." }),
|
|
308
|
-
children
|
|
309
|
-
] });
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// src/map/points.ts
|
|
313
|
-
var PENDING_POLL_MS = 3e3;
|
|
314
|
-
var mapPointsRefetchInterval = (data) => data?.pending ? PENDING_POLL_MS : false;
|
|
315
|
-
var pointKey = (p) => `${p.kind}:${p.id}`;
|
|
316
|
-
var isOnMap = (p) => (p.placement === "located" || p.placement === "approximate") && p.lat != null && p.lng != null;
|
|
317
|
-
function placementNote(placement) {
|
|
318
|
-
switch (placement) {
|
|
319
|
-
case "located":
|
|
320
|
-
return null;
|
|
321
|
-
case "approximate":
|
|
322
|
-
return "Approximate: only the suburb or postcode matched";
|
|
323
|
-
case "pending":
|
|
324
|
-
return "Locating\u2026";
|
|
325
|
-
case "not_found":
|
|
326
|
-
return "Not on the map: address not found";
|
|
327
|
-
case "failed":
|
|
328
|
-
return "Not on the map: the map service could not be reached";
|
|
329
|
-
case "no_address":
|
|
330
|
-
return "Not on the map: no city or postcode";
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
var MAP_CATEGORIES = {
|
|
334
|
-
importer: { label: "Importer", tone: "bg-sky-600 text-white" },
|
|
335
|
-
dealer: { label: "Dealer", tone: "bg-purple-600 text-white" },
|
|
336
|
-
retail: { label: "Retail", tone: "bg-green-600 text-white" },
|
|
337
|
-
supplier: { label: "Supplier", tone: "bg-sky-600 text-white" },
|
|
338
|
-
delivery_location: { label: "Delivery location", tone: "bg-amber-600 text-white" },
|
|
339
|
-
warehouse: { label: "Warehouse", tone: "bg-amber-600 text-white" }
|
|
340
|
-
};
|
|
341
|
-
var DEFAULT_TONE = "bg-gray-700 text-white";
|
|
342
|
-
var CATEGORY_ORDER = ["importer", "dealer", "retail", "supplier", "delivery_location", "warehouse"];
|
|
343
|
-
function pinCategory(p) {
|
|
344
|
-
if (p.kind === "supplier") return "supplier";
|
|
345
|
-
if (p.kind === "customer") return p.category || "importer";
|
|
346
|
-
return p.kind;
|
|
347
|
-
}
|
|
348
|
-
var categoryTone = (category, categories = MAP_CATEGORIES) => categories[category]?.tone ?? DEFAULT_TONE;
|
|
349
|
-
var categoryLabel = (category, categories = MAP_CATEGORIES) => categories[category]?.label ?? category;
|
|
350
|
-
var pinTone = (p, categories) => categoryTone(pinCategory(p), categories);
|
|
351
|
-
function pinGlyph(p, number, categories = MAP_CATEGORIES) {
|
|
352
|
-
if (number != null) return String(number);
|
|
353
|
-
return (categories[pinCategory(p)]?.label ?? "").charAt(0).toUpperCase();
|
|
354
|
-
}
|
|
355
|
-
var SECONDARY_KINDS = ["delivery_location", "warehouse"];
|
|
356
|
-
function locationNumbers(points, kinds = SECONDARY_KINDS) {
|
|
357
|
-
const numbers = /* @__PURE__ */ new Map();
|
|
358
|
-
let n = 0;
|
|
359
|
-
for (const p of points) {
|
|
360
|
-
if (kinds.includes(p.kind)) numbers.set(pointKey(p), ++n);
|
|
361
|
-
}
|
|
362
|
-
return numbers;
|
|
363
|
-
}
|
|
364
|
-
function summarize(points) {
|
|
365
|
-
const summary = { onMap: 0, approximate: 0, pending: 0, off: 0 };
|
|
366
|
-
for (const p of points) {
|
|
367
|
-
if (isOnMap(p)) {
|
|
368
|
-
summary.onMap += 1;
|
|
369
|
-
if (p.placement === "approximate") summary.approximate += 1;
|
|
370
|
-
} else if (p.placement === "pending") summary.pending += 1;
|
|
371
|
-
else summary.off += 1;
|
|
372
|
-
}
|
|
373
|
-
return summary;
|
|
374
|
-
}
|
|
375
|
-
function summaryText(s) {
|
|
376
|
-
const parts = [`${s.onMap} on the map`];
|
|
377
|
-
if (s.approximate) parts.push(`${s.approximate} approximate`);
|
|
378
|
-
if (s.pending) parts.push(`${s.pending} locating`);
|
|
379
|
-
if (s.off) parts.push(`${s.off} not on the map`);
|
|
380
|
-
return parts.join(" \xB7 ");
|
|
381
|
-
}
|
|
382
|
-
function legendCategories(points) {
|
|
383
|
-
const present = [...new Set(points.filter(isOnMap).map(pinCategory))];
|
|
384
|
-
const known = CATEGORY_ORDER.filter((c) => present.includes(c));
|
|
385
|
-
return [...known, ...present.filter((c) => !CATEGORY_ORDER.includes(c))];
|
|
386
|
-
}
|
|
387
|
-
function offMapNotes(points, numbers) {
|
|
388
|
-
return points.filter((p) => !isOnMap(p) && p.placement !== "pending").map((p) => {
|
|
389
|
-
const n = numbers?.get(pointKey(p));
|
|
390
|
-
const note = placementNote(p.placement)?.replace(/^Not on the map: /, "") ?? "";
|
|
391
|
-
return { key: pointKey(p), text: `${n != null ? `${n}. ` : ""}${p.label}: ${note}` };
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
function MapLegend({ categories, palette = MAP_CATEGORIES, floating = true }) {
|
|
395
|
-
if (categories.length < 2) return null;
|
|
396
|
-
return /* @__PURE__ */ jsx("div", { className: `${floating ? "absolute left-3 top-3 z-10 " : ""}flex flex-wrap gap-x-3 gap-y-1 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs text-gray-600 shadow-sm`, children: categories.map((c) => /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
397
|
-
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: `h-2.5 w-2.5 rounded-full ${categoryTone(c, palette)}` }),
|
|
398
|
-
categoryLabel(c, palette)
|
|
399
|
-
] }, c)) });
|
|
400
|
-
}
|
|
401
|
-
function SelectedCard({ point, number, onOpen, onClose, palette = MAP_CATEGORIES }) {
|
|
402
|
-
const note = placementNote(point.placement);
|
|
403
|
-
const category = pinCategory(point);
|
|
404
|
-
return /* @__PURE__ */ jsxs(
|
|
405
|
-
"section",
|
|
406
|
-
{
|
|
407
|
-
"aria-label": `${point.label}, chosen on the map`,
|
|
408
|
-
className: "absolute bottom-3 left-3 right-3 z-10 max-w-md space-y-1.5 rounded-lg border border-gray-200 bg-white p-3 shadow-md",
|
|
409
|
-
children: [
|
|
410
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
|
|
411
|
-
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
412
|
-
/* @__PURE__ */ jsxs("h3", { className: "text-sm font-semibold text-gray-900 [overflow-wrap:anywhere]", children: [
|
|
413
|
-
number != null && /* @__PURE__ */ jsxs("span", { className: "mr-1 text-gray-400", children: [
|
|
414
|
-
number,
|
|
415
|
-
"."
|
|
416
|
-
] }),
|
|
417
|
-
point.label,
|
|
418
|
-
point.code && /* @__PURE__ */ jsx("span", { className: "ml-1.5 text-xs font-normal text-gray-400", children: point.code })
|
|
419
|
-
] }),
|
|
420
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500", children: palette[category] ? categoryLabel(category, palette) : point.category })
|
|
421
|
-
] }),
|
|
422
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: onClose, "aria-label": "Close", className: "rounded p-0.5 text-gray-400 hover:text-gray-600", children: /* @__PURE__ */ jsx("svg", { "aria-hidden": true, className: "h-4 w-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) }) })
|
|
423
|
-
] }),
|
|
424
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-gray-700 [overflow-wrap:anywhere]", children: point.address || "\u2014" }),
|
|
425
|
-
note && /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500", children: note }),
|
|
426
|
-
point.matched && point.placement === "approximate" && /* @__PURE__ */ jsxs("p", { className: "text-xs text-gray-400 [overflow-wrap:anywhere]", children: [
|
|
427
|
-
"Placed at: ",
|
|
428
|
-
point.matched
|
|
429
|
-
] }),
|
|
430
|
-
onOpen && /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button_default, { variant: "secondary", size: "sm", onClick: onOpen, children: "Open" }) })
|
|
431
|
-
]
|
|
432
|
-
}
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
|
-
function useMapPoints(queryKey, queryFn, { staleTime } = {}) {
|
|
436
|
-
return useQuery({
|
|
437
|
-
queryKey,
|
|
438
|
-
queryFn,
|
|
439
|
-
staleTime,
|
|
440
|
-
refetchInterval: (query) => mapPointsRefetchInterval(query.state.data)
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
var NOTES_SHOWN = 3;
|
|
444
|
-
function LocationsMap({
|
|
445
|
-
queryKey,
|
|
446
|
-
queryFn,
|
|
447
|
-
refreshSignal,
|
|
448
|
-
onOpen,
|
|
449
|
-
ariaLabel,
|
|
450
|
-
title = "Locations",
|
|
451
|
-
palette = MAP_CATEGORIES,
|
|
452
|
-
numbers: givenNumbers,
|
|
453
|
-
className = "",
|
|
454
|
-
mapClassName = "min-h-[240px] flex-1"
|
|
455
|
-
}) {
|
|
456
|
-
const { data, isError, refetch } = useMapPoints(queryKey, queryFn, { staleTime: 0 });
|
|
457
|
-
const mounted = useRef(false);
|
|
458
|
-
useEffect(() => {
|
|
459
|
-
if (!mounted.current) {
|
|
460
|
-
mounted.current = true;
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
void refetch();
|
|
464
|
-
}, [refreshSignal]);
|
|
465
|
-
const [selectedKey, setSelectedKey] = useState(null);
|
|
466
|
-
const points = useMemo(() => data?.points ?? [], [data]);
|
|
467
|
-
const numbers = useMemo(() => givenNumbers ?? locationNumbers(points), [givenNumbers, points]);
|
|
468
|
-
const pins = useMemo(() => points.filter(isOnMap).map((p) => ({
|
|
469
|
-
key: pointKey(p),
|
|
470
|
-
label: p.label,
|
|
471
|
-
lat: p.lat,
|
|
472
|
-
lng: p.lng,
|
|
473
|
-
glyph: pinGlyph(p, numbers.get(pointKey(p)) ?? null, palette),
|
|
474
|
-
tone: pinTone(p, palette),
|
|
475
|
-
approximate: p.placement === "approximate"
|
|
476
|
-
})), [points, numbers, palette]);
|
|
477
|
-
const notes = useMemo(() => offMapNotes(points, numbers), [points, numbers]);
|
|
478
|
-
const legend = useMemo(() => legendCategories(points), [points]);
|
|
479
|
-
const pending = data?.pending ?? 0;
|
|
480
|
-
const selected = points.find((p) => pointKey(p) === selectedKey) ?? null;
|
|
481
|
-
const open = selected && onOpen ? onOpen(selected) : null;
|
|
482
|
-
return /* @__PURE__ */ jsxs("section", { "aria-label": title, className: `flex min-w-0 flex-col ${className}`, children: [
|
|
483
|
-
/* @__PURE__ */ jsxs("div", { className: "flex min-h-[30px] items-center justify-between mb-2", children: [
|
|
484
|
-
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-gray-900", children: title }),
|
|
485
|
-
data && /* @__PURE__ */ jsx("span", { className: "text-xs text-gray-500", children: summaryText(summarize(points)) })
|
|
486
|
-
] }),
|
|
487
|
-
/* @__PURE__ */ jsxs(
|
|
488
|
-
EntityMap,
|
|
489
|
-
{
|
|
490
|
-
pins,
|
|
491
|
-
selectedKey,
|
|
492
|
-
focus: null,
|
|
493
|
-
onSelect: setSelectedKey,
|
|
494
|
-
ariaLabel,
|
|
495
|
-
className: mapClassName,
|
|
496
|
-
children: [
|
|
497
|
-
/* @__PURE__ */ jsxs("div", { className: "absolute left-3 top-3 z-10 flex max-w-[70%] flex-col items-start gap-1.5", children: [
|
|
498
|
-
/* @__PURE__ */ jsx(MapLegend, { categories: legend, palette, floating: false }),
|
|
499
|
-
isError && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs text-gray-600 shadow-sm", children: [
|
|
500
|
-
"Couldn\u2019t load the locations.",
|
|
501
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => void refetch(), className: "font-medium text-blue-600 hover:text-blue-800 hover:underline", children: "Try again" })
|
|
502
|
-
] }),
|
|
503
|
-
!isError && (pending > 0 || notes.length > 0) && /* @__PURE__ */ jsxs("div", { className: "max-w-full space-y-0.5 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs shadow-sm", "aria-live": "polite", children: [
|
|
504
|
-
pending > 0 && /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1.5 text-gray-500", children: [
|
|
505
|
-
/* @__PURE__ */ jsxs("svg", { className: "h-3 w-3 animate-spin", fill: "none", viewBox: "0 0 24 24", children: [
|
|
506
|
-
/* @__PURE__ */ jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
507
|
-
/* @__PURE__ */ jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" })
|
|
508
|
-
] }),
|
|
509
|
-
"Locating ",
|
|
510
|
-
pending,
|
|
511
|
-
" address",
|
|
512
|
-
pending === 1 ? "" : "es",
|
|
513
|
-
"\u2026"
|
|
514
|
-
] }),
|
|
515
|
-
notes.slice(0, NOTES_SHOWN).map((n) => /* @__PURE__ */ jsx("p", { className: "truncate text-amber-700", title: n.text, children: n.text }, n.key)),
|
|
516
|
-
notes.length > NOTES_SHOWN && /* @__PURE__ */ jsxs("p", { className: "text-gray-500", children: [
|
|
517
|
-
"+",
|
|
518
|
-
notes.length - NOTES_SHOWN,
|
|
519
|
-
" more not on the map"
|
|
520
|
-
] })
|
|
521
|
-
] })
|
|
522
|
-
] }),
|
|
523
|
-
selected && /* @__PURE__ */ jsx(
|
|
524
|
-
SelectedCard,
|
|
525
|
-
{
|
|
526
|
-
point: selected,
|
|
527
|
-
number: numbers.get(pointKey(selected)) ?? null,
|
|
528
|
-
onOpen: open,
|
|
529
|
-
onClose: () => setSelectedKey(null),
|
|
530
|
-
palette
|
|
531
|
-
}
|
|
532
|
-
)
|
|
533
|
-
]
|
|
534
|
-
}
|
|
535
|
-
)
|
|
536
|
-
] });
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
export { COMPACT_SHOW, EntityMap, LocationsMap, MAPLIBRE_WORKER_FILE, MAP_CATEGORIES, MapLegend, PENDING_POLL_MS, SECONDARY_KINDS, SelectedCard, categoryLabel, categoryTone, foldAttributionOnce, isOnMap, legendCategories, loadMapLibre, locationNumbers, mapLibreWorkerUrl, mapPointsRefetchInterval, offMapNotes, pinCategory, pinGlyph, pinTone, placementNote, pointKey, summarize, summaryText, useMapPoints };
|
|
540
|
-
//# sourceMappingURL=index.js.map
|
|
541
|
-
//# sourceMappingURL=index.js.map
|
|
2
|
+
import{Button_default as e}from"../chunk-PH3PRIFP.js";import{rootIsDark as t,ROOT_THEME_ATTRIBUTES as n}from"../chunk-MAIHBBWT.js";import{useShellStrings as r}from"../chunk-TR6PLN7W.js";import{useRef as o,useState as a,useEffect as l,useCallback as i,useMemo as s,useSyncExternalStore as c}from"react";import{createPortal as u}from"react-dom";import{jsxs as d,jsx as p,Fragment as m}from"react/jsx-runtime";import{useQuery as h}from"@tanstack/react-query";var g="maplibregl-compact-show";function f(e){if(!e)return()=>{};const t=()=>!!e.classList.contains(g)&&(e.classList.remove(g),!0);if(t())return()=>{};const n=new MutationObserver(()=>{t()&&n.disconnect()});return n.observe(e,{attributes:!0,attributeFilter:["class"]}),()=>n.disconnect()}var y=20,b=12,x=480,v={center:[0,0],left:[y,0],right:[-20,0],top:[0,y],"top-left":[0,y],"top-right":[0,y],bottom:[0,-20],"bottom-left":[0,-20],"bottom-right":[0,-20]},w=(e,t=12)=>Math.max(0,Math.floor(e-t-b-y-10-16));function k(e,t,n,r=12){const o=e.y-y-r,a=n.height-e.y-y-b,l=t.height<=o||t.height>a&&o>=a,i=l?Math.max(0,t.height-o):-Math.max(0,t.height-a);let s="",c=0;return e.x-t.width/2<b?(s="-left",c=Math.max(0,b-e.x)):e.x+t.width/2>n.width-b&&(s="-right",c=-Math.max(0,e.x-(n.width-b))),{anchor:`${l?"bottom":"top"}${s}`,move:{x:c,y:i}}}var M="maplibre-gl-worker.mjs",N=e=>`/maplibre-gl/${e}/${M}`,C=null;function L(){return C??=Promise.all([import("maplibre-gl"),import("maplibre-gl/dist/maplibre-gl.css")]).then(([e])=>(e.setWorkerUrl(N(e.getVersion())),e)).catch(e=>{throw C=null,e}),C}var $=24,E=28,S=29;function j(e){const t=[...e].sort((e,t)=>e-t),n=[];for(let e=0;e<t.length;){let r=e;for(;r+1<t.length&&t[r+1]===t[r]+1;)r++;n.push(r===e?String(t[e]):`${t[e]}–${t[r]}`),e=r+1}return n.join(", ")}function A(e){const t=Math.max(E,12+8*e.length);return t+t%2}var z=(e,t,n,r)=>({left:e-n/2,top:t-r/2,right:e+n/2,bottom:t+r/2});function B(e,t){return e.left<t.right+1&&t.left<e.right+1&&e.top<t.bottom+1&&t.top<e.bottom+1}var R=e=>z(e.x,e.y,e.width,e.height);function T(e){for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(B(R(e[t]),R(e[n])))return[e[t],e[n]];return null}function O(e,t=[]){const n=[],r=e=>t.some(t=>B(t,e));let o=e.filter(e=>null!==e.stop).sort((e,t)=>e.stop-t.stop).map(e=>({keys:[e.key],stops:[e.stop],x:e.x,y:e.y,width:E,height:E,under:0}));for(let e=T(o);e;e=T(o)){const[t,n]=e;t.keys.push(...n.keys),t.stops.push(...n.stops),t.stops.sort((e,t)=>e-t),t.width=A(j(t.stops)),o=o.filter(e=>e!==n)}o=o.filter(e=>!r(R(e))||(n.push(...e.keys),!1));const a=[];for(const t of e){if(null!==t.stop)continue;const e=z(t.x,t.y,$,$),l=o.find(t=>B(R(t),e));if(l||r(e)){n.push(t.key),l&&l.under++;continue}const i=a.find(t=>B(R(t),e));i?i.keys.push(t.key):a.push({keys:[t.key],stops:[],x:t.x,y:t.y,width:$,height:$,under:0})}return{groups:[...o,...a],hidden:n}}function W(e,t,n){let r=-1/0;for(const o of t){const t=Math.max(Math.abs(o.x-e.x),Math.abs(o.y-e.y));r=Math.max(r,0===t?1/0:n+Math.log2(29/t))}return r}function F(e){const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:n}),()=>t.disconnect()}var P=t;var q="routes",K=["routes-road","routes-estimate"];function _(e){const t=document.createElement("span");t.style.display="none",t.style.color=e,document.body.appendChild(t);const n=getComputedStyle(t).color||"#2563eb";return t.remove(),H(n)}function H(e){const t=document.createElement("canvas").getContext("2d");if(!t)return"#2563eb";t.fillStyle="#2563eb",t.fillStyle=e,t.fillRect(0,0,1,1);const[n,r,o]=t.getImageData(0,0,1,1).data;return`rgb(${n}, ${r}, ${o})`}var I={light:"https://tiles.openfreemap.org/styles/positron",dark:"https://tiles.openfreemap.org/styles/dark"},D={center:[30,20],zoom:1},Z="ring-2 ring-gray-900 ring-offset-2";var V="var(--color-gray-600, #4b5563)",G="http://www.w3.org/2000/svg",U=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,J=/^(?:\d+|[xytrblse](?:-\d+)?|solid|dashed|dotted|double|hidden|none)$/;function Q(e){return e.split(/\s+/).some(e=>{const t=e.search(/[[(]/),n=t<0?e:e.slice(0,t),r=e.slice(n.lastIndexOf(":")+1);return r.startsWith("border-")&&!J.test(r.slice(7))})}var X=(...e)=>e.filter(Boolean).join(" ");function Y(e){const t=document.createElementNS(G,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("aria-hidden","true");for(const n of e){const e=document.createElementNS(G,"path");e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("d",n),t.appendChild(e)}return t}function ee(e,t){for(const[n,r]of Object.entries(t??{}))e.dataset[n]=r}var te=(e,t)=>X("relative grid place-items-center rounded-full cursor-pointer",t&&(null!=e.stop?"h-7 w-7":"h-6 w-6"));function ne(e,t,n,r){const o=t&&!r&&null==e.stop&&!e.dot;return X("grid place-items-center rounded-full border-2 font-semibold leading-none shadow-md transition-transform motion-reduce:transition-none",!Q(e.tone)&&"border-white",e.tone,e.dot?"h-4 w-4 opacity-80":null!=e.stop?"h-7 w-7 text-xs ring-2 ring-gray-900":o?"h-8 w-8 text-xs [&_svg]:h-4 [&_svg]:w-4":"h-6 w-6 text-[10px] [&_svg]:h-3.5 [&_svg]:w-3.5",t&&(o?"ring-2 ring-gray-900 ring-offset-1":Z),e.approximate&&"border-dashed opacity-80",e.faded&&!t&&"opacity-40",n&&"scale-125 opacity-100")}var re=e=>X("grid place-items-center border-2 px-0.5 text-xs font-semibold leading-none shadow-sm",e.stop?"h-7 min-w-7":"h-6 min-w-6",!Q(e.tone??"")&&"border-white",e.tone??"bg-gray-900 text-white");function oe({pins:t,selectedKey:n,focus:s,onSelect:m,ariaLabel:h,className:g="",children:y,routes:b,fitTo:x,attribution:M,marks:N,groupCrowded:C=!1,noun:S,highlightKey:A=null,picking:z=!1,onPick:B,card:R,cardMinMapWidth:T=480,fullScreen:G,initialView:J=D,cooperativeGestures:Q=!1}){const oe=r().map,ie=o(null),se=o(null),ce=o(null),ue=o(null),de=o([]),pe=o(/* @__PURE__ */new Map),me=o(/* @__PURE__ */new Map),he=o(/* @__PURE__ */new Map),ge=o(null),fe=o(/* @__PURE__ */new Map),ye=o(""),[be,xe]=a(!1),[ve,we]=a(!1),ke=c(F,P,()=>!1)?"dark":"light",Me=o({onSelect:m,onPick:B,picking:z,pins:t,selectedKey:n,highlightKey:A,groupCrowded:C,strings:oe,noun:S});l(()=>{Me.current={onSelect:m,onPick:B,picking:z,pins:t,selectedKey:n,highlightKey:A,groupCrowded:C,strings:oe,noun:S}});const Ne=i(()=>{const e=ce.current,{pins:t,selectedKey:n}=Me.current,r=n?t.find(e=>e.key===n):void 0;e&&r&&!e.getBounds().contains([r.lng,r.lat])&&e.easeTo({center:[r.lng,r.lat],duration:U()?0:400})},[]),Ce=o(!1),Le=i((e,t)=>{const n=ce.current,r=ue.current;if(!n||!r)return;const o=n.getZoom();if(o>=17.5){const t=e.indexOf(Me.current.selectedKey??"");return void Me.current.onSelect(e[(t+1)%e.length])}const a=e.map(e=>pe.current.get(e).pin),l=new r.LngLatBounds([a[0].lng,a[0].lat],[a[0].lng,a[0].lat]);for(const e of a)l.extend([e.lng,e.lat]);const i=a.map(e=>n.project([e.lng,e.lat])),s=Math.max(...i.map((e,t)=>W(e,i.filter((e,n)=>n!==t),o))),{clientWidth:c,clientHeight:u}=n.getContainer(),d=n.cameraForBounds(l,{padding:Math.min(64,c/4,u/4)})?.zoom??18,p=document.activeElement===t;Ce.current=!0,n.once("moveend",()=>{if(Ce.current=!1,!p)return;const e=a[0].key,t=pe.current.get(e)?.button,n=t&&"none"!==t.style.display?t:[...me.current.values()].find(t=>t.keys.includes(e))?.button;n?.focus({preventScroll:!0})}),n.easeTo({center:l.getCenter(),zoom:Math.min(18,Math.max(o+1,Math.min(d,s))),duration:U()?0:600})},[]),$e=i(()=>{const e=ce.current,t=ue.current;if(!e||!t||!ie.current||Ce.current&&e.isMoving())return;const{selectedKey:n,highlightKey:r,groupCrowded:o,strings:a,noun:l}=Me.current;for(const[e,t]of pe.current){const a=ne(t.pin,e===n,e===r,o);t.mark.className!==a&&(t.mark.className=a);const l=e===n?"1":"";t.button.style.zIndex!==l&&(t.button.style.zIndex=l)}let i=null;if(o){const r=e.getContainer().getBoundingClientRect(),o=[...ie.current.querySelectorAll("a[href], button, input, select, textarea, summary, [role='button'], [tabindex]:not([tabindex='-1'])")].filter(e=>!e.closest("[data-pin], [data-pin-group], .maplibregl-canvas")).map(e=>{const t=e.getBoundingClientRect(),n=e.closest("[data-map-card]")?.getBoundingClientRect()??t;return{left:Math.max(t.left,n.left)-r.left,top:Math.max(t.top,n.top)-r.top,right:Math.min(t.right,n.right)-r.left,bottom:Math.min(t.bottom,n.bottom)-r.top}}).filter(e=>e.right>e.left&&e.bottom>e.top);i=O([...pe.current.values()].map(({pin:t})=>{const n=e.project([t.lng,t.lat]);return{key:t.key,x:n.x,y:n.y,stop:t.stop??null}}),o);const s=e=>(l??a.places)(e),c=e.getZoom()<17.5?a.spread:a.cycle,u=(e,t)=>{const n=t?"":"none";e.style.display!==n&&(e.style.display=n)},d=/* @__PURE__ */new Map;for(const r of i.groups){const o=r.under>0?a.closeBy(r.under,s(r.under)):null,l=1===r.keys.length?pe.current.get(r.keys[0]):null;if(l){u(l.button,!0),l.button.setAttribute("aria-label",o?`${l.name}; ${o}`:l.name),l.button.title=o?`${l.title}\n${o}`:l.title;continue}for(const e of r.keys)u(pe.current.get(e).button,!1);const i=r.keys.join(" ");let p=me.current.get(i);if(!p){const n=document.createElement("button");n.type="button",n.dataset.pinGroup="",n.className="grid place-items-center rounded-full cursor-pointer",n.append(document.createElement("span"));const o=pe.current.get(r.keys[0]).pin,a={button:n,keys:r.keys,marker:new t.Marker({element:n,anchor:"center"}).setLngLat([o.lng,o.lat]).addTo(e)};n.addEventListener("click",e=>{e.stopPropagation(),Le(a.keys,n)}),p=a}p.keys=r.keys;const m=r.keys.map(e=>pe.current.get(e)),h=r.stops.length>0?j(r.stops):String(m.length),g=r.stops.length>0?a.stops(h):a.group(m.length,s(m.length));p.button.style.width=`${r.width}px`,p.button.style.height=`${r.height}px`,p.button.setAttribute("aria-label",`${g}: ${m.map(e=>e.pin.label).join("; ")}. ${c}${o?`; ${o}`:""}.`),p.button.title=[`${g}:`,...m.map(e=>e.title),...o?[o]:[],c].join("\n");const f=p.button.firstElementChild;f.textContent=h;const y=X("grid place-items-center rounded-full border-2 border-gray-700 bg-white font-semibold leading-none text-gray-900 shadow-sm",r.stops.length>0?"h-7 w-full px-1 text-xs ring-2 ring-gray-900":m.every(e=>e.pin.dot)?"h-5 w-5 text-[0.6rem]":"h-6 w-6 text-[0.7rem]",null!=n&&r.keys.includes(n)&&Z);f.className!==y&&(f.className=y),d.set(i,p)}for(const e of i.hidden)u(pe.current.get(e).button,!1);for(const[e,t]of me.current)d.has(e)||t.marker.remove();me.current=d}if(ge.current){const e=r&&i?i.groups.find(e=>e.keys.includes(r)&&e.keys.length>1):void 0,t=r?pe.current.get(r):void 0,n=r?he.current.get(r):void 0,o=e?{at:pe.current.get(e.keys[0]).pin,width:e.width,height:e.height}:t?{at:t.pin,width:t.button.offsetWidth||(null!=t.pin.stop?E:$),height:t.button.offsetHeight||(null!=t.pin.stop?E:$)}:n?{at:n.mark,width:n.element.offsetWidth||E,height:n.element.offsetHeight||E}:null,a=ge.current.getElement();a.style.display=o?"":"none",o&&(ge.current.setLngLat([o.at.lng,o.at.lat]),a.style.width=`${o.width+22}px`,a.style.height=`${o.height+22}px`)}},[Le]);l(()=>{if($e(),!ie.current)return;const e=new ResizeObserver(()=>$e());e.observe(ie.current);for(const t of ie.current.children)t.contains(se.current)||e.observe(t);return()=>e.disconnect()}),l(()=>{let e=!1,t=null,n=null,r=()=>{};return(async()=>{try{const o=await L();if(e||!se.current)return;ue.current=o,t=new o.Map({container:se.current,style:I[ke],center:J.center,zoom:J.zoom,attributionControl:M?{compact:!0,customAttribution:M}:{compact:!0},dragRotate:!1,pitchWithRotate:!1,touchPitch:!1,maxPitch:0,cooperativeGestures:"coarse"===Q?window.matchMedia("(pointer: coarse)").matches:Q}),t.touchZoomRotate.disableRotation(),t.keyboard.disableRotation(),t.addControl(new o.NavigationControl({showCompass:!1}),"top-right");const a=document.createElement("div");a.dataset.pinRing="",a.setAttribute("aria-hidden","true"),a.className="pointer-events-none rounded-full border-2 border-gray-900 bg-gray-900/15 shadow-[0_0_0_2px_var(--color-white,#fff)]",a.style.display="none",ge.current=new o.Marker({element:a,anchor:"center"}).setLngLat(J.center).addTo(t),t.on("click",e=>{Me.current.picking&&Me.current.onPick?.({lat:e.lngLat.lat,lng:e.lngLat.lng})}),t.on("move",$e),t.on("moveend",$e),t.on("resize",$e),t.on("error",e=>console.warn("[map]",e.error?.message)),r=f(se.current.querySelector(".maplibregl-ctrl-attrib"));const l=t;n=new ResizeObserver(()=>{l.resize(),Ne()}),n.observe(se.current),ce.current=t,xe(!0)}catch(t){console.error("[map] could not start",t),e||we(!0)}})(),()=>{e=!0,n?.disconnect(),r(),de.current.forEach(e=>e.remove()),de.current=[],me.current.forEach(e=>e.marker.remove()),me.current.clear(),ge.current?.remove(),ge.current=null,t?.remove(),ce.current=null}},[]);const Ee=o(ke);l(()=>{be&&ce.current&&Ee.current!==ke&&(Ee.current=ke,ce.current.setStyle(I[ke]))},[be,ke]),l(()=>{const e=ce.current,n=ue.current;if(!be||!e||!n)return;de.current.forEach(e=>e.remove()),de.current=[],me.current.forEach(e=>e.marker.remove()),me.current.clear(),pe.current.clear(),he.current.clear();for(const e of fe.current.keys())t.some(t=>t.key===e)||fe.current.delete(e);const r=Me.current.strings;for(const o of t){const t=document.createElement("button");t.type="button",t.dataset.pin=o.key,t.className=te(o,C);const a=o.approximate?r.approximate(o.label):o.label,l=o.title??(o.approximate?r.approximateTitle(o.label):o.label);t.setAttribute("aria-label",a),t.title=l;const i=document.createElement("span");if(ee(i,o.data),o.dot);else if(null!=o.iconNode){const e=fe.current.get(o.key);e&&i.append(e)}else o.icon?.length?i.append(Y(o.icon)):i.textContent=null!=o.stop?String(o.stop):o.glyph;if(t.append(i),o.badge){const e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.className=X("absolute -right-2 -top-2 grid h-4 min-w-4 place-items-center rounded-full px-0.5 text-[9px] font-semibold leading-none shadow",o.badgeTone??"bg-white text-gray-900"),e.textContent=o.badge,t.appendChild(e)}t.addEventListener("click",e=>{e.stopPropagation(),Me.current.onSelect(o.key)}),de.current.push(new n.Marker({element:t,anchor:"center"}).setLngLat([o.lng,o.lat]).addTo(e)),pe.current.set(o.key,{pin:o,button:t,mark:i,name:a,title:l})}for(const t of N??[]){const r=document.createElement("div");r.dataset.mapMark=t.key,ee(r,t.data),r.className=re(t),r.textContent=t.text,r.title=t.title??t.label,r.setAttribute("role","img"),r.setAttribute("aria-label",t.label),de.current.push(new n.Marker({element:r,anchor:"center"}).setLngLat([t.lng,t.lat]).addTo(e)),he.current.set(t.key,{mark:t,element:r})}$e()},[be,t,N,C,$e]),l(()=>{be&&$e()},[be,n,A,$e]),l(()=>{if(!be||!n)return;const e=requestAnimationFrame(Ne);return()=>cancelAnimationFrame(e)},[be,n,Ne]),l(()=>{const e=ce.current,n=ue.current,r=x?[...t,...N??[]].filter(e=>x.includes(e.key)):t;if(!be||!e||!n||0===r.length)return;const o=r.map(e=>`${e.key}@${e.lat},${e.lng}`).sort().join("|");if(ye.current===o)return;const a=""===ye.current;if(ye.current=o,1===r.length)return void e.jumpTo({center:[r[0].lng,r[0].lat],zoom:13});const l=new n.LngLatBounds([r[0].lng,r[0].lat],[r[0].lng,r[0].lat]);for(const e of r)l.extend([e.lng,e.lat]);e.fitBounds(l,{padding:48,maxZoom:14,animate:!a})},[be,t,N,x]),l(()=>{const e=ce.current;if(!be||!e)return;const t=(b??[]).filter(e=>e.coordinates.length>=2),n=[...new Set(t.flatMap(e=>e.attribution?[e.attribution]:[]))].join(" · "),r=()=>{const r=function(){const e=document.createElement("span");e.className="text-blue-600",e.style.display="none",document.body.appendChild(e);const t=getComputedStyle(e).color||"#2563eb";return e.remove(),H(t)}(),o={type:"FeatureCollection",features:t.map(e=>({type:"Feature",properties:{key:e.key,estimate:e.estimate,faded:!!e.faded,color:e.color?_(e.color):r},geometry:{type:"LineString",coordinates:e.coordinates}}))},a=["case",["get","faded"],.25,.85],l=["get","color"],i=e.getSource(q);if(i&&(i.attribution||"")!==n){for(const t of K)e.getLayer(t)&&e.removeLayer(t);e.removeSource(q)}const s=e.getSource(q);s?s.setData(o):e.addSource(q,{type:"geojson",data:o,...n?{attribution:n}:{}}),e.getLayer("routes-road")||e.addLayer({id:"routes-road",type:"line",source:q,filter:["!",["get","estimate"]],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":l,"line-width":4,"line-opacity":a}}),e.getLayer("routes-estimate")||e.addLayer({id:"routes-estimate",type:"line",source:q,filter:["get","estimate"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":l,"line-width":3,"line-dasharray":[1.5,1.5],"line-opacity":a}})},o=()=>{try{r()}catch(e){console.debug("[map] routes wait for the style",e)}};return o(),e.on("style.load",o),e.once("idle",o),()=>{e.off("style.load",o),e.off("idle",o)}},[be,b,ke]),l(()=>{const e=ce.current;if(!be||!e||!s)return;const n=t.find(e=>e.key===s.key);if(!n)return;const r=e.getZoom(),o=C?W(e.project([n.lng,n.lat]),t.filter(e=>e.key!==n.key).map(t=>e.project([t.lng,t.lat])),r):-1/0,a={center:[n.lng,n.lat],zoom:Math.min(18,Math.max(r,13,o))};U()?e.jumpTo(a):e.flyTo({...a,duration:600})},[be,s?.n]);const[Se,je]=a(!1);l(()=>{const e=ie.current;if(!e)return;const t=()=>je(e.clientWidth<T);t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[T]);const Ae=n?t.find(e=>e.key===n)??null:null,ze=Ae?.key??null,Be=Ae?.lng??0,Re=Ae?.lat??0,Te=be&&!Se&&null!=R&&!!Ae,[Oe,We]=a(null);l(()=>{const e=ce.current,t=ue.current;if(!(Te&&e&&t&&ze))return;const n=document.createElement("div");n.dataset.mapCard="",n.className="w-[26rem] overflow-y-auto overscroll-contain";const r=new t.Popup({anchor:"bottom",offset:v,className:"rosh-map-card",maxWidth:"none",closeButton:!1,closeOnClick:!1,closeOnMove:!1,focusAfterOpen:!1}).setLngLat([Be,Re]).setDOMContent(n).addTo(e),o=r.getElement(),a=o.querySelector(".maplibregl-popup-content");a&&Object.assign(a.style,{padding:"0",background:"transparent",borderRadius:"0",boxShadow:"none"});const l=o.querySelector(".maplibregl-popup-tip");l&&Object.assign(l.style,{borderTopColor:V,borderBottomColor:V}),We(n);let i=!1,s=!1;const c=(t=!0)=>{if(s)return;if(e.isMoving())return void(i||(i=!0,e.once("moveend",()=>{i=!1,c()})));const{clientWidth:o,clientHeight:a}=e.getContainer(),l=function(e,t){const n=e.getBoundingClientRect().top,r=[...e.querySelectorAll(".maplibregl-ctrl-top-left > *, .maplibregl-ctrl-top-right > *"),...t?.querySelectorAll(":scope > [data-map-control]")??[]];let o=0;for(const e of r){const t=e.getBoundingClientRect();t.height>0&&(o=Math.max(o,t.bottom-n))}return o}(e.getContainer(),ie.current)+8,u=`${w(a,l)}px`;n.style.maxHeight!==u&&(n.style.maxHeight=u);const d=r.getElement(),p=r.getLngLat(),{anchor:m,move:h}=k(e.project(p),{width:d.offsetWidth,height:d.offsetHeight},{width:o,height:a},l);r.options.anchor!==m&&(r.options.anchor=m,r.setLngLat(p)),!t||0===h.x&&0===h.y||e.panBy([-h.x,-h.y],{duration:U()?0:250}),$e()},u=new ResizeObserver(()=>c());u.observe(n);const d=()=>c(),p=()=>{i||c(!1)};e.on("resize",d),e.on("moveend",p);let m=!1;const h=pe.current,g=e=>{m=n.contains(e.target)};return document.addEventListener("focusin",g),()=>{if(s=!0,u.disconnect(),e.off("resize",d),e.off("moveend",p),document.removeEventListener("focusin",g),r.remove(),We(null),m&&(!document.activeElement||document.activeElement===document.body)){const e=h.get(ze)?.button;e&&"none"!==e.style.display&&e.focus({preventScroll:!0})}}},[Te,ze,Be,Re,$e]);const Fe=G?.active??!1,Pe=o(G?.onChange);l(()=>{Pe.current=G?.onChange}),l(()=>{if(!G)return;const e=document.documentElement;Fe&&!document.fullscreenElement&&e.requestFullscreen&&e.requestFullscreen().catch(()=>{}),!Fe&&document.fullscreenElement&&document.exitFullscreen().catch(()=>{})},[Fe]);const qe=!!G;return l(()=>{if(!qe)return;const e=()=>{document.fullscreenElement||Pe.current?.(!1)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[qe]),/* @__PURE__ */d("div",{ref:ie,className:X("relative min-h-72 overflow-hidden rounded-lg border border-gray-200 bg-gray-100",z&&"[&_canvas]:cursor-crosshair",g),children:[
|
|
3
|
+
/* @__PURE__ */p("div",{className:"absolute inset-0",children:/* @__PURE__ */p("div",{ref:se,className:"h-full w-full",role:"region","aria-label":h})}),ve&&/* @__PURE__ */p("p",{className:"absolute inset-0 grid place-items-center p-6 text-center text-sm text-gray-500",children:oe.failed}),G&&/* @__PURE__ */p(e,{"data-map-control":"",variant:"secondary",size:"sm",className:"absolute left-3 top-3 z-10",onClick:()=>G.onChange(!G.active),leftIcon:/* @__PURE__ */p(le,{leave:G.active}),children:G.active?oe.leaveFullScreen:oe.fullScreen}),y,null!=R&&!Te&&/* @__PURE__ */p("div",{"data-map-card":"",className:"absolute bottom-3 left-3 right-3 z-10 max-h-[calc(100%-1.5rem)] max-w-md overflow-y-auto overscroll-contain",children:R}),Te&&Oe?u(R,Oe):null,be&&/* @__PURE__ */p(ae,{pins:t,hosts:fe.current})]})}function ae({pins:e,hosts:t}){/* @__PURE__ */
|
|
4
|
+
return p(m,{children:e.map(e=>{if(null==e.iconNode||e.dot)return null;let n=t.get(e.key);return n||(n=document.createElement("span"),n.className="contents",t.set(e.key,n)),u(e.iconNode,n,e.key)})})}function le({leave:e}){/* @__PURE__ */
|
|
5
|
+
return p("svg",{"aria-hidden":"true",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */p("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e?"M9 9V4.5M9 9H4.5M9 9 3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5 5.25 5.25":"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"})})}function ie(){const[e,t]=a(null);return{highlightKey:e,pointAt:i(e=>{const n=()=>t(e),r=()=>t(t=>t===e?null:t);return{onMouseEnter:n,onMouseLeave:r,onFocus:n,onBlur:r}},[])}}var se=3e3,ce=e=>!!e?.pending&&3e3,ue=e=>`${e.kind}:${e.id}`,de=e=>("located"===e.placement||"approximate"===e.placement)&&null!=e.lat&&null!=e.lng;function pe(e){switch(e){case"located":return null;case"approximate":return"Approximate: only the suburb or postcode matched";case"pending":return"Locating…";case"not_found":return"Not on the map: address not found";case"failed":return"Not on the map: the map service could not be reached";case"no_address":return"Not on the map: no city or postcode"}}var me={importer:{label:"Importer",tone:"bg-sky-600 text-white"},dealer:{label:"Dealer",tone:"bg-purple-600 text-white"},retail:{label:"Retail",tone:"bg-green-600 text-white"},supplier:{label:"Supplier",tone:"bg-sky-600 text-white"},delivery_location:{label:"Delivery location",tone:"bg-amber-600 text-white"},warehouse:{label:"Warehouse",tone:"bg-amber-600 text-white"}},he=["importer","dealer","retail","supplier","delivery_location","warehouse"];function ge(e){return"supplier"===e.kind?"supplier":"customer"===e.kind?e.category||"importer":e.kind}var fe=(e,t=me)=>t[e]?.tone??"bg-gray-700 text-white",ye=(e,t=me)=>t[e]?.label??e,be=(e,t)=>fe(ge(e),t);function xe(e,t,n=me){return null!=t?String(t):(n[ge(e)]?.label??"").charAt(0).toUpperCase()}var ve=["delivery_location","warehouse"];function we(e,t=ve){const n=/* @__PURE__ */new Map;let r=0;for(const o of e)t.includes(o.kind)&&n.set(ue(o),++r);return n}function ke(e){const t={onMap:0,approximate:0,pending:0,off:0};for(const n of e)de(n)?(t.onMap+=1,"approximate"===n.placement&&(t.approximate+=1)):"pending"===n.placement?t.pending+=1:t.off+=1;return t}function Me(e){const t=[`${e.onMap} on the map`];return e.approximate&&t.push(`${e.approximate} approximate`),e.pending&&t.push(`${e.pending} locating`),e.off&&t.push(`${e.off} not on the map`),t.join(" · ")}function Ne(e){const t=[...new Set(e.filter(de).map(ge))];return[...he.filter(e=>t.includes(e)),...t.filter(e=>!he.includes(e))]}function Ce(e,t){return e.filter(e=>!de(e)&&"pending"!==e.placement).map(e=>{const n=t?.get(ue(e)),r=pe(e.placement)?.replace(/^Not on the map: /,"")??"";return{key:ue(e),text:`${null!=n?`${n}. `:""}${e.label}: ${r}`}})}function Le({categories:e,palette:t=me,floating:n=!0}){return e.length<2?null:/* @__PURE__ */p("div",{className:(n?"absolute left-3 top-3 z-10 ":"")+"flex flex-wrap gap-x-3 gap-y-1 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs text-gray-600 shadow-sm",children:e.map(e=>/* @__PURE__ */d("span",{className:"inline-flex items-center gap-1.5",children:[
|
|
6
|
+
/* @__PURE__ */p("span",{"aria-hidden":!0,className:`h-2.5 w-2.5 rounded-full ${fe(e,t)}`}),ye(e,t)]},e))})}function $e({point:t,number:n,onOpen:o,onClose:a,palette:l=me}){const i=pe(t.placement),s=ge(t),c=r().map;/* @__PURE__ */
|
|
7
|
+
return d("section",{"aria-label":c.chosen(t.label),className:"absolute bottom-3 left-3 right-3 z-10 max-w-md space-y-1.5 rounded-lg border border-gray-200 bg-white p-3 shadow-md",children:[
|
|
8
|
+
/* @__PURE__ */d("div",{className:"flex items-start justify-between gap-2",children:[
|
|
9
|
+
/* @__PURE__ */d("div",{className:"min-w-0",children:[
|
|
10
|
+
/* @__PURE__ */d("h3",{className:"text-sm font-semibold text-gray-900 [overflow-wrap:anywhere]",children:[null!=n&&/* @__PURE__ */d("span",{className:"mr-1 text-gray-400",children:[n,"."]}),t.label,t.code&&/* @__PURE__ */p("span",{className:"ml-1.5 text-xs font-normal text-gray-400",children:t.code})]}),
|
|
11
|
+
/* @__PURE__ */p("p",{className:"text-xs text-gray-500",children:l[s]?ye(s,l):t.category})]}),
|
|
12
|
+
/* @__PURE__ */p("button",{type:"button",onClick:a,"aria-label":c.closeCard,className:"rounded p-0.5 text-gray-400 hover:text-gray-600",children:/* @__PURE__ */p("svg",{"aria-hidden":!0,className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */p("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),
|
|
13
|
+
/* @__PURE__ */p("p",{className:"text-sm text-gray-700 [overflow-wrap:anywhere]",children:t.address||"—"}),i&&/* @__PURE__ */p("p",{className:"text-xs text-gray-500",children:i}),t.matched&&"approximate"===t.placement&&/* @__PURE__ */d("p",{className:"text-xs text-gray-400 [overflow-wrap:anywhere]",children:["Placed at: ",t.matched]}),o&&/* @__PURE__ */p("div",{className:"flex justify-end",children:/* @__PURE__ */p(e,{variant:"secondary",size:"sm",onClick:o,children:c.openRecord})})]})}function Ee(e,t,{staleTime:n}={}){return h({queryKey:e,queryFn:t,staleTime:n,refetchInterval:e=>ce(e.state.data)})}function Se({queryKey:e,queryFn:t,refreshSignal:n,onOpen:r,ariaLabel:i,title:c="Locations",palette:u=me,numbers:m,className:h="",mapClassName:g="min-h-[240px] flex-1"}){const{data:f,isError:y,refetch:b}=Ee(e,t,{staleTime:0}),x=o(!1);l(()=>{x.current?b():x.current=!0},[n]);const[v,w]=a(null),k=s(()=>f?.points??[],[f]),M=s(()=>m??we(k),[m,k]),N=s(()=>k.filter(de).map(e=>({key:ue(e),label:e.label,lat:e.lat,lng:e.lng,glyph:xe(e,M.get(ue(e))??null,u),tone:be(e,u),approximate:"approximate"===e.placement})),[k,M,u]),C=s(()=>Ce(k,M),[k,M]),L=s(()=>Ne(k),[k]),$=f?.pending??0,E=k.find(e=>ue(e)===v)??null,S=E&&r?r(E):null;/* @__PURE__ */
|
|
14
|
+
return d("section",{"aria-label":c,className:`flex min-w-0 flex-col ${h}`,children:[
|
|
15
|
+
/* @__PURE__ */d("div",{className:"flex min-h-[30px] items-center justify-between mb-2",children:[
|
|
16
|
+
/* @__PURE__ */p("h3",{className:"text-sm font-semibold text-gray-900",children:c}),f&&/* @__PURE__ */p("span",{className:"text-xs text-gray-500",children:Me(ke(k))})]}),
|
|
17
|
+
/* @__PURE__ */d(oe,{pins:N,selectedKey:v,focus:null,onSelect:w,ariaLabel:i,className:g,children:[
|
|
18
|
+
/* @__PURE__ */d("div",{className:"absolute left-3 top-3 z-10 flex max-w-[70%] flex-col items-start gap-1.5",children:[
|
|
19
|
+
/* @__PURE__ */p(Le,{categories:L,palette:u,floating:!1}),y&&/* @__PURE__ */d("div",{className:"flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs text-gray-600 shadow-sm",children:["Couldn’t load the locations.",
|
|
20
|
+
/* @__PURE__ */p("button",{type:"button",onClick:()=>{b()},className:"font-medium text-blue-600 hover:text-blue-800 hover:underline",children:"Try again"})]}),!y&&($>0||C.length>0)&&/* @__PURE__ */d("div",{className:"max-w-full space-y-0.5 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs shadow-sm","aria-live":"polite",children:[$>0&&/* @__PURE__ */d("p",{className:"flex items-center gap-1.5 text-gray-500",children:[
|
|
21
|
+
/* @__PURE__ */d("svg",{className:"h-3 w-3 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[
|
|
22
|
+
/* @__PURE__ */p("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),
|
|
23
|
+
/* @__PURE__ */p("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),"Locating ",$," address",1===$?"":"es","…"]}),C.slice(0,3).map(e=>/* @__PURE__ */p("p",{className:"truncate text-amber-700",title:e.text,children:e.text},e.key)),C.length>3&&/* @__PURE__ */d("p",{className:"text-gray-500",children:["+",C.length-3," more not on the map"]})]})]}),E&&/* @__PURE__ */p($e,{point:E,number:M.get(ue(E))??null,onOpen:S,onClose:()=>w(null),palette:u})]})]})}export{x as CARD_MIN_MAP_WIDTH,g as COMPACT_SHOW,oe as EntityMap,Se as LocationsMap,M as MAPLIBRE_WORKER_FILE,S as MAP_APART_PX,me as MAP_CATEGORIES,E as MAP_STOP_PX,$ as MAP_TARGET_PX,Le as MapLegend,se as PENDING_POLL_MS,ve as SECONDARY_KINDS,$e as SelectedCard,w as cardMaxHeight,ye as categoryLabel,fe as categoryTone,f as foldAttributionOnce,de as isOnMap,O as layoutPins,Ne as legendCategories,L as loadMapLibre,we as locationNumbers,N as mapLibreWorkerUrl,ce as mapPointsRefetchInterval,Ce as offMapNotes,ge as pinCategory,xe as pinGlyph,be as pinTone,k as placeCard,pe as placementNote,ue as pointKey,j as stopsLabel,ke as summarize,Me as summaryText,ie as useMapHighlight,Ee as useMapPoints,W as zoomApart};
|