@eyeon/map 2.0.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.
Files changed (58) hide show
  1. package/README.md +27 -0
  2. package/dist/assets/MapViewer.css +1 -0
  3. package/dist/assets/index.css +1 -0
  4. package/dist/chunks/MapViewer.js +530 -0
  5. package/dist/chunks/MapViewer.js.map +1 -0
  6. package/dist/chunks/graph-tools.js +153 -0
  7. package/dist/chunks/graph-tools.js.map +1 -0
  8. package/dist/chunks/pathfinding.js +343 -0
  9. package/dist/chunks/pathfinding.js.map +1 -0
  10. package/dist/core/geometry/index.d.ts +42 -0
  11. package/dist/core/geometry/index.d.ts.map +1 -0
  12. package/dist/core/import/index.d.ts +51 -0
  13. package/dist/core/import/index.d.ts.map +1 -0
  14. package/dist/core/index.d.ts +7 -0
  15. package/dist/core/index.d.ts.map +1 -0
  16. package/dist/core/index.js +282 -0
  17. package/dist/core/index.js.map +1 -0
  18. package/dist/core/publish/index.d.ts +28 -0
  19. package/dist/core/publish/index.d.ts.map +1 -0
  20. package/dist/core/routing/graph-tools.d.ts +47 -0
  21. package/dist/core/routing/graph-tools.d.ts.map +1 -0
  22. package/dist/core/routing/pathfinding.d.ts +22 -0
  23. package/dist/core/routing/pathfinding.d.ts.map +1 -0
  24. package/dist/core/types.d.ts +406 -0
  25. package/dist/core/types.d.ts.map +1 -0
  26. package/dist/editor/MapEditor.d.ts +31 -0
  27. package/dist/editor/MapEditor.d.ts.map +1 -0
  28. package/dist/editor/canvas/EditorCanvas.d.ts +22 -0
  29. package/dist/editor/canvas/EditorCanvas.d.ts.map +1 -0
  30. package/dist/editor/index.css +248 -0
  31. package/dist/editor/index.d.ts +5 -0
  32. package/dist/editor/index.d.ts.map +1 -0
  33. package/dist/editor/index.js +734 -0
  34. package/dist/editor/index.js.map +1 -0
  35. package/dist/editor/panels/Inspector.d.ts +14 -0
  36. package/dist/editor/panels/Inspector.d.ts.map +1 -0
  37. package/dist/editor/panels/LeftRail.d.ts +36 -0
  38. package/dist/editor/panels/LeftRail.d.ts.map +1 -0
  39. package/dist/editor/panels/PreviewOverlay.d.ts +6 -0
  40. package/dist/editor/panels/PreviewOverlay.d.ts.map +1 -0
  41. package/dist/index.d.ts +3 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/viewer/MapViewer.d.ts +26 -0
  44. package/dist/viewer/MapViewer.d.ts.map +1 -0
  45. package/dist/viewer/components/LevelMeshes.d.ts +11 -0
  46. package/dist/viewer/components/LevelMeshes.d.ts.map +1 -0
  47. package/dist/viewer/components/MapScene.d.ts +12 -0
  48. package/dist/viewer/components/MapScene.d.ts.map +1 -0
  49. package/dist/viewer/components/RouteLine.d.ts +8 -0
  50. package/dist/viewer/components/RouteLine.d.ts.map +1 -0
  51. package/dist/viewer/index.css +210 -0
  52. package/dist/viewer/index.d.ts +4 -0
  53. package/dist/viewer/index.d.ts.map +1 -0
  54. package/dist/viewer/index.js +7 -0
  55. package/dist/viewer/index.js.map +1 -0
  56. package/dist/viewer/ui/RuntimeChrome.d.ts +19 -0
  57. package/dist/viewer/ui/RuntimeChrome.d.ts.map +1 -0
  58. package/package.json +81 -0
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # @eyeon/map (Center Map v2)
2
+
3
+ DB-driven center map: pure-TS core, three.js viewer, SVG/DOM editor.
4
+
5
+ ## Subpath exports
6
+
7
+ ```ts
8
+ import { importSvg, compileDocument, findPath } from '@eyeon/map/core';
9
+ import { MapViewer } from '@eyeon/map/viewer';
10
+ import { MapEditor } from '@eyeon/map/editor';
11
+ import '@eyeon/map/viewer/index.css';
12
+ import '@eyeon/map/editor/index.css';
13
+ ```
14
+
15
+ ## Reversibility
16
+
17
+ - v2 never writes `mapit2_*`
18
+ - v2 S3 objects live under `media/map/` only
19
+ - `centers.map_version` (default `1`) is the only coupling
20
+ - Absent / unknown version → v1
21
+
22
+ ## Scripts
23
+
24
+ ```sh
25
+ npm test
26
+ npm run build
27
+ ```
@@ -0,0 +1 @@
1
+ .eyeon-map-viewer{position:relative;width:100%;height:100%;min-height:320px;overflow:hidden;background:var(--map-bg, #f5f5f5);font-family:system-ui,-apple-system,sans-serif;font-size:13px;color:#0f172a}.eyeon-map-viewer__canvas{position:absolute;top:0;right:0;bottom:0;left:0}.eyeon-map-viewer__loading,.eyeon-map-viewer__error{display:flex;align-items:center;justify-content:center;height:100%;padding:1rem}.eyeon-map-chrome{position:absolute;z-index:2;top:12px;left:12px;width:min(320px,calc(100% - 24px));display:flex;flex-direction:column;gap:8px;pointer-events:none}.eyeon-map-chrome>*{pointer-events:auto}.eyeon-map-chrome__top{display:flex;flex-direction:column;gap:8px}.eyeon-map-chrome__search-toggle{align-self:flex-start;border:0;border-radius:8px;background:#fff;box-shadow:0 1px 4px #0f172a1f;padding:8px 12px;font-size:12px;font-weight:600;cursor:pointer}.eyeon-map-chrome__amenities{display:grid;grid-template-columns:repeat(auto-fill,minmax(40px,1fr));gap:6px;background:#ffffffeb;border-radius:10px;padding:8px;box-shadow:0 1px 4px #0f172a1a}.eyeon-map-chrome__amenity{width:40px;height:40px;border:0;border-radius:8px;background:#f1f5f9;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:600}.eyeon-map-chrome__panel{background:#fff;border-radius:12px;box-shadow:0 8px 24px #0f172a24;padding:10px;max-height:min(60vh,480px);overflow:auto;animation:eyeon-map-slide .16s ease-out}@keyframes eyeon-map-slide{0%{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:translateY(0)}}.eyeon-map-chrome__search-input{width:100%;border:1px solid #e2e8f0;border-radius:8px;padding:8px 10px;font-size:13px;margin-bottom:8px}.eyeon-map-chrome__group-title{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:#64748b;margin:8px 0 4px}.eyeon-map-chrome__item{display:block;width:100%;text-align:left;border:0;background:transparent;padding:6px 4px;border-radius:6px;cursor:pointer;font-size:13px}.eyeon-map-chrome__item:hover{background:#f1f5f9}.eyeon-map-chrome__detail{border-top:1px solid #e2e8f0;margin-top:8px;padding-top:8px}.eyeon-map-chrome__detail-title{font-weight:700}.eyeon-map-chrome__detail-meta{color:#64748b;font-size:12px}.eyeon-map-chrome__route{display:grid;gap:6px;margin-top:10px;border-top:1px solid #e2e8f0;padding-top:8px}.eyeon-map-chrome__route label{display:grid;gap:4px;font-size:11px;font-weight:600;color:#475569}.eyeon-map-chrome__route select{font-size:12px;padding:6px;border-radius:6px;border:1px solid #e2e8f0}.eyeon-map-chrome__accessible{display:flex!important;align-items:center;gap:6px;font-weight:500!important}.eyeon-map-chrome__floors{position:absolute;right:12px;bottom:12px;left:auto;top:auto;display:flex;gap:6px;width:auto}.eyeon-map-chrome__floor{border:0;border-radius:8px;background:#fff;box-shadow:0 1px 4px #0f172a1f;padding:8px 10px;font-size:12px;font-weight:600;cursor:pointer}.eyeon-map-chrome__floor.is-active{background:var(--map-accent, #2563eb);color:#fff}
@@ -0,0 +1 @@
1
+ .eyeon-map-editor{display:grid;grid-template-columns:220px 1fr 260px;height:100%;min-height:560px;background:#f8fafc;color:#0f172a;font-family:system-ui,-apple-system,sans-serif;font-size:12px}.eyeon-map-rail{display:flex;flex-direction:column;border-right:1px solid #e2e8f0;background:#fff;min-width:0}.eyeon-map-rail__tabs{display:grid;grid-template-columns:repeat(3,1fr);gap:2px;padding:6px;border-bottom:1px solid #e2e8f0}.eyeon-map-rail__tabs button{border:0;background:transparent;border-radius:6px;padding:6px 4px;font-size:11px;font-weight:600;cursor:pointer;color:#64748b}.eyeon-map-rail__tabs button.is-active{background:#eff6ff;color:#1d4ed8}.eyeon-map-rail__body{overflow:auto;padding:8px;flex:1}.eyeon-map-rail__heading{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:#94a3b8;margin:8px 0 4px}.eyeon-map-rail__row{display:flex;justify-content:space-between;gap:6px;width:100%;text-align:left;border:0;background:transparent;border-radius:6px;padding:6px 8px;cursor:pointer;font-size:12px}.eyeon-map-rail__row.is-active,.eyeon-map-rail__row:hover{background:#f1f5f9}.eyeon-map-rail__muted{color:#94a3b8;font-size:10px}.eyeon-map-rail__hint{color:#64748b;line-height:1.4;margin:0 0 8px}.eyeon-map-rail__actions{display:grid;gap:6px;margin-top:10px}.eyeon-map-rail__file{display:grid;gap:4px;font-weight:600;font-size:11px}.eyeon-map-rail__file input{font-size:11px}.eyeon-map-rail__field{display:grid;gap:4px;margin-bottom:8px;font-size:11px;font-weight:600;color:#475569}.eyeon-map-rail__field input,.eyeon-map-rail__field select{font-size:12px;padding:6px 8px;border:1px solid #e2e8f0;border-radius:6px}.eyeon-map-editor__center{display:flex;flex-direction:column;min-width:0}.eyeon-map-editor__toolbar{display:flex;justify-content:space-between;gap:8px;padding:6px 8px;border-bottom:1px solid #e2e8f0;background:#fff}.eyeon-map-editor__tools,.eyeon-map-editor__actions{display:flex;gap:4px;align-items:center;flex-wrap:wrap}.eyeon-map-editor__toolbar button{border:1px solid #e2e8f0;background:#fff;border-radius:6px;padding:4px 8px;font-size:11px;font-weight:600;cursor:pointer}.eyeon-map-editor__toolbar button.is-active,.eyeon-map-editor__publish{background:#2563eb;border-color:#2563eb;color:#fff}.eyeon-map-editor__angle{display:flex;align-items:center;gap:4px;font-size:11px;font-weight:600}.eyeon-map-editor__angle input{width:56px;font-size:11px;padding:3px 6px;border:1px solid #e2e8f0;border-radius:4px}.eyeon-map-editor__canvas-wrap{flex:1;min-height:0;position:relative}.eyeon-map-canvas{position:absolute;top:0;right:0;bottom:0;left:0;overflow:hidden;background:linear-gradient(#e2e8f0 1px,transparent 1px) 0 0 / 24px 24px,linear-gradient(90deg,#e2e8f0 1px,transparent 1px) 0 0 / 24px 24px,#f8fafc}.eyeon-map-canvas__svg{width:100%;height:100%;touch-action:none}.eyeon-map-canvas__empty{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center;color:#94a3b8}.eyeon-map-inspector{border-left:1px solid #e2e8f0;background:#fff;padding:10px;overflow:auto}.eyeon-map-inspector__heading{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:#94a3b8;margin:10px 0 6px}.eyeon-map-inspector__empty{color:#94a3b8;padding:12px 4px}.eyeon-map-inspector__save{margin-top:10px;width:100%;border:0;border-radius:6px;background:#2563eb;color:#fff;padding:8px;font-size:12px;font-weight:600;cursor:pointer}.eyeon-map-preview,.eyeon-map-preview__loading{position:absolute;top:0;right:0;bottom:0;left:0}
@@ -0,0 +1,530 @@
1
+ import { jsx as t, jsxs as g } from "react/jsx-runtime";
2
+ import { useMemo as T, useState as R, useEffect as z, Suspense as U } from "react";
3
+ import { f as X, e as K, q as W } from "./pathfinding.js";
4
+ import { Canvas as j } from "@react-three/fiber";
5
+ import { OrthographicCamera as q, OrbitControls as V } from "@react-three/drei";
6
+ import * as S from "three";
7
+ function Q(l, i, a) {
8
+ if (a) return a;
9
+ switch (l) {
10
+ case "unit":
11
+ return i.STORE_DEFAULT_COLOR;
12
+ case "walkable":
13
+ return i.WALKABLE_COLOR;
14
+ case "wall":
15
+ case "boundary":
16
+ return i.WALL_COLOR;
17
+ case "parking_zone":
18
+ return i.PARKING_ZONE_COLOR;
19
+ case "green_area":
20
+ return i.GREEN_AREA_COLOR;
21
+ case "water":
22
+ return i.WATER_COLOR;
23
+ case "floorplate":
24
+ return i.BASE_COLOR;
25
+ case "void":
26
+ return "#00000000";
27
+ default:
28
+ return "#e2e8f0";
29
+ }
30
+ }
31
+ function Z(l) {
32
+ if (l.length < 3) return null;
33
+ const i = new S.Shape();
34
+ i.moveTo(l[0].x, l[0].y);
35
+ for (let a = 1; a < l.length; a++)
36
+ i.lineTo(l[a].x, l[a].y);
37
+ return i.closePath(), i;
38
+ }
39
+ function J({
40
+ level: l,
41
+ theme: i,
42
+ is3d: a,
43
+ selectedRetailerId: p,
44
+ onSelectShape: k
45
+ }) {
46
+ const y = T(() => l.shapes.filter((o) => o.kind !== "void").map((o) => {
47
+ var _;
48
+ const A = o.geometry.polygons.map(Z).filter((b) => b != null);
49
+ if (A.length === 0) return null;
50
+ const s = p != null && ((_ = o.assignment) == null ? void 0 : _.retailerId) === p, v = s ? i.ACCENT_COLOR : Q(o.kind, i, o.style.fill), n = a && (o.kind === "unit" || o.kind === "wall") ? o.style.extrudeHeight ?? (o.kind === "unit" ? i.STORE_HEIGHT : 2) : 0;
51
+ return { shape: o, threeShapes: A, color: v, extrude: n, selected: s };
52
+ }).filter(Boolean), [l, i, a, p]);
53
+ return /* @__PURE__ */ t("group", { children: y.map(({ shape: o, threeShapes: h, color: A, extrude: s, selected: v }) => /* @__PURE__ */ t("group", { children: h.map((n, _) => /* @__PURE__ */ g(
54
+ "mesh",
55
+ {
56
+ position: [0, 0, o.zIndex * 0.01],
57
+ onClick: (b) => {
58
+ b.stopPropagation(), (o.kind === "unit" || o.kind === "amenity" || o.kind === "kiosk_screen" || o.kind === "entrance") && (k == null || k(o.id));
59
+ },
60
+ children: [
61
+ s > 0 ? /* @__PURE__ */ t(
62
+ "extrudeGeometry",
63
+ {
64
+ args: [
65
+ n,
66
+ { depth: s, bevelEnabled: !1 }
67
+ ]
68
+ }
69
+ ) : /* @__PURE__ */ t("shapeGeometry", { args: [n] }),
70
+ /* @__PURE__ */ t(
71
+ "meshBasicMaterial",
72
+ {
73
+ color: A,
74
+ transparent: o.style.transparent || o.kind === "amenity",
75
+ opacity: o.style.opacity ?? (o.kind === "amenity" ? 0.01 : 1),
76
+ side: S.DoubleSide
77
+ }
78
+ ),
79
+ v && /* @__PURE__ */ g("lineSegments", { children: [
80
+ /* @__PURE__ */ t(
81
+ "edgesGeometry",
82
+ {
83
+ args: [
84
+ s > 0 ? new S.ExtrudeGeometry(n, {
85
+ depth: s,
86
+ bevelEnabled: !1
87
+ }) : new S.ShapeGeometry(n)
88
+ ]
89
+ }
90
+ ),
91
+ /* @__PURE__ */ t("lineBasicMaterial", { color: i.ACCENT_COLOR })
92
+ ] })
93
+ ]
94
+ },
95
+ `${o.id}-${_}`
96
+ )) }, o.id)) });
97
+ }
98
+ function ee({
99
+ route: l,
100
+ activeLevelId: i,
101
+ color: a
102
+ }) {
103
+ const p = T(() => l.points.filter((y) => i == null || y.levelId === i).map((y) => new S.Vector3(y.x, y.y, 2)), [l, i]);
104
+ if (p.length < 2) return null;
105
+ const k = new S.CatmullRomCurve3(p);
106
+ return /* @__PURE__ */ g("mesh", { children: [
107
+ /* @__PURE__ */ t("tubeGeometry", { args: [k, Math.max(p.length * 4, 8), 1.5, 8, !1] }),
108
+ /* @__PURE__ */ t("meshBasicMaterial", { color: a })
109
+ ] });
110
+ }
111
+ function ne({
112
+ doc: l,
113
+ theme: i,
114
+ activeLevelId: a,
115
+ route: p,
116
+ selectedRetailerId: k,
117
+ onSelectShape: y
118
+ }) {
119
+ const o = i.MAP_STYLE === "3D", h = T(() => {
120
+ let s = 1 / 0, v = 1 / 0, n = -1 / 0, _ = -1 / 0;
121
+ for (const b of l.levels)
122
+ if (!(a != null && b.id !== a && b.kind !== "outdoor"))
123
+ for (const x of b.shapes)
124
+ s = Math.min(s, x.bbox.minX), v = Math.min(v, x.bbox.minY), n = Math.max(n, x.bbox.maxX), _ = Math.max(_, x.bbox.maxY);
125
+ return Number.isFinite(s) ? {
126
+ cx: (s + n) / 2,
127
+ cy: (v + _) / 2,
128
+ size: Math.max(n - s, _ - v, 100)
129
+ } : { cx: 0, cy: 0, size: 500 };
130
+ }, [l, a]), A = 800 / h.size;
131
+ return /* @__PURE__ */ g(
132
+ j,
133
+ {
134
+ style: { width: "100%", height: "100%", background: i.MAP_BACKGROUND_COLOR },
135
+ orthographic: !o,
136
+ camera: o ? { position: [h.cx, h.cy - h.size, h.size], fov: 50, near: 1, far: 1e4 } : void 0,
137
+ children: [
138
+ !o && /* @__PURE__ */ t(
139
+ q,
140
+ {
141
+ makeDefault: !0,
142
+ position: [h.cx, h.cy, 500],
143
+ zoom: A,
144
+ near: 0.1,
145
+ far: 5e3
146
+ }
147
+ ),
148
+ /* @__PURE__ */ t("ambientLight", { intensity: 0.85 }),
149
+ /* @__PURE__ */ t("directionalLight", { position: [200, 400, 200], intensity: 0.4 }),
150
+ l.levels.map((s) => s.kind === "outdoor" || a == null || s.id === a ? /* @__PURE__ */ t(
151
+ J,
152
+ {
153
+ level: s,
154
+ theme: i,
155
+ is3d: o,
156
+ selectedRetailerId: k,
157
+ onSelectShape: (n) => y == null ? void 0 : y(n, s.id)
158
+ },
159
+ s.id
160
+ ) : null),
161
+ p && /* @__PURE__ */ t(ee, { route: p, activeLevelId: a, color: i.ACCENT_COLOR }),
162
+ /* @__PURE__ */ t(
163
+ V,
164
+ {
165
+ enableRotate: o,
166
+ enablePan: !0,
167
+ target: [h.cx, h.cy, 0],
168
+ maxDistance: i.CAMERA_MAX_DISTANCE,
169
+ minDistance: i.CAMERA_MIN_DISTANCE
170
+ }
171
+ )
172
+ ]
173
+ }
174
+ );
175
+ }
176
+ function te({
177
+ doc: l,
178
+ amenities: i,
179
+ searchOpen: a,
180
+ onSearchOpenChange: p,
181
+ activeLevelId: k,
182
+ onActiveLevelChange: y,
183
+ fromAnchorId: o,
184
+ toAnchorId: h,
185
+ onFromChange: A,
186
+ onToChange: s,
187
+ accessibleOnly: v,
188
+ onAccessibleOnlyChange: n,
189
+ route: _
190
+ }) {
191
+ const [b, x] = R(""), [P, D] = R(null), E = T(() => {
192
+ var f, d;
193
+ const e = [];
194
+ for (const N of l.levels)
195
+ for (const I of N.shapes) {
196
+ const M = N.anchors.find((w) => w.shapeId === I.id) ?? null;
197
+ if (I.kind === "unit" && ((f = I.assignment) != null && f.retailerId) && e.push({
198
+ id: `store-${I.id}`,
199
+ label: I.assignment.customLabel || I.label.text || I.key,
200
+ group: N.name,
201
+ anchorId: (M == null ? void 0 : M.id) ?? null,
202
+ levelId: N.id,
203
+ kind: "store"
204
+ }), I.kind === "amenity" && ((d = I.assignment) != null && d.amenityId)) {
205
+ const w = i.find((B) => B.id === I.assignment.amenityId);
206
+ e.push({
207
+ id: `amenity-${I.id}`,
208
+ label: (w == null ? void 0 : w.name) ?? I.key,
209
+ group: "Amenities",
210
+ anchorId: (M == null ? void 0 : M.id) ?? null,
211
+ levelId: N.id,
212
+ kind: "amenity"
213
+ });
214
+ }
215
+ }
216
+ return e;
217
+ }, [l, i]), G = T(() => {
218
+ const e = b.trim().toLowerCase();
219
+ return e ? E.filter((f) => f.label.toLowerCase().includes(e)) : E;
220
+ }, [E, b]), $ = T(() => {
221
+ const e = /* @__PURE__ */ new Map();
222
+ for (const f of G) {
223
+ const d = e.get(f.group) ?? [];
224
+ d.push(f), e.set(f.group, d);
225
+ }
226
+ return Array.from(e.entries());
227
+ }, [G]), L = E.filter((e) => e.anchorId != null);
228
+ return /* @__PURE__ */ g("div", { className: "eyeon-map-chrome", children: [
229
+ /* @__PURE__ */ g("div", { className: "eyeon-map-chrome__top", children: [
230
+ /* @__PURE__ */ t(
231
+ "button",
232
+ {
233
+ type: "button",
234
+ className: "eyeon-map-chrome__search-toggle",
235
+ onClick: () => p(!a),
236
+ "aria-expanded": a,
237
+ children: a ? "Close" : "Search"
238
+ }
239
+ ),
240
+ /* @__PURE__ */ t("div", { className: "eyeon-map-chrome__amenities", children: i.map((e) => /* @__PURE__ */ t(
241
+ "button",
242
+ {
243
+ type: "button",
244
+ className: "eyeon-map-chrome__amenity",
245
+ title: e.name,
246
+ onClick: () => {
247
+ const f = E.find(
248
+ (d) => d.kind === "amenity" && d.label === e.name && d.anchorId != null
249
+ );
250
+ (f == null ? void 0 : f.anchorId) != null && (s(f.anchorId), y(f.levelId));
251
+ },
252
+ children: e.builtinIcon ? /* @__PURE__ */ t("span", { className: "eyeon-map-chrome__amenity-icon", children: e.builtinIcon }) : /* @__PURE__ */ t("span", { className: "eyeon-map-chrome__amenity-label", children: e.name.slice(0, 2) })
253
+ },
254
+ e.id
255
+ )) })
256
+ ] }),
257
+ a && /* @__PURE__ */ g("div", { className: "eyeon-map-chrome__panel", children: [
258
+ /* @__PURE__ */ t(
259
+ "input",
260
+ {
261
+ className: "eyeon-map-chrome__search-input",
262
+ placeholder: "Search stores & amenities",
263
+ value: b,
264
+ onChange: (e) => x(e.target.value),
265
+ autoFocus: !0
266
+ }
267
+ ),
268
+ /* @__PURE__ */ t("div", { className: "eyeon-map-chrome__groups", children: $.map(([e, f]) => /* @__PURE__ */ g("div", { className: "eyeon-map-chrome__group", children: [
269
+ /* @__PURE__ */ t("div", { className: "eyeon-map-chrome__group-title", children: e }),
270
+ f.map((d) => /* @__PURE__ */ t(
271
+ "button",
272
+ {
273
+ type: "button",
274
+ className: "eyeon-map-chrome__item",
275
+ onClick: () => {
276
+ D(d), d.anchorId != null && (s(d.anchorId), y(d.levelId));
277
+ },
278
+ children: d.label
279
+ },
280
+ d.id
281
+ ))
282
+ ] }, e)) }),
283
+ P && /* @__PURE__ */ g("div", { className: "eyeon-map-chrome__detail", children: [
284
+ /* @__PURE__ */ t("div", { className: "eyeon-map-chrome__detail-title", children: P.label }),
285
+ /* @__PURE__ */ t("div", { className: "eyeon-map-chrome__detail-meta", children: P.group })
286
+ ] }),
287
+ /* @__PURE__ */ g("div", { className: "eyeon-map-chrome__route", children: [
288
+ /* @__PURE__ */ g("label", { children: [
289
+ "From",
290
+ /* @__PURE__ */ g(
291
+ "select",
292
+ {
293
+ value: o ?? "",
294
+ onChange: (e) => A(e.target.value ? Number(e.target.value) : null),
295
+ children: [
296
+ /* @__PURE__ */ t("option", { value: "", children: "Select start" }),
297
+ L.map((e) => /* @__PURE__ */ t("option", { value: e.anchorId, children: e.label }, e.id))
298
+ ]
299
+ }
300
+ )
301
+ ] }),
302
+ /* @__PURE__ */ g("label", { children: [
303
+ "To",
304
+ /* @__PURE__ */ g(
305
+ "select",
306
+ {
307
+ value: h ?? "",
308
+ onChange: (e) => s(e.target.value ? Number(e.target.value) : null),
309
+ children: [
310
+ /* @__PURE__ */ t("option", { value: "", children: "Select destination" }),
311
+ L.map((e) => /* @__PURE__ */ t("option", { value: e.anchorId, children: e.label }, e.id))
312
+ ]
313
+ }
314
+ )
315
+ ] }),
316
+ /* @__PURE__ */ g("label", { className: "eyeon-map-chrome__accessible", children: [
317
+ /* @__PURE__ */ t(
318
+ "input",
319
+ {
320
+ type: "checkbox",
321
+ checked: v,
322
+ onChange: (e) => n(e.target.checked)
323
+ }
324
+ ),
325
+ "Accessible route"
326
+ ] }),
327
+ _ && /* @__PURE__ */ t("div", { className: "eyeon-map-chrome__route-meta", children: _.levelChanges.length > 0 ? `${_.levelChanges.length} level change(s)` : "Same level" })
328
+ ] })
329
+ ] }),
330
+ /* @__PURE__ */ t("div", { className: "eyeon-map-chrome__floors", children: l.levels.filter((e) => e.kind === "floor").map((e) => /* @__PURE__ */ t(
331
+ "button",
332
+ {
333
+ type: "button",
334
+ className: e.id === k ? "eyeon-map-chrome__floor is-active" : "eyeon-map-chrome__floor",
335
+ onClick: () => y(e.id),
336
+ children: e.name
337
+ },
338
+ e.id
339
+ )) })
340
+ ] });
341
+ }
342
+ async function ie(l) {
343
+ const i = l.replace(/\/$/, ""), a = await fetch(`${i}/v1/map/document`, { credentials: "include" });
344
+ if (!a.ok)
345
+ throw new Error(`Failed to load map document (${a.status})`);
346
+ return a.json();
347
+ }
348
+ function ce(l) {
349
+ const {
350
+ document: i,
351
+ webApiURI: a,
352
+ role: p = "WP_SITE",
353
+ kioskId: k = null,
354
+ selectedRetailerId: y = null,
355
+ themeOverrides: o,
356
+ onExtractedAmenities: h,
357
+ createRouteRef: A,
358
+ className: s,
359
+ style: v
360
+ } = l, [n, _] = R(i ?? null), [b, x] = R(null), [P, D] = R(null), [E, G] = R(null), [$, L] = R(null), [e, f] = R(!1), [d, N] = R(null), [I, M] = R(!1);
361
+ z(() => {
362
+ if (i) {
363
+ _(i);
364
+ return;
365
+ }
366
+ if (!a) return;
367
+ let r = !1;
368
+ return ie(a).then((c) => {
369
+ r || _(c);
370
+ }).catch((c) => {
371
+ r || x(c instanceof Error ? c.message : String(c));
372
+ }), () => {
373
+ r = !0;
374
+ };
375
+ }, [i, a]), z(() => {
376
+ var c;
377
+ if (!n) return;
378
+ d == null && n.levels.length > 0 && N(n.levels[0].id);
379
+ const r = /* @__PURE__ */ new Set();
380
+ for (const u of n.levels)
381
+ for (const m of u.shapes)
382
+ if (m.kind === "amenity" && ((c = m.assignment) == null ? void 0 : c.amenityId) != null) {
383
+ const C = n.amenities.find((O) => O.id === m.assignment.amenityId);
384
+ C && r.add(C.code);
385
+ }
386
+ h == null || h(Array.from(r));
387
+ }, [n, d, h]), z(() => {
388
+ var r;
389
+ if (!(!n || p !== "DISPLAY_APP" || k == null)) {
390
+ for (const c of n.levels)
391
+ for (const u of c.shapes)
392
+ if (u.kind === "kiosk_screen" && ((r = u.assignment) == null ? void 0 : r.kioskId) === k) {
393
+ const m = c.anchors.find((C) => C.shapeId === u.id);
394
+ m && G(m.id);
395
+ }
396
+ }
397
+ }, [n, p, k]);
398
+ const w = T(() => n ? X(
399
+ n.graph.nodes.map((r) => ({
400
+ id: r.id,
401
+ levelId: r.levelId,
402
+ shapeId: r.shapeId,
403
+ kind: r.kind,
404
+ x: r.x,
405
+ y: r.y,
406
+ connectorId: r.connectorId
407
+ })),
408
+ n.graph.edges.map((r) => ({
409
+ id: r.id,
410
+ mapId: n.mapId,
411
+ fromAnchorId: r.from,
412
+ toAnchorId: r.to,
413
+ weight: r.weight,
414
+ directed: r.directed,
415
+ accessible: r.accessible,
416
+ kind: r.kind
417
+ })),
418
+ n.connectors
419
+ ) : null, [n]), B = (r, c) => {
420
+ if (!w || r == null || c == null) {
421
+ D(null);
422
+ return;
423
+ }
424
+ const u = W(w, r, c, { accessibleOnly: e });
425
+ D(u);
426
+ };
427
+ z(() => {
428
+ B(E, $);
429
+ }, [E, $, e, w]), z(() => {
430
+ !A || !n || (A.current = {
431
+ createRouteToStore(r) {
432
+ var c;
433
+ for (const u of n.levels)
434
+ for (const m of u.shapes)
435
+ if (((c = m.assignment) == null ? void 0 : c.retailerId) === r) {
436
+ const C = u.anchors.find((O) => O.shapeId === m.id);
437
+ C && (L(C.id), N(u.id));
438
+ }
439
+ },
440
+ createRouteToAmenity(r) {
441
+ var u;
442
+ const c = n.amenities.find((m) => m.code === r);
443
+ if (c) {
444
+ for (const m of n.levels)
445
+ for (const C of m.shapes)
446
+ if (((u = C.assignment) == null ? void 0 : u.amenityId) === c.id) {
447
+ const O = m.anchors.find((H) => H.shapeId === C.id);
448
+ if (O) {
449
+ L(O.id), N(m.id);
450
+ return;
451
+ }
452
+ }
453
+ }
454
+ },
455
+ clearRoute() {
456
+ L(null), D(null);
457
+ }
458
+ });
459
+ }, [A, n]);
460
+ const F = {
461
+ ...K,
462
+ ...(n == null ? void 0 : n.theme) ?? {},
463
+ ...o ?? {}
464
+ };
465
+ if (b)
466
+ return /* @__PURE__ */ t("div", { className: `eyeon-map-viewer eyeon-map-viewer--error ${s ?? ""}`, style: v, children: /* @__PURE__ */ t("div", { className: "eyeon-map-viewer__error", children: b }) });
467
+ if (!n)
468
+ return /* @__PURE__ */ t("div", { className: `eyeon-map-viewer eyeon-map-viewer--loading ${s ?? ""}`, style: v, children: /* @__PURE__ */ t("div", { className: "eyeon-map-viewer__loading", children: "Loading map…" }) });
469
+ const Y = n.amenities.filter(
470
+ (r) => n.levels.some(
471
+ (c) => c.shapes.some((u) => {
472
+ var m;
473
+ return ((m = u.assignment) == null ? void 0 : m.amenityId) === r.id;
474
+ })
475
+ )
476
+ );
477
+ return /* @__PURE__ */ g(
478
+ "div",
479
+ {
480
+ className: `eyeon-map-viewer eyeon-map-viewer--${p} ${s ?? ""}`,
481
+ style: {
482
+ ...v,
483
+ "--map-accent": F.ACCENT_COLOR,
484
+ "--map-bg": F.MAP_BACKGROUND_COLOR
485
+ },
486
+ children: [
487
+ p !== "DISPLAY_APP" && /* @__PURE__ */ t(
488
+ te,
489
+ {
490
+ doc: n,
491
+ amenities: Y,
492
+ searchOpen: I,
493
+ onSearchOpenChange: M,
494
+ activeLevelId: d,
495
+ onActiveLevelChange: N,
496
+ fromAnchorId: E,
497
+ toAnchorId: $,
498
+ onFromChange: G,
499
+ onToChange: L,
500
+ accessibleOnly: e,
501
+ onAccessibleOnlyChange: f,
502
+ route: P
503
+ }
504
+ ),
505
+ /* @__PURE__ */ t("div", { className: "eyeon-map-viewer__canvas", children: /* @__PURE__ */ t(U, { fallback: null, children: /* @__PURE__ */ t(
506
+ ne,
507
+ {
508
+ doc: n,
509
+ theme: F,
510
+ activeLevelId: d,
511
+ route: P,
512
+ selectedRetailerId: y,
513
+ onSelectShape: (r, c) => {
514
+ var C;
515
+ N(c);
516
+ const u = n.levels.find((O) => O.id === c), m = u == null ? void 0 : u.anchors.find((O) => O.shapeId === r);
517
+ m && L(m.id), (C = l.onSelectShape) == null || C.call(l, r);
518
+ }
519
+ }
520
+ ) }) })
521
+ ]
522
+ }
523
+ );
524
+ }
525
+ export {
526
+ ne as M,
527
+ te as R,
528
+ ce as a
529
+ };
530
+ //# sourceMappingURL=MapViewer.js.map