@heroui/agent 0.2.0-beta.8 → 0.2.0-beta.9

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 (47) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/chart-content-BBHQVMP4.js +1 -0
  3. package/dist/chunk-2XBFFSW2.js +1 -0
  4. package/dist/chunk-64RI74L5.js +1 -0
  5. package/dist/chunk-6ZJJN322.js +1 -0
  6. package/dist/chunk-7KCGPNEN.js +1 -0
  7. package/dist/chunk-BBB5EHDN.js +5 -0
  8. package/dist/chunk-CR3H7AVI.js +1 -0
  9. package/dist/chunk-HCLXS4HQ.js +1 -0
  10. package/dist/chunk-MXLGM4WV.js +1 -0
  11. package/dist/chunk-OA3TG5CS.js +1 -0
  12. package/dist/chunk-PZJ4NC3J.js +1 -0
  13. package/dist/chunk-RNNGE7KM.js +1 -0
  14. package/dist/chunk-S6OIAJSC.js +1 -0
  15. package/dist/chunk-SUDHJNTJ.js +2 -0
  16. package/dist/chunk-WUAFMD7Z.js +2 -0
  17. package/dist/component-renderer-GG6JVRUG.js +1 -0
  18. package/dist/composer-draft-NSKK65F3.js +1 -0
  19. package/dist/composer-image-draft-KAGTNQR7.js +1 -0
  20. package/dist/contracts.d.ts +1 -1
  21. package/dist/contracts.js +2 -2445
  22. package/dist/embed-runtime-GYXK7V6N.js +5 -0
  23. package/dist/index.js +1 -31
  24. package/dist/interactive-map-surface-WC2LPCR7.js +1 -0
  25. package/dist/internal/client-tools.js +1 -0
  26. package/dist/internal/models.js +1 -0
  27. package/dist/internal/runtime.js +1 -0
  28. package/dist/internal/theme.js +1 -0
  29. package/dist/next.js +1 -25
  30. package/dist/server.js +1 -136
  31. package/package.json +4 -4
  32. package/dist/chart-content-E4NPTUPR.js +0 -2696
  33. package/dist/chunk-3FG5NRTX.js +0 -9
  34. package/dist/chunk-CMZDZGUZ.js +0 -1132
  35. package/dist/chunk-DS4X5K2R.js +0 -56
  36. package/dist/chunk-FNGGMHVR.js +0 -625
  37. package/dist/chunk-G6GFNSG4.js +0 -284
  38. package/dist/chunk-Q7LGTVBL.js +0 -43
  39. package/dist/chunk-TOOT6SZ2.js +0 -74
  40. package/dist/chunk-UUPU3MYB.js +0 -42
  41. package/dist/chunk-VJA52U5P.js +0 -137
  42. package/dist/chunk-W7SCMB3O.js +0 -1285
  43. package/dist/component-renderer-MDDQMQTU.js +0 -10629
  44. package/dist/composer-draft-DTQAEO5K.js +0 -20
  45. package/dist/composer-image-draft-IVJ352E6.js +0 -174
  46. package/dist/embed-runtime-VVAGDPYY.js +0 -9422
  47. package/dist/interactive-map-surface-67KHT3VB.js +0 -362
@@ -1,362 +0,0 @@
1
- "use client";
2
- import {
3
- createMapLayout,
4
- getMapSelectionCenter
5
- } from "./chunk-VJA52U5P.js";
6
- import {
7
- mergeClassNames
8
- } from "./chunk-3FG5NRTX.js";
9
-
10
- // ../agent-ui/src/components/display-information/map/interactive-map-surface.tsx
11
- import { StarFill } from "@gravity-ui/icons";
12
-
13
- // ../agent-ui/src/components/display-information/map/interactive-map.tsx
14
- import MapLibreGL from "maplibre-gl";
15
- import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
16
- import { createPortal } from "react-dom";
17
- import { jsx, jsxs } from "react/jsx-runtime";
18
- var InteractiveMapContext = createContext(null);
19
- function getDocumentTheme() {
20
- if (typeof document === "undefined") return void 0;
21
- if (document.documentElement.classList.contains("dark") || document.documentElement.dataset["theme"] === "dark") {
22
- return "dark";
23
- }
24
- if (document.documentElement.classList.contains("light") || document.documentElement.dataset["theme"] === "light") {
25
- return "light";
26
- }
27
- return void 0;
28
- }
29
- function getLocalTheme(element) {
30
- const themeRoot = element?.closest("[data-theme]");
31
- const theme = themeRoot?.dataset["theme"];
32
- return theme === "dark" || theme === "light" ? theme : void 0;
33
- }
34
- function getSystemTheme() {
35
- if (typeof window === "undefined") return "light";
36
- return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
37
- }
38
- function useMapTheme(containerRef) {
39
- const [theme, setTheme] = useState(() => getDocumentTheme() ?? getSystemTheme());
40
- useEffect(() => {
41
- const localThemeRoot = containerRef.current?.closest("[data-theme]");
42
- const updateTheme = () => setTheme(getLocalTheme(containerRef.current) ?? getDocumentTheme() ?? getSystemTheme());
43
- const observer = new MutationObserver(updateTheme);
44
- const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
45
- updateTheme();
46
- observer.observe(document.documentElement, {
47
- attributeFilter: ["class", "data-theme"],
48
- attributes: true
49
- });
50
- if (localThemeRoot && localThemeRoot !== document.documentElement) {
51
- observer.observe(localThemeRoot, {
52
- attributeFilter: ["data-theme"],
53
- attributes: true
54
- });
55
- }
56
- mediaQuery.addEventListener("change", updateTheme);
57
- return () => {
58
- observer.disconnect();
59
- mediaQuery.removeEventListener("change", updateTheme);
60
- };
61
- }, [containerRef]);
62
- return theme;
63
- }
64
- function InteractiveMapRoot({
65
- center,
66
- children,
67
- className,
68
- padding,
69
- styles,
70
- zoom,
71
- ...options
72
- }) {
73
- const [longitude, latitude] = center;
74
- const containerRef = useRef(null);
75
- const initialOptionsRef = useRef({
76
- ...options,
77
- center: [longitude, latitude],
78
- zoom
79
- });
80
- const [map, setMap] = useState(null);
81
- const [loadState, setLoadState] = useState("loading");
82
- const theme = useMapTheme(containerRef);
83
- const activeStyle = styles[theme];
84
- const activeStyleRef = useRef(activeStyle);
85
- const initialPaddingRef = useRef(padding);
86
- const zoomRef = useRef(zoom);
87
- useEffect(() => {
88
- const container = containerRef.current;
89
- if (!container) return;
90
- const nextMap = new MapLibreGL.Map({
91
- attributionControl: false,
92
- container,
93
- renderWorldCopies: false,
94
- style: activeStyleRef.current,
95
- ...initialOptionsRef.current
96
- });
97
- const loadTimeout = window.setTimeout(() => setLoadState("error"), 12e3);
98
- const handleLoad = () => {
99
- window.clearTimeout(loadTimeout);
100
- setLoadState("loaded");
101
- };
102
- const observer = new ResizeObserver(() => nextMap.resize());
103
- nextMap.touchZoomRotate.disableRotation();
104
- if (initialPaddingRef.current) nextMap.setPadding(initialPaddingRef.current);
105
- nextMap.on("load", handleLoad);
106
- observer.observe(container);
107
- setMap(nextMap);
108
- return () => {
109
- window.clearTimeout(loadTimeout);
110
- observer.disconnect();
111
- nextMap.off("load", handleLoad);
112
- nextMap.remove();
113
- setMap(null);
114
- };
115
- }, []);
116
- useEffect(() => {
117
- if (!map || activeStyleRef.current === activeStyle) return;
118
- const styleLoadTimeout = window.setTimeout(() => setLoadState("error"), 12e3);
119
- const handleStyleLoad = () => {
120
- window.clearTimeout(styleLoadTimeout);
121
- setLoadState("loaded");
122
- };
123
- const handleStyleLoading = () => setLoadState("loading");
124
- activeStyleRef.current = activeStyle;
125
- map.once("styledataloading", handleStyleLoading);
126
- map.setStyle(activeStyle, { diff: false });
127
- map.once("style.load", handleStyleLoad);
128
- return () => {
129
- window.clearTimeout(styleLoadTimeout);
130
- map.off("style.load", handleStyleLoad);
131
- map.off("styledataloading", handleStyleLoading);
132
- };
133
- }, [activeStyle, map]);
134
- useEffect(() => {
135
- if (!map) return;
136
- const currentCenter = map.getCenter();
137
- const centerChanged = currentCenter.lng !== longitude || currentCenter.lat !== latitude;
138
- const zoomChanged = zoomRef.current !== zoom;
139
- zoomRef.current = zoom;
140
- if (!centerChanged && !zoomChanged) return;
141
- map.easeTo({
142
- center: [longitude, latitude],
143
- duration: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : 350,
144
- ...zoomChanged ? { zoom } : {}
145
- });
146
- }, [latitude, longitude, map, zoom]);
147
- return /* @__PURE__ */ jsx(InteractiveMapContext, { value: map, children: /* @__PURE__ */ jsxs(
148
- "div",
149
- {
150
- ref: containerRef,
151
- className: mergeClassNames("aui-interactive-map", className),
152
- "data-load-state": loadState,
153
- "data-slot": "agent-ui-interactive-map",
154
- children: [
155
- loadState === "loading" ? /* @__PURE__ */ jsx("div", { "aria-label": "Loading map", className: "aui-interactive-map__loader", role: "status", children: /* @__PURE__ */ jsx("span", {}) }) : null,
156
- loadState === "error" ? /* @__PURE__ */ jsxs("div", { className: "aui-interactive-map__error", role: "status", children: [
157
- /* @__PURE__ */ jsx("strong", { children: "Map unavailable" }),
158
- /* @__PURE__ */ jsx("span", { children: "Location results remain available." })
159
- ] }) : null,
160
- map ? children : null
161
- ]
162
- }
163
- ) });
164
- }
165
- function InteractiveMapMarker({ children, latitude, longitude }) {
166
- const map = useContext(InteractiveMapContext);
167
- const initialPositionRef = useRef({ latitude, longitude });
168
- const [marker, setMarker] = useState(null);
169
- useEffect(() => {
170
- const nextElement = document.createElement("div");
171
- const initialPosition = initialPositionRef.current;
172
- const nextMarker = new MapLibreGL.Marker({ element: nextElement }).setLngLat([
173
- initialPosition.longitude,
174
- initialPosition.latitude
175
- ]);
176
- nextElement.className = "aui-interactive-map__marker-host";
177
- setMarker(nextMarker);
178
- return () => {
179
- nextMarker.remove();
180
- };
181
- }, []);
182
- useEffect(() => {
183
- if (!map || !marker) return;
184
- marker.addTo(map);
185
- const markerElement = marker.getElement();
186
- markerElement.removeAttribute("aria-label");
187
- markerElement.removeAttribute("role");
188
- markerElement.removeAttribute("tabindex");
189
- return () => {
190
- marker.remove();
191
- };
192
- }, [map, marker]);
193
- useEffect(() => {
194
- marker?.setLngLat([longitude, latitude]);
195
- }, [latitude, longitude, marker]);
196
- return marker ? createPortal(
197
- /* @__PURE__ */ jsx("div", { className: "aui-interactive-map__marker-content", children }),
198
- marker.getElement()
199
- ) : null;
200
- }
201
- function ControlButton({ children, label, ...props }) {
202
- return /* @__PURE__ */ jsx(
203
- "button",
204
- {
205
- "aria-label": label,
206
- className: "aui-interactive-map__control-button",
207
- type: "button",
208
- ...props,
209
- children
210
- }
211
- );
212
- }
213
- function PlusIcon(props) {
214
- return /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ jsx("path", { d: "M8 3v10M3 8h10", stroke: "currentColor", strokeLinecap: "round", strokeWidth: "1.5" }) });
215
- }
216
- function MinusIcon(props) {
217
- return /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ jsx("path", { d: "M3 8h10", stroke: "currentColor", strokeLinecap: "round", strokeWidth: "1.5" }) });
218
- }
219
- function CompassIcon(props) {
220
- return /* @__PURE__ */ jsxs("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 24 24", ...props, children: [
221
- /* @__PURE__ */ jsx("path", { d: "M12 2 16 12h-4V2Z", "data-needle": "north-right" }),
222
- /* @__PURE__ */ jsx("path", { d: "m12 2-4 10h4V2Z", "data-needle": "north-left" }),
223
- /* @__PURE__ */ jsx("path", { d: "m12 22 4-10h-4v10Z", "data-needle": "south-right" }),
224
- /* @__PURE__ */ jsx("path", { d: "m12 22-4-10h4v10Z", "data-needle": "south-left" })
225
- ] });
226
- }
227
- function InteractiveMapControls() {
228
- const map = useContext(InteractiveMapContext);
229
- const compassRef = useRef(null);
230
- const updateCompass = useCallback(() => {
231
- if (!map || !compassRef.current) return;
232
- compassRef.current.style.transform = `rotateX(${map.getPitch()}deg) rotateZ(${-map.getBearing()}deg)`;
233
- }, [map]);
234
- useEffect(() => {
235
- if (!map) return;
236
- map.on("pitch", updateCompass);
237
- map.on("rotate", updateCompass);
238
- updateCompass();
239
- return () => {
240
- map.off("pitch", updateCompass);
241
- map.off("rotate", updateCompass);
242
- };
243
- }, [map, updateCompass]);
244
- return /* @__PURE__ */ jsxs("div", { className: "aui-interactive-map__controls", "data-slot": "agent-ui-map-controls", children: [
245
- /* @__PURE__ */ jsxs("div", { className: "aui-interactive-map__control-group", children: [
246
- /* @__PURE__ */ jsx(
247
- ControlButton,
248
- {
249
- label: "Zoom in",
250
- onClick: () => map?.zoomTo(map.getZoom() + 1, { duration: 250 }),
251
- children: /* @__PURE__ */ jsx(PlusIcon, {})
252
- }
253
- ),
254
- /* @__PURE__ */ jsx(
255
- ControlButton,
256
- {
257
- label: "Zoom out",
258
- onClick: () => map?.zoomTo(map.getZoom() - 1, { duration: 250 }),
259
- children: /* @__PURE__ */ jsx(MinusIcon, {})
260
- }
261
- )
262
- ] }),
263
- /* @__PURE__ */ jsx("div", { className: "aui-interactive-map__control-group", children: /* @__PURE__ */ jsx(
264
- ControlButton,
265
- {
266
- label: "Reset bearing to north",
267
- onClick: () => map?.resetNorthPitch({ duration: 250 }),
268
- children: /* @__PURE__ */ jsx(CompassIcon, { ref: compassRef, className: "aui-interactive-map__compass" })
269
- }
270
- ) })
271
- ] });
272
- }
273
- var InteractiveMap = Object.assign(InteractiveMapRoot, {
274
- Controls: InteractiveMapControls,
275
- Marker: InteractiveMapMarker
276
- });
277
-
278
- // ../agent-ui/src/components/display-information/map/interactive-map-surface.tsx
279
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
280
- var mapStyles = {
281
- dark: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
282
- light: "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"
283
- };
284
- var resultRailPadding = { bottom: 132, left: 0, right: 0, top: 0 };
285
- var ratingFormatter = new Intl.NumberFormat(void 0, {
286
- maximumFractionDigits: 1,
287
- minimumFractionDigits: 1
288
- });
289
- function InteractiveMapSurface({
290
- component,
291
- onSelect,
292
- selectedLocationId
293
- }) {
294
- const layout = createMapLayout(component);
295
- const center = getMapSelectionCenter(component.locations, selectedLocationId, layout.center);
296
- return /* @__PURE__ */ jsxs2(
297
- "div",
298
- {
299
- "aria-label": `${component.title} map with ${component.locations.length} locations`,
300
- className: "aui-map__surface",
301
- "data-renderer": "interactive",
302
- "data-slot": "agent-ui-map-surface",
303
- role: "region",
304
- children: [
305
- /* @__PURE__ */ jsxs2(
306
- InteractiveMap,
307
- {
308
- center: [center.longitude, center.latitude],
309
- className: "aui-map__interactive-map",
310
- dragRotate: false,
311
- padding: resultRailPadding,
312
- pitchWithRotate: false,
313
- styles: mapStyles,
314
- zoom: layout.zoom,
315
- children: [
316
- component.locations.map((location, index) => {
317
- const selected = location.id === selectedLocationId;
318
- const markerLabel = location.rating !== void 0 ? ratingFormatter.format(location.rating) : location.relevance !== void 0 ? `${Math.round(location.relevance * 100)}%` : String(index + 1);
319
- const accessibleLabel = `Select ${location.title} on map${location.rating === void 0 ? "" : `, rated ${ratingFormatter.format(location.rating)} out of 5`}`;
320
- return /* @__PURE__ */ jsx2(
321
- InteractiveMap.Marker,
322
- {
323
- latitude: location.latitude,
324
- longitude: location.longitude,
325
- children: /* @__PURE__ */ jsxs2(
326
- "button",
327
- {
328
- "aria-label": accessibleLabel,
329
- "aria-pressed": selected,
330
- className: "aui-map__marker",
331
- "data-renderer": "interactive",
332
- "data-selected": selected,
333
- "data-slot": "agent-ui-map-marker",
334
- title: location.title,
335
- type: "button",
336
- onClick: () => onSelect(location),
337
- children: [
338
- /* @__PURE__ */ jsx2(StarFill, { "aria-hidden": "true" }),
339
- /* @__PURE__ */ jsx2("span", { children: markerLabel })
340
- ]
341
- }
342
- )
343
- },
344
- location.id
345
- );
346
- }),
347
- /* @__PURE__ */ jsx2(InteractiveMap.Controls, {})
348
- ]
349
- }
350
- ),
351
- /* @__PURE__ */ jsxs2("span", { className: "aui-map__attribution", "data-slot": "agent-ui-map-attribution", children: [
352
- /* @__PURE__ */ jsx2("a", { href: "https://www.openstreetmap.org/copyright", rel: "noreferrer", target: "_blank", children: "\xA9 OpenStreetMap" }),
353
- /* @__PURE__ */ jsx2("span", { "aria-hidden": "true", children: " \xB7 " }),
354
- /* @__PURE__ */ jsx2("a", { href: "https://carto.com/attributions", rel: "noreferrer", target: "_blank", children: "\xA9 CARTO" })
355
- ] })
356
- ]
357
- }
358
- );
359
- }
360
- export {
361
- InteractiveMapSurface
362
- };