@luzmo/embed 6.13.3 → 6.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [6.13.6] - 2026-07-03
6
+
7
+ ### Added
8
+ - `getDashboardContext()` on `<luzmo-embed-dashboard>`, returning the live dashboard context as the unified `dashboard` aiprompt input (`{ type, value }`, where `value` carries the current screen mode as `value.currentScreenMode`) in both iframe and web-component embed modes.
9
+ - `getVizItemContext()` on `<luzmo-embed-viz-item>`, returning a flex chart's live context (id, type, slots, options, filters and datasetIds).
10
+ - `contextChanged` event on `<luzmo-embed-dashboard>` and `<luzmo-embed-viz-item>`, emitted on any change and carrying the full context.
11
+ - Context-aware IQ chat: `dashboardId`, `contextIds` and `availableDatasets` properties on `<luzmo-iq-embed-chat>` to auto-connect the chat to an embedded dashboard or flex charts on the same page, plus a `connectionStatusChanged` event reporting `standalone` / `connecting` / `connected` / `not-found`.
12
+
13
+ ## [6.13.5] - 2026-06-09
14
+
15
+ ### Fixed
16
+ - Fixed IQ analyst panel positioning and dashboard sizing. The dashboard now fills its container (removing overflowing charts and the double scrollbar) and the analyst panel stays pinned to the visible viewport while scrolling.
17
+
18
+ ## [6.13.4] - 2026-05-28
19
+
20
+ ### Added
21
+ - Added the `dashboardContext` property on `<luzmo-iq-embed-chat>` to pass the current dashboard layout, metadata and runtime filters to the IQ chat for context-aware answers.
22
+
5
23
  ## [6.13.3] - 2026-05-27
6
24
 
7
25
  ### Changed
package/README.md CHANGED
@@ -82,13 +82,14 @@ Below a list of available properties on the viz item web component
82
82
 
83
83
  ### Events luzmo-embed-viz-item
84
84
 
85
- | Name | Description |
86
- |----------------|----------------------------------------|
87
- | changedFilters | Emitted when filters are changed |
88
- | customEvent | Emitted when a custom event is fired |
89
- | exported | Emitted when export completes or fails |
90
- | rendered | Emitted when the item is rendered |
91
- | load | Emitted when viz item is loaded |
85
+ | Name | Description |
86
+ |----------------|-------------------------------------------------------------|
87
+ | changedFilters | Emitted when filters are changed |
88
+ | contextChanged | Emitted on any change, carries the full viz-item context |
89
+ | customEvent | Emitted when a custom event is fired |
90
+ | exported | Emitted when export completes or fails |
91
+ | rendered | Emitted when the item is rendered |
92
+ | load | Emitted when viz item is loaded |
92
93
 
93
94
  <br/>
94
95
 
@@ -101,6 +102,10 @@ getData(): ItemData;
101
102
  // Return an array of active filters on the viz item.
102
103
  getFilters(): FilterGroup[];
103
104
 
105
+ // Return the live context of the viz item: id (contextId/DOM id), type, slots, options, filters and datasetIds.
106
+ // Used to feed a flex chart's context into an IQ chat or an /aiprompt call.
107
+ getVizItemContext(): VizItemContext;
108
+
104
109
  // Refresh the data of the viz item.
105
110
  refreshData(): void;
106
111
 
@@ -196,13 +201,14 @@ Below a list of available properties on the dashboard web component
196
201
 
197
202
  ### Events luzmo-embed-dashboard
198
203
 
199
- | Name | Description | Event Arguments |
200
- | -------------- | -------------------------------------- | --------------------- |
201
- | changedFilters | Emitted when filters are changed | `ChangedFiltersEvent` |
202
- | customEvent | Emitted when a custom event is fired | `CustomEvent` |
203
- | exported | Emitted when export completes or fails | `ExportedEvent` |
204
- | itemsRendered | Emitted when all items are rendered | `ItemsRenderedEvent` |
205
- | load | Emitted when dashboard is loaded | `LoadEvent` |
204
+ | Name | Description | Event Arguments |
205
+ | -------------- | ------------------------------------------------------------ | ---------------------- |
206
+ | changedFilters | Emitted when filters are changed | `ChangedFiltersEvent` |
207
+ | contextChanged | Emitted on any dashboard change, carries the full context | `ContextChangedEvent` |
208
+ | customEvent | Emitted when a custom event is fired | `CustomEvent` |
209
+ | exported | Emitted when export completes or fails | `ExportedEvent` |
210
+ | itemsRendered | Emitted when all items are rendered | `ItemsRenderedEvent` |
211
+ | load | Emitted when dashboard is loaded | `LoadEvent` |
206
212
 
207
213
  <br/>
208
214
 
@@ -218,6 +224,13 @@ getData(itemId: string): Promise<ItemData>;
218
224
  // Returns an array of active filters.
219
225
  getFilters(): Promise<FilterGroup[]>;
220
226
 
227
+ // Returns the live dashboard context (current views, runtime filters and titles) as the
228
+ // unified `dashboard` aiprompt input (`{ type: 'dashboard', value }`, where `value` carries
229
+ // the current screen mode as `value.currentScreenMode`).
230
+ // Works in both iframe and web-component embed modes. Feed it into an IQ chat (via its
231
+ // `dashboardContext` input) or an /aiprompt call.
232
+ getDashboardContext(): Promise<DashboardContext | undefined>;
233
+
221
234
  // Changes the authorization of all or one dashboard. To fetch data based on new authorization parameters, reloadDashboard() or refreshData() needs to be called.
222
235
  setAuthorization(key: string, token: string): Promise<void>;
223
236
 
@@ -354,6 +367,33 @@ All available properties for the IQ chat component can be seen in the table belo
354
367
  | `apiHost` | string | Tenancy of Luzmo API to connect to (Default: 'https://api.luzmo.com/' , for US set apiHost to 'https://api.us.luzmo.com/') |
355
368
  | `options` | IQChatOptions | Specifies the customization options of the IQ chat component that affect its appearance and functionality. |
356
369
  | `initialSuggestionsDatasetId` | string | ID of a dataset that assists the AI service in generating automated, initial prompts based on the provided data. |
370
+ | `availableDatasets` | string[] | Restrict the analyst to these dataset ids. Accepts a JSON array string attribute. |
371
+ | `dashboardContext` | DashboardContext | A `dashboard-context` to answer over (manual API path). Accepts a JSON object string attribute. |
372
+ | `dashboardId` | string | Connect the chat to a dashboard embedded on the same page; it auto-reads live context and refreshes on change. |
373
+ | `contextIds` | string[] | Connect the chat to one or more flex charts by their `context-id`; a synthetic dashboard-context is assembled. JSON array. |
374
+
375
+ <br/>
376
+
377
+ #### Context-aware chat (dashboards & flex charts)
378
+
379
+ The IQ chat can answer using the **live context** of an embedded dashboard or one/more standalone flex charts on the same page. Connection is always explicit:
380
+
381
+ - Set neither `dashboardId` nor `contextIds` → standalone chat (no context).
382
+ - Set `dashboardId` → the chat finds the `luzmo-embed-dashboard` with that id, reads its context via `getDashboardContext()` and refreshes on each `contextChanged`.
383
+ - Set `contextIds` → the chat finds each `luzmo-embed-viz-item` whose `context-id` matches, reads each via `getVizItemContext()` and assembles a synthetic dashboard-context.
384
+ - If an id is not found on the page, the chat does not connect and surfaces a clear message; a `connectionStatusChanged` event reports the status (`standalone` / `connecting` / `connected` / `not-found`).
385
+
386
+ For a customer's own UI you can also skip auto-connect and forward context yourself: listen to the dashboard's `contextChanged` (or call `getDashboardContext()`), then pass the payload into the chat's `dashboardContext` input or into an `/aiprompt` call.
387
+
388
+ ```html
389
+ <!-- Auto-connect to a dashboard on the same page -->
390
+ <luzmo-embed-dashboard dashboardId="<dashboard-id>" authKey="..." authToken="..."></luzmo-embed-dashboard>
391
+ <luzmo-iq-embed-chat dashboardId="<dashboard-id>" authKey="..." authToken="..."></luzmo-iq-embed-chat>
392
+
393
+ <!-- Auto-connect to one or more flex charts -->
394
+ <luzmo-embed-viz-item context-id="sales-by-product" authKey="..." authToken="..."></luzmo-embed-viz-item>
395
+ <luzmo-iq-embed-chat contextIds='["sales-by-product"]' authKey="..." authToken="..."></luzmo-iq-embed-chat>
396
+ ```
357
397
 
358
398
  <br/>
359
399
 
package/index.cjs CHANGED
@@ -65,7 +65,7 @@ var import_decorators = require("lit/decorators.js");
65
65
  var import_style_map = require("lit/directives/style-map.js");
66
66
 
67
67
  // libs/embed-libs/embed/package.json
68
- var version = "6.13.3";
68
+ var version = "6.13.6";
69
69
 
70
70
  // libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
71
71
  var SharedLib = __toESM(require("@luzmo/shared-embed"));
@@ -131,6 +131,14 @@ var _setEventHandler = () => {
131
131
  );
132
132
  break;
133
133
  }
134
+ case "dashboardContext": {
135
+ SharedLib.resolvePromise(
136
+ dashboardComponent,
137
+ event.data.requestId,
138
+ event.data.context
139
+ );
140
+ break;
141
+ }
134
142
  case "getAccessibleDashboards": {
135
143
  SharedLib.resolvePromise(
136
144
  dashboardComponent,
@@ -170,6 +178,12 @@ var _setEventHandler = () => {
170
178
  );
171
179
  break;
172
180
  }
181
+ case "contextChanged": {
182
+ dashboardComponent.dispatchEvent(
183
+ new CustomEvent("contextChanged", { detail: { data: event.data } })
184
+ );
185
+ break;
186
+ }
173
187
  case "customEvent": {
174
188
  dashboardComponent.dispatchEvent(
175
189
  new CustomEvent("customEvent", { detail: { data: event.data } })
@@ -211,6 +225,14 @@ var _setEventHandler = () => {
211
225
  SharedLib._setCalculatedDimensions(dashboardComponent);
212
226
  break;
213
227
  }
228
+ case "trackViewport": {
229
+ if (event.data.enabled) {
230
+ dashboardComponent._startViewportTracking();
231
+ } else {
232
+ dashboardComponent._stopViewportTracking();
233
+ }
234
+ break;
235
+ }
214
236
  case "setSelectedData":
215
237
  case "setFilters": {
216
238
  if (event.data.error) {
@@ -297,6 +319,24 @@ var dashboardStyles = import_lit.css`
297
319
  height: 100%;
298
320
  }
299
321
 
322
+ /*
323
+ * Web component mode: the dashboard app renders directly (no iframe). Make its host fill the
324
+ * sized .dashboard-container so the app's internal height:100% chain resolves to the calculated
325
+ * dashboard height - exactly like the iframe gets its height. Without this the app collapses to
326
+ * its intrinsic size and its inner scroll container produces a second scrollbar, and content can
327
+ * spill outside the container.
328
+ */
329
+ #dashboard-wc-container {
330
+ width: 100%;
331
+ height: 100%;
332
+ }
333
+
334
+ #dashboard-wc-container dashboard-component {
335
+ display: block;
336
+ width: 100%;
337
+ height: 100%;
338
+ }
339
+
300
340
  .luzmo-container-loader {
301
341
  width: 100%;
302
342
  position: relative;
@@ -421,6 +461,12 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
421
461
  this.loaderSize = 32;
422
462
  this.borderWidth = 3;
423
463
  this.minHeight = 400;
464
+ this._viewportTrackingActive = false;
465
+ // Post synchronously on scroll/resize (not via requestAnimationFrame) so the iframe receives the
466
+ // new slice as early as possible in the frame, minimizing the lag of the pinned analyst panel.
467
+ this._onViewportChange = () => {
468
+ this._postViewport();
469
+ };
424
470
  this._containerId = SharedLib2.uuidv4();
425
471
  this._iframeId = `luzmo-dashboard-${this._containerId}`;
426
472
  this.iframeLoaded = false;
@@ -463,12 +509,48 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
463
509
  disconnectedCallback() {
464
510
  super.disconnectedCallback();
465
511
  this._resizeObserver.disconnect();
512
+ this._stopViewportTracking();
466
513
  for (const promiseKey of Object.keys(this.promises)) {
467
514
  this.promises[promiseKey].reject(
468
515
  new Error("Dashboard component was removed")
469
516
  );
470
517
  }
471
518
  }
519
+ // Relay the iframe's visible slice within the host viewport to the dashboard app, so embedded
520
+ // overlays (e.g. the IQ analyst) can pin themselves to the visible area while the host page
521
+ // scrolls the full-height iframe. Opt-in: started when the iframe requests it via 'trackViewport'.
522
+ _startViewportTracking() {
523
+ if (this.embedMode !== "iframe") {
524
+ return;
525
+ }
526
+ if (!this._viewportTrackingActive) {
527
+ this._viewportTrackingActive = true;
528
+ window.addEventListener("scroll", this._onViewportChange, { passive: true, capture: true });
529
+ window.addEventListener("resize", this._onViewportChange, { passive: true });
530
+ }
531
+ this._postViewport();
532
+ }
533
+ _stopViewportTracking() {
534
+ if (!this._viewportTrackingActive) {
535
+ return;
536
+ }
537
+ this._viewportTrackingActive = false;
538
+ window.removeEventListener("scroll", this._onViewportChange, { capture: true });
539
+ window.removeEventListener("resize", this._onViewportChange);
540
+ }
541
+ _postViewport() {
542
+ const contentWindow = this.iframe?.contentWindow;
543
+ if (!contentWindow) {
544
+ return;
545
+ }
546
+ const rect = this.iframe.getBoundingClientRect();
547
+ const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
548
+ const visibleTop = Math.max(rect.top, 0);
549
+ const visibleBottom = Math.min(rect.bottom, viewportHeight);
550
+ const visibleHeight = Math.max(visibleBottom - visibleTop, 0);
551
+ const offsetTop = Math.min(Math.max(-rect.top, 0), rect.height);
552
+ contentWindow.postMessage({ action: "setViewport", offsetTop, visibleHeight }, "*");
553
+ }
472
554
  firstUpdated() {
473
555
  this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
474
556
  this._loaderStyles();
@@ -497,6 +579,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
497
579
  el.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
498
580
  el.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
499
581
  el.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
582
+ el.addEventListener("contextChanged", (payload) => this.dispatchEvent(new CustomEvent("contextChanged", payload)));
500
583
  const container = this.renderRoot.querySelector("#dashboard-wc-container");
501
584
  if (container) {
502
585
  container.append(el);
@@ -852,6 +935,15 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
852
935
  }
853
936
  return Promise.reject();
854
937
  }
938
+ getDashboardContext() {
939
+ if (this.isWebComponentViewMode() && this.dashboardReference) {
940
+ return this.dashboardReference.getDashboardContext();
941
+ }
942
+ if (!this.isWebComponentViewMode()) {
943
+ return SharedLib2.getDashboardContext(this, this.iframe);
944
+ }
945
+ return Promise.reject(new Error("getDashboardContext is not available: dashboard reference is not ready."));
946
+ }
855
947
  setSelectedData(itemId, filters) {
856
948
  if (this.isWebComponentViewMode() && this.dashboardReference) {
857
949
  return this.dashboardReference.setSelectedData(itemId, filters);
@@ -1122,15 +1214,26 @@ if (!customElements.get("luzmo-embed-dashboard")) {
1122
1214
  customElements.define("luzmo-embed-dashboard", LuzmoEmbedDashboard);
1123
1215
  }
1124
1216
 
1125
- // libs/dashboard-contents-types/src/lib/shared/version.ts
1126
- var CONTENTS_VERSION = "0.1.100";
1127
-
1128
1217
  // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
1218
+ var import_dashboard_contents_types = require("@luzmo/dashboard-contents-types");
1129
1219
  var SharedLib3 = __toESM(require("@luzmo/shared-embed"));
1130
1220
  var import_lit3 = require("lit");
1131
1221
  var import_decorators2 = require("lit/decorators.js");
1132
- var dashboardContentsVersion = CONTENTS_VERSION;
1222
+ var dashboardContentsVersion = import_dashboard_contents_types.CONTENTS_VERSION;
1133
1223
  var vizItemRemote = "VizItemApp";
1224
+ function collectVizItemDatasetIds(slots) {
1225
+ const ids = /* @__PURE__ */ new Set();
1226
+ for (const slot of slots ?? []) {
1227
+ for (const content of slot?.content ?? []) {
1228
+ const column = content;
1229
+ const datasetId = column.datasetId ?? column.set;
1230
+ if (datasetId) {
1231
+ ids.add(datasetId);
1232
+ }
1233
+ }
1234
+ }
1235
+ return [...ids];
1236
+ }
1134
1237
  var LuzmoBaseVizItem = class extends import_lit3.LitElement {
1135
1238
  constructor() {
1136
1239
  super(...arguments);
@@ -1176,6 +1279,22 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
1176
1279
  getFilters() {
1177
1280
  return this.chartElement.getFilters();
1178
1281
  }
1282
+ /**
1283
+ * Snapshot of this flex chart's live context: its definition (type, slots,
1284
+ * options), current filters and the datasets it reads. Used by context-aware
1285
+ * embeds such as the Luzmo IQ chat component.
1286
+ */
1287
+ getVizItemContext() {
1288
+ const slots = this.slots ?? [];
1289
+ return {
1290
+ id: this.contextId ?? this.getAttribute("context-id") ?? this.id ?? this.itemId ?? "",
1291
+ type: this.type,
1292
+ slots,
1293
+ options: this.options,
1294
+ filters: typeof this.chartElement?.getFilters === "function" ? this.getFilters() : this.filters ?? [],
1295
+ datasetIds: collectVizItemDatasetIds(slots)
1296
+ };
1297
+ }
1179
1298
  export(type = "png") {
1180
1299
  return this.chartElement.export(type);
1181
1300
  }
@@ -1228,7 +1347,12 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
1228
1347
  }
1229
1348
  this.dispatchEvent(new CustomEvent("rendered", payload));
1230
1349
  });
1231
- this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
1350
+ this.chartElement.addEventListener("changedFilters", (payload) => {
1351
+ this.dispatchEvent(new CustomEvent("changedFilters", payload));
1352
+ this.dispatchEvent(new CustomEvent("contextChanged", {
1353
+ detail: { data: { type: "contextChanged", context: this.getVizItemContext() } }
1354
+ }));
1355
+ });
1232
1356
  this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
1233
1357
  this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
1234
1358
  this.chartElement.addEventListener("authorizationExpired", (payload) => this.dispatchEvent(new CustomEvent("authorizationExpired", payload)));
@@ -1315,6 +1439,9 @@ __decorateClass([
1315
1439
  __decorateClass([
1316
1440
  (0, import_decorators2.property)()
1317
1441
  ], LuzmoBaseVizItem.prototype, "itemId", 2);
1442
+ __decorateClass([
1443
+ (0, import_decorators2.property)({ attribute: "ai-message-asset-id" })
1444
+ ], LuzmoBaseVizItem.prototype, "aiMessageAssetId", 2);
1318
1445
  __decorateClass([
1319
1446
  (0, import_decorators2.property)({ type: Object })
1320
1447
  ], LuzmoBaseVizItem.prototype, "selectedData", 2);
@@ -1347,7 +1474,10 @@ var inputMap = {
1347
1474
  version: "version",
1348
1475
  libVersion: "lib-version",
1349
1476
  aydHost: "ayd-host",
1350
- availableDatasets: "available-datasets"
1477
+ availableDatasets: "available-datasets",
1478
+ dashboardContext: "dashboard-context",
1479
+ dashboardId: "dashboard-id",
1480
+ contextIds: "context-ids"
1351
1481
  };
1352
1482
  var embedChatTag = "luzmo-iq-embed-chat";
1353
1483
  var chatComponentTag = "luzmo-iq-chat-component";
@@ -1386,6 +1516,10 @@ var LuzmoIQEmbedChatComponent = class extends import_lit4.LitElement {
1386
1516
  if (!this.chartElement) {
1387
1517
  this.chartElement = document.createElement(chatComponentTag);
1388
1518
  this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
1519
+ this.chartElement.addEventListener(
1520
+ "connectionStatusChanged",
1521
+ (event) => this.dispatchEvent(new CustomEvent("connectionStatusChanged", { detail: event.detail }))
1522
+ );
1389
1523
  this.updateVizItemProperties();
1390
1524
  this.renderRoot.append(this.chartElement);
1391
1525
  }
@@ -1408,7 +1542,12 @@ var LuzmoIQEmbedChatComponent = class extends import_lit4.LitElement {
1408
1542
  if (this.chartElement) {
1409
1543
  for (const [propertyName] of changedProperties.entries()) {
1410
1544
  const mappedAttributeName = inputMap[propertyName] ?? propertyName;
1411
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1545
+ const propertyValue = this[propertyName];
1546
+ if (propertyValue == null) {
1547
+ this.chartElement.removeAttribute(mappedAttributeName);
1548
+ continue;
1549
+ }
1550
+ const attributeValue = typeof propertyValue === "object" ? JSON.stringify(propertyValue) : propertyValue.toString();
1412
1551
  this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1413
1552
  }
1414
1553
  } else {
@@ -1475,6 +1614,15 @@ __decorateClass([
1475
1614
  __decorateClass([
1476
1615
  (0, import_decorators3.property)({ type: Array })
1477
1616
  ], LuzmoIQEmbedChatComponent.prototype, "availableDatasets", 2);
1617
+ __decorateClass([
1618
+ (0, import_decorators3.property)({ type: Object })
1619
+ ], LuzmoIQEmbedChatComponent.prototype, "dashboardContext", 2);
1620
+ __decorateClass([
1621
+ (0, import_decorators3.property)()
1622
+ ], LuzmoIQEmbedChatComponent.prototype, "dashboardId", 2);
1623
+ __decorateClass([
1624
+ (0, import_decorators3.property)({ type: Array })
1625
+ ], LuzmoIQEmbedChatComponent.prototype, "contextIds", 2);
1478
1626
  if (!customElements.get(embedChatTag)) {
1479
1627
  customElements.define(embedChatTag, LuzmoIQEmbedChatComponent);
1480
1628
  }
package/index.js CHANGED
@@ -23,7 +23,7 @@ import { property, query, state } from "lit/decorators.js";
23
23
  import { styleMap } from "lit/directives/style-map.js";
24
24
 
25
25
  // libs/embed-libs/embed/package.json
26
- var version = "6.13.3";
26
+ var version = "6.13.6";
27
27
 
28
28
  // libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
29
29
  import * as SharedLib from "@luzmo/shared-embed";
@@ -89,6 +89,14 @@ var _setEventHandler = () => {
89
89
  );
90
90
  break;
91
91
  }
92
+ case "dashboardContext": {
93
+ SharedLib.resolvePromise(
94
+ dashboardComponent,
95
+ event.data.requestId,
96
+ event.data.context
97
+ );
98
+ break;
99
+ }
92
100
  case "getAccessibleDashboards": {
93
101
  SharedLib.resolvePromise(
94
102
  dashboardComponent,
@@ -128,6 +136,12 @@ var _setEventHandler = () => {
128
136
  );
129
137
  break;
130
138
  }
139
+ case "contextChanged": {
140
+ dashboardComponent.dispatchEvent(
141
+ new CustomEvent("contextChanged", { detail: { data: event.data } })
142
+ );
143
+ break;
144
+ }
131
145
  case "customEvent": {
132
146
  dashboardComponent.dispatchEvent(
133
147
  new CustomEvent("customEvent", { detail: { data: event.data } })
@@ -169,6 +183,14 @@ var _setEventHandler = () => {
169
183
  SharedLib._setCalculatedDimensions(dashboardComponent);
170
184
  break;
171
185
  }
186
+ case "trackViewport": {
187
+ if (event.data.enabled) {
188
+ dashboardComponent._startViewportTracking();
189
+ } else {
190
+ dashboardComponent._stopViewportTracking();
191
+ }
192
+ break;
193
+ }
172
194
  case "setSelectedData":
173
195
  case "setFilters": {
174
196
  if (event.data.error) {
@@ -255,6 +277,24 @@ var dashboardStyles = css`
255
277
  height: 100%;
256
278
  }
257
279
 
280
+ /*
281
+ * Web component mode: the dashboard app renders directly (no iframe). Make its host fill the
282
+ * sized .dashboard-container so the app's internal height:100% chain resolves to the calculated
283
+ * dashboard height - exactly like the iframe gets its height. Without this the app collapses to
284
+ * its intrinsic size and its inner scroll container produces a second scrollbar, and content can
285
+ * spill outside the container.
286
+ */
287
+ #dashboard-wc-container {
288
+ width: 100%;
289
+ height: 100%;
290
+ }
291
+
292
+ #dashboard-wc-container dashboard-component {
293
+ display: block;
294
+ width: 100%;
295
+ height: 100%;
296
+ }
297
+
258
298
  .luzmo-container-loader {
259
299
  width: 100%;
260
300
  position: relative;
@@ -379,6 +419,12 @@ var LuzmoDashboard = class extends LitElement {
379
419
  this.loaderSize = 32;
380
420
  this.borderWidth = 3;
381
421
  this.minHeight = 400;
422
+ this._viewportTrackingActive = false;
423
+ // Post synchronously on scroll/resize (not via requestAnimationFrame) so the iframe receives the
424
+ // new slice as early as possible in the frame, minimizing the lag of the pinned analyst panel.
425
+ this._onViewportChange = () => {
426
+ this._postViewport();
427
+ };
382
428
  this._containerId = SharedLib2.uuidv4();
383
429
  this._iframeId = `luzmo-dashboard-${this._containerId}`;
384
430
  this.iframeLoaded = false;
@@ -421,12 +467,48 @@ var LuzmoDashboard = class extends LitElement {
421
467
  disconnectedCallback() {
422
468
  super.disconnectedCallback();
423
469
  this._resizeObserver.disconnect();
470
+ this._stopViewportTracking();
424
471
  for (const promiseKey of Object.keys(this.promises)) {
425
472
  this.promises[promiseKey].reject(
426
473
  new Error("Dashboard component was removed")
427
474
  );
428
475
  }
429
476
  }
477
+ // Relay the iframe's visible slice within the host viewport to the dashboard app, so embedded
478
+ // overlays (e.g. the IQ analyst) can pin themselves to the visible area while the host page
479
+ // scrolls the full-height iframe. Opt-in: started when the iframe requests it via 'trackViewport'.
480
+ _startViewportTracking() {
481
+ if (this.embedMode !== "iframe") {
482
+ return;
483
+ }
484
+ if (!this._viewportTrackingActive) {
485
+ this._viewportTrackingActive = true;
486
+ window.addEventListener("scroll", this._onViewportChange, { passive: true, capture: true });
487
+ window.addEventListener("resize", this._onViewportChange, { passive: true });
488
+ }
489
+ this._postViewport();
490
+ }
491
+ _stopViewportTracking() {
492
+ if (!this._viewportTrackingActive) {
493
+ return;
494
+ }
495
+ this._viewportTrackingActive = false;
496
+ window.removeEventListener("scroll", this._onViewportChange, { capture: true });
497
+ window.removeEventListener("resize", this._onViewportChange);
498
+ }
499
+ _postViewport() {
500
+ const contentWindow = this.iframe?.contentWindow;
501
+ if (!contentWindow) {
502
+ return;
503
+ }
504
+ const rect = this.iframe.getBoundingClientRect();
505
+ const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
506
+ const visibleTop = Math.max(rect.top, 0);
507
+ const visibleBottom = Math.min(rect.bottom, viewportHeight);
508
+ const visibleHeight = Math.max(visibleBottom - visibleTop, 0);
509
+ const offsetTop = Math.min(Math.max(-rect.top, 0), rect.height);
510
+ contentWindow.postMessage({ action: "setViewport", offsetTop, visibleHeight }, "*");
511
+ }
430
512
  firstUpdated() {
431
513
  this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
432
514
  this._loaderStyles();
@@ -455,6 +537,7 @@ var LuzmoDashboard = class extends LitElement {
455
537
  el.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
456
538
  el.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
457
539
  el.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
540
+ el.addEventListener("contextChanged", (payload) => this.dispatchEvent(new CustomEvent("contextChanged", payload)));
458
541
  const container = this.renderRoot.querySelector("#dashboard-wc-container");
459
542
  if (container) {
460
543
  container.append(el);
@@ -810,6 +893,15 @@ var LuzmoDashboard = class extends LitElement {
810
893
  }
811
894
  return Promise.reject();
812
895
  }
896
+ getDashboardContext() {
897
+ if (this.isWebComponentViewMode() && this.dashboardReference) {
898
+ return this.dashboardReference.getDashboardContext();
899
+ }
900
+ if (!this.isWebComponentViewMode()) {
901
+ return SharedLib2.getDashboardContext(this, this.iframe);
902
+ }
903
+ return Promise.reject(new Error("getDashboardContext is not available: dashboard reference is not ready."));
904
+ }
813
905
  setSelectedData(itemId, filters) {
814
906
  if (this.isWebComponentViewMode() && this.dashboardReference) {
815
907
  return this.dashboardReference.setSelectedData(itemId, filters);
@@ -1080,15 +1172,26 @@ if (!customElements.get("luzmo-embed-dashboard")) {
1080
1172
  customElements.define("luzmo-embed-dashboard", LuzmoEmbedDashboard);
1081
1173
  }
1082
1174
 
1083
- // libs/dashboard-contents-types/src/lib/shared/version.ts
1084
- var CONTENTS_VERSION = "0.1.100";
1085
-
1086
1175
  // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
1176
+ import { CONTENTS_VERSION } from "@luzmo/dashboard-contents-types";
1087
1177
  import * as SharedLib3 from "@luzmo/shared-embed";
1088
1178
  import { css as css2, html as html2, LitElement as LitElement2 } from "lit";
1089
1179
  import { property as property2 } from "lit/decorators.js";
1090
1180
  var dashboardContentsVersion = CONTENTS_VERSION;
1091
1181
  var vizItemRemote = "VizItemApp";
1182
+ function collectVizItemDatasetIds(slots) {
1183
+ const ids = /* @__PURE__ */ new Set();
1184
+ for (const slot of slots ?? []) {
1185
+ for (const content of slot?.content ?? []) {
1186
+ const column = content;
1187
+ const datasetId = column.datasetId ?? column.set;
1188
+ if (datasetId) {
1189
+ ids.add(datasetId);
1190
+ }
1191
+ }
1192
+ }
1193
+ return [...ids];
1194
+ }
1092
1195
  var LuzmoBaseVizItem = class extends LitElement2 {
1093
1196
  constructor() {
1094
1197
  super(...arguments);
@@ -1134,6 +1237,22 @@ var LuzmoBaseVizItem = class extends LitElement2 {
1134
1237
  getFilters() {
1135
1238
  return this.chartElement.getFilters();
1136
1239
  }
1240
+ /**
1241
+ * Snapshot of this flex chart's live context: its definition (type, slots,
1242
+ * options), current filters and the datasets it reads. Used by context-aware
1243
+ * embeds such as the Luzmo IQ chat component.
1244
+ */
1245
+ getVizItemContext() {
1246
+ const slots = this.slots ?? [];
1247
+ return {
1248
+ id: this.contextId ?? this.getAttribute("context-id") ?? this.id ?? this.itemId ?? "",
1249
+ type: this.type,
1250
+ slots,
1251
+ options: this.options,
1252
+ filters: typeof this.chartElement?.getFilters === "function" ? this.getFilters() : this.filters ?? [],
1253
+ datasetIds: collectVizItemDatasetIds(slots)
1254
+ };
1255
+ }
1137
1256
  export(type = "png") {
1138
1257
  return this.chartElement.export(type);
1139
1258
  }
@@ -1186,7 +1305,12 @@ var LuzmoBaseVizItem = class extends LitElement2 {
1186
1305
  }
1187
1306
  this.dispatchEvent(new CustomEvent("rendered", payload));
1188
1307
  });
1189
- this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
1308
+ this.chartElement.addEventListener("changedFilters", (payload) => {
1309
+ this.dispatchEvent(new CustomEvent("changedFilters", payload));
1310
+ this.dispatchEvent(new CustomEvent("contextChanged", {
1311
+ detail: { data: { type: "contextChanged", context: this.getVizItemContext() } }
1312
+ }));
1313
+ });
1190
1314
  this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
1191
1315
  this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
1192
1316
  this.chartElement.addEventListener("authorizationExpired", (payload) => this.dispatchEvent(new CustomEvent("authorizationExpired", payload)));
@@ -1273,6 +1397,9 @@ __decorateClass([
1273
1397
  __decorateClass([
1274
1398
  property2()
1275
1399
  ], LuzmoBaseVizItem.prototype, "itemId", 2);
1400
+ __decorateClass([
1401
+ property2({ attribute: "ai-message-asset-id" })
1402
+ ], LuzmoBaseVizItem.prototype, "aiMessageAssetId", 2);
1276
1403
  __decorateClass([
1277
1404
  property2({ type: Object })
1278
1405
  ], LuzmoBaseVizItem.prototype, "selectedData", 2);
@@ -1305,7 +1432,10 @@ var inputMap = {
1305
1432
  version: "version",
1306
1433
  libVersion: "lib-version",
1307
1434
  aydHost: "ayd-host",
1308
- availableDatasets: "available-datasets"
1435
+ availableDatasets: "available-datasets",
1436
+ dashboardContext: "dashboard-context",
1437
+ dashboardId: "dashboard-id",
1438
+ contextIds: "context-ids"
1309
1439
  };
1310
1440
  var embedChatTag = "luzmo-iq-embed-chat";
1311
1441
  var chatComponentTag = "luzmo-iq-chat-component";
@@ -1344,6 +1474,10 @@ var LuzmoIQEmbedChatComponent = class extends LitElement3 {
1344
1474
  if (!this.chartElement) {
1345
1475
  this.chartElement = document.createElement(chatComponentTag);
1346
1476
  this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
1477
+ this.chartElement.addEventListener(
1478
+ "connectionStatusChanged",
1479
+ (event) => this.dispatchEvent(new CustomEvent("connectionStatusChanged", { detail: event.detail }))
1480
+ );
1347
1481
  this.updateVizItemProperties();
1348
1482
  this.renderRoot.append(this.chartElement);
1349
1483
  }
@@ -1366,7 +1500,12 @@ var LuzmoIQEmbedChatComponent = class extends LitElement3 {
1366
1500
  if (this.chartElement) {
1367
1501
  for (const [propertyName] of changedProperties.entries()) {
1368
1502
  const mappedAttributeName = inputMap[propertyName] ?? propertyName;
1369
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1503
+ const propertyValue = this[propertyName];
1504
+ if (propertyValue == null) {
1505
+ this.chartElement.removeAttribute(mappedAttributeName);
1506
+ continue;
1507
+ }
1508
+ const attributeValue = typeof propertyValue === "object" ? JSON.stringify(propertyValue) : propertyValue.toString();
1370
1509
  this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1371
1510
  }
1372
1511
  } else {
@@ -1433,6 +1572,15 @@ __decorateClass([
1433
1572
  __decorateClass([
1434
1573
  property3({ type: Array })
1435
1574
  ], LuzmoIQEmbedChatComponent.prototype, "availableDatasets", 2);
1575
+ __decorateClass([
1576
+ property3({ type: Object })
1577
+ ], LuzmoIQEmbedChatComponent.prototype, "dashboardContext", 2);
1578
+ __decorateClass([
1579
+ property3()
1580
+ ], LuzmoIQEmbedChatComponent.prototype, "dashboardId", 2);
1581
+ __decorateClass([
1582
+ property3({ type: Array })
1583
+ ], LuzmoIQEmbedChatComponent.prototype, "contextIds", 2);
1436
1584
  if (!customElements.get(embedChatTag)) {
1437
1585
  customElements.define(embedChatTag, LuzmoIQEmbedChatComponent);
1438
1586
  }
@@ -754,6 +754,30 @@ var getAccessibleDashboards = async (dashboardComponent) => {
754
754
  throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
755
755
  };
756
756
 
757
+ // libs/embed-libs/shared-embed/src/lib/methods/get-dashboard-context.ts
758
+ var getDashboardContext = (dashboardComponent, iframe) => {
759
+ if (iframe?.contentWindow) {
760
+ const requestId = uuidv4();
761
+ iframe.contentWindow.postMessage(
762
+ { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
763
+ "*"
764
+ );
765
+ return new Promise((resolve, reject) => {
766
+ dashboardComponent.promises[requestId] = { resolve, reject };
767
+ setTimeout(() => {
768
+ if (dashboardComponent.promises[requestId]) {
769
+ const errorMessage = "getDashboardContext request timed out.";
770
+ dashboardComponent.promises[requestId].reject(
771
+ new Error(errorMessage)
772
+ );
773
+ delete dashboardComponent.promises[requestId];
774
+ }
775
+ }, 2e3);
776
+ });
777
+ }
778
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
779
+ };
780
+
757
781
  // libs/embed-libs/shared-embed/src/lib/methods/get-data.ts
758
782
  var getData = (dashboardComponent, iframe, itemId) => {
759
783
  if (iframe?.contentWindow) {
@@ -1255,6 +1279,7 @@ var libraryTypeToWebComponentTypeMapping = {
1255
1279
  filters: "filters",
1256
1280
  dashboardId: "dashboard-id",
1257
1281
  itemId: "item-id",
1282
+ aiMessageAssetId: "ai-message-asset-id",
1258
1283
  dashboardContentsVersion: "dashboard-contents-version",
1259
1284
  libVersion: "lib-version"
1260
1285
  };
@@ -2026,7 +2051,7 @@ function getGlobalFederationConstructor() {
2026
2051
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
2027
2052
  if (isDebug) {
2028
2053
  CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
2029
- CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.5.0";
2054
+ CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.5.1";
2030
2055
  }
2031
2056
  }
2032
2057
  function getInfoWithoutType(target, key) {
@@ -4841,7 +4866,7 @@ var ModuleFederation = class {
4841
4866
  beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
4842
4867
  initContainer: new AsyncWaterfallHook("initContainer")
4843
4868
  });
4844
- this.version = "2.5.0";
4869
+ this.version = "2.5.1";
4845
4870
  this.moduleCache = /* @__PURE__ */ new Map();
4846
4871
  this.loaderHook = new PluginSystem({
4847
4872
  getModuleInfo: new SyncHook(),
@@ -5742,7 +5767,7 @@ var o6 = e6(class extends i5 {
5742
5767
  });
5743
5768
 
5744
5769
  // libs/embed-libs/embed/package.json
5745
- var version = "6.13.3";
5770
+ var version = "6.13.6";
5746
5771
 
5747
5772
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
5748
5773
  var LuzmoDashboardService = class {
@@ -5805,6 +5830,14 @@ var _setEventHandler = () => {
5805
5830
  );
5806
5831
  break;
5807
5832
  }
5833
+ case "dashboardContext": {
5834
+ resolvePromise(
5835
+ dashboardComponent,
5836
+ event.data.requestId,
5837
+ event.data.context
5838
+ );
5839
+ break;
5840
+ }
5808
5841
  case "getAccessibleDashboards": {
5809
5842
  resolvePromise(
5810
5843
  dashboardComponent,
@@ -5844,6 +5877,12 @@ var _setEventHandler = () => {
5844
5877
  );
5845
5878
  break;
5846
5879
  }
5880
+ case "contextChanged": {
5881
+ dashboardComponent.dispatchEvent(
5882
+ new CustomEvent("contextChanged", { detail: { data: event.data } })
5883
+ );
5884
+ break;
5885
+ }
5847
5886
  case "customEvent": {
5848
5887
  dashboardComponent.dispatchEvent(
5849
5888
  new CustomEvent("customEvent", { detail: { data: event.data } })
@@ -5885,6 +5924,14 @@ var _setEventHandler = () => {
5885
5924
  _setCalculatedDimensions(dashboardComponent);
5886
5925
  break;
5887
5926
  }
5927
+ case "trackViewport": {
5928
+ if (event.data.enabled) {
5929
+ dashboardComponent._startViewportTracking();
5930
+ } else {
5931
+ dashboardComponent._stopViewportTracking();
5932
+ }
5933
+ break;
5934
+ }
5888
5935
  case "setSelectedData":
5889
5936
  case "setFilters": {
5890
5937
  if (event.data.error) {
@@ -5970,6 +6017,24 @@ var dashboardStyles = i`
5970
6017
  height: 100%;
5971
6018
  }
5972
6019
 
6020
+ /*
6021
+ * Web component mode: the dashboard app renders directly (no iframe). Make its host fill the
6022
+ * sized .dashboard-container so the app's internal height:100% chain resolves to the calculated
6023
+ * dashboard height - exactly like the iframe gets its height. Without this the app collapses to
6024
+ * its intrinsic size and its inner scroll container produces a second scrollbar, and content can
6025
+ * spill outside the container.
6026
+ */
6027
+ #dashboard-wc-container {
6028
+ width: 100%;
6029
+ height: 100%;
6030
+ }
6031
+
6032
+ #dashboard-wc-container dashboard-component {
6033
+ display: block;
6034
+ width: 100%;
6035
+ height: 100%;
6036
+ }
6037
+
5973
6038
  .luzmo-container-loader {
5974
6039
  width: 100%;
5975
6040
  position: relative;
@@ -6094,6 +6159,12 @@ var LuzmoDashboard = class extends i4 {
6094
6159
  this.loaderSize = 32;
6095
6160
  this.borderWidth = 3;
6096
6161
  this.minHeight = 400;
6162
+ this._viewportTrackingActive = false;
6163
+ // Post synchronously on scroll/resize (not via requestAnimationFrame) so the iframe receives the
6164
+ // new slice as early as possible in the frame, minimizing the lag of the pinned analyst panel.
6165
+ this._onViewportChange = () => {
6166
+ this._postViewport();
6167
+ };
6097
6168
  this._containerId = uuidv4();
6098
6169
  this._iframeId = `luzmo-dashboard-${this._containerId}`;
6099
6170
  this.iframeLoaded = false;
@@ -6136,12 +6207,48 @@ var LuzmoDashboard = class extends i4 {
6136
6207
  disconnectedCallback() {
6137
6208
  super.disconnectedCallback();
6138
6209
  this._resizeObserver.disconnect();
6210
+ this._stopViewportTracking();
6139
6211
  for (const promiseKey of Object.keys(this.promises)) {
6140
6212
  this.promises[promiseKey].reject(
6141
6213
  new Error("Dashboard component was removed")
6142
6214
  );
6143
6215
  }
6144
6216
  }
6217
+ // Relay the iframe's visible slice within the host viewport to the dashboard app, so embedded
6218
+ // overlays (e.g. the IQ analyst) can pin themselves to the visible area while the host page
6219
+ // scrolls the full-height iframe. Opt-in: started when the iframe requests it via 'trackViewport'.
6220
+ _startViewportTracking() {
6221
+ if (this.embedMode !== "iframe") {
6222
+ return;
6223
+ }
6224
+ if (!this._viewportTrackingActive) {
6225
+ this._viewportTrackingActive = true;
6226
+ window.addEventListener("scroll", this._onViewportChange, { passive: true, capture: true });
6227
+ window.addEventListener("resize", this._onViewportChange, { passive: true });
6228
+ }
6229
+ this._postViewport();
6230
+ }
6231
+ _stopViewportTracking() {
6232
+ if (!this._viewportTrackingActive) {
6233
+ return;
6234
+ }
6235
+ this._viewportTrackingActive = false;
6236
+ window.removeEventListener("scroll", this._onViewportChange, { capture: true });
6237
+ window.removeEventListener("resize", this._onViewportChange);
6238
+ }
6239
+ _postViewport() {
6240
+ const contentWindow = this.iframe?.contentWindow;
6241
+ if (!contentWindow) {
6242
+ return;
6243
+ }
6244
+ const rect = this.iframe.getBoundingClientRect();
6245
+ const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
6246
+ const visibleTop = Math.max(rect.top, 0);
6247
+ const visibleBottom = Math.min(rect.bottom, viewportHeight);
6248
+ const visibleHeight = Math.max(visibleBottom - visibleTop, 0);
6249
+ const offsetTop = Math.min(Math.max(-rect.top, 0), rect.height);
6250
+ contentWindow.postMessage({ action: "setViewport", offsetTop, visibleHeight }, "*");
6251
+ }
6145
6252
  firstUpdated() {
6146
6253
  this._loaderMsg = getLoader(this)?.loadingMsg;
6147
6254
  this._loaderStyles();
@@ -6170,6 +6277,7 @@ var LuzmoDashboard = class extends i4 {
6170
6277
  el.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
6171
6278
  el.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
6172
6279
  el.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
6280
+ el.addEventListener("contextChanged", (payload) => this.dispatchEvent(new CustomEvent("contextChanged", payload)));
6173
6281
  const container = this.renderRoot.querySelector("#dashboard-wc-container");
6174
6282
  if (container) {
6175
6283
  container.append(el);
@@ -6525,6 +6633,15 @@ var LuzmoDashboard = class extends i4 {
6525
6633
  }
6526
6634
  return Promise.reject();
6527
6635
  }
6636
+ getDashboardContext() {
6637
+ if (this.isWebComponentViewMode() && this.dashboardReference) {
6638
+ return this.dashboardReference.getDashboardContext();
6639
+ }
6640
+ if (!this.isWebComponentViewMode()) {
6641
+ return getDashboardContext(this, this.iframe);
6642
+ }
6643
+ return Promise.reject(new Error("getDashboardContext is not available: dashboard reference is not ready."));
6644
+ }
6528
6645
  setSelectedData(itemId, filters) {
6529
6646
  if (this.isWebComponentViewMode() && this.dashboardReference) {
6530
6647
  return this.dashboardReference.setSelectedData(itemId, filters);
@@ -6801,6 +6918,19 @@ var CONTENTS_VERSION = "0.1.100";
6801
6918
  // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
6802
6919
  var dashboardContentsVersion = CONTENTS_VERSION;
6803
6920
  var vizItemRemote = "VizItemApp";
6921
+ function collectVizItemDatasetIds(slots) {
6922
+ const ids = /* @__PURE__ */ new Set();
6923
+ for (const slot of slots ?? []) {
6924
+ for (const content of slot?.content ?? []) {
6925
+ const column = content;
6926
+ const datasetId = column.datasetId ?? column.set;
6927
+ if (datasetId) {
6928
+ ids.add(datasetId);
6929
+ }
6930
+ }
6931
+ }
6932
+ return [...ids];
6933
+ }
6804
6934
  var LuzmoBaseVizItem = class extends i4 {
6805
6935
  constructor() {
6806
6936
  super(...arguments);
@@ -6846,6 +6976,22 @@ var LuzmoBaseVizItem = class extends i4 {
6846
6976
  getFilters() {
6847
6977
  return this.chartElement.getFilters();
6848
6978
  }
6979
+ /**
6980
+ * Snapshot of this flex chart's live context: its definition (type, slots,
6981
+ * options), current filters and the datasets it reads. Used by context-aware
6982
+ * embeds such as the Luzmo IQ chat component.
6983
+ */
6984
+ getVizItemContext() {
6985
+ const slots = this.slots ?? [];
6986
+ return {
6987
+ id: this.contextId ?? this.getAttribute("context-id") ?? this.id ?? this.itemId ?? "",
6988
+ type: this.type,
6989
+ slots,
6990
+ options: this.options,
6991
+ filters: typeof this.chartElement?.getFilters === "function" ? this.getFilters() : this.filters ?? [],
6992
+ datasetIds: collectVizItemDatasetIds(slots)
6993
+ };
6994
+ }
6849
6995
  export(type = "png") {
6850
6996
  return this.chartElement.export(type);
6851
6997
  }
@@ -6898,7 +7044,12 @@ var LuzmoBaseVizItem = class extends i4 {
6898
7044
  }
6899
7045
  this.dispatchEvent(new CustomEvent("rendered", payload));
6900
7046
  });
6901
- this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
7047
+ this.chartElement.addEventListener("changedFilters", (payload) => {
7048
+ this.dispatchEvent(new CustomEvent("changedFilters", payload));
7049
+ this.dispatchEvent(new CustomEvent("contextChanged", {
7050
+ detail: { data: { type: "contextChanged", context: this.getVizItemContext() } }
7051
+ }));
7052
+ });
6902
7053
  this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
6903
7054
  this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
6904
7055
  this.chartElement.addEventListener("authorizationExpired", (payload) => this.dispatchEvent(new CustomEvent("authorizationExpired", payload)));
@@ -6985,6 +7136,9 @@ __decorateClass([
6985
7136
  __decorateClass([
6986
7137
  n4()
6987
7138
  ], LuzmoBaseVizItem.prototype, "itemId", 2);
7139
+ __decorateClass([
7140
+ n4({ attribute: "ai-message-asset-id" })
7141
+ ], LuzmoBaseVizItem.prototype, "aiMessageAssetId", 2);
6988
7142
  __decorateClass([
6989
7143
  n4({ type: Object })
6990
7144
  ], LuzmoBaseVizItem.prototype, "selectedData", 2);
@@ -7014,7 +7168,10 @@ var inputMap = {
7014
7168
  version: "version",
7015
7169
  libVersion: "lib-version",
7016
7170
  aydHost: "ayd-host",
7017
- availableDatasets: "available-datasets"
7171
+ availableDatasets: "available-datasets",
7172
+ dashboardContext: "dashboard-context",
7173
+ dashboardId: "dashboard-id",
7174
+ contextIds: "context-ids"
7018
7175
  };
7019
7176
  var embedChatTag = "luzmo-iq-embed-chat";
7020
7177
  var chatComponentTag = "luzmo-iq-chat-component";
@@ -7053,6 +7210,10 @@ var LuzmoIQEmbedChatComponent = class extends i4 {
7053
7210
  if (!this.chartElement) {
7054
7211
  this.chartElement = document.createElement(chatComponentTag);
7055
7212
  this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
7213
+ this.chartElement.addEventListener(
7214
+ "connectionStatusChanged",
7215
+ (event) => this.dispatchEvent(new CustomEvent("connectionStatusChanged", { detail: event.detail }))
7216
+ );
7056
7217
  this.updateVizItemProperties();
7057
7218
  this.renderRoot.append(this.chartElement);
7058
7219
  }
@@ -7075,7 +7236,12 @@ var LuzmoIQEmbedChatComponent = class extends i4 {
7075
7236
  if (this.chartElement) {
7076
7237
  for (const [propertyName] of changedProperties.entries()) {
7077
7238
  const mappedAttributeName = inputMap[propertyName] ?? propertyName;
7078
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
7239
+ const propertyValue = this[propertyName];
7240
+ if (propertyValue == null) {
7241
+ this.chartElement.removeAttribute(mappedAttributeName);
7242
+ continue;
7243
+ }
7244
+ const attributeValue = typeof propertyValue === "object" ? JSON.stringify(propertyValue) : propertyValue.toString();
7079
7245
  this.chartElement.setAttribute(mappedAttributeName, attributeValue);
7080
7246
  }
7081
7247
  } else {
@@ -7142,6 +7308,15 @@ __decorateClass([
7142
7308
  __decorateClass([
7143
7309
  n4({ type: Array })
7144
7310
  ], LuzmoIQEmbedChatComponent.prototype, "availableDatasets", 2);
7311
+ __decorateClass([
7312
+ n4({ type: Object })
7313
+ ], LuzmoIQEmbedChatComponent.prototype, "dashboardContext", 2);
7314
+ __decorateClass([
7315
+ n4()
7316
+ ], LuzmoIQEmbedChatComponent.prototype, "dashboardId", 2);
7317
+ __decorateClass([
7318
+ n4({ type: Array })
7319
+ ], LuzmoIQEmbedChatComponent.prototype, "contextIds", 2);
7145
7320
  if (!customElements.get(embedChatTag)) {
7146
7321
  customElements.define(embedChatTag, LuzmoIQEmbedChatComponent);
7147
7322
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@luzmo/embed",
3
- "version": "6.13.3",
3
+ "version": "6.13.6",
4
4
  "dependencies": {
5
5
  "lit": "^3.3.1",
6
- "@luzmo/shared-embed": "5.12.2"
6
+ "@luzmo/shared-embed": "5.12.3"
7
7
  },
8
8
  "keywords": [
9
9
  "es6",
@@ -65,9 +65,14 @@ export declare class LuzmoDashboard extends LitElement implements SharedLib.WebC
65
65
  iframeHeight?: string;
66
66
  iframeWidth?: string;
67
67
  _resizeObserver: ResizeObserver;
68
+ private _viewportTrackingActive;
69
+ private _onViewportChange;
68
70
  constructor();
69
71
  connectedCallback(): void;
70
72
  disconnectedCallback(): void;
73
+ _startViewportTracking(): void;
74
+ _stopViewportTracking(): void;
75
+ private _postViewport;
71
76
  firstUpdated(): void;
72
77
  initComponent(): void;
73
78
  setAllAttributes(): void;
@@ -84,6 +89,7 @@ export declare class LuzmoDashboard extends LitElement implements SharedLib.WebC
84
89
  getDashboards(): Promise<LuzmoDashboard[]>;
85
90
  getData(itemId: string): Promise<SharedLib.ItemData>;
86
91
  getFilters(): Promise<FilterGroup[]>;
92
+ getDashboardContext(): Promise<SharedLib.DashboardContext | undefined>;
87
93
  setSelectedData<K extends CombinedSelectedDataInput>(itemId: string, filters: K): Promise<SharedLib.SetSelectedData>;
88
94
  setAuthorization(key: string, token: string): Promise<void>;
89
95
  refreshData(itemId?: string): Promise<void>;
@@ -1,6 +1,14 @@
1
1
  import type { IQChatOptions } from '@luzmo/dashboard-contents-types';
2
+ import { type DashboardContext } from '@luzmo/shared-embed';
2
3
  import { LitElement, PropertyValues } from 'lit';
3
4
  import type { TemplateResult } from 'lit-html';
5
+ /**
6
+ * Dashboard context accepted by the embedded IQ chat. Alias of the shared embed
7
+ * {@link DashboardContext} so the published contract stays in lockstep with
8
+ * `getDashboardContext()` and the `contextChanged` event (including the typed
9
+ * `runtimeFilters`).
10
+ */
11
+ export type SerializedDashboardContext = DashboardContext;
4
12
  export declare class LuzmoIQEmbedChatComponent extends LitElement {
5
13
  appServer?: string;
6
14
  apiHost?: string;
@@ -14,6 +22,9 @@ export declare class LuzmoIQEmbedChatComponent extends LitElement {
14
22
  remoteEntryServer: string;
15
23
  aydHost: string;
16
24
  availableDatasets?: string[];
25
+ dashboardContext?: SerializedDashboardContext;
26
+ dashboardId?: string;
27
+ contextIds?: string[];
17
28
  chartElement: HTMLElement;
18
29
  static styles: import("lit").CSSResult;
19
30
  protected createRenderRoot(): HTMLElement | DocumentFragment;
@@ -24,7 +24,9 @@ interface LuzmoVizItemComponentInterface extends HTMLElement {
24
24
  authToken?: string;
25
25
  dashboardId?: string;
26
26
  itemId?: string;
27
+ aiMessageAssetId?: string;
27
28
  getFilters: () => FilterGroup[];
29
+ getVizItemContext?: () => SharedLib.VizItemContext;
28
30
  export: (type?: VizItemExportType) => Promise<string | void>;
29
31
  refreshData: () => void;
30
32
  getData: () => SharedLib.ItemData;
@@ -46,6 +48,7 @@ export declare class LuzmoBaseVizItem extends LitElement implements LuzmoVizItem
46
48
  filters?: FilterGroup[];
47
49
  dashboardId?: string;
48
50
  itemId?: string;
51
+ aiMessageAssetId?: string;
49
52
  selectedData: SharedLib.SelectedDataInput;
50
53
  dashboardContentsVersion?: string;
51
54
  libVersion?: string;
@@ -57,6 +60,12 @@ export declare class LuzmoBaseVizItem extends LitElement implements LuzmoVizItem
57
60
  protected createRenderRoot(): HTMLElement | DocumentFragment;
58
61
  canInitializeVizItem(): boolean;
59
62
  getFilters(): FilterGroup[];
63
+ /**
64
+ * Snapshot of this flex chart's live context: its definition (type, slots,
65
+ * options), current filters and the datasets it reads. Used by context-aware
66
+ * embeds such as the Luzmo IQ chat component.
67
+ */
68
+ getVizItemContext(): SharedLib.VizItemContext;
60
69
  export(type?: VizItemExportType): Promise<string | void>;
61
70
  getData(): SharedLib.ItemData;
62
71
  refreshData(): void;