@luzmo/embed 5.0.6 → 5.0.7

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.js CHANGED
@@ -10,8 +10,1180 @@ var __decorateClass = (decorators, target, key, kind) => {
10
10
  return result;
11
11
  };
12
12
 
13
+ // libs/embed-libs/shared-embed/src/lib/helpers/error.ts
14
+ var _handleError = (errorMessage, parameters) => {
15
+ let message = "The dashboard component encountered an error";
16
+ if (typeof parameters?.dashboardId === "string") {
17
+ message += ` for dashboard with id ${parameters.dashboardId}`;
18
+ }
19
+ if (typeof parameters?.dashboardSlug === "string") {
20
+ message += ` for dashboard with slug ${parameters.dashboardSlug}`;
21
+ }
22
+ if (typeof parameters?.container === "string") {
23
+ message += ` in container ${parameters.container}`;
24
+ }
25
+ if (errorMessage) {
26
+ message += `:
27
+ ${errorMessage}`;
28
+ console.error(message);
29
+ }
30
+ };
31
+
32
+ // libs/embed-libs/shared-embed/src/lib/helpers/browser-check.ts
33
+ var _browserCheck = (dashboardComponent) => {
34
+ let hasError = false;
35
+ let errorMessage = "";
36
+ const document_ = document.body || document.documentElement;
37
+ const style = document_.style;
38
+ const browserCheck = {
39
+ svg: !!("createElementNS" in document && document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect),
40
+ flexbox: style.webkitFlexWrap === "" || style.flexWrap === "",
41
+ postMessage: !!window.postMessage
42
+ };
43
+ const browserCheckKeys = ["svg", "flexbox", "postMessage"];
44
+ for (const key of browserCheckKeys) {
45
+ if (!browserCheck[key]) {
46
+ hasError = true;
47
+ dashboardComponent.browserNotSupported = dashboardComponent.browserNotSupported || [];
48
+ dashboardComponent.browserNotSupported.push(key);
49
+ errorMessage += `Your browser does not support: ${key}
50
+ `;
51
+ }
52
+ }
53
+ const ua = window.navigator.userAgent;
54
+ const msie = ua.includes("MSIE");
55
+ const trident = ua.includes("Trident/");
56
+ if (msie || trident) {
57
+ hasError = true;
58
+ errorMessage = "IE is not supported.";
59
+ }
60
+ if (hasError) {
61
+ _handleError(errorMessage);
62
+ }
63
+ };
64
+
65
+ // libs/embed-libs/shared-embed/src/lib/helpers/default-parameters.ts
66
+ var DEFAULT_PARAMETERS = {
67
+ appServer: "https://app.luzmo.com/",
68
+ apiHost: "https://api.luzmo.com/",
69
+ dashboardId: null,
70
+ dashboardSlug: null,
71
+ container: null,
72
+ key: null,
73
+ token: null,
74
+ language: "auto",
75
+ qeVersion: null,
76
+ editMode: null,
77
+ screenMode: null,
78
+ switchScreenModeOnResize: true,
79
+ itemId: null,
80
+ mainColor: "",
81
+ accentColor: "",
82
+ itemDimensions: {
83
+ width: "auto",
84
+ height: "auto"
85
+ },
86
+ loaderBackground: "#f9f9f9",
87
+ loaderFontColor: "#5a5a5a",
88
+ loaderSpinnerColor: "rgba(255, 165, 0, 0.7)",
89
+ loaderSpinnerBackground: "rgba(169, 169, 169, 0.14)",
90
+ timezoneId: null,
91
+ contextId: null
92
+ };
93
+
94
+ // libs/embed-libs/shared-embed/src/lib/helpers/extents.ts
95
+ var EXTENTS = [
96
+ { mode: "mobile", width: [150, 767] },
97
+ { mode: "tablet", width: [768, 1199] },
98
+ { mode: "desktop", width: [1200, 1599] },
99
+ { mode: "largeScreen", width: [1600, 9999] },
100
+ { mode: "fixed", width: [] }
101
+ ];
102
+
103
+ // libs/embed-libs/shared-embed/src/lib/helpers/translations.ts
104
+ var TRANSLATIONS = {
105
+ initializing: { en: "Initializing...", nl: "Laden...", fr: "Chargement..." },
106
+ errorDashboard: {
107
+ en: "Oops, we could not load this dashboard!",
108
+ nl: "Oeps, we konden het dashboard niet laden.",
109
+ fr: "Le chargement a echou\xE9."
110
+ },
111
+ errorItem: {
112
+ en: "Oops, we could not load this item!",
113
+ nl: "Oeps, we konden de grafiek niet laden.",
114
+ fr: "Le chargement a echou\xE9."
115
+ }
116
+ };
117
+ var translations_default = TRANSLATIONS;
118
+
119
+ // libs/embed-libs/shared-embed/src/lib/helpers/utils.ts
120
+ var addTrailingSlash = (serverUrl) => {
121
+ if (!serverUrl) {
122
+ return "";
123
+ }
124
+ return serverUrl.endsWith("/") ? serverUrl : `${serverUrl}/`;
125
+ };
126
+ var removeTrailingSlash = (serverUrl) => {
127
+ if (!serverUrl) {
128
+ return "";
129
+ }
130
+ return serverUrl.endsWith("/") ? serverUrl.slice(0, -1) : serverUrl;
131
+ };
132
+ var formatDashboardList = (dashboards, integrationId, user, dashboardComponent) => {
133
+ const combineRights = (securable, user2) => {
134
+ const matchingUser = securable.users.find((u) => u.id === user2.id);
135
+ const securableAccessRights = matchingUser && matchingUser.userAccessRight ? {
136
+ flagRead: matchingUser.userAccessRight.flagRead,
137
+ flagUse: matchingUser.userAccessRight.flagUse,
138
+ flagModify: matchingUser.userAccessRight.flagModify,
139
+ flagOwn: matchingUser.userAccessRight.flagOwn
140
+ } : {
141
+ flagRead: false,
142
+ flagUse: false,
143
+ flagModify: false,
144
+ flagOwn: false
145
+ };
146
+ const groups = securable.groups.filter(
147
+ (group) => user2.userGroups.includes(group.id) || group.public === true
148
+ );
149
+ const groupsAccess = groups.map((group) => {
150
+ if (group.groupAccessRight) {
151
+ return group.groupAccessRight;
152
+ }
153
+ });
154
+ for (const groupAccess of groupsAccess) {
155
+ if (!securableAccessRights.flagRead && groupAccess.flagRead) {
156
+ securableAccessRights.flagRead = groupAccess.flagRead;
157
+ }
158
+ if (!securableAccessRights.flagUse && groupAccess.flagUse) {
159
+ securableAccessRights.flagUse = groupAccess.flagUse;
160
+ }
161
+ if (!securableAccessRights.flagModify && groupAccess.flagModify) {
162
+ securableAccessRights.flagModify = groupAccess.flagModify;
163
+ }
164
+ if (!securableAccessRights.flagOwn && groupAccess.flagOwn) {
165
+ securableAccessRights.flagOwn = groupAccess.flagOwn;
166
+ }
167
+ }
168
+ const integrationsAccess = securable.integrations?.length > 0 ? securable.integrations.map((integration) => {
169
+ if (integration.integrationAccessRight) {
170
+ return integration.integrationAccessRight;
171
+ }
172
+ }) : [];
173
+ for (const integrationAccess of integrationsAccess) {
174
+ if (!securableAccessRights.flagRead && integrationAccess.flagRead) {
175
+ securableAccessRights.flagRead = integrationAccess.flagRead;
176
+ }
177
+ if (!securableAccessRights.flagUse && integrationAccess.flagUse) {
178
+ securableAccessRights.flagUse = integrationAccess.flagUse;
179
+ }
180
+ if (!securableAccessRights.flagModify && integrationAccess.flagModify) {
181
+ securableAccessRights.flagModify = integrationAccess.flagModify;
182
+ }
183
+ }
184
+ return securableAccessRights;
185
+ };
186
+ const localize = (item, locale) => {
187
+ if (item === null || item === void 0) {
188
+ return "";
189
+ }
190
+ if (typeof item !== "object" || Object.keys(item).length === 0) {
191
+ if (typeof item === "object" && Object.keys(item).length === 0) {
192
+ return "";
193
+ }
194
+ return item;
195
+ }
196
+ let localizedItem;
197
+ localizedItem = locale && item[locale] ? item[locale] : item[Object.keys(item)[0]];
198
+ if (localizedItem === void 0 || localizedItem === null) {
199
+ localizedItem = "";
200
+ }
201
+ return localizedItem;
202
+ };
203
+ const treatedDashboards = [];
204
+ for (const dashboard of dashboards) {
205
+ const treatedDashboard = {
206
+ accessibleBy: [],
207
+ accessRights: combineRights(dashboard, user),
208
+ id: dashboard.id,
209
+ modifiedAt: dashboard.modified_at,
210
+ name: localize(dashboard.name, dashboardComponent.language),
211
+ slug: null,
212
+ tags: dashboard.tags.map((t) => t.tag).sort((t1, t2) => t1.localeCompare(t2))
213
+ };
214
+ const currentIntegration = dashboard.integrations.find(
215
+ (i) => i.id === integrationId
216
+ );
217
+ if (currentIntegration?.integrationAccessRight?.slug) {
218
+ treatedDashboard.slug = currentIntegration.integrationAccessRight.slug;
219
+ }
220
+ const users = dashboard.users.map((u) => ({
221
+ model: "User",
222
+ id: u.id,
223
+ name: localize(u.name, user.locale_id)
224
+ }));
225
+ const groups = dashboard.groups.map((g) => ({
226
+ model: "Group",
227
+ id: g.id,
228
+ name: localize(g.name, user.locale_id) || {}
229
+ }));
230
+ const integrations = dashboard.integrations.map((i) => ({
231
+ model: "Integration",
232
+ id: i.id,
233
+ name: localize(i.name, user.locale_id) || {}
234
+ }));
235
+ treatedDashboard.accessibleBy = [...users, ...groups, ...integrations];
236
+ treatedDashboards.push(treatedDashboard);
237
+ }
238
+ return treatedDashboards;
239
+ };
240
+ var VERSION = "0.0.0-shared-luzmo";
241
+ var sanitizeUrl = (url) => {
242
+ const invalidPrototcolRegex = /^(%20|\s)*(javascript|data)/im;
243
+ const ctrlCharactersRegex = /[^\u0020-\u007E]/gim;
244
+ const urlSchemeRegex = /^([^:]+):/gm;
245
+ const relativeFirstCharacters = /* @__PURE__ */ new Set([".", "/"]);
246
+ const isRelativeUrlWithoutProtocol = (relativeUrl) => relativeFirstCharacters.has(relativeUrl[0]);
247
+ if (!url) {
248
+ return "about:blank";
249
+ }
250
+ const sanitizedUrl = url.replaceAll(ctrlCharactersRegex, "").trim();
251
+ if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
252
+ return sanitizedUrl;
253
+ }
254
+ const urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex);
255
+ if (!urlSchemeParseResults) {
256
+ return sanitizedUrl;
257
+ }
258
+ const urlScheme = urlSchemeParseResults[0];
259
+ if (invalidPrototcolRegex.test(urlScheme)) {
260
+ return "about:blank";
261
+ }
262
+ return sanitizedUrl;
263
+ };
264
+ var cloneDeep = (obj) => JSON.parse(JSON.stringify(obj));
265
+ var isObject = (o) => o && typeof o === "object";
266
+ var defaultsDeep = (target, defaults) => {
267
+ Object.entries(defaults).forEach(([k, v]) => {
268
+ if (k in target) {
269
+ if (target[k] === void 0) {
270
+ target[k] = v;
271
+ } else {
272
+ target[k] = isObject(v) ? defaultsDeep(
273
+ target[k],
274
+ v
275
+ ) : target[k];
276
+ }
277
+ } else {
278
+ target[k] = v;
279
+ }
280
+ });
281
+ return target;
282
+ };
283
+ var uuidv4 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g, function(c) {
284
+ const r = Math.random() * 16 | 0;
285
+ const v = c == "x" ? r : r & 3 | 8;
286
+ return v.toString(16);
287
+ });
288
+
289
+ // libs/embed-libs/shared-embed/src/lib/helpers/iframe-url.ts
290
+ var createIframeUrl = (dashboardContent) => {
291
+ const searchString = [];
292
+ const {
293
+ appServer,
294
+ language,
295
+ qeVersion,
296
+ loaderBackground,
297
+ loaderSpinnerColor,
298
+ loaderSpinnerBackground,
299
+ loaderFontColor,
300
+ screenMode,
301
+ key,
302
+ token,
303
+ timezoneId,
304
+ itemEmbedding,
305
+ itemDimensions,
306
+ dashboardId,
307
+ dashboardSlug,
308
+ itemId,
309
+ mainColor,
310
+ accentColor,
311
+ editMode
312
+ } = dashboardContent.params;
313
+ if (language && language !== "auto") {
314
+ searchString.push("language=" + language);
315
+ }
316
+ if (qeVersion) {
317
+ searchString.push(`qe_version=${qeVersion}`);
318
+ }
319
+ if (loaderBackground) {
320
+ searchString.push(`ldrbg=${loaderBackground}`);
321
+ }
322
+ if (loaderFontColor) {
323
+ searchString.push(`ldrftclr=${loaderFontColor}`);
324
+ }
325
+ if (loaderSpinnerColor) {
326
+ searchString.push(`ldrspclr=${loaderSpinnerColor}`);
327
+ }
328
+ if (loaderSpinnerBackground) {
329
+ searchString.push(`ldrspbg=${loaderSpinnerBackground}`);
330
+ }
331
+ if (mainColor) {
332
+ searchString.push(`mainColor=${mainColor}`);
333
+ }
334
+ if (accentColor) {
335
+ searchString.push(`accentColor=${accentColor}`);
336
+ }
337
+ if (screenMode && screenMode !== "auto") {
338
+ searchString.push("screenMode=" + screenMode);
339
+ }
340
+ if (timezoneId) {
341
+ searchString.push("timezoneId=" + timezoneId);
342
+ }
343
+ if (itemEmbedding && itemDimensions && itemDimensions.width) {
344
+ searchString.push("width=" + itemDimensions.width);
345
+ }
346
+ if (itemEmbedding && itemDimensions && itemDimensions.height) {
347
+ searchString.push("height=" + itemDimensions.height);
348
+ }
349
+ if (editMode) {
350
+ searchString.push("editMode=" + editMode);
351
+ }
352
+ const keyTokenUrlAnchor = key && token ? "#" + key + ":" + token : "";
353
+ searchString.push("version=" + (dashboardContent.VERSION || VERSION));
354
+ const iframeUrl = itemEmbedding ? `${appServer}i/${dashboardId || dashboardSlug}/${itemId}?${encodeURIComponent(
355
+ searchString.join("&")
356
+ )}${keyTokenUrlAnchor}` : `${appServer}i/${dashboardId || dashboardSlug}?${encodeURIComponent(
357
+ searchString.join("&")
358
+ )}${keyTokenUrlAnchor}`;
359
+ return sanitizeUrl(iframeUrl);
360
+ };
361
+
362
+ // libs/embed-libs/shared-embed/src/lib/helpers/get-loader.ts
363
+ var getLoader = (dashboardComponent) => {
364
+ let errorMsg;
365
+ if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
366
+ dashboardComponent.params.error = true;
367
+ if (dashboardComponent.browserNotSupported) {
368
+ errorMsg = "Browser is not supported.";
369
+ }
370
+ }
371
+ const loadingMsg = translations_default.initializing[dashboardComponent.params.language] || translations_default.initializing.en;
372
+ return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
373
+ };
374
+
375
+ // libs/embed-libs/shared-embed/src/lib/helpers/promise-dispatch.ts
376
+ function resolvePromise(dashboardComponent, requestId, data) {
377
+ if (dashboardComponent.promises[requestId]) {
378
+ dashboardComponent.promises[requestId].resolve(data);
379
+ delete dashboardComponent.promises[requestId];
380
+ }
381
+ }
382
+ function rejectPromise(dashboardComponent, requestId, data) {
383
+ if (dashboardComponent.promises[requestId]) {
384
+ dashboardComponent.promises[requestId].reject(data);
385
+ delete dashboardComponent.promises[requestId];
386
+ }
387
+ }
388
+
389
+ // libs/embed-libs/shared-embed/src/lib/helpers/styles.ts
390
+ function containerStyles(dashboardComponent) {
391
+ const styles = {};
392
+ if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
393
+ styles.background = dashboardComponent.params.loaderBackground;
394
+ }
395
+ return styles;
396
+ }
397
+ function containerLoaderStyles(dashboardComponent) {
398
+ const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
399
+ const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
400
+ const display = dashboardComponent.iframeLoaded ? "none" : "";
401
+ return {
402
+ display,
403
+ height: `${chartHeightDefined ? height : dashboardComponent.minHeight}px`
404
+ };
405
+ }
406
+ function loaderStyles(dashboardComponent) {
407
+ const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
408
+ if (dashboardComponent.params.itemEmbedding) {
409
+ dashboardComponent.loaderSize = 24;
410
+ dashboardComponent.borderWidth = 4;
411
+ dashboardComponent.minHeight = 200;
412
+ const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
413
+ const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
414
+ const chartWidthDefined = width !== "auto";
415
+ const chartHeightDefined = height !== "auto";
416
+ return {
417
+ background,
418
+ width: chartWidthDefined ? `${width}px` : "100%",
419
+ height: `${chartHeightDefined ? height : "200"}px`,
420
+ "min-height": chartHeightDefined ? "" : "200px"
421
+ };
422
+ }
423
+ return {
424
+ background
425
+ };
426
+ }
427
+ function plStyles(dashboardComponent) {
428
+ const {
429
+ loaderSpinnerColor: defaultSpinnerColor,
430
+ loaderSpinnerBackground: defaultSpinnerBackground
431
+ } = DEFAULT_PARAMETERS;
432
+ const spinnerColorBorder = generateBorderStyle(
433
+ dashboardComponent.borderWidth,
434
+ dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
435
+ );
436
+ const spinnerBackgroundBorder = generateBorderStyle(
437
+ dashboardComponent.borderWidth,
438
+ dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
439
+ );
440
+ const size = `${dashboardComponent.loaderSize}px`;
441
+ return {
442
+ "border-top": spinnerColorBorder,
443
+ "border-right": spinnerColorBorder,
444
+ "border-bottom": spinnerBackgroundBorder,
445
+ "border-left": spinnerBackgroundBorder,
446
+ width: size,
447
+ height: size
448
+ };
449
+ }
450
+ function lcStyles(dashboardComponent) {
451
+ const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
452
+ const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
453
+ const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
454
+ const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
455
+ return {
456
+ padding: `${verticalPadding} 16px`
457
+ };
458
+ }
459
+ function calculateIframeStyles(dashboardComponent) {
460
+ const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
461
+ const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
462
+ if (dashboardComponent.params.itemEmbedding && height !== "auto") {
463
+ dashboardComponent.iframeHeight = `${height}px`;
464
+ } else if (dashboardComponent.params.itemEmbedding) {
465
+ dashboardComponent.iframeHeight = "200px";
466
+ } else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
467
+ dashboardComponent.iframeHeight = "100%";
468
+ } else {
469
+ dashboardComponent.iframeHeight = "400px";
470
+ }
471
+ dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
472
+ const styles = {
473
+ height: dashboardComponent.iframeHeight,
474
+ width: dashboardComponent.iframeWidth
475
+ };
476
+ if (dashboardComponent.iframeLoaded) {
477
+ styles.opacity = 1;
478
+ } else if (dashboardComponent.error) {
479
+ styles.opacity = 1;
480
+ styles.width = "100%";
481
+ styles.height = "400px";
482
+ } else {
483
+ styles.opacity = 0;
484
+ }
485
+ return styles;
486
+ }
487
+ function generateBorderStyle(borderWidth, color) {
488
+ return `${borderWidth}px solid ${color}`;
489
+ }
490
+
491
+ // libs/embed-libs/shared-embed/src/lib/helpers/update-iframe-url.ts
492
+ var updateIframeUrl = (iframe, iframeUrl) => {
493
+ if (iframe?.contentWindow) {
494
+ iframe.contentWindow.location.replace(iframeUrl);
495
+ }
496
+ };
497
+
498
+ // libs/embed-libs/shared-embed/src/lib/methods/export-dashboard.ts
499
+ var exportDashboard = (dashboardComponent, iframe, format) => {
500
+ const requestId = uuidv4();
501
+ if (iframe?.contentWindow) {
502
+ iframe.contentWindow.postMessage(
503
+ {
504
+ action: "exportDashboard",
505
+ format: format || "png",
506
+ _version: dashboardComponent.VERSION,
507
+ requestId
508
+ },
509
+ "*"
510
+ );
511
+ return new Promise((resolve, reject) => {
512
+ dashboardComponent.promises[requestId] = { resolve, reject };
513
+ setTimeout(() => {
514
+ if (dashboardComponent.promises[requestId]) {
515
+ const errorMessage = "exportDashboard request timed out.";
516
+ dashboardComponent.promises[requestId].reject(
517
+ new Error(errorMessage)
518
+ );
519
+ delete dashboardComponent.promises[requestId];
520
+ }
521
+ }, 12e5);
522
+ });
523
+ }
524
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
525
+ };
526
+
527
+ // libs/embed-libs/shared-embed/src/lib/methods/get-accessible-dashboards.ts
528
+ var getAccessibleDashboards = (dashboardComponent, iframe) => {
529
+ if ((dashboardComponent.dashboardId || dashboardComponent.dashboardSlug) && iframe?.contentWindow) {
530
+ const requestId = uuidv4();
531
+ iframe.contentWindow.postMessage(
532
+ {
533
+ action: "getAccessibleDashboards",
534
+ _version: dashboardComponent.VERSION,
535
+ requestId
536
+ },
537
+ "*"
538
+ );
539
+ return new Promise((resolve, reject) => {
540
+ dashboardComponent.promises[requestId] = { resolve, reject };
541
+ setTimeout(() => {
542
+ if (dashboardComponent.promises[requestId]) {
543
+ const errorMessage = "getAccessibleDashboards request timed out.";
544
+ dashboardComponent.promises[requestId].reject(
545
+ new Error(errorMessage)
546
+ );
547
+ delete dashboardComponent.promises[requestId];
548
+ }
549
+ }, 2e3);
550
+ });
551
+ }
552
+ const fetchUser = new Promise((resolve, reject) => {
553
+ void (() => {
554
+ try {
555
+ const responsePromise = window.fetch(
556
+ `${String(dashboardComponent.params.apiHost)}0.1.0/authorization`,
557
+ {
558
+ method: "POST",
559
+ mode: "cors",
560
+ cache: "no-cache",
561
+ headers: { "Content-Type": "application/json" },
562
+ redirect: "follow",
563
+ body: JSON.stringify({
564
+ action: "get",
565
+ version: "0.1.0",
566
+ key: dashboardComponent.authKey,
567
+ token: dashboardComponent.authToken,
568
+ find: {
569
+ where: { id: dashboardComponent.authKey },
570
+ attributes: ["id", "integration_id"],
571
+ include: [
572
+ {
573
+ model: "User",
574
+ attributes: ["id", "name", "locale_id"],
575
+ include: [{ model: "Group" }]
576
+ }
577
+ ]
578
+ }
579
+ })
580
+ }
581
+ );
582
+ responsePromise.then((response) => response.json()).then((data) => {
583
+ if (!data || !data.rows || data.rows.length === 0 || !data.rows[0].user || !data.rows[0].integration_id) {
584
+ reject();
585
+ } else {
586
+ data.rows[0].user.userGroups = data.rows[0].user.groups.map(
587
+ (group) => group.id
588
+ );
589
+ delete data.rows[0].user.groups;
590
+ resolve({
591
+ integrationId: data.rows[0].integration_id,
592
+ user: data.rows[0].user
593
+ });
594
+ }
595
+ });
596
+ } catch (error) {
597
+ reject(error);
598
+ }
599
+ })();
600
+ });
601
+ return new Promise((resolve, reject) => void (() => {
602
+ try {
603
+ fetchUser.then((authorizationData) => {
604
+ const responsePromise = window.fetch(
605
+ `${String(dashboardComponent.params.apiHost)}0.1.0/securable`,
606
+ {
607
+ method: "POST",
608
+ mode: "cors",
609
+ cache: "no-cache",
610
+ headers: { "Content-Type": "application/json" },
611
+ redirect: "follow",
612
+ body: JSON.stringify({
613
+ action: "get",
614
+ version: "0.1.0",
615
+ key: dashboardComponent.authKey,
616
+ token: dashboardComponent.authToken,
617
+ find: {
618
+ where: { type: "dashboard", is_variant: false },
619
+ attributes: ["id", "name", "modified_at"],
620
+ order: [["modified_at", "desc"]],
621
+ include: [
622
+ { model: "Tag", attributes: ["tag"] },
623
+ { model: "User", attributes: ["id", "name"] },
624
+ {
625
+ model: "Group",
626
+ attributes: ["id", "name", "public"]
627
+ },
628
+ { model: "Integration", attributes: ["id", "name"] }
629
+ ]
630
+ }
631
+ })
632
+ }
633
+ );
634
+ responsePromise.then((response) => response.json()).then((data) => {
635
+ const dashboardList = data.rows.length > 0 ? formatDashboardList(
636
+ data.rows,
637
+ authorizationData.integrationId,
638
+ authorizationData.user,
639
+ dashboardComponent
640
+ ) : [];
641
+ resolve(dashboardList);
642
+ });
643
+ }).catch((error) => {
644
+ reject(error);
645
+ });
646
+ } catch (error) {
647
+ reject(error);
648
+ }
649
+ })());
650
+ };
651
+
652
+ // libs/embed-libs/shared-embed/src/lib/methods/get-data.ts
653
+ var getData = (dashboardComponent, iframe, itemId) => {
654
+ if (iframe?.contentWindow) {
655
+ const requestId = uuidv4();
656
+ iframe.contentWindow.postMessage(
657
+ {
658
+ action: "getData",
659
+ id: itemId,
660
+ _version: dashboardComponent.VERSION,
661
+ requestId
662
+ },
663
+ "*"
664
+ );
665
+ return new Promise((resolve, reject) => {
666
+ dashboardComponent.promises[requestId] = { resolve, reject };
667
+ setTimeout(() => {
668
+ if (dashboardComponent.promises[requestId]) {
669
+ const errorMessage = "getData request timed out.";
670
+ dashboardComponent.promises[requestId].reject(
671
+ new Error(errorMessage)
672
+ );
673
+ delete dashboardComponent.promises[requestId];
674
+ }
675
+ }, 2e3);
676
+ });
677
+ }
678
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
679
+ };
680
+
681
+ // libs/embed-libs/shared-embed/src/lib/methods/get-filters.ts
682
+ var getFilters = (dashboardComponent, iframe) => {
683
+ if (iframe?.contentWindow) {
684
+ const requestId = uuidv4();
685
+ iframe.contentWindow.postMessage(
686
+ { action: "getFilters", _version: dashboardComponent.VERSION, requestId },
687
+ "*"
688
+ );
689
+ return new Promise((resolve, reject) => {
690
+ dashboardComponent.promises[requestId] = { resolve, reject };
691
+ setTimeout(() => {
692
+ if (dashboardComponent.promises[requestId]) {
693
+ const errorMessage = "getFilters request timed out.";
694
+ dashboardComponent.promises[requestId].reject(
695
+ new Error(errorMessage)
696
+ );
697
+ delete dashboardComponent.promises[requestId];
698
+ }
699
+ }, 2e3);
700
+ });
701
+ }
702
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
703
+ };
704
+
705
+ // libs/embed-libs/shared-embed/src/lib/methods/refresh-data.ts
706
+ var refreshData = (dashboardComponent, iframe, itemId) => {
707
+ if (iframe) {
708
+ iframe.contentWindow.postMessage(
709
+ {
710
+ action: "refreshData",
711
+ id: itemId ?? null,
712
+ _version: dashboardComponent.VERSION
713
+ },
714
+ "*"
715
+ );
716
+ return Promise.resolve();
717
+ }
718
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
719
+ };
720
+
721
+ // libs/embed-libs/shared-embed/src/lib/methods/reload-dashboard.ts
722
+ var reloadDashboard = (dashboardComponent, iframe) => {
723
+ if (iframe) {
724
+ iframe.contentWindow.postMessage(
725
+ { action: "reloadDashboard", _version: dashboardComponent.VERSION },
726
+ "*"
727
+ );
728
+ return Promise.resolve();
729
+ }
730
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
731
+ };
732
+
733
+ // libs/embed-libs/shared-embed/src/lib/methods/set-authorization.ts
734
+ var setAuthorization = (dashboardComponent, iframe, key, token) => {
735
+ if (iframe) {
736
+ iframe.contentWindow.postMessage(
737
+ {
738
+ action: "setAuthorization",
739
+ key,
740
+ token,
741
+ _version: dashboardComponent.VERSION
742
+ },
743
+ "*"
744
+ );
745
+ return Promise.resolve();
746
+ }
747
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
748
+ };
749
+
750
+ // libs/embed-libs/shared-embed/src/lib/methods/set-edit-mode.ts
751
+ var setEditMode = (dashboardComponent, iframe, editMode) => {
752
+ if (iframe && iframe.contentWindow) {
753
+ const requestId = uuidv4();
754
+ if (dashboardComponent.params.editMode === editMode) {
755
+ return Promise.reject(
756
+ new Error("editMode parameter is currently already set to " + editMode)
757
+ );
758
+ } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
759
+ return Promise.reject(
760
+ new Error(
761
+ "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
762
+ )
763
+ );
764
+ }
765
+ iframe.contentWindow.postMessage(
766
+ {
767
+ action: "setEditMode",
768
+ editMode,
769
+ _version: dashboardComponent.VERSION,
770
+ requestId
771
+ },
772
+ "*"
773
+ );
774
+ return new Promise((resolve, reject) => {
775
+ dashboardComponent.promises[requestId] = { resolve, reject };
776
+ });
777
+ }
778
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
779
+ };
780
+
781
+ // libs/embed-libs/shared-embed/src/lib/methods/set-filters.ts
782
+ var setFilters = (dashboardComponent, iframe, itemId, filters) => {
783
+ if (iframe) {
784
+ const requestId = uuidv4();
785
+ iframe.contentWindow.postMessage(
786
+ {
787
+ action: "setFilters",
788
+ itemId,
789
+ filters,
790
+ _version: dashboardComponent.VERSION,
791
+ requestId
792
+ },
793
+ "*"
794
+ );
795
+ return new Promise((resolve, reject) => {
796
+ dashboardComponent.promises[requestId] = { resolve, reject };
797
+ setTimeout(() => {
798
+ if (dashboardComponent.promises[requestId]) {
799
+ const errorMessage = "setFilters request timed out.";
800
+ dashboardComponent.promises[requestId].reject(
801
+ new Error(errorMessage)
802
+ );
803
+ delete dashboardComponent.promises[requestId];
804
+ }
805
+ }, 2e3);
806
+ });
807
+ }
808
+ return Promise.reject();
809
+ };
810
+
811
+ // libs/embed-libs/shared-embed/src/lib/methods/set-preview.ts
812
+ var setPreview = (dashboardComponent, iframe, preview) => {
813
+ if (iframe) {
814
+ const requestId = uuidv4();
815
+ iframe.contentWindow.postMessage(
816
+ {
817
+ action: "setPreview",
818
+ preview,
819
+ requestId,
820
+ _version: dashboardComponent.VERSION
821
+ },
822
+ "*"
823
+ );
824
+ return new Promise((resolve, reject) => {
825
+ dashboardComponent.promises[requestId] = { resolve, reject };
826
+ setTimeout(() => {
827
+ if (dashboardComponent.promises[requestId]) {
828
+ const errorMessage = "setPreview request timed out.";
829
+ dashboardComponent.promises[requestId].reject(
830
+ new Error(errorMessage)
831
+ );
832
+ delete dashboardComponent.promises[requestId];
833
+ }
834
+ }, 2e3);
835
+ });
836
+ }
837
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
838
+ };
839
+
840
+ // libs/embed-libs/shared-embed/src/lib/service/calculate-dimensions.ts
841
+ var _setCalculatedDimensions = (dashboardComponent) => {
842
+ if (!dashboardComponent.dimensions) {
843
+ dashboardComponent.params.error = true;
844
+ _handleError("Got no valid dimensions.", dashboardComponent.params);
845
+ return;
846
+ }
847
+ const dashboardDimensionKeys = Object.keys(
848
+ dashboardComponent.dimensions
849
+ );
850
+ const availableScreenModeExtents = [];
851
+ let currentMode;
852
+ let currentWidth = 0;
853
+ let currentHeight = 0;
854
+ if (!dashboardComponent.params.switchScreenModeOnResize && dashboardComponent.currentScreenMode) {
855
+ dashboardComponent.params.screenMode = dashboardComponent.currentScreenMode;
856
+ }
857
+ if (dashboardComponent.dimensions && dashboardDimensionKeys?.[0] === "fixed") {
858
+ currentMode = "fixed";
859
+ currentWidth = dashboardComponent.dimensions.fixed[0];
860
+ currentHeight = dashboardComponent.dimensions.fixed[1];
861
+ } else {
862
+ const screenModes = [
863
+ "mobile",
864
+ "tablet",
865
+ "desktop",
866
+ "largeScreen"
867
+ ];
868
+ if (dashboardComponent.params.itemEmbedding) {
869
+ const [firstMatch] = dashboardDimensionKeys;
870
+ let match = cloneDeep(firstMatch);
871
+ for (const screenMode of screenModes) {
872
+ const found = dashboardDimensionKeys.find((key) => key === screenMode);
873
+ if (found) {
874
+ match = cloneDeep(found);
875
+ } else {
876
+ dashboardComponent.dimensions[screenMode] = dashboardComponent.dimensions[match];
877
+ }
878
+ }
879
+ }
880
+ for (const key of dashboardDimensionKeys) {
881
+ if (screenModes.includes(key)) {
882
+ const screenMode = EXTENTS.find((extent) => extent.mode === key);
883
+ availableScreenModeExtents.push({
884
+ ...screenMode,
885
+ height: dashboardComponent.dimensions[key][1] || 50
886
+ });
887
+ }
888
+ }
889
+ if (!availableScreenModeExtents.map((screenModeExtent) => screenModeExtent.mode).includes(dashboardComponent.params.screenMode)) {
890
+ dashboardComponent.params.screenMode = "auto";
891
+ }
892
+ if (dashboardComponent.params.screenMode === "auto") {
893
+ availableScreenModeExtents.sort(
894
+ (a, b) => screenModes.indexOf(a.mode) - screenModes.indexOf(b.mode)
895
+ );
896
+ for (const screenModeExtent of availableScreenModeExtents) {
897
+ const [screenModeExtentMinWidth, screenModeExtentMaxWidth] = screenModeExtent.width;
898
+ if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
899
+ if (screenModeExtentMinWidth < dashboardComponent.params.itemDimensions.width) {
900
+ currentMode = screenModeExtent.mode;
901
+ currentWidth = Number.parseInt(
902
+ dashboardComponent.params.itemDimensions.width,
903
+ 10
904
+ );
905
+ currentHeight = dashboardComponent.dimensions[currentMode][1];
906
+ }
907
+ } else {
908
+ if (screenModeExtentMinWidth < dashboardComponent.containerWidth) {
909
+ currentMode = screenModeExtent.mode;
910
+ if (dashboardComponent.params.itemEmbedding) {
911
+ currentWidth = dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto" ? Number.parseInt(
912
+ dashboardComponent.params.itemDimensions.width,
913
+ 10
914
+ ) : Math.min(
915
+ dashboardComponent.containerWidth,
916
+ screenModeExtentMaxWidth
917
+ );
918
+ currentHeight = dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto" ? Number.parseInt(
919
+ dashboardComponent.params.itemDimensions.height,
920
+ 10
921
+ ) : dashboardComponent.dimensions[currentMode][1];
922
+ if (dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
923
+ currentWidth = Number.parseInt(
924
+ dashboardComponent.params.itemDimensions.width,
925
+ 10
926
+ );
927
+ currentHeight = dashboardComponent.dimensions[currentMode][1];
928
+ }
929
+ } else {
930
+ currentWidth = Math.max(
931
+ Math.min(
932
+ screenModeExtentMaxWidth,
933
+ dashboardComponent.containerWidth
934
+ ),
935
+ screenModeExtentMinWidth
936
+ );
937
+ currentHeight = screenModeExtent.height;
938
+ }
939
+ }
940
+ }
941
+ }
942
+ } else {
943
+ const {
944
+ height: chosenModeHeight,
945
+ width: [chosenModeMinWidth, chosenModeMaxWidth]
946
+ } = availableScreenModeExtents.find(
947
+ (d) => d.mode === dashboardComponent.params.screenMode
948
+ );
949
+ currentMode = dashboardComponent.params.screenMode;
950
+ currentWidth = Math.max(
951
+ Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
952
+ chosenModeMinWidth
953
+ );
954
+ currentHeight = chosenModeHeight;
955
+ if (dashboardComponent.params.itemEmbedding) {
956
+ if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
957
+ currentWidth = Number.parseInt(
958
+ dashboardComponent.params.itemDimensions.width,
959
+ 10
960
+ );
961
+ }
962
+ if (dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto") {
963
+ currentHeight = Number.parseInt(
964
+ dashboardComponent.params.itemDimensions.height,
965
+ 10
966
+ );
967
+ }
968
+ }
969
+ }
970
+ if (!currentMode && availableScreenModeExtents.length > 0) {
971
+ const [lowestModeExtent] = availableScreenModeExtents;
972
+ currentMode = lowestModeExtent.mode;
973
+ currentWidth = lowestModeExtent.width[0];
974
+ currentHeight = lowestModeExtent.height;
975
+ }
976
+ }
977
+ dashboardComponent.currentScreenMode = currentMode;
978
+ const style = {
979
+ height: currentHeight === 0 ? "100%" : `${String(currentHeight)}px`,
980
+ width: currentWidth === 0 ? "100%" : `${String(currentWidth)}px`,
981
+ opacity: 1
982
+ };
983
+ const dashboardEditModes = ["editFull", "editLimited"];
984
+ if (dashboardEditModes.includes(dashboardComponent.params.editMode)) {
985
+ style.height = "100%";
986
+ style.width = "100%";
987
+ } else if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions) {
988
+ style.height = dashboardComponent.params.itemDimensions.height === "auto" ? style.height : `${String(dashboardComponent.params.itemDimensions.height).replace(
989
+ "px",
990
+ ""
991
+ )}px`;
992
+ style.width = dashboardComponent.params.itemDimensions.width === "auto" ? style.width : `${String(dashboardComponent.params.itemDimensions.width).replace(
993
+ "px",
994
+ ""
995
+ )}px`;
996
+ } else {
997
+ style.height = currentHeight === 0 ? "100%" : `${String(currentHeight)}px`;
998
+ style.width = currentWidth === 0 ? "100%" : `${String(currentWidth)}px`;
999
+ }
1000
+ dashboardComponent.currentScreenMode = currentMode;
1001
+ dashboardComponent.iframeStyle = style;
1002
+ };
1003
+
1004
+ // libs/embed-libs/shared-embed/src/lib/service/extend-and-validate.ts
1005
+ var _extendAndValidate = (dashboardContent) => {
1006
+ const defaultKeys = Object.keys(
1007
+ DEFAULT_PARAMETERS
1008
+ );
1009
+ const errorMessages = [];
1010
+ const requiredStringParams = [
1011
+ "appServer",
1012
+ "language",
1013
+ "apiHost"
1014
+ ];
1015
+ const requiredStringOrEmptyParams = [
1016
+ "key",
1017
+ "token",
1018
+ "screenMode",
1019
+ "timezoneId",
1020
+ "itemId",
1021
+ "container",
1022
+ "loaderBackground",
1023
+ "loaderFontColor",
1024
+ "loaderSpinnerColor",
1025
+ "loaderSpinnerBackground"
1026
+ ];
1027
+ const objectParams = ["itemDimensions"];
1028
+ const screenModes = [
1029
+ "mobile",
1030
+ "tablet",
1031
+ "desktop",
1032
+ "largeScreen",
1033
+ "fixed",
1034
+ "auto"
1035
+ ];
1036
+ for (const key of defaultKeys) {
1037
+ if (dashboardContent.params[key] === null) {
1038
+ delete dashboardContent.params[key];
1039
+ }
1040
+ }
1041
+ dashboardContent.params = defaultsDeep(
1042
+ dashboardContent.params,
1043
+ DEFAULT_PARAMETERS
1044
+ );
1045
+ if ((!dashboardContent.params.dashboardId || typeof dashboardContent.params.dashboardId !== "string") && (!dashboardContent.params.dashboardSlug || typeof dashboardContent.params.dashboardSlug !== "string")) {
1046
+ delete dashboardContent.params.dashboardId;
1047
+ delete dashboardContent.params.dashboardSlug;
1048
+ }
1049
+ for (const key of requiredStringParams) {
1050
+ if (typeof dashboardContent.params[key] !== "string") {
1051
+ delete dashboardContent.params[key];
1052
+ errorMessages.push(`${key} needs to be of type string.`);
1053
+ }
1054
+ }
1055
+ for (const key of requiredStringOrEmptyParams) {
1056
+ if (typeof dashboardContent.params[key] !== "string" && dashboardContent.params[key] !== null && dashboardContent.params[key] !== void 0) {
1057
+ delete dashboardContent.params[key];
1058
+ errorMessages.push(`${key} needs to be of type string or empty.`);
1059
+ }
1060
+ }
1061
+ if (dashboardContent.params.screenMode && !screenModes.includes(dashboardContent.params.screenMode)) {
1062
+ const validTypesString = screenModes.map((mode) => `"${mode}"`).join(", ");
1063
+ errorMessages.push(
1064
+ `"screenMode" needs should be one of these types: ${validTypesString}`
1065
+ );
1066
+ dashboardContent.params.screenMode = "auto";
1067
+ }
1068
+ if (dashboardContent.params.itemId) {
1069
+ dashboardContent.params.itemEmbedding = true;
1070
+ }
1071
+ for (const key of objectParams) {
1072
+ if (typeof dashboardContent.params[key] !== "object" && dashboardContent.params[key] !== null) {
1073
+ delete dashboardContent.params[key];
1074
+ errorMessages.push(`${key} needs to be of type object or empty.`);
1075
+ }
1076
+ }
1077
+ if (typeof dashboardContent.params.switchScreenModeOnResize !== "boolean") {
1078
+ errorMessages.push("switchScreenModeOnResize needs to be of type boolean.");
1079
+ dashboardContent.params.switchScreenModeOnResize = true;
1080
+ }
1081
+ if (dashboardContent.params.itemDimensions) {
1082
+ const itemDimensionsKeys = [
1083
+ "width",
1084
+ "height"
1085
+ ];
1086
+ for (const key of itemDimensionsKeys) {
1087
+ if (!["string", "number"].includes(
1088
+ typeof dashboardContent.params.itemDimensions[key]
1089
+ ) && dashboardContent.params.itemDimensions[key] !== null) {
1090
+ errorMessages.push(
1091
+ `itemDimensions ${key} needs to be of type string, number or empty.`
1092
+ );
1093
+ }
1094
+ }
1095
+ }
1096
+ dashboardContent.params = defaultsDeep(
1097
+ dashboardContent.params,
1098
+ DEFAULT_PARAMETERS
1099
+ );
1100
+ if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
1101
+ dashboardContent.params.switchScreenModeOnResize = false;
1102
+ }
1103
+ if (dashboardContent.params.itemDimensions.width !== "auto") {
1104
+ dashboardContent.params.itemDimensions.width = Number.parseInt(
1105
+ `${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
1106
+ 10
1107
+ ) || "auto";
1108
+ }
1109
+ if (dashboardContent.params.itemDimensions.height !== "auto") {
1110
+ dashboardContent.params.itemDimensions.height = Number.parseInt(
1111
+ `${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
1112
+ 10
1113
+ ) || "auto";
1114
+ }
1115
+ dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
1116
+ if (dashboardContent.params.error || errorMessages.length > 0) {
1117
+ _handleError(errorMessages.join("\n"), dashboardContent.params);
1118
+ }
1119
+ };
1120
+
1121
+ // libs/embed-libs/shared-embed/src/lib/helpers/remote-federation.ts
1122
+ var remotesMap = {
1123
+ // "remote_app": { url: "http://localhost:4201/remoteEntry.mjs", format: "esm", from: "vite" },
1124
+ };
1125
+ var loadJS = async (url, fn) => {
1126
+ const resolvedUrl = typeof url === "function" ? await url() : url;
1127
+ const script = document.createElement("script");
1128
+ script.type = "text/javascript";
1129
+ script.addEventListener("load", fn);
1130
+ script.src = resolvedUrl;
1131
+ document.querySelectorAll("head")[0].append(script);
1132
+ };
1133
+ var wrapShareModule = (remoteFrom) => ({});
1134
+ async function __federationMethodEnsure(remoteId) {
1135
+ const remote = remotesMap[remoteId];
1136
+ if (remote.inited) {
1137
+ return remote.lib;
1138
+ }
1139
+ if (remote.format === "var") {
1140
+ return new Promise((resolve) => {
1141
+ const callback = () => {
1142
+ if (!remote.inited) {
1143
+ remote.lib = window[remoteId];
1144
+ remote.lib.init(wrapShareModule(remote.from));
1145
+ remote.inited = true;
1146
+ }
1147
+ resolve(remote.lib);
1148
+ };
1149
+ return loadJS(remote.url, callback);
1150
+ });
1151
+ } else if (["esm", "systemjs"].includes(remote.format)) {
1152
+ return new Promise((resolve, reject) => {
1153
+ const getUrl = typeof remote.url === "function" ? remote.url : () => Promise.resolve(remote.url);
1154
+ getUrl().then((url) => {
1155
+ import(
1156
+ /* @vite-ignore */
1157
+ /* webpackIgnore: true */
1158
+ url
1159
+ ).then((lib) => {
1160
+ if (!remote.inited) {
1161
+ const shareScope = wrapShareModule(remote.from);
1162
+ lib.init(shareScope);
1163
+ remote.lib = lib;
1164
+ remote.lib.init(shareScope);
1165
+ remote.inited = true;
1166
+ }
1167
+ resolve(remote.lib);
1168
+ }).catch(reject);
1169
+ });
1170
+ });
1171
+ }
1172
+ }
1173
+ function __federationMethodWrapDefault(module, need) {
1174
+ if (!(module == null ? void 0 : module.default) && need) {
1175
+ const obj = /* @__PURE__ */ Object.create(null);
1176
+ obj.default = module;
1177
+ obj.__esModule = true;
1178
+ return obj;
1179
+ }
1180
+ return module;
1181
+ }
1182
+ async function __federationMethodGetRemote(remoteName, componentName) {
1183
+ return __federationMethodEnsure(remoteName).then((remote) => remote.get(componentName).then((factory) => factory()));
1184
+ }
1185
+
13
1186
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
14
- import * as SharedLib2 from "@luzmo/shared-embed";
15
1187
  import {
16
1188
  html,
17
1189
  LitElement
@@ -25,14 +1197,9 @@ import {
25
1197
  import {
26
1198
  styleMap
27
1199
  } from "lit/directives/style-map.js";
28
- import {
29
- __federationMethodGetRemote,
30
- __federationMethodWrapDefault,
31
- remotesMap
32
- } from "@luzmo/shared-embed";
33
1200
 
34
1201
  // libs/embed-libs/embed/package.json
35
- var version = "5.0.6";
1202
+ var version = "5.0.7";
36
1203
 
37
1204
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
38
1205
  var LuzmoService = class {
@@ -43,7 +1210,6 @@ var LuzmoService = class {
43
1210
  var luzmo_service_default = new LuzmoService();
44
1211
 
45
1212
  // libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
46
- import * as SharedLib from "@luzmo/shared-embed";
47
1213
  var _setEventHandler = () => {
48
1214
  if (typeof window.__luzmoMessageHandler === "function") {
49
1215
  return;
@@ -80,7 +1246,7 @@ var _setEventHandler = () => {
80
1246
  break;
81
1247
  }
82
1248
  case "data": {
83
- SharedLib.resolvePromise(
1249
+ resolvePromise(
84
1250
  dashboardComponent,
85
1251
  event.data.requestId,
86
1252
  event.data.data
@@ -88,7 +1254,7 @@ var _setEventHandler = () => {
88
1254
  break;
89
1255
  }
90
1256
  case "filters": {
91
- SharedLib.resolvePromise(
1257
+ resolvePromise(
92
1258
  dashboardComponent,
93
1259
  event.data.requestId,
94
1260
  event.data.filters
@@ -96,7 +1262,7 @@ var _setEventHandler = () => {
96
1262
  break;
97
1263
  }
98
1264
  case "getAccessibleDashboards": {
99
- SharedLib.resolvePromise(
1265
+ resolvePromise(
100
1266
  dashboardComponent,
101
1267
  event.data.requestId,
102
1268
  event.data.accessibleDashboards
@@ -111,7 +1277,7 @@ var _setEventHandler = () => {
111
1277
  }
112
1278
  case "export": {
113
1279
  if (event.data.error) {
114
- SharedLib.rejectPromise(
1280
+ rejectPromise(
115
1281
  dashboardComponent,
116
1282
  event.data.requestId,
117
1283
  event.data
@@ -120,7 +1286,7 @@ var _setEventHandler = () => {
120
1286
  dashboardComponent.dispatchEvent(
121
1287
  new CustomEvent("exported", { detail: { data: event.data } })
122
1288
  );
123
- SharedLib.resolvePromise(
1289
+ resolvePromise(
124
1290
  dashboardComponent,
125
1291
  event.data.requestId,
126
1292
  event.data
@@ -150,31 +1316,31 @@ var _setEventHandler = () => {
150
1316
  }
151
1317
  case "setEditMode": {
152
1318
  if (event.data.error) {
153
- SharedLib.rejectPromise(
1319
+ rejectPromise(
154
1320
  dashboardComponent,
155
1321
  event.data.requestId,
156
1322
  event.data
157
1323
  );
158
1324
  } else {
159
- SharedLib.resolvePromise(
1325
+ resolvePromise(
160
1326
  dashboardComponent,
161
1327
  event.data.requestId,
162
1328
  event.data
163
1329
  );
164
1330
  dashboardComponent.params.editMode = event.data.editMode;
165
- dashboardComponent._containerStyle = SharedLib.containerStyles(dashboardComponent);
1331
+ dashboardComponent._containerStyle = containerStyles(dashboardComponent);
166
1332
  if (dashboardComponent.dimensions) {
167
- SharedLib._setCalculatedDimensions(dashboardComponent);
1333
+ _setCalculatedDimensions(dashboardComponent);
168
1334
  }
169
1335
  }
170
1336
  break;
171
1337
  }
172
1338
  case "setFilters": {
173
- event.data.error ? SharedLib.rejectPromise(
1339
+ event.data.error ? rejectPromise(
174
1340
  dashboardComponent,
175
1341
  event.data.requestId,
176
1342
  event.data
177
- ) : SharedLib.resolvePromise(
1343
+ ) : resolvePromise(
178
1344
  dashboardComponent,
179
1345
  event.data.requestId,
180
1346
  event.data
@@ -182,11 +1348,11 @@ var _setEventHandler = () => {
182
1348
  break;
183
1349
  }
184
1350
  case "setPreview": {
185
- event.data.error ? SharedLib.rejectPromise(
1351
+ event.data.error ? rejectPromise(
186
1352
  dashboardComponent,
187
1353
  event.data.requestId,
188
1354
  event.data
189
- ) : SharedLib.resolvePromise(
1355
+ ) : resolvePromise(
190
1356
  dashboardComponent,
191
1357
  event.data.requestId,
192
1358
  event.data
@@ -350,7 +1516,7 @@ var LuzmoDashboard = class extends LitElement {
350
1516
  this.loaderSize = 32;
351
1517
  this.borderWidth = 3;
352
1518
  this.minHeight = 400;
353
- this._containerId = SharedLib2.uuidv4();
1519
+ this._containerId = uuidv4();
354
1520
  this._iframeId = `luzmo-dashboard-${this._containerId}`;
355
1521
  this.iframeLoaded = false;
356
1522
  this.promises = {};
@@ -360,7 +1526,7 @@ var LuzmoDashboard = class extends LitElement {
360
1526
  if (this.shadowRoot?.querySelector(".dashboard-container")) {
361
1527
  this.containerWidth = this.container.clientWidth;
362
1528
  if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
363
- for (const d of SharedLib2.EXTENTS) {
1529
+ for (const d of EXTENTS) {
364
1530
  if (d.width[0] <= window.innerWidth && window.innerWidth <= d.width[1]) {
365
1531
  this.currentScreenMode = d.mode;
366
1532
  }
@@ -384,7 +1550,7 @@ var LuzmoDashboard = class extends LitElement {
384
1550
  if (remotesMap[appServer]) {
385
1551
  return Promise.resolve(remotesMap[appServer].module);
386
1552
  }
387
- remotesMap[appServer] = { url: appServer?.startsWith("http://localhost") ? `${SharedLib2.removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${SharedLib2.removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`, format: "esm", from: "vite", module: void 0 };
1553
+ remotesMap[appServer] = { url: appServer?.startsWith("http://localhost") ? `${removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`, format: "esm", from: "vite", module: void 0 };
388
1554
  return __federationMethodGetRemote(appServer, "./DashboardApp").then((module) => {
389
1555
  const wrappedModule = __federationMethodWrapDefault(module, true);
390
1556
  remotesMap[appServer].module = wrappedModule;
@@ -426,7 +1592,7 @@ var LuzmoDashboard = class extends LitElement {
426
1592
  this.experimental = inputParameters.experimental;
427
1593
  }
428
1594
  if (inputParameters.appServer) {
429
- this.appServer = SharedLib2.addTrailingSlash(inputParameters.appServer);
1595
+ this.appServer = addTrailingSlash(inputParameters.appServer);
430
1596
  }
431
1597
  }
432
1598
  // Set resize event listener
@@ -444,7 +1610,7 @@ var LuzmoDashboard = class extends LitElement {
444
1610
  }
445
1611
  }
446
1612
  firstUpdated() {
447
- this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
1613
+ this._loaderMsg = getLoader(this)?.loadingMsg;
448
1614
  this._loaderStyles();
449
1615
  luzmo_service_default._components.push(this);
450
1616
  this.initComponent();
@@ -458,7 +1624,14 @@ var LuzmoDashboard = class extends LitElement {
458
1624
  const oldReference = this.renderRoot.querySelector("dashboard-component");
459
1625
  this.dashboardReference = oldReference.cloneNode(true);
460
1626
  oldReference.replaceWith(this.dashboardReference);
461
- this.dashboardReference.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload.detail)));
1627
+ this.dashboardReference.addEventListener("load", (payload) => {
1628
+ setTimeout(() => {
1629
+ this.containerWidth = this.dashboardReference.offsetWidth;
1630
+ this.dimensions = payload.detail.dimensions;
1631
+ _setCalculatedDimensions(this);
1632
+ this.dispatchEvent(new CustomEvent("load", payload.detail));
1633
+ });
1634
+ });
462
1635
  this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload.detail)));
463
1636
  this.dashboardReference.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload.detail)));
464
1637
  this.dashboardReference.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload.detail)));
@@ -468,15 +1641,15 @@ var LuzmoDashboard = class extends LitElement {
468
1641
  });
469
1642
  } else {
470
1643
  this.containerWidth = this.container?.clientWidth;
471
- SharedLib2._extendAndValidate(this);
472
- SharedLib2._browserCheck(this);
1644
+ _extendAndValidate(this);
1645
+ _browserCheck(this);
473
1646
  this._setupLoader();
474
1647
  if (!this.params.error) {
475
1648
  this._loaderStyles();
476
1649
  _setEventHandler();
477
- this._iframeUrl = SharedLib2.createIframeUrl(this);
1650
+ this._iframeUrl = createIframeUrl(this);
478
1651
  this.iframe?.setAttribute("src", this._iframeUrl);
479
- this.iframeStyle = SharedLib2.calculateIframeStyles(this);
1652
+ this.iframeStyle = calculateIframeStyles(this);
480
1653
  }
481
1654
  if (this.container) {
482
1655
  this._resizeObserver.observe(this.container);
@@ -493,7 +1666,7 @@ var LuzmoDashboard = class extends LitElement {
493
1666
  this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
494
1667
  }
495
1668
  if (this.params.apiHost) {
496
- this.dashboardReference.setAttribute("api-host", SharedLib2.removeTrailingSlash(this.params.apiHost));
1669
+ this.dashboardReference.setAttribute("api-host", removeTrailingSlash(this.params.apiHost));
497
1670
  }
498
1671
  if (this.params.key) {
499
1672
  this.dashboardReference.setAttribute("auth-key", this.params.key);
@@ -551,14 +1724,14 @@ var LuzmoDashboard = class extends LitElement {
551
1724
  );
552
1725
  }, 15 * 1e3);
553
1726
  this.params = this._setOptions();
554
- SharedLib2._extendAndValidate(this);
1727
+ _extendAndValidate(this);
555
1728
  this._setupLoader();
556
1729
  this._loaderStyles();
557
- this._iframeUrl = SharedLib2.createIframeUrl(this);
1730
+ this._iframeUrl = createIframeUrl(this);
558
1731
  if (this.iframe) {
559
1732
  this._updateIframeUrl();
560
1733
  }
561
- this.iframeStyle = SharedLib2.calculateIframeStyles(this);
1734
+ this.iframeStyle = calculateIframeStyles(this);
562
1735
  } else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
563
1736
  if (this.iframeLoaded) {
564
1737
  this.setEditMode(this.editMode);
@@ -624,16 +1797,16 @@ var LuzmoDashboard = class extends LitElement {
624
1797
  defaultParameters.itemDimensions = this.itemDimensions;
625
1798
  }
626
1799
  if (this.appServer) {
627
- this.appServer = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.appServer) : SharedLib2.addTrailingSlash(this.appServer);
1800
+ this.appServer = this.getIsViewMode() ? removeTrailingSlash(this.appServer) : addTrailingSlash(this.appServer);
628
1801
  defaultParameters.appServer = this.appServer;
629
1802
  } else {
630
- this.appServer = SharedLib2.addTrailingSlash(
631
- SharedLib2.DEFAULT_PARAMETERS.appServer
1803
+ this.appServer = addTrailingSlash(
1804
+ DEFAULT_PARAMETERS.appServer
632
1805
  );
633
1806
  defaultParameters.appServer = this.appServer;
634
1807
  }
635
1808
  if (this.apiHost) {
636
- this.apiHost = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.apiHost) : SharedLib2.addTrailingSlash(this.apiHost);
1809
+ this.apiHost = this.getIsViewMode() ? removeTrailingSlash(this.apiHost) : addTrailingSlash(this.apiHost);
637
1810
  defaultParameters.apiHost = this.apiHost;
638
1811
  } else {
639
1812
  this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
@@ -642,11 +1815,11 @@ var LuzmoDashboard = class extends LitElement {
642
1815
  return defaultParameters;
643
1816
  }
644
1817
  _updateIframeUrl() {
645
- SharedLib2.updateIframeUrl(this.iframe, this._iframeUrl);
1818
+ updateIframeUrl(this.iframe, this._iframeUrl);
646
1819
  }
647
1820
  // Setup loader / browser error
648
1821
  _setupLoader() {
649
- const data = SharedLib2.getLoader(this);
1822
+ const data = getLoader(this);
650
1823
  this._loaderMsg = data.loadingMsg;
651
1824
  if (data.errorMsg) {
652
1825
  this.browserError = true;
@@ -666,15 +1839,15 @@ var LuzmoDashboard = class extends LitElement {
666
1839
  _calculateDimAfterDashboardLoaded() {
667
1840
  this.dashboardError = false;
668
1841
  this._loaderStyles();
669
- SharedLib2._setCalculatedDimensions(this);
1842
+ _setCalculatedDimensions(this);
670
1843
  }
671
1844
  // Set loader styles
672
1845
  _loaderStyles() {
673
- this._containerStyle = SharedLib2.containerStyles(this);
674
- this._loaderStyle = SharedLib2.loaderStyles(this);
675
- this._loadingCircleStyle = SharedLib2.plStyles(this);
676
- this._containerLoaderStyle = SharedLib2.containerLoaderStyles(this);
677
- this._lcStyle = SharedLib2.lcStyles(this);
1846
+ this._containerStyle = containerStyles(this);
1847
+ this._loaderStyle = loaderStyles(this);
1848
+ this._loadingCircleStyle = plStyles(this);
1849
+ this._containerLoaderStyle = containerLoaderStyles(this);
1850
+ this._lcStyle = lcStyles(this);
678
1851
  }
679
1852
  static get styles() {
680
1853
  return [dashboardStyles];
@@ -767,7 +1940,7 @@ var LuzmoDashboard = class extends LitElement {
767
1940
  return this.dashboardReference.getData(itemId);
768
1941
  }
769
1942
  if (!this.getIsViewMode()) {
770
- return SharedLib2.getData(this, this.iframe, itemId);
1943
+ return getData(this, this.iframe, itemId);
771
1944
  }
772
1945
  return Promise.reject();
773
1946
  }
@@ -776,7 +1949,7 @@ var LuzmoDashboard = class extends LitElement {
776
1949
  return this.dashboardReference.getFilters();
777
1950
  }
778
1951
  if (!this.getIsViewMode()) {
779
- return SharedLib2.getFilters(this, this.iframe);
1952
+ return getFilters(this, this.iframe);
780
1953
  }
781
1954
  return Promise.reject();
782
1955
  }
@@ -785,7 +1958,7 @@ var LuzmoDashboard = class extends LitElement {
785
1958
  return this.dashboardReference.setFilters(itemId, filters);
786
1959
  }
787
1960
  if (!this.getIsViewMode()) {
788
- return SharedLib2.setFilters(this, this.iframe, itemId, filters);
1961
+ return setFilters(this, this.iframe, itemId, filters);
789
1962
  }
790
1963
  return Promise.reject();
791
1964
  }
@@ -794,7 +1967,7 @@ var LuzmoDashboard = class extends LitElement {
794
1967
  return this.dashboardReference.setAuthorization(key, token);
795
1968
  }
796
1969
  if (!this.getIsViewMode()) {
797
- return SharedLib2.setAuthorization(this, this.iframe, key, token);
1970
+ return setAuthorization(this, this.iframe, key, token);
798
1971
  }
799
1972
  return Promise.reject();
800
1973
  }
@@ -803,7 +1976,7 @@ var LuzmoDashboard = class extends LitElement {
803
1976
  return this.dashboardReference.refreshData(itemId);
804
1977
  }
805
1978
  if (!this.getIsViewMode()) {
806
- return itemId ? SharedLib2.refreshData(this, this.iframe, itemId) : SharedLib2.refreshData(this, this.iframe);
1979
+ return itemId ? refreshData(this, this.iframe, itemId) : refreshData(this, this.iframe);
807
1980
  }
808
1981
  return Promise.reject();
809
1982
  }
@@ -812,7 +1985,7 @@ var LuzmoDashboard = class extends LitElement {
812
1985
  return this.dashboardReference.reloadDashboard();
813
1986
  }
814
1987
  if (!this.getIsViewMode()) {
815
- return SharedLib2.reloadDashboard(this, this.iframe);
1988
+ return reloadDashboard(this, this.iframe);
816
1989
  }
817
1990
  return Promise.reject();
818
1991
  }
@@ -821,13 +1994,13 @@ var LuzmoDashboard = class extends LitElement {
821
1994
  return this.dashboardReference.exportDashboard(format);
822
1995
  }
823
1996
  if (!this.getIsViewMode()) {
824
- return format ? SharedLib2.exportDashboard(this, this.iframe, format) : SharedLib2.exportDashboard(this, this.iframe);
1997
+ return format ? exportDashboard(this, this.iframe, format) : exportDashboard(this, this.iframe);
825
1998
  }
826
1999
  return Promise.reject();
827
2000
  }
828
2001
  getAccessibleDashboards() {
829
2002
  if (!this.getIsViewMode()) {
830
- return SharedLib2.getAccessibleDashboards(this, this.iframe);
2003
+ return getAccessibleDashboards(this, this.iframe);
831
2004
  }
832
2005
  if (this.getIsViewMode() && this.dashboardReference) {
833
2006
  return this.dashboardReference.getAccessibleDashboards();
@@ -860,7 +2033,7 @@ var LuzmoDashboard = class extends LitElement {
860
2033
  return this.dashboardReference.setEditMode(editMode);
861
2034
  }
862
2035
  if (!this.getIsViewMode()) {
863
- return SharedLib2.setEditMode(this, this.iframe, editMode);
2036
+ return setEditMode(this, this.iframe, editMode);
864
2037
  }
865
2038
  return Promise.reject();
866
2039
  }
@@ -868,7 +2041,7 @@ var LuzmoDashboard = class extends LitElement {
868
2041
  if (this.getIsViewMode() && this.dashboardReference) {
869
2042
  return this.dashboardReference.setPreview(preview);
870
2043
  }
871
- return SharedLib2.setPreview(this, this.iframe, preview);
2044
+ return setPreview(this, this.iframe, preview);
872
2045
  }
873
2046
  getIsViewMode() {
874
2047
  if (this.experimental && this.params.editMode === "view" || this.params.editMode === void 0) {