@luzmo/embed 6.2.2 → 6.2.3

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 (37) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/index.cjs +1611 -0
  3. package/index.js +1580 -0
  4. package/luzmo-embed.min.js +3662 -0
  5. package/package.json +1 -1
  6. package/src/index.d.ts +8 -0
  7. package/src/lib/dashboard-component/dashboard-base.d.ts +98 -0
  8. package/src/lib/dashboard-component/dashboard-component.d.ts +8 -0
  9. package/src/lib/dashboard-component/dashboard-styles.d.ts +1 -0
  10. package/src/lib/helper/event-bus-handler.d.ts +1 -0
  11. package/src/lib/helper/json-schema-utils.d.ts +64 -0
  12. package/src/lib/luzmo-iq-components/luzmo-iq-answer.d.ts +22 -0
  13. package/src/lib/luzmo-iq-components/luzmo-iq-chat.d.ts +24 -0
  14. package/src/lib/luzmo-service.d.ts +6 -0
  15. package/src/lib/viz-item/viz-item-component.d.ts +4 -0
  16. package/src/lib/viz-item/viz-item.base.d.ts +71 -0
  17. package/.prettierignore +0 -4
  18. package/esbuild.config.cjs +0 -13
  19. package/eslint.config.cjs +0 -8
  20. package/jest.config.ts +0 -11
  21. package/project.json +0 -39
  22. package/src/index.ts +0 -42
  23. package/src/lib/dashboard-component/dashboard-base.ts +0 -828
  24. package/src/lib/dashboard-component/dashboard-component.spec.ts +0 -27
  25. package/src/lib/dashboard-component/dashboard-component.ts +0 -12
  26. package/src/lib/dashboard-component/dashboard-styles.ts +0 -117
  27. package/src/lib/helper/event-bus-handler.ts +0 -195
  28. package/src/lib/helper/json-schema-utils.ts +0 -129
  29. package/src/lib/luzmo-iq-components/luzmo-iq-answer.ts +0 -106
  30. package/src/lib/luzmo-iq-components/luzmo-iq-chat.ts +0 -106
  31. package/src/lib/luzmo-service.ts +0 -7
  32. package/src/lib/viz-item/viz-item-component.ts +0 -9
  33. package/src/lib/viz-item/viz-item.base.ts +0 -227
  34. package/src/vite-env.d.ts +0 -1
  35. package/tsconfig.json +0 -27
  36. package/tsconfig.lib.json +0 -10
  37. package/tsconfig.spec.json +0 -9
package/index.js ADDED
@@ -0,0 +1,1580 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
12
+
13
+ // libs/embed-libs/embed/src/index.ts
14
+ import { selectedDataUtils } from "@luzmo/shared-embed";
15
+
16
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
17
+ import * as SharedLib2 from "@luzmo/shared-embed";
18
+ import {
19
+ html,
20
+ LitElement
21
+ } from "lit";
22
+ import {
23
+ property,
24
+ query,
25
+ state
26
+ } from "lit/decorators.js";
27
+ import {
28
+ styleMap
29
+ } from "lit/directives/style-map.js";
30
+ import {
31
+ luzmoEmbedContainerClass
32
+ } from "@luzmo/shared-embed";
33
+
34
+ // libs/embed-libs/embed/package.json
35
+ var version = "6.2.3";
36
+
37
+ // libs/embed-libs/embed/src/lib/luzmo-service.ts
38
+ var LuzmoService = class {
39
+ constructor() {
40
+ this._components = [];
41
+ }
42
+ };
43
+ var luzmo_service_default = new LuzmoService();
44
+
45
+ // libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
46
+ import * as SharedLib from "@luzmo/shared-embed";
47
+ var _setEventHandler = () => {
48
+ if (typeof window.__luzmoMessageHandler === "function") {
49
+ return;
50
+ }
51
+ window.__luzmoMessageHandler = (event) => {
52
+ const dashboardComponent = luzmo_service_default._components.find(
53
+ (c) => event.data.name === c._iframeId
54
+ );
55
+ if (!dashboardComponent) {
56
+ return;
57
+ }
58
+ switch (event.data?.type) {
59
+ case "load": {
60
+ dashboardComponent.dispatchEvent(
61
+ new CustomEvent("load", { detail: { data: event.data } })
62
+ );
63
+ if (dashboardComponent._loadTimeoutHandle) {
64
+ clearTimeout(dashboardComponent._loadTimeoutHandle);
65
+ dashboardComponent._loadTimeoutHandle = void 0;
66
+ }
67
+ dashboardComponent.iframeLoaded = true;
68
+ dashboardComponent.dimensions = event.data.dimensions;
69
+ dashboardComponent._calculateDimAfterDashboardLoaded();
70
+ break;
71
+ }
72
+ case "error": {
73
+ dashboardComponent.dashboardError = true;
74
+ if (dashboardComponent._loadTimeoutHandle) {
75
+ clearTimeout(dashboardComponent._loadTimeoutHandle);
76
+ dashboardComponent._loadTimeoutHandle = void 0;
77
+ }
78
+ dashboardComponent.iframeLoaded = true;
79
+ dashboardComponent._displayError();
80
+ console.error("Dashboard error:", event.data.errorMsg ?? event.data.error?.msg);
81
+ break;
82
+ }
83
+ case "data": {
84
+ SharedLib.resolvePromise(
85
+ dashboardComponent,
86
+ event.data.requestId,
87
+ event.data.data
88
+ );
89
+ break;
90
+ }
91
+ case "filters": {
92
+ SharedLib.resolvePromise(
93
+ dashboardComponent,
94
+ event.data.requestId,
95
+ event.data.filters
96
+ );
97
+ break;
98
+ }
99
+ case "getAccessibleDashboards": {
100
+ SharedLib.resolvePromise(
101
+ dashboardComponent,
102
+ event.data.requestId,
103
+ event.data.accessibleDashboards
104
+ );
105
+ break;
106
+ }
107
+ case "dashboardAction": {
108
+ dashboardComponent.dispatchEvent(
109
+ new CustomEvent("dashboardAction", { detail: { data: event.data } })
110
+ );
111
+ break;
112
+ }
113
+ case "export": {
114
+ if (event.data.error) {
115
+ SharedLib.rejectPromise(
116
+ dashboardComponent,
117
+ event.data.requestId,
118
+ event.data
119
+ );
120
+ } else {
121
+ dashboardComponent.dispatchEvent(
122
+ new CustomEvent("exported", { detail: { data: event.data } })
123
+ );
124
+ SharedLib.resolvePromise(
125
+ dashboardComponent,
126
+ event.data.requestId,
127
+ event.data
128
+ );
129
+ }
130
+ break;
131
+ }
132
+ case "changedFilters": {
133
+ dashboardComponent.dispatchEvent(
134
+ new CustomEvent("changedFilters", { detail: { data: event.data } })
135
+ );
136
+ break;
137
+ }
138
+ case "customEvent": {
139
+ dashboardComponent.dispatchEvent(
140
+ new CustomEvent("customEvent", { detail: { data: event.data } })
141
+ );
142
+ break;
143
+ }
144
+ case "chartsRendered":
145
+ case "itemsRendered": {
146
+ event.data.type = "itemsRendered";
147
+ dashboardComponent.dispatchEvent(
148
+ new CustomEvent("itemsRendered", { detail: { data: event.data } })
149
+ );
150
+ break;
151
+ }
152
+ case "setEditMode": {
153
+ if (event.data.error) {
154
+ SharedLib.rejectPromise(
155
+ dashboardComponent,
156
+ event.data.requestId,
157
+ event.data
158
+ );
159
+ } else {
160
+ SharedLib.resolvePromise(
161
+ dashboardComponent,
162
+ event.data.requestId,
163
+ event.data
164
+ );
165
+ dashboardComponent.params.editMode = event.data.editMode;
166
+ dashboardComponent._containerStyle = SharedLib.containerStyles(dashboardComponent);
167
+ if (dashboardComponent.dimensions) {
168
+ SharedLib._setCalculatedDimensions(dashboardComponent);
169
+ }
170
+ }
171
+ break;
172
+ }
173
+ case "calculatedDimensions": {
174
+ dashboardComponent.dimensions = event.data.dimensions;
175
+ SharedLib._setCalculatedDimensions(dashboardComponent);
176
+ break;
177
+ }
178
+ case "setSelectedData":
179
+ case "setFilters": {
180
+ if (event.data.error) {
181
+ SharedLib.rejectPromise(
182
+ dashboardComponent,
183
+ event.data.requestId,
184
+ event.data
185
+ );
186
+ } else {
187
+ SharedLib.resolvePromise(
188
+ dashboardComponent,
189
+ event.data.requestId,
190
+ event.data
191
+ );
192
+ }
193
+ break;
194
+ }
195
+ case "setPreview": {
196
+ if (event.data.error) {
197
+ SharedLib.rejectPromise(
198
+ dashboardComponent,
199
+ event.data.requestId,
200
+ event.data
201
+ );
202
+ } else {
203
+ SharedLib.resolvePromise(
204
+ dashboardComponent,
205
+ event.data.requestId,
206
+ event.data
207
+ );
208
+ }
209
+ break;
210
+ }
211
+ }
212
+ };
213
+ window.addEventListener("message", window.__luzmoMessageHandler, false);
214
+ };
215
+
216
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-styles.ts
217
+ import { css } from "lit";
218
+ var dashboardStyles = css`
219
+ :host {
220
+ display: block;
221
+ height: 100%;
222
+ }
223
+
224
+ @-webkit-keyframes spin {
225
+ 0% {
226
+ -webkit-transform: rotate(0deg);
227
+ transform: rotate(0deg);
228
+ }
229
+ 100% {
230
+ -webkit-transform: rotate(360deg);
231
+ transform: rotate(360deg);
232
+ }
233
+ }
234
+
235
+ @keyframes spin {
236
+ 0% {
237
+ -webkit-transform: rotate(0deg);
238
+ transform: rotate(0deg);
239
+ }
240
+ 100% {
241
+ -webkit-transform: rotate(360deg);
242
+ transform: rotate(360deg);
243
+ }
244
+ }
245
+ :host {
246
+ position: relative;
247
+ width: 100%;
248
+ }
249
+
250
+ .luzmo-embed-dashboard {
251
+ background: transparent;
252
+ padding: 0;
253
+ border: 0;
254
+ }
255
+
256
+ .luzmo-embed-dashboard-ede {
257
+ }
258
+
259
+ .luzmo-embed-container-ede {
260
+ width: 100%;
261
+ height: 100%;
262
+ }
263
+
264
+ .luzmo-container-loader {
265
+ width: 100%;
266
+ position: relative;
267
+ }
268
+
269
+ .luzmo-lc {
270
+ margin: 0 auto;
271
+ }
272
+
273
+ .luzmo-loading-message {
274
+ width: 100%;
275
+ height: 20px;
276
+ text-align: center;
277
+ margin-bottom: 16px;
278
+ font-family: Helvetica, Arial, sans-serif;
279
+ font-size: 14px;
280
+ }
281
+
282
+ .luzmo-loading-circle {
283
+ box-sizing: border-box;
284
+ margin: 16px auto;
285
+ position: relative;
286
+ text-indent: -9999em;
287
+ animation: spin 0.6s infinite linear;
288
+ }
289
+
290
+ .luzmo-loading-circle,
291
+ .luzmo-loading-circle:after {
292
+ border-radius: 50%;
293
+ width: 32px;
294
+ height: 32px;
295
+ }
296
+
297
+ .itemEmbedding:after {
298
+ width: 24px;
299
+ height: 24px;
300
+ }
301
+
302
+ .luzmo-error {
303
+ background: transparent;
304
+ padding: 48px 0;
305
+ margin: 0 auto;
306
+ width: 80%;
307
+ border: 0;
308
+ text-align: center;
309
+ min-height: 192px;
310
+ }
311
+
312
+ .dashboard-error {
313
+ font-size: 30px;
314
+ background: transparent;
315
+ padding: 48px 0;
316
+ margin: 0 auto;
317
+ width: 80%;
318
+ border: 0;
319
+ text-align: center;
320
+ min-height: 192px;
321
+ }
322
+
323
+ .luzmo-loader {
324
+ top: 0;
325
+ left: 0;
326
+ width: 100%;
327
+ min-height: 400px;
328
+ position: absolute;
329
+ transition-duration: 0.3s;
330
+ }
331
+ `;
332
+
333
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
334
+ var LuzmoDashboard = class extends LitElement {
335
+ constructor() {
336
+ super();
337
+ this.language = "auto";
338
+ this.screenMode = "auto";
339
+ this.switchScreenModeOnResize = true;
340
+ this.editMode = "view";
341
+ this.experimental = false;
342
+ this.iframeStyle = {};
343
+ this._containerStyle = {};
344
+ this._loaderStyle = {};
345
+ this._lcStyle = {};
346
+ this._loadingCircleStyle = {};
347
+ this._containerLoaderStyle = {};
348
+ this._loaderMsg = "";
349
+ this._itemEmbedding = false;
350
+ this.browserError = false;
351
+ this.browserErrorMsg = "";
352
+ this.dashboardError = false;
353
+ this.browserNotSupported = [];
354
+ this.libVersion = version + "-wc-luzmo";
355
+ this.isLibraryLoaded = false;
356
+ this.currentAuthKey = null;
357
+ this.currentAuthToken = null;
358
+ this.isInitCalled = false;
359
+ this.attributesMap = {
360
+ dashboardId: "dashboard-id",
361
+ dashboardSlug: "dashboard-slug",
362
+ itemId: "item-id",
363
+ language: "language",
364
+ qeVersion: "qe-version",
365
+ screenMode: "screen-mode",
366
+ switchScreenModeOnResize: "switch-screen-mode-on-resize",
367
+ authKey: "auth-key",
368
+ authToken: "auth-token",
369
+ editMode: "edit-mode",
370
+ mainColor: "main-color",
371
+ accentColor: "accent-color",
372
+ loaderBackground: "loader-background",
373
+ loaderFontColor: "loader-font-color",
374
+ loaderSpinnerColor: "loader-spinner-color",
375
+ loaderSpinnerBackground: "loader-spinner-background",
376
+ appServer: "app-server",
377
+ apiHost: "api-host",
378
+ itemDimensions: "item-dimensions",
379
+ timezoneId: "timezone-id"
380
+ };
381
+ this.loaderSize = 32;
382
+ this.borderWidth = 3;
383
+ this.minHeight = 400;
384
+ this._containerId = SharedLib2.uuidv4();
385
+ this._iframeId = `luzmo-dashboard-${this._containerId}`;
386
+ this.iframeLoaded = false;
387
+ this.promises = {};
388
+ this.params = this._setOptions();
389
+ this._onResize = () => {
390
+ if (this.shadowRoot?.querySelector(".dashboard-container")) {
391
+ this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
392
+ if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
393
+ for (const d of SharedLib2.EXTENTS) {
394
+ if (d.width[0] <= window.innerWidth && window.innerWidth <= d.width[1]) {
395
+ this.currentScreenMode = d.mode;
396
+ }
397
+ }
398
+ }
399
+ if (this.iframeLoaded) {
400
+ this._calculateDimAfterDashboardLoaded();
401
+ } else {
402
+ if (this.dimensions) {
403
+ this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
404
+ SharedLib2._setCalculatedDimensions(this);
405
+ }
406
+ }
407
+ }
408
+ };
409
+ this._resizeObserver = new ResizeObserver((entries) => {
410
+ window.requestAnimationFrame(() => {
411
+ if (!Array.isArray(entries) || entries.length === 0) {
412
+ return;
413
+ }
414
+ this._onResize();
415
+ });
416
+ });
417
+ }
418
+ // Set resize event listener
419
+ connectedCallback() {
420
+ super.connectedCallback();
421
+ }
422
+ // Set resize event listener
423
+ disconnectedCallback() {
424
+ super.disconnectedCallback();
425
+ this._resizeObserver.disconnect();
426
+ for (const promiseKey of Object.keys(this.promises)) {
427
+ this.promises[promiseKey].reject(
428
+ new Error("Dashboard component was removed")
429
+ );
430
+ }
431
+ }
432
+ firstUpdated() {
433
+ this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
434
+ this._loaderStyles();
435
+ luzmo_service_default._components.push(this);
436
+ if (this.luzmoEmbedContainer) {
437
+ this._resizeObserver.observe(this.luzmoEmbedContainer);
438
+ }
439
+ }
440
+ initComponent() {
441
+ this.params = this._setOptions();
442
+ if (this.getIsViewMode()) {
443
+ SharedLib2.loadLibrary(this.params.appServer).then(async () => {
444
+ this.isLibraryLoaded = true;
445
+ await this.updateComplete;
446
+ const oldReference = this.renderRoot.querySelector("dashboard-component");
447
+ this.dashboardReference = oldReference.cloneNode(true);
448
+ oldReference.replaceWith(this.dashboardReference);
449
+ this.dashboardReference.addEventListener("load", (payload) => {
450
+ this.containerWidth = this.dashboardReference.offsetWidth;
451
+ this.dimensions = payload.detail.dimensions;
452
+ SharedLib2._setCalculatedDimensions(this);
453
+ window.dispatchEvent(new Event("resize"));
454
+ this.dispatchEvent(new CustomEvent("load", payload));
455
+ });
456
+ this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
457
+ this.dashboardReference.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
458
+ this.dashboardReference.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
459
+ this.dashboardReference.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
460
+ this.dashboardReference.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
461
+ this.setAllAttributes();
462
+ });
463
+ } else {
464
+ this.containerWidth = this.container?.clientWidth;
465
+ SharedLib2._extendAndValidate(this);
466
+ SharedLib2._browserCheck(this);
467
+ this._setupLoader();
468
+ if (!this.params.error) {
469
+ this._loaderStyles();
470
+ _setEventHandler();
471
+ this._iframeUrl = SharedLib2.createIframeUrl(this);
472
+ this.iframe?.setAttribute("src", this._iframeUrl);
473
+ this.iframeStyle = SharedLib2.calculateIframeStyles(this);
474
+ }
475
+ }
476
+ }
477
+ setAllAttributes() {
478
+ if (this.dashboardReference) {
479
+ for (const key in this.attributesMap) {
480
+ if (!["authKey", "authToken", "apiHost", "itemDimensions"].includes(key) && this.params[key]) {
481
+ this.dashboardReference.setAttribute(this.attributesMap[key], this.params[key]);
482
+ }
483
+ }
484
+ if (this.params.itemDimensions) {
485
+ this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
486
+ }
487
+ if (this.params.apiHost) {
488
+ this.dashboardReference.setAttribute("api-host", SharedLib2.removeTrailingSlash(this.params.apiHost));
489
+ }
490
+ if (this.params.key) {
491
+ this.dashboardReference.setAttribute("auth-key", this.params.key);
492
+ }
493
+ if (this.params.token) {
494
+ this.dashboardReference.setAttribute("auth-token", this.params.token);
495
+ }
496
+ }
497
+ }
498
+ // Reload dashboard when triggerproperty changes
499
+ updated(changedProperties) {
500
+ const triggerProperties = /* @__PURE__ */ new Set([
501
+ "dashboardId",
502
+ "dashboardSlug",
503
+ "itemId",
504
+ "language",
505
+ "qeVersion",
506
+ "editMode",
507
+ "screenMode",
508
+ "switchScreenModeOnResize",
509
+ "authToken",
510
+ "authKey",
511
+ "appServer",
512
+ "apiHost",
513
+ "timezoneId",
514
+ "itemDimensions"
515
+ ]);
516
+ const conditionsToCheck = ["dashboardId", "dashboardSlug", "itemId"];
517
+ let callInitComponent = false;
518
+ for (const condition of conditionsToCheck) {
519
+ callInitComponent = callInitComponent || changedProperties.get(condition) === void 0 && this[condition] !== void 0;
520
+ }
521
+ if (callInitComponent && !this.isInitCalled) {
522
+ this.initComponent();
523
+ this.isInitCalled = true;
524
+ return;
525
+ }
526
+ if (this.getIsViewMode()) {
527
+ if (this.dashboardReference) {
528
+ for (const [propertyName] of changedProperties.entries()) {
529
+ if (propertyName === "appSever") {
530
+ SharedLib2.loadLibrary(changedProperties[propertyName]).then(async () => {
531
+ this.isLibraryLoaded = true;
532
+ await this.updateComplete;
533
+ this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
534
+ this.setAllAttributes();
535
+ });
536
+ } else if (this.attributesMap[propertyName]) {
537
+ const mappedAttributeName = this.attributesMap[propertyName] ?? propertyName;
538
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() || this[propertyName];
539
+ this.dashboardReference.setAttribute(mappedAttributeName, attributeValue);
540
+ }
541
+ }
542
+ }
543
+ } else {
544
+ for (const [propertyName] of changedProperties.entries()) {
545
+ if (triggerProperties.has(propertyName) && propertyName !== "editMode") {
546
+ this.iframeLoaded = false;
547
+ if (this._loadTimeoutHandle) {
548
+ clearTimeout(this._loadTimeoutHandle);
549
+ }
550
+ this._loadTimeoutHandle = setTimeout(() => {
551
+ console.warn(
552
+ "Failed to load dashboard, appServer is likely down or unreachable."
553
+ );
554
+ }, 15 * 1e3);
555
+ this.params = this._setOptions();
556
+ SharedLib2._extendAndValidate(this);
557
+ this._setupLoader();
558
+ this._loaderStyles();
559
+ this._iframeUrl = SharedLib2.createIframeUrl(this);
560
+ if (this.iframe) {
561
+ this._updateIframeUrl();
562
+ }
563
+ this.iframeStyle = SharedLib2.calculateIframeStyles(this);
564
+ } else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
565
+ if (this.iframeLoaded) {
566
+ this.setEditMode(this.editMode);
567
+ }
568
+ this.params = this._setOptions();
569
+ }
570
+ }
571
+ }
572
+ }
573
+ // Set params
574
+ _setOptions() {
575
+ const defaultParameters = {
576
+ dashboardId: this.dashboardId,
577
+ dashboardSlug: this.dashboardSlug
578
+ };
579
+ if (this.itemId) {
580
+ defaultParameters.itemId = this.itemId;
581
+ this._itemEmbedding = true;
582
+ } else {
583
+ this._itemEmbedding = false;
584
+ }
585
+ if (this.language) {
586
+ defaultParameters.language = this.language;
587
+ }
588
+ if (this.qeVersion) {
589
+ defaultParameters.qeVersion = this.qeVersion;
590
+ }
591
+ if (this.screenMode) {
592
+ defaultParameters.screenMode = this.screenMode;
593
+ }
594
+ defaultParameters.switchScreenModeOnResize = this.switchScreenModeOnResize;
595
+ if (this.authToken) {
596
+ defaultParameters.token = this.authToken;
597
+ }
598
+ if (this.authKey) {
599
+ defaultParameters.key = this.authKey;
600
+ }
601
+ if (this.editMode) {
602
+ defaultParameters.editMode = this.editMode;
603
+ }
604
+ if (this.mainColor) {
605
+ defaultParameters.mainColor = this.mainColor;
606
+ }
607
+ if (this.accentColor) {
608
+ defaultParameters.accentColor = this.accentColor;
609
+ }
610
+ if (this.loaderBackground) {
611
+ defaultParameters.loaderBackground = this.loaderBackground;
612
+ }
613
+ if (this.loaderFontColor) {
614
+ defaultParameters.loaderFontColor = this.loaderFontColor;
615
+ }
616
+ if (this.loaderSpinnerColor) {
617
+ defaultParameters.loaderSpinnerColor = this.loaderSpinnerColor;
618
+ }
619
+ if (this.loaderSpinnerBackground) {
620
+ defaultParameters.loaderSpinnerBackground = this.loaderSpinnerBackground;
621
+ }
622
+ if (this.timezoneId) {
623
+ defaultParameters.timezoneId = this.timezoneId;
624
+ }
625
+ if (this.itemDimensions) {
626
+ defaultParameters.itemDimensions = this.itemDimensions;
627
+ }
628
+ if (this.appServer) {
629
+ this.appServer = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.appServer) : SharedLib2.addTrailingSlash(this.appServer);
630
+ defaultParameters.appServer = this.appServer;
631
+ } else {
632
+ this.appServer = SharedLib2.addTrailingSlash(
633
+ SharedLib2.DEFAULT_PARAMETERS.appServer
634
+ );
635
+ defaultParameters.appServer = this.appServer;
636
+ }
637
+ if (this.apiHost) {
638
+ this.apiHost = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.apiHost) : SharedLib2.addTrailingSlash(this.apiHost);
639
+ defaultParameters.apiHost = this.apiHost;
640
+ } else {
641
+ this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
642
+ defaultParameters.apiHost = this.apiHost;
643
+ }
644
+ this.currentAuthKey = this.authKey;
645
+ this.currentAuthToken = this.authToken;
646
+ return defaultParameters;
647
+ }
648
+ _updateIframeUrl() {
649
+ SharedLib2.updateIframeUrl(this.iframe, this._iframeUrl);
650
+ }
651
+ // Setup loader / browser error
652
+ _setupLoader() {
653
+ const data = SharedLib2.getLoader(this);
654
+ this._loaderMsg = data.loadingMsg;
655
+ if (data.errorMsg) {
656
+ this.browserError = true;
657
+ this.browserErrorMsg = data.errorMsg;
658
+ this._displayError();
659
+ }
660
+ }
661
+ _displayError() {
662
+ if (this.dashboardError) {
663
+ this._loaderStyles();
664
+ this.iframeStyle.opacity = 1;
665
+ }
666
+ if (this.browserError) {
667
+ this._containerStyle.display = "none";
668
+ }
669
+ }
670
+ _calculateDimAfterDashboardLoaded() {
671
+ this.dashboardError = false;
672
+ this._loaderStyles();
673
+ SharedLib2._setCalculatedDimensions(this);
674
+ }
675
+ // Set loader styles
676
+ _loaderStyles() {
677
+ this._containerStyle = SharedLib2.containerStyles(this);
678
+ this._loaderStyle = SharedLib2.loaderStyles(this);
679
+ this._loadingCircleStyle = SharedLib2.plStyles(this);
680
+ this._containerLoaderStyle = SharedLib2.containerLoaderStyles(this);
681
+ this._lcStyle = SharedLib2.lcStyles(this);
682
+ }
683
+ static get styles() {
684
+ return [dashboardStyles];
685
+ }
686
+ render() {
687
+ let toBeRenderedHTML;
688
+ const loader = html`
689
+ <div
690
+ class="luzmo-container-loader"
691
+ id="luzmo-container-loader-${this._containerId}"
692
+ style=${styleMap(
693
+ this._containerLoaderStyle
694
+ )}
695
+ >
696
+ <div
697
+ class="luzmo-loader"
698
+ id="luzmo-loader-${this._containerId}"
699
+ style=${styleMap(this._loaderStyle)}
700
+ >
701
+ <div
702
+ class="luzmo-lc"
703
+ style=${styleMap(this._lcStyle)}
704
+ >
705
+ <div
706
+ class="luzmo-loading-circle"
707
+ style=${styleMap(
708
+ this._loadingCircleStyle
709
+ )}
710
+ ></div>
711
+ ${this._itemEmbedding ? "" : html`
712
+ <div
713
+ class="luzmo-loading-message"
714
+ style=${styleMap({ color: this.loaderFontColor })}
715
+ >
716
+ ${this._loaderMsg}
717
+ </div>
718
+ `}
719
+ </div>
720
+ </div>
721
+ </div>
722
+ `;
723
+ if (this.getIsViewMode()) {
724
+ toBeRenderedHTML = this.isLibraryLoaded ? html`
725
+ ${this.dashboardId || this.dashboardSlug ? html`
726
+ <dashboard-component dashboard-id="${this.params.dashboardId}" app-server="${this.params.appServer}"
727
+ api-host="${this.params.apiHost}"></dashboard-component>` : html`
728
+ <div id="luzmo-error-${this._containerId}">
729
+ <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
730
+ </div>
731
+ `}
732
+ ` : html`${loader}`;
733
+ } else {
734
+ toBeRenderedHTML = html`
735
+ ${this.dashboardId || this.dashboardSlug ? html`
736
+ ${loader}
737
+ <iframe
738
+ class="luzmo-embed-dashboard ${!this.getIsViewMode() ? `luzmo-embed-dashboard-ede` : ""}"
739
+ id="${this._iframeId}"
740
+ name="${this._iframeId}"
741
+ style=${styleMap(this.iframeStyle)}
742
+ src="${this._iframeUrl}"
743
+ frameborder="0"
744
+ ></iframe>
745
+ ` : html`<!-- the dashboard will inititialize when you provide a dashboardSlug or a dashboardId -->`}
746
+ ${this.browserError ? html`
747
+ <div id="luzmo-error-${this._containerId}">
748
+ <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
749
+ </div>
750
+ ` : ""}
751
+ `;
752
+ }
753
+ return html`
754
+ <div class="${luzmoEmbedContainerClass} ${!this.getIsViewMode() ? `${luzmoEmbedContainerClass}-ede` : ""}">
755
+ <div
756
+ class="dashboard-container"
757
+ style=${styleMap(Object.assign({}, this._containerStyle, {
758
+ width: this.iframeStyle.width ?? "100%",
759
+ height: this.iframeStyle.height ?? "100%"
760
+ }))}
761
+ >
762
+ ${toBeRenderedHTML}
763
+ </div>
764
+ </div>
765
+
766
+ `;
767
+ }
768
+ getDashboards() {
769
+ return new Promise(
770
+ (resolve) => resolve(luzmo_service_default._components)
771
+ );
772
+ }
773
+ // Public methods
774
+ getData(itemId) {
775
+ if (this.getIsViewMode() && this.dashboardReference) {
776
+ return this.dashboardReference.getData(itemId);
777
+ }
778
+ if (!this.getIsViewMode()) {
779
+ return SharedLib2.getData(this, this.iframe, itemId);
780
+ }
781
+ return Promise.reject();
782
+ }
783
+ getFilters() {
784
+ if (this.getIsViewMode() && this.dashboardReference) {
785
+ return this.dashboardReference.getFilters();
786
+ }
787
+ if (!this.getIsViewMode()) {
788
+ return SharedLib2.getFilters(this, this.iframe);
789
+ }
790
+ return Promise.reject();
791
+ }
792
+ setSelectedData(itemId, filters) {
793
+ if (this.getIsViewMode() && this.dashboardReference) {
794
+ return this.dashboardReference.setSelectedData(itemId, filters);
795
+ }
796
+ if (!this.getIsViewMode()) {
797
+ return SharedLib2.setSelectedData(this, this.iframe, itemId, filters);
798
+ }
799
+ return Promise.reject();
800
+ }
801
+ setAuthorization(key, token) {
802
+ this.currentAuthKey = key;
803
+ this.currentAuthToken = token;
804
+ if (this.getIsViewMode() && this.dashboardReference) {
805
+ return this.dashboardReference.setAuthorization(key, token);
806
+ }
807
+ if (!this.getIsViewMode()) {
808
+ return SharedLib2.setAuthorization(this, this.iframe, key, token);
809
+ }
810
+ return Promise.reject();
811
+ }
812
+ refreshData(itemId) {
813
+ if (this.getIsViewMode() && this.dashboardReference) {
814
+ return this.dashboardReference.refreshData(itemId);
815
+ }
816
+ if (!this.getIsViewMode()) {
817
+ return itemId ? SharedLib2.refreshData(this, this.iframe, itemId) : SharedLib2.refreshData(this, this.iframe);
818
+ }
819
+ return Promise.reject();
820
+ }
821
+ reloadDashboard() {
822
+ if (this.getIsViewMode() && this.dashboardReference) {
823
+ return this.dashboardReference.reloadDashboard();
824
+ }
825
+ if (!this.getIsViewMode()) {
826
+ return SharedLib2.reloadDashboard(this, this.iframe);
827
+ }
828
+ return Promise.reject();
829
+ }
830
+ exportDashboard(format) {
831
+ if (this.getIsViewMode() && this.dashboardReference) {
832
+ return this.dashboardReference.exportDashboard(format);
833
+ }
834
+ if (!this.getIsViewMode()) {
835
+ return format ? SharedLib2.exportDashboard(this, this.iframe, format) : SharedLib2.exportDashboard(this, this.iframe);
836
+ }
837
+ return Promise.reject();
838
+ }
839
+ getAccessibleDashboards() {
840
+ return SharedLib2.getAccessibleDashboards(this);
841
+ }
842
+ addFilters(itemId, filters) {
843
+ return this.dashboardReference.addFilters(itemId, filters);
844
+ }
845
+ setEditMode(editMode) {
846
+ if (this.dashboardReference && editMode === "view") {
847
+ this.editMode = "view";
848
+ this.params.editMode = "view";
849
+ this.initComponent();
850
+ return Promise.resolve({
851
+ type: "setEditMode",
852
+ editMode
853
+ });
854
+ }
855
+ if (this.dashboardReference && ["editFull", "editLimited"].includes(editMode)) {
856
+ this.editMode = editMode;
857
+ this.params.editMode = editMode;
858
+ this.initComponent();
859
+ return Promise.resolve({
860
+ type: "setEditMode",
861
+ editMode
862
+ });
863
+ }
864
+ if (this.getIsViewMode() && this.dashboardReference) {
865
+ return this.dashboardReference.setEditMode(editMode);
866
+ }
867
+ if (!this.getIsViewMode()) {
868
+ return SharedLib2.setEditMode(this, this.iframe, editMode);
869
+ }
870
+ return Promise.reject();
871
+ }
872
+ setPreview(preview) {
873
+ if (this.getIsViewMode() && this.dashboardReference) {
874
+ return this.dashboardReference.setPreview(preview);
875
+ }
876
+ return SharedLib2.setPreview(this, this.iframe, preview);
877
+ }
878
+ getIsViewMode() {
879
+ return this.experimental && this.params.editMode === "view" || this.params.editMode === void 0;
880
+ }
881
+ };
882
+ __decorateClass([
883
+ query(".dashboard-container")
884
+ ], LuzmoDashboard.prototype, "container", 2);
885
+ __decorateClass([
886
+ query(`.${luzmoEmbedContainerClass}`)
887
+ ], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2);
888
+ __decorateClass([
889
+ query("iframe")
890
+ ], LuzmoDashboard.prototype, "iframe", 2);
891
+ __decorateClass([
892
+ property()
893
+ ], LuzmoDashboard.prototype, "dashboardId", 2);
894
+ __decorateClass([
895
+ property()
896
+ ], LuzmoDashboard.prototype, "dashboardSlug", 2);
897
+ __decorateClass([
898
+ property()
899
+ ], LuzmoDashboard.prototype, "itemId", 2);
900
+ __decorateClass([
901
+ property()
902
+ ], LuzmoDashboard.prototype, "language", 2);
903
+ __decorateClass([
904
+ property()
905
+ ], LuzmoDashboard.prototype, "qeVersion", 2);
906
+ __decorateClass([
907
+ property()
908
+ ], LuzmoDashboard.prototype, "screenMode", 2);
909
+ __decorateClass([
910
+ property({
911
+ converter: {
912
+ fromAttribute: (value) => value === "true",
913
+ toAttribute: String
914
+ }
915
+ })
916
+ ], LuzmoDashboard.prototype, "switchScreenModeOnResize", 2);
917
+ __decorateClass([
918
+ property()
919
+ ], LuzmoDashboard.prototype, "editMode", 2);
920
+ __decorateClass([
921
+ property()
922
+ ], LuzmoDashboard.prototype, "mainColor", 2);
923
+ __decorateClass([
924
+ property()
925
+ ], LuzmoDashboard.prototype, "accentColor", 2);
926
+ __decorateClass([
927
+ property()
928
+ ], LuzmoDashboard.prototype, "authToken", 2);
929
+ __decorateClass([
930
+ property()
931
+ ], LuzmoDashboard.prototype, "authKey", 2);
932
+ __decorateClass([
933
+ property()
934
+ ], LuzmoDashboard.prototype, "loaderBackground", 2);
935
+ __decorateClass([
936
+ property()
937
+ ], LuzmoDashboard.prototype, "loaderFontColor", 2);
938
+ __decorateClass([
939
+ property()
940
+ ], LuzmoDashboard.prototype, "loaderSpinnerColor", 2);
941
+ __decorateClass([
942
+ property()
943
+ ], LuzmoDashboard.prototype, "loaderSpinnerBackground", 2);
944
+ __decorateClass([
945
+ property()
946
+ ], LuzmoDashboard.prototype, "appServer", 2);
947
+ __decorateClass([
948
+ property()
949
+ ], LuzmoDashboard.prototype, "timezoneId", 2);
950
+ __decorateClass([
951
+ property()
952
+ ], LuzmoDashboard.prototype, "apiHost", 2);
953
+ __decorateClass([
954
+ property({ type: Object })
955
+ ], LuzmoDashboard.prototype, "itemDimensions", 2);
956
+ __decorateClass([
957
+ property({
958
+ converter: {
959
+ fromAttribute: (value) => value === "true",
960
+ toAttribute: String
961
+ }
962
+ })
963
+ ], LuzmoDashboard.prototype, "experimental", 2);
964
+ __decorateClass([
965
+ property({ attribute: false })
966
+ ], LuzmoDashboard.prototype, "_containerId", 2);
967
+ __decorateClass([
968
+ property({ attribute: false })
969
+ ], LuzmoDashboard.prototype, "_iframeId", 2);
970
+ __decorateClass([
971
+ property({ attribute: false })
972
+ ], LuzmoDashboard.prototype, "params", 2);
973
+ __decorateClass([
974
+ property({ attribute: false })
975
+ ], LuzmoDashboard.prototype, "_iframeUrl", 2);
976
+ __decorateClass([
977
+ property({ attribute: false })
978
+ ], LuzmoDashboard.prototype, "iframeLoaded", 2);
979
+ __decorateClass([
980
+ property({ attribute: false })
981
+ ], LuzmoDashboard.prototype, "promises", 2);
982
+ __decorateClass([
983
+ property({ attribute: false })
984
+ ], LuzmoDashboard.prototype, "iframeStyle", 2);
985
+ __decorateClass([
986
+ property({ attribute: false })
987
+ ], LuzmoDashboard.prototype, "_containerStyle", 2);
988
+ __decorateClass([
989
+ property({ attribute: false })
990
+ ], LuzmoDashboard.prototype, "_loaderStyle", 2);
991
+ __decorateClass([
992
+ property({ attribute: false })
993
+ ], LuzmoDashboard.prototype, "_lcStyle", 2);
994
+ __decorateClass([
995
+ property({ attribute: false })
996
+ ], LuzmoDashboard.prototype, "_loadingCircleStyle", 2);
997
+ __decorateClass([
998
+ property({ attribute: false })
999
+ ], LuzmoDashboard.prototype, "_containerLoaderStyle", 2);
1000
+ __decorateClass([
1001
+ property({ attribute: false })
1002
+ ], LuzmoDashboard.prototype, "_loaderMsg", 2);
1003
+ __decorateClass([
1004
+ property({ attribute: false })
1005
+ ], LuzmoDashboard.prototype, "containerWidth", 2);
1006
+ __decorateClass([
1007
+ property({ attribute: false })
1008
+ ], LuzmoDashboard.prototype, "dimensions", 2);
1009
+ __decorateClass([
1010
+ property({ attribute: false })
1011
+ ], LuzmoDashboard.prototype, "currentScreenMode", 2);
1012
+ __decorateClass([
1013
+ property({ attribute: false })
1014
+ ], LuzmoDashboard.prototype, "_itemEmbedding", 2);
1015
+ __decorateClass([
1016
+ property({ attribute: false })
1017
+ ], LuzmoDashboard.prototype, "browserError", 2);
1018
+ __decorateClass([
1019
+ property({ attribute: false })
1020
+ ], LuzmoDashboard.prototype, "browserErrorMsg", 2);
1021
+ __decorateClass([
1022
+ property({ attribute: false })
1023
+ ], LuzmoDashboard.prototype, "dashboardError", 2);
1024
+ __decorateClass([
1025
+ property({ attribute: false })
1026
+ ], LuzmoDashboard.prototype, "browserNotSupported", 2);
1027
+ __decorateClass([
1028
+ property()
1029
+ ], LuzmoDashboard.prototype, "libVersion", 2);
1030
+ __decorateClass([
1031
+ state()
1032
+ ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
1033
+ __decorateClass([
1034
+ state()
1035
+ ], LuzmoDashboard.prototype, "dashboardReference", 2);
1036
+ __decorateClass([
1037
+ state()
1038
+ ], LuzmoDashboard.prototype, "currentAuthKey", 2);
1039
+ __decorateClass([
1040
+ state()
1041
+ ], LuzmoDashboard.prototype, "currentAuthToken", 2);
1042
+ __decorateClass([
1043
+ state()
1044
+ ], LuzmoDashboard.prototype, "isInitCalled", 2);
1045
+
1046
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
1047
+ var LuzmoEmbedDashboard = class extends LuzmoDashboard {
1048
+ };
1049
+ if (!customElements.get("luzmo-embed-dashboard")) {
1050
+ customElements.define("luzmo-embed-dashboard", LuzmoEmbedDashboard);
1051
+ }
1052
+
1053
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
1054
+ import { property as property2 } from "lit/decorators.js";
1055
+ import { LitElement as LitElement2, html as html2, css as css2 } from "lit";
1056
+ import * as SharedLib3 from "@luzmo/shared-embed";
1057
+ var dashboardContentsVersion = "0.1.91";
1058
+ var LuzmoBaseVizItem = class extends LitElement2 {
1059
+ constructor() {
1060
+ super(...arguments);
1061
+ this.appServer = "https://app.luzmo.com";
1062
+ this.apiHost = "https://api.luzmo.com";
1063
+ this.slots = [];
1064
+ this.version = version + "-wc-luzmo";
1065
+ this.dashboardContentsVersion = dashboardContentsVersion;
1066
+ this.libVersion = version + "-wc-luzmo";
1067
+ this.postInitCallQueue = [];
1068
+ }
1069
+ static {
1070
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1071
+ this.styles = css2`
1072
+ :host {
1073
+ display: block;
1074
+ width: 100%;
1075
+ height: 100%;
1076
+ }
1077
+
1078
+ luzmo-embed-viz-item {
1079
+ width: 100%;
1080
+ height: 1000%;
1081
+ display: block;
1082
+ }
1083
+ `;
1084
+ }
1085
+ createRenderRoot() {
1086
+ if (!this.style.display) {
1087
+ this.style.display = "block";
1088
+ }
1089
+ if (!this.style.height) {
1090
+ this.style.height = "100%";
1091
+ }
1092
+ if (!this.style.width) {
1093
+ this.style.width = "100%";
1094
+ }
1095
+ return this;
1096
+ }
1097
+ canInitializeVizItem() {
1098
+ return !!(this.type || this.dashboardId && this.itemId);
1099
+ }
1100
+ getFilters() {
1101
+ return this.chartElement.getFilters();
1102
+ }
1103
+ export() {
1104
+ return this.chartElement.export();
1105
+ }
1106
+ getData() {
1107
+ return this.chartElement.getData();
1108
+ }
1109
+ refreshData() {
1110
+ return this.chartElement.refreshData();
1111
+ }
1112
+ setSelectedData(selectedDataInput) {
1113
+ return this.chartElement.setSelectedData(void 0, selectedDataInput);
1114
+ }
1115
+ setAuthorization(key, token) {
1116
+ return this.chartElement.setAuthorization(key, token);
1117
+ }
1118
+ attributeChangedCallback(name, _old, value) {
1119
+ super.attributeChangedCallback(name, _old, value);
1120
+ if (name === "selecteddata") {
1121
+ if (this.chartElement) {
1122
+ this.setSelectedData(JSON.parse(value ?? "{}"));
1123
+ } else {
1124
+ this.postInitCallQueue.push([this.setSelectedData, [JSON.parse(value ?? "{}")]]);
1125
+ }
1126
+ }
1127
+ }
1128
+ async firstUpdated(_changedProperties) {
1129
+ super.firstUpdated(_changedProperties);
1130
+ if (this.canInitializeVizItem()) {
1131
+ await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
1132
+ this.createAndAppendElement();
1133
+ }
1134
+ }
1135
+ createAndAppendElement() {
1136
+ if (!this.chartElement) {
1137
+ this.chartElement = document.createElement("chart-component");
1138
+ this.chartElement.setAttribute("embedding-mode", "chart");
1139
+ this.chartElement.style.height = "100%";
1140
+ this.chartElement.style.width = "100%";
1141
+ this.chartElement.style.display = "block";
1142
+ this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
1143
+ this.chartElement.addEventListener("rendered", (payload) => {
1144
+ if (this.postInitCallQueue?.length > 0) {
1145
+ for (const functionToCall of this.postInitCallQueue) {
1146
+ functionToCall[0].bind(this)(...functionToCall[1]);
1147
+ }
1148
+ } else {
1149
+ if (this.selectedData) {
1150
+ this.setSelectedData(this.selectedData);
1151
+ }
1152
+ }
1153
+ this.dispatchEvent(new CustomEvent("rendered", payload));
1154
+ });
1155
+ this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
1156
+ this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
1157
+ this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
1158
+ this.updateVizItemProperties();
1159
+ this.renderRoot.append(this.chartElement);
1160
+ }
1161
+ }
1162
+ updateVizItemProperties() {
1163
+ if (this.chartElement) {
1164
+ for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
1165
+ const value = this[key];
1166
+ if (value) {
1167
+ const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib3.removeTrailingSlash(value) : value;
1168
+ this.chartElement.setAttribute(
1169
+ SharedLib3.libraryTypeToWebComponentTypeMapping[key],
1170
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
1171
+ );
1172
+ }
1173
+ }
1174
+ }
1175
+ }
1176
+ async updated(changedProperties) {
1177
+ if (this.chartElement) {
1178
+ for (const [propertyName] of changedProperties.entries()) {
1179
+ const mappedAttributeName = SharedLib3.libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
1180
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1181
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1182
+ }
1183
+ } else {
1184
+ if (this.canInitializeVizItem()) {
1185
+ await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
1186
+ this.createAndAppendElement();
1187
+ }
1188
+ }
1189
+ }
1190
+ render() {
1191
+ return html2` `;
1192
+ }
1193
+ };
1194
+ __decorateClass([
1195
+ property2()
1196
+ ], LuzmoBaseVizItem.prototype, "appServer", 2);
1197
+ __decorateClass([
1198
+ property2()
1199
+ ], LuzmoBaseVizItem.prototype, "apiHost", 2);
1200
+ __decorateClass([
1201
+ property2({ type: Array })
1202
+ ], LuzmoBaseVizItem.prototype, "slots", 2);
1203
+ __decorateClass([
1204
+ property2({ type: Object })
1205
+ ], LuzmoBaseVizItem.prototype, "options", 2);
1206
+ __decorateClass([
1207
+ property2()
1208
+ ], LuzmoBaseVizItem.prototype, "type", 2);
1209
+ __decorateClass([
1210
+ property2()
1211
+ ], LuzmoBaseVizItem.prototype, "authKey", 2);
1212
+ __decorateClass([
1213
+ property2()
1214
+ ], LuzmoBaseVizItem.prototype, "authToken", 2);
1215
+ __decorateClass([
1216
+ property2()
1217
+ ], LuzmoBaseVizItem.prototype, "version", 2);
1218
+ __decorateClass([
1219
+ property2()
1220
+ ], LuzmoBaseVizItem.prototype, "contextId", 2);
1221
+ __decorateClass([
1222
+ property2({
1223
+ converter: (value) => {
1224
+ try {
1225
+ return JSON.parse(value);
1226
+ } catch {
1227
+ return value;
1228
+ }
1229
+ }
1230
+ })
1231
+ ], LuzmoBaseVizItem.prototype, "canFilter", 2);
1232
+ __decorateClass([
1233
+ property2({ type: Array })
1234
+ ], LuzmoBaseVizItem.prototype, "filters", 2);
1235
+ __decorateClass([
1236
+ property2()
1237
+ ], LuzmoBaseVizItem.prototype, "dashboardId", 2);
1238
+ __decorateClass([
1239
+ property2()
1240
+ ], LuzmoBaseVizItem.prototype, "itemId", 2);
1241
+ __decorateClass([
1242
+ property2({ type: Object })
1243
+ ], LuzmoBaseVizItem.prototype, "selectedData", 2);
1244
+ __decorateClass([
1245
+ property2()
1246
+ ], LuzmoBaseVizItem.prototype, "dashboardContentsVersion", 2);
1247
+ __decorateClass([
1248
+ property2()
1249
+ ], LuzmoBaseVizItem.prototype, "libVersion", 2);
1250
+
1251
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
1252
+ var LuzmoEmbedVizItem = class extends LuzmoBaseVizItem {
1253
+ };
1254
+ if (!customElements.get("luzmo-embed-viz-item")) {
1255
+ customElements.define("luzmo-embed-viz-item", LuzmoEmbedVizItem);
1256
+ }
1257
+
1258
+ // libs/embed-libs/embed/src/lib/luzmo-iq-components/luzmo-iq-chat.ts
1259
+ import { property as property3 } from "lit/decorators.js";
1260
+ import { LitElement as LitElement3, html as html3, css as css3 } from "lit";
1261
+ import * as SharedLib4 from "@luzmo/shared-embed";
1262
+ var inputMap = {
1263
+ aiEndpoint: "ai-endpoint",
1264
+ appServer: "app-server",
1265
+ apiHost: "api-host",
1266
+ options: "options",
1267
+ initialSuggestionsDatasetId: "initialSuggestionsDatasetId",
1268
+ authKey: "auth-key",
1269
+ authToken: "auth-token",
1270
+ version: "version",
1271
+ libVersion: "lib-version",
1272
+ aydHost: "ayd-host"
1273
+ };
1274
+ var LuzmoIQEmbedChatComponent = class extends LitElement3 {
1275
+ constructor() {
1276
+ super(...arguments);
1277
+ this.appServer = "https://app.luzmo.com";
1278
+ this.apiHost = "https://api.luzmo.com";
1279
+ this.version = version + "-wc-luzmo";
1280
+ this.libVersion = version + "-wc-luzmo";
1281
+ this.remoteEntryServer = "http://localhost:4202/";
1282
+ this.aydHost = "https://ayd.luzmo.com/";
1283
+ }
1284
+ static {
1285
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1286
+ this.styles = css3`
1287
+ :host {
1288
+ display: block;
1289
+ width: 100%;
1290
+ height: 100%;
1291
+ }
1292
+ `;
1293
+ }
1294
+ createRenderRoot() {
1295
+ return this;
1296
+ }
1297
+ async firstUpdated(_changedProperties) {
1298
+ super.firstUpdated(_changedProperties);
1299
+ await SharedLib4.loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
1300
+ this.createAndAppendElement();
1301
+ }
1302
+ createAndAppendElement() {
1303
+ if (!this.chartElement) {
1304
+ this.chartElement = document.createElement("luzmo-iq-chat-component");
1305
+ this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
1306
+ this.updateVizItemProperties();
1307
+ this.renderRoot.append(this.chartElement);
1308
+ }
1309
+ }
1310
+ updateVizItemProperties() {
1311
+ if (this.chartElement) {
1312
+ for (const key in inputMap) {
1313
+ const value = this[key];
1314
+ if (value) {
1315
+ const attributeValue = ["appServer", "apiHost", "aydHost"].includes(key) ? SharedLib4.removeTrailingSlash(value) : value;
1316
+ this.chartElement.setAttribute(
1317
+ inputMap[key],
1318
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
1319
+ );
1320
+ }
1321
+ }
1322
+ }
1323
+ }
1324
+ async updated(changedProperties) {
1325
+ if (this.chartElement) {
1326
+ for (const [propertyName] of changedProperties.entries()) {
1327
+ const mappedAttributeName = inputMap[propertyName] ?? propertyName;
1328
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1329
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1330
+ }
1331
+ } else {
1332
+ await SharedLib4.loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
1333
+ this.createAndAppendElement();
1334
+ }
1335
+ }
1336
+ render() {
1337
+ return html3``;
1338
+ }
1339
+ connectedCallback() {
1340
+ super.connectedCallback();
1341
+ const embedChat = document.querySelector("luzmo-iq-embed-chat");
1342
+ if (!embedChat) {
1343
+ return;
1344
+ }
1345
+ const observer = new MutationObserver(() => {
1346
+ const customChatWidgetContentSlot = embedChat.querySelector('*[slot="custom-chat-widget-content"]');
1347
+ if (!customChatWidgetContentSlot) {
1348
+ return;
1349
+ }
1350
+ const chatElement = embedChat.querySelector("luzmo-iq-chat-component");
1351
+ if (chatElement) {
1352
+ chatElement.append(customChatWidgetContentSlot);
1353
+ observer.disconnect();
1354
+ }
1355
+ });
1356
+ observer.observe(embedChat, { childList: true, subtree: true });
1357
+ }
1358
+ };
1359
+ __decorateClass([
1360
+ property3()
1361
+ ], LuzmoIQEmbedChatComponent.prototype, "appServer", 2);
1362
+ __decorateClass([
1363
+ property3()
1364
+ ], LuzmoIQEmbedChatComponent.prototype, "apiHost", 2);
1365
+ __decorateClass([
1366
+ property3({ type: Object })
1367
+ ], LuzmoIQEmbedChatComponent.prototype, "options", 2);
1368
+ __decorateClass([
1369
+ property3({ type: String })
1370
+ ], LuzmoIQEmbedChatComponent.prototype, "initialSuggestionsDatasetId", 2);
1371
+ __decorateClass([
1372
+ property3()
1373
+ ], LuzmoIQEmbedChatComponent.prototype, "aiEndpoint", 2);
1374
+ __decorateClass([
1375
+ property3()
1376
+ ], LuzmoIQEmbedChatComponent.prototype, "authKey", 2);
1377
+ __decorateClass([
1378
+ property3()
1379
+ ], LuzmoIQEmbedChatComponent.prototype, "authToken", 2);
1380
+ __decorateClass([
1381
+ property3()
1382
+ ], LuzmoIQEmbedChatComponent.prototype, "version", 2);
1383
+ __decorateClass([
1384
+ property3()
1385
+ ], LuzmoIQEmbedChatComponent.prototype, "libVersion", 2);
1386
+ __decorateClass([
1387
+ property3()
1388
+ ], LuzmoIQEmbedChatComponent.prototype, "remoteEntryServer", 2);
1389
+ __decorateClass([
1390
+ property3()
1391
+ ], LuzmoIQEmbedChatComponent.prototype, "aydHost", 2);
1392
+ if (!customElements.get("luzmo-iq-embed-chat")) {
1393
+ customElements.define("luzmo-iq-embed-chat", LuzmoIQEmbedChatComponent);
1394
+ }
1395
+
1396
+ // libs/embed-libs/embed/src/lib/luzmo-iq-components/luzmo-iq-answer.ts
1397
+ import { property as property4 } from "lit/decorators.js";
1398
+ import { LitElement as LitElement4, html as html4, css as css4 } from "lit";
1399
+ import * as SharedLib5 from "@luzmo/shared-embed";
1400
+ var inputMap2 = {
1401
+ aiEndPoint: "ai-end-point",
1402
+ appServer: "app-server",
1403
+ apiHost: "api-host",
1404
+ options: "options",
1405
+ authKey: "auth-key",
1406
+ authToken: "auth-token",
1407
+ version: "version",
1408
+ libVersion: "lib-version",
1409
+ messages: "messages"
1410
+ };
1411
+ var LuzmoIQEmbedAnswerComponent = class extends LitElement4 {
1412
+ constructor() {
1413
+ super(...arguments);
1414
+ this.appServer = "https://app.luzmo.com";
1415
+ this.apiHost = "https://api.luzmo.com";
1416
+ this.version = version + "-wc-luzmo";
1417
+ this.libVersion = version + "-wc-luzmo";
1418
+ this.remoteEntryServer = "http://localhost:4202";
1419
+ }
1420
+ static {
1421
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1422
+ this.styles = css4`
1423
+ :host {
1424
+ display: block;
1425
+ width: 100%;
1426
+ height: 100%;
1427
+ }
1428
+ `;
1429
+ }
1430
+ createRenderRoot() {
1431
+ return this;
1432
+ }
1433
+ async firstUpdated(_changedProperties) {
1434
+ super.firstUpdated(_changedProperties);
1435
+ await SharedLib5.loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
1436
+ this.createAndAppendElement();
1437
+ }
1438
+ createAndAppendElement() {
1439
+ if (!this.chartElement) {
1440
+ this.chartElement = document.createElement("luzmo-iq-answer-component");
1441
+ this.chartElement.addEventListener("addQuestion", (payload) => this.dispatchEvent(new CustomEvent("addQuestion", payload)));
1442
+ this.chartElement.addEventListener("addAnswer", (payload) => this.dispatchEvent(new CustomEvent("addAnswer", payload)));
1443
+ this.updateVizItemProperties();
1444
+ this.renderRoot.append(this.chartElement);
1445
+ }
1446
+ }
1447
+ updateVizItemProperties() {
1448
+ if (this.chartElement) {
1449
+ for (const key in inputMap2) {
1450
+ const value = this[key];
1451
+ if (value) {
1452
+ const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib5.removeTrailingSlash(value) : value;
1453
+ this.chartElement.setAttribute(
1454
+ inputMap2[key],
1455
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
1456
+ );
1457
+ }
1458
+ }
1459
+ }
1460
+ }
1461
+ async updated(changedProperties) {
1462
+ if (this.chartElement) {
1463
+ for (const [propertyName] of changedProperties.entries()) {
1464
+ const mappedAttributeName = inputMap2[propertyName] ?? propertyName;
1465
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1466
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1467
+ }
1468
+ } else {
1469
+ await SharedLib5.loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
1470
+ this.createAndAppendElement();
1471
+ }
1472
+ }
1473
+ render() {
1474
+ return html4` `;
1475
+ }
1476
+ };
1477
+ __decorateClass([
1478
+ property4()
1479
+ ], LuzmoIQEmbedAnswerComponent.prototype, "appServer", 2);
1480
+ __decorateClass([
1481
+ property4()
1482
+ ], LuzmoIQEmbedAnswerComponent.prototype, "apiHost", 2);
1483
+ __decorateClass([
1484
+ property4({ type: Object })
1485
+ ], LuzmoIQEmbedAnswerComponent.prototype, "options", 2);
1486
+ __decorateClass([
1487
+ property4()
1488
+ ], LuzmoIQEmbedAnswerComponent.prototype, "aiEndPoint", 2);
1489
+ __decorateClass([
1490
+ property4()
1491
+ ], LuzmoIQEmbedAnswerComponent.prototype, "authKey", 2);
1492
+ __decorateClass([
1493
+ property4()
1494
+ ], LuzmoIQEmbedAnswerComponent.prototype, "authToken", 2);
1495
+ __decorateClass([
1496
+ property4()
1497
+ ], LuzmoIQEmbedAnswerComponent.prototype, "messages", 2);
1498
+ __decorateClass([
1499
+ property4()
1500
+ ], LuzmoIQEmbedAnswerComponent.prototype, "version", 2);
1501
+ __decorateClass([
1502
+ property4()
1503
+ ], LuzmoIQEmbedAnswerComponent.prototype, "libVersion", 2);
1504
+ __decorateClass([
1505
+ property4()
1506
+ ], LuzmoIQEmbedAnswerComponent.prototype, "remoteEntryServer", 2);
1507
+ if (!customElements.get("luzmo-iq-embed-answer")) {
1508
+ customElements.define("luzmo-iq-embed-answer", LuzmoIQEmbedAnswerComponent);
1509
+ }
1510
+
1511
+ // libs/embed-libs/embed/src/lib/helper/json-schema-utils.ts
1512
+ var cachedSchemas = {};
1513
+ function addJSONSchemas(schemas) {
1514
+ if (schemas.some((schema) => !schema.$id)) {
1515
+ throw new Error("To add schemas they all must have an $id property.");
1516
+ }
1517
+ schemas.forEach((schema) => {
1518
+ cachedSchemas[schema.$id] = schema;
1519
+ });
1520
+ }
1521
+ function getCachedJSONSchema(schemaUrl) {
1522
+ return cachedSchemas[schemaUrl];
1523
+ }
1524
+ function getCachedJSONSchemas() {
1525
+ return cachedSchemas;
1526
+ }
1527
+ function getJSONSchemaUrl(schemaName) {
1528
+ return `https://developer.luzmo.com/assets/json-schemas/${dashboardContentsVersion}/${schemaName}.schema.json`;
1529
+ }
1530
+ async function fetchJSONSchema(schemaName) {
1531
+ const schemaUrl = getJSONSchemaUrl(schemaName);
1532
+ if (getCachedJSONSchema(schemaUrl)) {
1533
+ return getCachedJSONSchema(schemaUrl);
1534
+ }
1535
+ try {
1536
+ const response = await fetch(schemaUrl, { credentials: "omit" });
1537
+ if (!response.ok) {
1538
+ throw new Error(`Failed to fetch schema ${schemaUrl}, response status: ${response.status}`);
1539
+ }
1540
+ const schema = await response.json();
1541
+ addJSONSchemas([schema]);
1542
+ return schema;
1543
+ } catch (error) {
1544
+ console.error(error);
1545
+ }
1546
+ }
1547
+ var luzmoRefParserResolver = {
1548
+ order: 101,
1549
+ // 101 would make it run after the file resolver, but before the HTTP resolver
1550
+ canRead: (file) => {
1551
+ const isLuzmoUrl = file.url.startsWith("https://developer.luzmo.com");
1552
+ if (isLuzmoUrl) {
1553
+ return !!getCachedJSONSchema(file.url);
1554
+ }
1555
+ return false;
1556
+ },
1557
+ read: (file, callback) => {
1558
+ callback(null, getCachedJSONSchema(file.url));
1559
+ }
1560
+ };
1561
+ var luzmoRefParserOptions = {
1562
+ mutateInputSchema: false,
1563
+ resolve: {
1564
+ luzmo: luzmoRefParserResolver,
1565
+ external: true
1566
+ }
1567
+ };
1568
+ export {
1569
+ LuzmoEmbedDashboard,
1570
+ LuzmoEmbedVizItem,
1571
+ LuzmoIQEmbedAnswerComponent,
1572
+ LuzmoIQEmbedChatComponent,
1573
+ addJSONSchemas,
1574
+ fetchJSONSchema,
1575
+ getCachedJSONSchema,
1576
+ getCachedJSONSchemas,
1577
+ getJSONSchemaUrl,
1578
+ luzmoRefParserOptions,
1579
+ selectedDataUtils
1580
+ };