@luzmo/embed 5.0.13-beta.0 → 5.0.13

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/index.libs.cjs ADDED
@@ -0,0 +1,1099 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var __decorateClass = (decorators, target, key, kind) => {
30
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
31
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
32
+ if (decorator = decorators[i])
33
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
34
+ if (kind && result)
35
+ __defProp(target, key, result);
36
+ return result;
37
+ };
38
+
39
+ // libs/embed-libs/embed/src/index.libs.ts
40
+ var index_libs_exports = {};
41
+ __export(index_libs_exports, {
42
+ LuzmoDashboardWebComponent: () => LuzmoDashboardWebComponent
43
+ });
44
+ module.exports = __toCommonJS(index_libs_exports);
45
+
46
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-web-component.ts
47
+ var import_decorators2 = require("lit/decorators.js");
48
+
49
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
50
+ var SharedLib2 = __toESM(require("@luzmo/shared-embed"), 1);
51
+ var import_lit2 = require("lit");
52
+ var import_decorators = require("lit/decorators.js");
53
+ var import_style_map = require("lit/directives/style-map.js");
54
+ var import_shared_embed = require("@luzmo/shared-embed");
55
+
56
+ // libs/embed-libs/embed/package.json
57
+ var version = "5.0.13";
58
+
59
+ // libs/embed-libs/embed/src/lib/luzmo-service.ts
60
+ var LuzmoService = class {
61
+ constructor() {
62
+ this._components = [];
63
+ }
64
+ };
65
+ var luzmo_service_default = new LuzmoService();
66
+
67
+ // libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
68
+ var SharedLib = __toESM(require("@luzmo/shared-embed"), 1);
69
+ var _setEventHandler = () => {
70
+ if (typeof window.__luzmoMessageHandler === "function") {
71
+ return;
72
+ }
73
+ window.__luzmoMessageHandler = (event) => {
74
+ const dashboardComponent = luzmo_service_default._components.find(
75
+ (c) => event.data.name === c._iframeId
76
+ );
77
+ if (!dashboardComponent) {
78
+ return;
79
+ }
80
+ switch (event.data?.type) {
81
+ case "load": {
82
+ dashboardComponent.dispatchEvent(
83
+ new CustomEvent("load", { detail: { data: event.data } })
84
+ );
85
+ if (dashboardComponent._loadTimeoutHandle) {
86
+ clearTimeout(dashboardComponent._loadTimeoutHandle);
87
+ dashboardComponent._loadTimeoutHandle = void 0;
88
+ }
89
+ dashboardComponent.iframeLoaded = true;
90
+ dashboardComponent.dimensions = event.data.dimensions;
91
+ dashboardComponent._calculateDimAfterDashboardLoaded();
92
+ break;
93
+ }
94
+ case "error": {
95
+ dashboardComponent.dashboardError = true;
96
+ if (dashboardComponent._loadTimeoutHandle) {
97
+ clearTimeout(dashboardComponent._loadTimeoutHandle);
98
+ dashboardComponent._loadTimeoutHandle = void 0;
99
+ }
100
+ dashboardComponent.iframeLoaded = true;
101
+ dashboardComponent._displayError();
102
+ break;
103
+ }
104
+ case "data": {
105
+ SharedLib.resolvePromise(
106
+ dashboardComponent,
107
+ event.data.requestId,
108
+ event.data.data
109
+ );
110
+ break;
111
+ }
112
+ case "filters": {
113
+ SharedLib.resolvePromise(
114
+ dashboardComponent,
115
+ event.data.requestId,
116
+ event.data.filters
117
+ );
118
+ break;
119
+ }
120
+ case "getAccessibleDashboards": {
121
+ SharedLib.resolvePromise(
122
+ dashboardComponent,
123
+ event.data.requestId,
124
+ event.data.accessibleDashboards
125
+ );
126
+ break;
127
+ }
128
+ case "dashboardAction": {
129
+ dashboardComponent.dispatchEvent(
130
+ new CustomEvent("dashboardAction", { detail: { data: event.data } })
131
+ );
132
+ break;
133
+ }
134
+ case "export": {
135
+ if (event.data.error) {
136
+ SharedLib.rejectPromise(
137
+ dashboardComponent,
138
+ event.data.requestId,
139
+ event.data
140
+ );
141
+ } else {
142
+ dashboardComponent.dispatchEvent(
143
+ new CustomEvent("exported", { detail: { data: event.data } })
144
+ );
145
+ SharedLib.resolvePromise(
146
+ dashboardComponent,
147
+ event.data.requestId,
148
+ event.data
149
+ );
150
+ }
151
+ break;
152
+ }
153
+ case "changedFilters": {
154
+ dashboardComponent.dispatchEvent(
155
+ new CustomEvent("changedFilters", { detail: { data: event.data } })
156
+ );
157
+ break;
158
+ }
159
+ case "customEvent": {
160
+ dashboardComponent.dispatchEvent(
161
+ new CustomEvent("customEvent", { detail: { data: event.data } })
162
+ );
163
+ break;
164
+ }
165
+ case "chartsRendered":
166
+ case "itemsRendered": {
167
+ event.data.type = "itemsRendered";
168
+ dashboardComponent.dispatchEvent(
169
+ new CustomEvent("itemsRendered", { detail: { data: event.data } })
170
+ );
171
+ break;
172
+ }
173
+ case "setEditMode": {
174
+ if (event.data.error) {
175
+ SharedLib.rejectPromise(
176
+ dashboardComponent,
177
+ event.data.requestId,
178
+ event.data
179
+ );
180
+ } else {
181
+ SharedLib.resolvePromise(
182
+ dashboardComponent,
183
+ event.data.requestId,
184
+ event.data
185
+ );
186
+ dashboardComponent.params.editMode = event.data.editMode;
187
+ dashboardComponent._containerStyle = SharedLib.containerStyles(dashboardComponent);
188
+ if (dashboardComponent.dimensions) {
189
+ SharedLib._setCalculatedDimensions(dashboardComponent);
190
+ }
191
+ }
192
+ break;
193
+ }
194
+ case "setFilters": {
195
+ event.data.error ? SharedLib.rejectPromise(
196
+ dashboardComponent,
197
+ event.data.requestId,
198
+ event.data
199
+ ) : SharedLib.resolvePromise(
200
+ dashboardComponent,
201
+ event.data.requestId,
202
+ event.data
203
+ );
204
+ break;
205
+ }
206
+ case "setPreview": {
207
+ event.data.error ? SharedLib.rejectPromise(
208
+ dashboardComponent,
209
+ event.data.requestId,
210
+ event.data
211
+ ) : SharedLib.resolvePromise(
212
+ dashboardComponent,
213
+ event.data.requestId,
214
+ event.data
215
+ );
216
+ break;
217
+ }
218
+ }
219
+ };
220
+ window.addEventListener("message", window.__luzmoMessageHandler, false);
221
+ };
222
+
223
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-styles.ts
224
+ var import_lit = require("lit");
225
+ var dashboardStyles = import_lit.css`
226
+ :host {
227
+ display: block;
228
+ }
229
+
230
+ @-webkit-keyframes spin {
231
+ 0% {
232
+ -webkit-transform: rotate(0deg);
233
+ transform: rotate(0deg);
234
+ }
235
+ 100% {
236
+ -webkit-transform: rotate(360deg);
237
+ transform: rotate(360deg);
238
+ }
239
+ }
240
+
241
+ @keyframes spin {
242
+ 0% {
243
+ -webkit-transform: rotate(0deg);
244
+ transform: rotate(0deg);
245
+ }
246
+ 100% {
247
+ -webkit-transform: rotate(360deg);
248
+ transform: rotate(360deg);
249
+ }
250
+ }
251
+ :host {
252
+ position: relative;
253
+ width: 100%;
254
+ }
255
+
256
+ .luzmo-embed-dashboard {
257
+ background: transparent;
258
+ padding: 0;
259
+ border: 0;
260
+ }
261
+
262
+ .luzmo-embed-container-ede {
263
+ width: 100%;
264
+ height: 100%;
265
+ }
266
+
267
+ .luzmo-container-loader {
268
+ width: 100%;
269
+ position: relative;
270
+ }
271
+
272
+ .luzmo-lc {
273
+ margin: 0 auto;
274
+ }
275
+
276
+ .luzmo-loading-message {
277
+ width: 100%;
278
+ height: 20px;
279
+ text-align: center;
280
+ margin-bottom: 16px;
281
+ font-family: Helvetica, Arial, sans-serif;
282
+ font-size: 14px;
283
+ }
284
+
285
+ .luzmo-loading-circle {
286
+ box-sizing: border-box;
287
+ margin: 16px auto;
288
+ position: relative;
289
+ text-indent: -9999em;
290
+ animation: spin 0.6s infinite linear;
291
+ }
292
+
293
+ .luzmo-loading-circle,
294
+ .luzmo-loading-circle:after {
295
+ border-radius: 50%;
296
+ width: 32px;
297
+ height: 32px;
298
+ }
299
+
300
+ .itemEmbedding:after {
301
+ width: 24px;
302
+ height: 24px;
303
+ }
304
+
305
+ .luzmo-error {
306
+ background: transparent;
307
+ padding: 48px 0;
308
+ margin: 0 auto;
309
+ width: 80%;
310
+ border: 0;
311
+ text-align: center;
312
+ min-height: 192px;
313
+ }
314
+
315
+ .dashboard-error {
316
+ font-size: 30px;
317
+ background: transparent;
318
+ padding: 48px 0;
319
+ margin: 0 auto;
320
+ width: 80%;
321
+ border: 0;
322
+ text-align: center;
323
+ min-height: 192px;
324
+ }
325
+
326
+ .luzmo-loader {
327
+ top: 0;
328
+ left: 0;
329
+ width: 100%;
330
+ min-height: 400px;
331
+ position: absolute;
332
+ transition-duration: 0.3s;
333
+ }
334
+ `;
335
+
336
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
337
+ var LuzmoDashboard = class extends import_lit2.LitElement {
338
+ constructor(inputParameters) {
339
+ super();
340
+ this.language = "auto";
341
+ this.screenMode = "auto";
342
+ this.switchScreenModeOnResize = true;
343
+ this.editMode = "view";
344
+ this.experimental = false;
345
+ this.iframeStyle = {};
346
+ this._containerStyle = {};
347
+ this._loaderStyle = {};
348
+ this._lcStyle = {};
349
+ this._loadingCircleStyle = {};
350
+ this._containerLoaderStyle = {};
351
+ this._loaderMsg = "";
352
+ this._itemEmbedding = false;
353
+ this.browserError = false;
354
+ this.browserErrorMsg = "";
355
+ this.dashboardError = false;
356
+ this.browserNotSupported = [];
357
+ this.VERSION = version + "-wc-luzmo";
358
+ this.isLibraryLoaded = false;
359
+ this.currentAuthKey = null;
360
+ this.currentAuthToken = null;
361
+ this.attributesMap = {
362
+ dashboardId: "dashboard-id",
363
+ dashboardSlug: "dashboard-slug",
364
+ itemId: "item-id",
365
+ language: "language",
366
+ qeVersion: "qe-version",
367
+ screenMode: "screen-mode",
368
+ switchScreenModeOnResize: "switch-screen-mode-on-resize",
369
+ authKey: "auth-key",
370
+ authToken: "auth-token",
371
+ editMode: "edit-mode",
372
+ mainColor: "main-color",
373
+ accentColor: "accent-color",
374
+ loaderBackground: "loader-background",
375
+ loaderFontColor: "loader-font-color",
376
+ loaderSpinnerColor: "loader-spinner-color",
377
+ loaderSpinnerBackground: "loader-spinner-background",
378
+ appServer: "app-server",
379
+ apiHost: "api-host",
380
+ itemDimensions: "item-dimensions",
381
+ timezoneId: "timezone-id"
382
+ };
383
+ this.loaderSize = 32;
384
+ this.borderWidth = 3;
385
+ this.minHeight = 400;
386
+ this._containerId = SharedLib2.uuidv4();
387
+ this._iframeId = `luzmo-dashboard-${this._containerId}`;
388
+ this.iframeLoaded = false;
389
+ this.promises = {};
390
+ this.setInputParameters(inputParameters);
391
+ this.params = this._setOptions();
392
+ this._onResize = () => {
393
+ if (this.shadowRoot?.querySelector(".dashboard-container")) {
394
+ this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
395
+ if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
396
+ for (const d of SharedLib2.EXTENTS) {
397
+ if (d.width[0] <= window.innerWidth && window.innerWidth <= d.width[1]) {
398
+ this.currentScreenMode = d.mode;
399
+ }
400
+ }
401
+ }
402
+ if (this.iframeLoaded) {
403
+ this._calculateDimAfterDashboardLoaded();
404
+ } else {
405
+ if (this.dimensions) {
406
+ this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
407
+ SharedLib2._setCalculatedDimensions(this);
408
+ }
409
+ }
410
+ }
411
+ };
412
+ this._resizeObserver = new ResizeObserver((entries) => {
413
+ window.requestAnimationFrame(() => {
414
+ if (!Array.isArray(entries) || entries.length === 0) {
415
+ return;
416
+ }
417
+ this._onResize();
418
+ });
419
+ });
420
+ }
421
+ loadLibrary(appServer) {
422
+ if (import_shared_embed.remotesMap[appServer]) {
423
+ return Promise.resolve(import_shared_embed.remotesMap[appServer].module);
424
+ }
425
+ import_shared_embed.remotesMap[appServer] = {
426
+ url: appServer?.startsWith("http://localhost") ? `${SharedLib2.removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${SharedLib2.removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`,
427
+ format: "esm",
428
+ from: "vite",
429
+ module: void 0
430
+ };
431
+ return (0, import_shared_embed.__federationMethodGetRemote)(appServer, "./DashboardApp").then((module2) => {
432
+ const wrappedModule = (0, import_shared_embed.__federationMethodWrapDefault)(module2, true);
433
+ import_shared_embed.remotesMap[appServer].module = wrappedModule;
434
+ return wrappedModule;
435
+ });
436
+ }
437
+ setInputParameters(inputParameters) {
438
+ if (!inputParameters) {
439
+ return;
440
+ }
441
+ const params = [
442
+ "dashboardId",
443
+ "dashboardSlug",
444
+ "itemId",
445
+ "language",
446
+ "qeVersion",
447
+ "screenMode",
448
+ "switchScreenModeOnResize",
449
+ "accentColor",
450
+ "mainColor",
451
+ "authToken",
452
+ "authKey",
453
+ "editMode",
454
+ "loaderBackground",
455
+ "loaderFontColor",
456
+ "loaderSpinnerColor",
457
+ "loaderSpinnerBackground",
458
+ "timezoneId",
459
+ "itemDimensions",
460
+ "apiHost"
461
+ ];
462
+ for (const key of params) {
463
+ const value = inputParameters[key];
464
+ if (value) {
465
+ this[key] = value;
466
+ }
467
+ }
468
+ if (inputParameters.experimental) {
469
+ this.experimental = inputParameters.experimental;
470
+ }
471
+ if (inputParameters.appServer) {
472
+ this.appServer = SharedLib2.addTrailingSlash(inputParameters.appServer);
473
+ }
474
+ }
475
+ // Set resize event listener
476
+ connectedCallback() {
477
+ super.connectedCallback();
478
+ }
479
+ // Set resize event listener
480
+ disconnectedCallback() {
481
+ super.disconnectedCallback();
482
+ this._resizeObserver.disconnect();
483
+ for (const promiseKey of Object.keys(this.promises)) {
484
+ this.promises[promiseKey].reject(
485
+ new Error("Dashboard component was removed")
486
+ );
487
+ }
488
+ }
489
+ firstUpdated() {
490
+ this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
491
+ this._loaderStyles();
492
+ luzmo_service_default._components.push(this);
493
+ this.initComponent();
494
+ if (this.luzmoEmbedContainer) {
495
+ this._resizeObserver.observe(this.luzmoEmbedContainer);
496
+ }
497
+ }
498
+ initComponent() {
499
+ this.params = this._setOptions();
500
+ if (this.getIsViewMode()) {
501
+ this.loadLibrary(this.params.appServer).then(async () => {
502
+ this.isLibraryLoaded = true;
503
+ await this.updateComplete;
504
+ const oldReference = this.renderRoot.querySelector("dashboard-component");
505
+ this.dashboardReference = oldReference.cloneNode(true);
506
+ oldReference.replaceWith(this.dashboardReference);
507
+ this.dashboardReference.addEventListener("load", (payload) => {
508
+ this.containerWidth = this.dashboardReference.offsetWidth;
509
+ this.dimensions = payload.detail.dimensions;
510
+ SharedLib2._setCalculatedDimensions(this);
511
+ window.dispatchEvent(new Event("resize"));
512
+ this.dispatchEvent(new CustomEvent("load", payload));
513
+ });
514
+ this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
515
+ this.dashboardReference.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
516
+ this.dashboardReference.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
517
+ this.dashboardReference.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
518
+ this.dashboardReference.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
519
+ this.setAllAttributes();
520
+ });
521
+ } else {
522
+ this.containerWidth = this.container?.clientWidth;
523
+ SharedLib2._extendAndValidate(this);
524
+ SharedLib2._browserCheck(this);
525
+ this._setupLoader();
526
+ if (!this.params.error) {
527
+ this._loaderStyles();
528
+ _setEventHandler();
529
+ this._iframeUrl = SharedLib2.createIframeUrl(this);
530
+ this.iframe?.setAttribute("src", this._iframeUrl);
531
+ this.iframeStyle = SharedLib2.calculateIframeStyles(this);
532
+ }
533
+ }
534
+ }
535
+ setAllAttributes() {
536
+ if (this.dashboardReference) {
537
+ for (const key in this.attributesMap) {
538
+ if (!["authKey", "authToken", "apiHost", "itemDimensions"].includes(key) && this.params[key]) {
539
+ this.dashboardReference.setAttribute(this.attributesMap[key], this.params[key]);
540
+ }
541
+ if (this.params.itemDimensions) {
542
+ this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
543
+ }
544
+ if (this.params.apiHost) {
545
+ this.dashboardReference.setAttribute("api-host", SharedLib2.removeTrailingSlash(this.params.apiHost));
546
+ }
547
+ if (this.params.key) {
548
+ this.dashboardReference.setAttribute("auth-key", this.params.key);
549
+ }
550
+ if (this.params.token) {
551
+ this.dashboardReference.setAttribute("auth-token", this.params.token);
552
+ }
553
+ }
554
+ }
555
+ }
556
+ // Reload dashboard when triggerproperty changes
557
+ updated(changedProperties) {
558
+ const triggerProperties = /* @__PURE__ */ new Set([
559
+ "dashboardId",
560
+ "dashboardSlug",
561
+ "itemId",
562
+ "language",
563
+ "qeVersion",
564
+ "editMode",
565
+ "screenMode",
566
+ "switchScreenModeOnResize",
567
+ "authToken",
568
+ "authKey",
569
+ "appServer",
570
+ "timezoneId",
571
+ "itemDimensions"
572
+ ]);
573
+ if (this.getIsViewMode()) {
574
+ if (this.dashboardReference) {
575
+ for (const [propertyName] of changedProperties.entries()) {
576
+ if (propertyName === "appSever") {
577
+ this.loadLibrary(changedProperties[propertyName]).then(async () => {
578
+ this.isLibraryLoaded = true;
579
+ await this.updateComplete;
580
+ this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
581
+ this.setAllAttributes();
582
+ });
583
+ } else if (this.attributesMap[propertyName]) {
584
+ const mappedAttributeName = this.attributesMap[propertyName] ?? propertyName;
585
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() || this[propertyName];
586
+ this.dashboardReference.setAttribute(mappedAttributeName, attributeValue);
587
+ }
588
+ }
589
+ }
590
+ } else {
591
+ for (const [propertyName] of changedProperties.entries()) {
592
+ if (triggerProperties.has(propertyName) && propertyName !== "editMode") {
593
+ this.iframeLoaded = false;
594
+ if (this._loadTimeoutHandle) {
595
+ clearTimeout(this._loadTimeoutHandle);
596
+ }
597
+ this._loadTimeoutHandle = setTimeout(() => {
598
+ console.error(
599
+ "Failed to load dashboard, appServer is likely down or unreachable."
600
+ );
601
+ }, 15 * 1e3);
602
+ this.params = this._setOptions();
603
+ SharedLib2._extendAndValidate(this);
604
+ this._setupLoader();
605
+ this._loaderStyles();
606
+ this._iframeUrl = SharedLib2.createIframeUrl(this);
607
+ if (this.iframe) {
608
+ this._updateIframeUrl();
609
+ }
610
+ this.iframeStyle = SharedLib2.calculateIframeStyles(this);
611
+ } else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
612
+ if (this.iframeLoaded) {
613
+ this.setEditMode(this.editMode);
614
+ }
615
+ this.params = this._setOptions();
616
+ }
617
+ }
618
+ }
619
+ }
620
+ // Set params
621
+ _setOptions() {
622
+ const defaultParameters = {
623
+ dashboardId: this.dashboardId,
624
+ dashboardSlug: this.dashboardSlug
625
+ };
626
+ if (this.itemId) {
627
+ defaultParameters.itemId = this.itemId;
628
+ this._itemEmbedding = true;
629
+ } else {
630
+ this._itemEmbedding = false;
631
+ }
632
+ if (this.language) {
633
+ defaultParameters.language = this.language;
634
+ }
635
+ if (this.qeVersion) {
636
+ defaultParameters.qeVersion = this.qeVersion;
637
+ }
638
+ if (this.screenMode) {
639
+ defaultParameters.screenMode = this.screenMode;
640
+ }
641
+ defaultParameters.switchScreenModeOnResize = this.switchScreenModeOnResize;
642
+ if (this.authToken) {
643
+ defaultParameters.token = this.authToken;
644
+ }
645
+ if (this.authKey) {
646
+ defaultParameters.key = this.authKey;
647
+ }
648
+ if (this.editMode) {
649
+ defaultParameters.editMode = this.editMode;
650
+ }
651
+ if (this.mainColor) {
652
+ defaultParameters.mainColor = this.mainColor;
653
+ }
654
+ if (this.accentColor) {
655
+ defaultParameters.accentColor = this.accentColor;
656
+ }
657
+ if (this.loaderBackground) {
658
+ defaultParameters.loaderBackground = this.loaderBackground;
659
+ }
660
+ if (this.loaderFontColor) {
661
+ defaultParameters.loaderFontColor = this.loaderFontColor;
662
+ }
663
+ if (this.loaderSpinnerColor) {
664
+ defaultParameters.loaderSpinnerColor = this.loaderSpinnerColor;
665
+ }
666
+ if (this.loaderSpinnerBackground) {
667
+ defaultParameters.loaderSpinnerBackground = this.loaderSpinnerBackground;
668
+ }
669
+ if (this.timezoneId) {
670
+ defaultParameters.timezoneId = this.timezoneId;
671
+ }
672
+ if (this.itemDimensions) {
673
+ defaultParameters.itemDimensions = this.itemDimensions;
674
+ }
675
+ if (this.appServer) {
676
+ this.appServer = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.appServer) : SharedLib2.addTrailingSlash(this.appServer);
677
+ defaultParameters.appServer = this.appServer;
678
+ } else {
679
+ this.appServer = SharedLib2.addTrailingSlash(
680
+ SharedLib2.DEFAULT_PARAMETERS.appServer
681
+ );
682
+ defaultParameters.appServer = this.appServer;
683
+ }
684
+ if (this.apiHost) {
685
+ this.apiHost = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.apiHost) : SharedLib2.addTrailingSlash(this.apiHost);
686
+ defaultParameters.apiHost = this.apiHost;
687
+ } else {
688
+ this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
689
+ defaultParameters.apiHost = this.apiHost;
690
+ }
691
+ this.currentAuthKey = this.authKey;
692
+ this.currentAuthToken = this.authToken;
693
+ return defaultParameters;
694
+ }
695
+ _updateIframeUrl() {
696
+ SharedLib2.updateIframeUrl(this.iframe, this._iframeUrl);
697
+ }
698
+ // Setup loader / browser error
699
+ _setupLoader() {
700
+ const data = SharedLib2.getLoader(this);
701
+ this._loaderMsg = data.loadingMsg;
702
+ if (data.errorMsg) {
703
+ this.browserError = true;
704
+ this.browserErrorMsg = data.errorMsg;
705
+ this._displayError();
706
+ }
707
+ }
708
+ _displayError() {
709
+ if (this.dashboardError) {
710
+ this._loaderStyles();
711
+ this.iframeStyle.opacity = 1;
712
+ }
713
+ if (this.browserError) {
714
+ this._containerStyle.display = "none";
715
+ }
716
+ }
717
+ _calculateDimAfterDashboardLoaded() {
718
+ this.dashboardError = false;
719
+ this._loaderStyles();
720
+ SharedLib2._setCalculatedDimensions(this);
721
+ }
722
+ // Set loader styles
723
+ _loaderStyles() {
724
+ this._containerStyle = SharedLib2.containerStyles(this);
725
+ this._loaderStyle = SharedLib2.loaderStyles(this);
726
+ this._loadingCircleStyle = SharedLib2.plStyles(this);
727
+ this._containerLoaderStyle = SharedLib2.containerLoaderStyles(this);
728
+ this._lcStyle = SharedLib2.lcStyles(this);
729
+ }
730
+ static get styles() {
731
+ return [dashboardStyles];
732
+ }
733
+ render() {
734
+ let toBeRenderedHTML;
735
+ const loader = import_lit2.html`
736
+ <div
737
+ class="luzmo-container-loader"
738
+ id="luzmo-container-loader-${this._containerId}"
739
+ style=${(0, import_style_map.styleMap)(
740
+ this._containerLoaderStyle
741
+ )}
742
+ >
743
+ <div
744
+ class="luzmo-loader"
745
+ id="luzmo-loader-${this._containerId}"
746
+ style=${(0, import_style_map.styleMap)(this._loaderStyle)}
747
+ >
748
+ <div
749
+ class="luzmo-lc"
750
+ style=${(0, import_style_map.styleMap)(this._lcStyle)}
751
+ >
752
+ <div
753
+ class="luzmo-loading-circle"
754
+ style=${(0, import_style_map.styleMap)(
755
+ this._loadingCircleStyle
756
+ )}
757
+ ></div>
758
+ ${this._itemEmbedding ? "" : import_lit2.html`
759
+ <div
760
+ class="luzmo-loading-message"
761
+ style=${(0, import_style_map.styleMap)({ color: this.loaderFontColor })}
762
+ >
763
+ ${this._loaderMsg}
764
+ </div>
765
+ `}
766
+ </div>
767
+ </div>
768
+ </div>
769
+ `;
770
+ if (this.getIsViewMode()) {
771
+ toBeRenderedHTML = this.isLibraryLoaded ? import_lit2.html`
772
+ ${this.dashboardId || this.dashboardSlug ? import_lit2.html`
773
+ <dashboard-component dashboard-id="${this.params.dashboardId}" app-server="${this.params.appServer}"
774
+ api-host="${this.params.apiHost}"></dashboard-component>` : import_lit2.html`
775
+ <div id="luzmo-error-${this._containerId}">
776
+ <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
777
+ </div>
778
+ `}
779
+ ` : import_lit2.html`${loader}`;
780
+ } else {
781
+ toBeRenderedHTML = import_lit2.html`
782
+ ${this.dashboardId || this.dashboardSlug ? import_lit2.html`
783
+ ${loader}
784
+ <iframe
785
+ class="luzmo-embed-dashboard"
786
+ id="${this._iframeId}"
787
+ name="${this._iframeId}"
788
+ style=${(0, import_style_map.styleMap)(this.iframeStyle)}
789
+ src="${this._iframeUrl}"
790
+ frameborder="0"
791
+ ></iframe>
792
+ ` : import_lit2.html`<!-- the dashboard will inititialize when you provide a dashboardSlug or a dashboardId -->`}
793
+ ${this.browserError ? import_lit2.html`
794
+ <div id="luzmo-error-${this._containerId}">
795
+ <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
796
+ </div>
797
+ ` : ""}
798
+ `;
799
+ }
800
+ return import_lit2.html`
801
+ <div class="${import_shared_embed.luzmoEmbedContainerClass} ${!this.getIsViewMode() ? `${import_shared_embed.luzmoEmbedContainerClass}-ede` : ""}">
802
+ <div
803
+ class="dashboard-container"
804
+ style=${(0, import_style_map.styleMap)(Object.assign({}, this._containerStyle, {
805
+ width: this.iframeStyle.width ?? "100%",
806
+ height: this.iframeStyle.height ?? "100%"
807
+ }))}
808
+ >
809
+ ${toBeRenderedHTML}
810
+ </div>
811
+ </div>
812
+
813
+ `;
814
+ }
815
+ getDashboards() {
816
+ return new Promise(
817
+ (resolve) => resolve(luzmo_service_default._components)
818
+ );
819
+ }
820
+ // Public methods
821
+ getData(itemId) {
822
+ if (this.getIsViewMode() && this.dashboardReference) {
823
+ return this.dashboardReference.getData(itemId);
824
+ }
825
+ if (!this.getIsViewMode()) {
826
+ return SharedLib2.getData(this, this.iframe, itemId);
827
+ }
828
+ return Promise.reject();
829
+ }
830
+ getFilters() {
831
+ if (this.getIsViewMode() && this.dashboardReference) {
832
+ return this.dashboardReference.getFilters();
833
+ }
834
+ if (!this.getIsViewMode()) {
835
+ return SharedLib2.getFilters(this, this.iframe);
836
+ }
837
+ return Promise.reject();
838
+ }
839
+ setFilters(itemId, filters) {
840
+ if (this.getIsViewMode() && this.dashboardReference) {
841
+ return this.dashboardReference.setFilters(itemId, filters);
842
+ }
843
+ if (!this.getIsViewMode()) {
844
+ return SharedLib2.setFilters(this, this.iframe, itemId, filters);
845
+ }
846
+ return Promise.reject();
847
+ }
848
+ setAuthorization(key, token) {
849
+ this.currentAuthKey = key;
850
+ this.currentAuthToken = token;
851
+ if (this.getIsViewMode() && this.dashboardReference) {
852
+ return this.dashboardReference.setAuthorization(key, token);
853
+ }
854
+ if (!this.getIsViewMode()) {
855
+ return SharedLib2.setAuthorization(this, this.iframe, key, token);
856
+ }
857
+ return Promise.reject();
858
+ }
859
+ refreshData(itemId) {
860
+ if (this.getIsViewMode() && this.dashboardReference) {
861
+ return this.dashboardReference.refreshData(itemId);
862
+ }
863
+ if (!this.getIsViewMode()) {
864
+ return itemId ? SharedLib2.refreshData(this, this.iframe, itemId) : SharedLib2.refreshData(this, this.iframe);
865
+ }
866
+ return Promise.reject();
867
+ }
868
+ reloadDashboard() {
869
+ if (this.getIsViewMode() && this.dashboardReference) {
870
+ return this.dashboardReference.reloadDashboard();
871
+ }
872
+ if (!this.getIsViewMode()) {
873
+ return SharedLib2.reloadDashboard(this, this.iframe);
874
+ }
875
+ return Promise.reject();
876
+ }
877
+ exportDashboard(format) {
878
+ if (this.getIsViewMode() && this.dashboardReference) {
879
+ return this.dashboardReference.exportDashboard(format);
880
+ }
881
+ if (!this.getIsViewMode()) {
882
+ return format ? SharedLib2.exportDashboard(this, this.iframe, format) : SharedLib2.exportDashboard(this, this.iframe);
883
+ }
884
+ return Promise.reject();
885
+ }
886
+ getAccessibleDashboards() {
887
+ return SharedLib2.getAccessibleDashboards(this);
888
+ }
889
+ addFilters(itemId, filters) {
890
+ return this.dashboardReference.addFilters(itemId, filters);
891
+ }
892
+ setEditMode(editMode) {
893
+ if (this.dashboardReference && editMode === "view") {
894
+ this.editMode = "view";
895
+ this.params.editMode = "view";
896
+ this.initComponent();
897
+ return Promise.resolve({
898
+ type: "setEditMode",
899
+ editMode
900
+ });
901
+ }
902
+ if (this.dashboardReference && ["editFull", "editLimited"].includes(editMode)) {
903
+ this.editMode = editMode;
904
+ this.params.editMode = editMode;
905
+ this.initComponent();
906
+ return Promise.resolve({
907
+ type: "setEditMode",
908
+ editMode
909
+ });
910
+ }
911
+ if (this.getIsViewMode() && this.dashboardReference) {
912
+ return this.dashboardReference.setEditMode(editMode);
913
+ }
914
+ if (!this.getIsViewMode()) {
915
+ return SharedLib2.setEditMode(this, this.iframe, editMode);
916
+ }
917
+ return Promise.reject();
918
+ }
919
+ setPreview(preview) {
920
+ if (this.getIsViewMode() && this.dashboardReference) {
921
+ return this.dashboardReference.setPreview(preview);
922
+ }
923
+ return SharedLib2.setPreview(this, this.iframe, preview);
924
+ }
925
+ getIsViewMode() {
926
+ return this.experimental && this.params.editMode === "view" || this.params.editMode === void 0;
927
+ }
928
+ };
929
+ __decorateClass([
930
+ (0, import_decorators.query)(".dashboard-container")
931
+ ], LuzmoDashboard.prototype, "container", 2);
932
+ __decorateClass([
933
+ (0, import_decorators.query)(`.${import_shared_embed.luzmoEmbedContainerClass}`)
934
+ ], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2);
935
+ __decorateClass([
936
+ (0, import_decorators.query)("iframe")
937
+ ], LuzmoDashboard.prototype, "iframe", 2);
938
+ __decorateClass([
939
+ (0, import_decorators.property)()
940
+ ], LuzmoDashboard.prototype, "dashboardId", 2);
941
+ __decorateClass([
942
+ (0, import_decorators.property)()
943
+ ], LuzmoDashboard.prototype, "dashboardSlug", 2);
944
+ __decorateClass([
945
+ (0, import_decorators.property)()
946
+ ], LuzmoDashboard.prototype, "itemId", 2);
947
+ __decorateClass([
948
+ (0, import_decorators.property)()
949
+ ], LuzmoDashboard.prototype, "language", 2);
950
+ __decorateClass([
951
+ (0, import_decorators.property)()
952
+ ], LuzmoDashboard.prototype, "qeVersion", 2);
953
+ __decorateClass([
954
+ (0, import_decorators.property)()
955
+ ], LuzmoDashboard.prototype, "screenMode", 2);
956
+ __decorateClass([
957
+ (0, import_decorators.property)({
958
+ converter: {
959
+ fromAttribute: (value) => value === "true",
960
+ toAttribute: String
961
+ }
962
+ })
963
+ ], LuzmoDashboard.prototype, "switchScreenModeOnResize", 2);
964
+ __decorateClass([
965
+ (0, import_decorators.property)()
966
+ ], LuzmoDashboard.prototype, "editMode", 2);
967
+ __decorateClass([
968
+ (0, import_decorators.property)()
969
+ ], LuzmoDashboard.prototype, "mainColor", 2);
970
+ __decorateClass([
971
+ (0, import_decorators.property)()
972
+ ], LuzmoDashboard.prototype, "accentColor", 2);
973
+ __decorateClass([
974
+ (0, import_decorators.property)()
975
+ ], LuzmoDashboard.prototype, "authToken", 2);
976
+ __decorateClass([
977
+ (0, import_decorators.property)()
978
+ ], LuzmoDashboard.prototype, "authKey", 2);
979
+ __decorateClass([
980
+ (0, import_decorators.property)()
981
+ ], LuzmoDashboard.prototype, "loaderBackground", 2);
982
+ __decorateClass([
983
+ (0, import_decorators.property)()
984
+ ], LuzmoDashboard.prototype, "loaderFontColor", 2);
985
+ __decorateClass([
986
+ (0, import_decorators.property)()
987
+ ], LuzmoDashboard.prototype, "loaderSpinnerColor", 2);
988
+ __decorateClass([
989
+ (0, import_decorators.property)()
990
+ ], LuzmoDashboard.prototype, "loaderSpinnerBackground", 2);
991
+ __decorateClass([
992
+ (0, import_decorators.property)()
993
+ ], LuzmoDashboard.prototype, "appServer", 2);
994
+ __decorateClass([
995
+ (0, import_decorators.property)()
996
+ ], LuzmoDashboard.prototype, "timezoneId", 2);
997
+ __decorateClass([
998
+ (0, import_decorators.property)()
999
+ ], LuzmoDashboard.prototype, "apiHost", 2);
1000
+ __decorateClass([
1001
+ (0, import_decorators.property)({ type: Object })
1002
+ ], LuzmoDashboard.prototype, "itemDimensions", 2);
1003
+ __decorateClass([
1004
+ (0, import_decorators.property)({
1005
+ converter: {
1006
+ fromAttribute: (value) => value === "true",
1007
+ toAttribute: String
1008
+ }
1009
+ })
1010
+ ], LuzmoDashboard.prototype, "experimental", 2);
1011
+ __decorateClass([
1012
+ (0, import_decorators.property)({ attribute: false })
1013
+ ], LuzmoDashboard.prototype, "_containerId", 2);
1014
+ __decorateClass([
1015
+ (0, import_decorators.property)({ attribute: false })
1016
+ ], LuzmoDashboard.prototype, "_iframeId", 2);
1017
+ __decorateClass([
1018
+ (0, import_decorators.property)({ attribute: false })
1019
+ ], LuzmoDashboard.prototype, "params", 2);
1020
+ __decorateClass([
1021
+ (0, import_decorators.property)({ attribute: false })
1022
+ ], LuzmoDashboard.prototype, "_iframeUrl", 2);
1023
+ __decorateClass([
1024
+ (0, import_decorators.property)({ attribute: false })
1025
+ ], LuzmoDashboard.prototype, "iframeLoaded", 2);
1026
+ __decorateClass([
1027
+ (0, import_decorators.property)({ attribute: false })
1028
+ ], LuzmoDashboard.prototype, "promises", 2);
1029
+ __decorateClass([
1030
+ (0, import_decorators.property)({ attribute: false })
1031
+ ], LuzmoDashboard.prototype, "iframeStyle", 2);
1032
+ __decorateClass([
1033
+ (0, import_decorators.property)({ attribute: false })
1034
+ ], LuzmoDashboard.prototype, "_containerStyle", 2);
1035
+ __decorateClass([
1036
+ (0, import_decorators.property)({ attribute: false })
1037
+ ], LuzmoDashboard.prototype, "_loaderStyle", 2);
1038
+ __decorateClass([
1039
+ (0, import_decorators.property)({ attribute: false })
1040
+ ], LuzmoDashboard.prototype, "_lcStyle", 2);
1041
+ __decorateClass([
1042
+ (0, import_decorators.property)({ attribute: false })
1043
+ ], LuzmoDashboard.prototype, "_loadingCircleStyle", 2);
1044
+ __decorateClass([
1045
+ (0, import_decorators.property)({ attribute: false })
1046
+ ], LuzmoDashboard.prototype, "_containerLoaderStyle", 2);
1047
+ __decorateClass([
1048
+ (0, import_decorators.property)({ attribute: false })
1049
+ ], LuzmoDashboard.prototype, "_loaderMsg", 2);
1050
+ __decorateClass([
1051
+ (0, import_decorators.property)({ attribute: false })
1052
+ ], LuzmoDashboard.prototype, "containerWidth", 2);
1053
+ __decorateClass([
1054
+ (0, import_decorators.property)({ attribute: false })
1055
+ ], LuzmoDashboard.prototype, "dimensions", 2);
1056
+ __decorateClass([
1057
+ (0, import_decorators.property)({ attribute: false })
1058
+ ], LuzmoDashboard.prototype, "currentScreenMode", 2);
1059
+ __decorateClass([
1060
+ (0, import_decorators.property)({ attribute: false })
1061
+ ], LuzmoDashboard.prototype, "_itemEmbedding", 2);
1062
+ __decorateClass([
1063
+ (0, import_decorators.property)({ attribute: false })
1064
+ ], LuzmoDashboard.prototype, "browserError", 2);
1065
+ __decorateClass([
1066
+ (0, import_decorators.property)({ attribute: false })
1067
+ ], LuzmoDashboard.prototype, "browserErrorMsg", 2);
1068
+ __decorateClass([
1069
+ (0, import_decorators.property)({ attribute: false })
1070
+ ], LuzmoDashboard.prototype, "dashboardError", 2);
1071
+ __decorateClass([
1072
+ (0, import_decorators.property)({ attribute: false })
1073
+ ], LuzmoDashboard.prototype, "browserNotSupported", 2);
1074
+ __decorateClass([
1075
+ (0, import_decorators.property)()
1076
+ ], LuzmoDashboard.prototype, "VERSION", 2);
1077
+ __decorateClass([
1078
+ (0, import_decorators.state)()
1079
+ ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
1080
+ __decorateClass([
1081
+ (0, import_decorators.state)()
1082
+ ], LuzmoDashboard.prototype, "dashboardReference", 2);
1083
+ __decorateClass([
1084
+ (0, import_decorators.state)()
1085
+ ], LuzmoDashboard.prototype, "currentAuthKey", 2);
1086
+ __decorateClass([
1087
+ (0, import_decorators.state)()
1088
+ ], LuzmoDashboard.prototype, "currentAuthToken", 2);
1089
+
1090
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-web-component.ts
1091
+ var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
1092
+ };
1093
+ LuzmoDashboardWebComponent = __decorateClass([
1094
+ (0, import_decorators2.customElement)("luzmo-dashboard-web-component")
1095
+ ], LuzmoDashboardWebComponent);
1096
+ // Annotate the CommonJS export names for ESM import in node:
1097
+ 0 && (module.exports = {
1098
+ LuzmoDashboardWebComponent
1099
+ });