@luzmo/analytics-components-kit 1.0.1-alpha.140 → 1.0.1-alpha.141

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +17 -5
  2. package/angular/components/ai-interaction-textarea.component.ts +2 -0
  3. package/angular/components/grid.component.ts +2 -2
  4. package/angular/esm/components/ai-interaction-textarea.component.d.ts +2 -1
  5. package/angular/esm/components/ai-interaction-textarea.component.js +7 -2
  6. package/angular/esm/components/grid.component.d.ts +2 -2
  7. package/angular/esm/types/ai-chat.types.d.ts +1 -0
  8. package/angular/types/ai-chat.types.ts +1 -0
  9. package/components/ai-chat/ai-chat.d.ts +21 -1
  10. package/components/ai-chat/index.cjs +1 -1
  11. package/components/ai-chat/index.d.ts +1 -0
  12. package/components/ai-chat/index.js +3 -3
  13. package/components/ai-chat/request-contract.d.ts +38 -0
  14. package/components/ai-chat-BrTAn0m-.cjs +62 -0
  15. package/components/{ai-chat-Dg2dvhDq.js → ai-chat-D6fPnWEi.js} +211 -151
  16. package/components/ai-interaction-textarea/ai-interaction-textarea.d.ts +6 -0
  17. package/components/ai-interaction-textarea/index.cjs +1 -1
  18. package/components/ai-interaction-textarea/index.js +1 -1
  19. package/components/{ai-interaction-textarea-DDVKMfTQ.cjs → ai-interaction-textarea-BGnQbDpJ.cjs} +2 -2
  20. package/components/{ai-interaction-textarea-ZDQPVgXC.js → ai-interaction-textarea-EdWcPK0w.js} +6 -3
  21. package/components/grid/grid.d.ts +4 -9
  22. package/components/grid/helpers/grid-effects.d.ts +1 -0
  23. package/components/grid/helpers/grid-events.d.ts +50 -0
  24. package/components/grid/helpers/grid-interactions.d.ts +91 -0
  25. package/components/grid/helpers/grid-item-management.d.ts +45 -0
  26. package/components/grid/helpers/grid-item-popover.d.ts +15 -0
  27. package/components/grid/helpers/grid-items.d.ts +9 -0
  28. package/components/grid/helpers/grid-keyboard-updates.d.ts +18 -0
  29. package/components/grid/helpers/grid-keydown-event.d.ts +18 -0
  30. package/components/grid/helpers/grid-popover-cleanup.d.ts +4 -0
  31. package/components/grid/helpers/grid-rendering.d.ts +63 -0
  32. package/components/grid/helpers/grid-stack-lifecycle.d.ts +26 -0
  33. package/components/grid/helpers/grid-theme.d.ts +16 -0
  34. package/components/grid/helpers/grid-update-cycle.d.ts +24 -0
  35. package/components/grid/index.cjs +1 -1
  36. package/components/grid/index.js +1 -1
  37. package/components/grid-BNbbl-9p.cjs +316 -0
  38. package/components/{grid-BW6LPvCu.js → grid-Ca-fxUK1.js} +2341 -1965
  39. package/components/index.cjs +1 -1
  40. package/components/index.js +5 -5
  41. package/components/item-data-picker-panel/index.cjs +1 -1
  42. package/components/item-data-picker-panel/index.js +1 -1
  43. package/components/slot-contents-picker/index.cjs +1 -1
  44. package/components/slot-contents-picker/index.js +1 -1
  45. package/components/slot-contents-picker/slot-contents-picker.d.ts +4 -2
  46. package/components/{slot-contents-picker-HRJuZQq5.cjs → slot-contents-picker-BO5lSTDz.cjs} +4 -4
  47. package/components/{slot-contents-picker-CgACNIVS.js → slot-contents-picker-Bw_G1BwZ.js} +112 -92
  48. package/custom-elements.json +1558 -17
  49. package/package.json +2 -2
  50. package/types/ai-chat.types.d.ts +1 -0
  51. package/components/ai-chat-CbqvVZDp.cjs +0 -60
  52. package/components/grid-xtLaTdhb.cjs +0 -316
@@ -31,6 +31,7 @@ import { repeat } from "lit/directives/repeat.js";
31
31
  import "@luzmo/lucero/icon";
32
32
  import "@luzmo/lucero/action-button";
33
33
  import "@luzmo/lucero/action-group";
34
+ import { guard } from "lit/directives/guard.js";
34
35
  import { LuzmoElement } from "@luzmo/lucero/utils";
35
36
  import { styleMap } from "lit/directives/style-map.js";
36
37
  var byteToHex = [];
@@ -61,980 +62,241 @@ function _v4(e, k, A) {
61
62
  function v4(e, k, A) {
62
63
  return native_default.randomUUID && !k && !e ? native_default.randomUUID() : _v4(e, k, A);
63
64
  }
64
- var v4_default = v4, min = Math.min, max = Math.max, round = Math.round, floor = Math.floor, createCoords = (e) => ({
65
- x: e,
66
- y: e
67
- }), oppositeSideMap = {
68
- left: "right",
69
- right: "left",
70
- bottom: "top",
71
- top: "bottom"
72
- }, oppositeAlignmentMap = {
73
- start: "end",
74
- end: "start"
65
+ var v4_default = v4;
66
+ const _handleError = (e, k) => {
67
+ let A = "The dashboard component encountered an error";
68
+ typeof k?.dashboardId == "string" && (A += ` for dashboard with id ${k.dashboardId}`), typeof k?.dashboardSlug == "string" && (A += ` for dashboard with slug ${k.dashboardSlug}`), typeof k?.container == "string" && (A += ` in container ${k.container}`), e && (A += `:\n${e}`, console.warn(A));
69
+ }, _browserCheck = (e) => {
70
+ let k = !1, A = "", j = (document.body || document.documentElement).style, M = {
71
+ svg: !!("createElementNS" in document && document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect),
72
+ flexbox: j.webkitFlexWrap === "" || j.flexWrap === "",
73
+ postMessage: !!window.postMessage
74
+ };
75
+ for (let j of [
76
+ "svg",
77
+ "flexbox",
78
+ "postMessage"
79
+ ]) M[j] || (k = !0, e.browserNotSupported = e.browserNotSupported || [], e.browserNotSupported.push(j), A += `Your browser does not support: ${j}\n`);
80
+ let N = window.navigator.userAgent, P = N.includes("MSIE"), F = N.includes("Trident/");
81
+ (P || F) && (k = !0, A = "IE is not supported."), k && _handleError(A);
82
+ }, DEFAULT_PARAMETERS = {
83
+ appServer: "https://app.luzmo.com/",
84
+ apiHost: "https://api.luzmo.com/",
85
+ dashboardId: null,
86
+ dashboardSlug: null,
87
+ container: null,
88
+ key: null,
89
+ token: null,
90
+ language: "auto",
91
+ editorLanguage: "auto",
92
+ qeVersion: null,
93
+ editMode: null,
94
+ screenMode: null,
95
+ switchScreenModeOnResize: !0,
96
+ itemId: null,
97
+ theme: "",
98
+ mainColor: "",
99
+ accentColor: "",
100
+ itemDimensions: {
101
+ width: "auto",
102
+ height: "auto"
103
+ },
104
+ loaderBackground: "#f9f9f9",
105
+ loaderFontColor: "#5a5a5a",
106
+ loaderSpinnerColor: "rgba(255, 165, 0, 0.7)",
107
+ loaderSpinnerBackground: "rgba(169, 169, 169, 0.14)",
108
+ timezoneId: null,
109
+ contextId: null
110
+ }, EXTENTS = [
111
+ {
112
+ mode: "mobile",
113
+ width: [150, 767]
114
+ },
115
+ {
116
+ mode: "tablet",
117
+ width: [768, 1199]
118
+ },
119
+ {
120
+ mode: "desktop",
121
+ width: [1200, 1599]
122
+ },
123
+ {
124
+ mode: "largeScreen",
125
+ width: [1600, 9999]
126
+ },
127
+ {
128
+ mode: "fixed",
129
+ width: []
130
+ }
131
+ ];
132
+ var translations_default = {
133
+ initializing: {
134
+ en: "Initializing...",
135
+ nl: "Laden...",
136
+ fr: "Chargement...",
137
+ de: "Initialisiere...",
138
+ es: "Inicializando..."
139
+ },
140
+ errorDashboard: {
141
+ en: "Oops, we could not load this dashboard!",
142
+ nl: "Oeps, we konden het dashboard niet laden.",
143
+ fr: "Le chargement a echoué.",
144
+ de: "Hoppla, wir konnten dieses Dashboard nicht laden!",
145
+ es: "¡Ups! No pudimos cargar este tablero."
146
+ },
147
+ errorItem: {
148
+ en: "Oops, we could not load this item!",
149
+ nl: "Oeps, we konden de grafiek niet laden.",
150
+ fr: "Le chargement a echoué.",
151
+ de: "Hoppla, wir konnten dieses Diagramm nicht laden!",
152
+ es: "¡Ups! No pudimos cargar este elemento."
153
+ }
75
154
  };
76
- function evaluate(e, k) {
77
- return typeof e == "function" ? e(k) : e;
155
+ const addTrailingSlash = (e) => e ? e.endsWith("/") ? e : `${e}/` : "", removeTrailingSlash = (e) => e ? e.endsWith("/") ? e.slice(0, -1) : e : "", formatDashboardList = (e, k, A, j) => {
156
+ let M = (e, k) => {
157
+ let A = e.users.find((e) => e.id === k.id), j = A && A.userAccessRight ? {
158
+ flagRead: A.userAccessRight.flagRead,
159
+ flagUse: A.userAccessRight.flagUse,
160
+ flagModify: A.userAccessRight.flagModify,
161
+ flagOwn: A.userAccessRight.flagOwn
162
+ } : {
163
+ flagRead: !1,
164
+ flagUse: !1,
165
+ flagModify: !1,
166
+ flagOwn: !1
167
+ }, M = e.groups.filter((e) => k.userGroups.includes(e.id) || e.public === !0).map((e) => {
168
+ if (e.groupAccessRight) return e.groupAccessRight;
169
+ });
170
+ for (let e of M) !j.flagRead && e.flagRead && (j.flagRead = e.flagRead), !j.flagUse && e.flagUse && (j.flagUse = e.flagUse), !j.flagModify && e.flagModify && (j.flagModify = e.flagModify), !j.flagOwn && e.flagOwn && (j.flagOwn = e.flagOwn);
171
+ let N = e.integrations?.length > 0 ? e.integrations.map((e) => {
172
+ if (e.integrationAccessRight) return e.integrationAccessRight;
173
+ }) : [];
174
+ for (let e of N) !j.flagRead && e.flagRead && (j.flagRead = e.flagRead), !j.flagUse && e.flagUse && (j.flagUse = e.flagUse), !j.flagModify && e.flagModify && (j.flagModify = e.flagModify);
175
+ return j;
176
+ }, N = (e, k) => {
177
+ if (e == null) return "";
178
+ if (typeof e != "object" || Object.keys(e).length === 0) return typeof e == "object" && Object.keys(e).length === 0 ? "" : e;
179
+ let A;
180
+ return A = k && e[k] ? e[k] : e[Object.keys(e)[0]], A ??= "", A;
181
+ }, P = [];
182
+ for (let F of e) {
183
+ let e = {
184
+ accessibleBy: [],
185
+ accessRights: M(F, A),
186
+ id: F.id,
187
+ modifiedAt: F.modified_at,
188
+ name: N(F.name, j.language),
189
+ slug: null,
190
+ tags: F.tags.map((e) => e.tag).sort((e, k) => e.localeCompare(k))
191
+ }, I = F.integrations.find((e) => e.id === k);
192
+ I?.integrationAccessRight?.slug && (e.slug = I.integrationAccessRight.slug);
193
+ let L = F.users.map((e) => ({
194
+ model: "User",
195
+ id: e.id,
196
+ name: N(e.name, A.locale_id)
197
+ })), R = F.groups.map((e) => ({
198
+ model: "Group",
199
+ id: e.id,
200
+ name: N(e.name, A.locale_id) || {}
201
+ })), z = F.integrations.map((e) => ({
202
+ model: "Integration",
203
+ id: e.id,
204
+ name: N(e.name, A.locale_id) || {}
205
+ }));
206
+ e.accessibleBy = [
207
+ ...L,
208
+ ...R,
209
+ ...z
210
+ ], P.push(e);
211
+ }
212
+ return P;
213
+ }, sanitizeUrl = (e) => {
214
+ let k = /^(%20|\s)*(javascript|data)/im, A = /[^\u0020-\u007E]/gim, j = /^([^:]+):/gm, M = new Set([".", "/"]), N = (e) => M.has(e[0]);
215
+ if (!e) return "about:blank";
216
+ let P = e.replaceAll(A, "").trim();
217
+ if (N(P)) return P;
218
+ let F = P.match(j);
219
+ if (!F) return P;
220
+ let I = F[0];
221
+ return k.test(I) ? "about:blank" : P;
222
+ }, cloneDeep = (e) => JSON.parse(JSON.stringify(e));
223
+ var isObject = (e) => e && typeof e == "object";
224
+ const defaultsDeep = (e, k) => (Object.entries(k).forEach(([k, A]) => {
225
+ k in e ? e[k] === void 0 ? e[k] = A : e[k] = isObject(A) ? defaultsDeep(e[k], A) : e[k] : e[k] = A;
226
+ }), e), uuidv4 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g, function(e) {
227
+ let k = Math.random() * 16 | 0;
228
+ return (e == "x" ? k : k & 3 | 8).toString(16);
229
+ }), createIframeUrl = (e) => {
230
+ let k = [], { appServer: A, language: j, editorLanguage: M, qeVersion: N, loaderBackground: P, loaderSpinnerColor: F, loaderSpinnerBackground: I, loaderFontColor: L, screenMode: R, key: z, token: B, timezoneId: V, itemEmbedding: H, itemDimensions: U, dashboardId: W, dashboardSlug: G, itemId: K, theme: q, mainColor: J, accentColor: Y, editMode: X } = e.params;
231
+ j && j !== "auto" && k.push(`language=${j}`), M && M !== "auto" && k.push(`editorLanguage=${M}`), N && k.push(`qe_version=${N}`), P && k.push(`ldrbg=${P}`), L && k.push(`ldrftclr=${L}`), F && k.push(`ldrspclr=${F}`), I && k.push(`ldrspbg=${I}`), q && k.push(`theme=${q}`), J && k.push(`mainColor=${J}`), Y && k.push(`accentColor=${Y}`), R && R !== "auto" && k.push("screenMode=&{screenMode}"), V && k.push("timezoneId=" + V), H && U && U.width && k.push("width=" + U.width), H && U && U.height && k.push("height=" + U.height), X && k.push("editMode=" + X);
232
+ let Z = z && B ? "#" + z + ":" + B : "";
233
+ return k.push("version=" + (e.libVersion || "0.0.0-unknown-luzmo")), sanitizeUrl(H ? `${A}i/${W || G}/${K}?${encodeURIComponent(k.join("&"))}${Z}` : `${A}i/${W || G}?${encodeURIComponent(k.join("&"))}${Z}`);
234
+ }, getLoader = (e) => {
235
+ let k;
236
+ (e.params.error || e.browserNotSupported.length > 0) && (e.params.error = !0, e.browserNotSupported && (k = "Browser is not supported."));
237
+ let A = translations_default.initializing[e.params.language] || translations_default.initializing.en;
238
+ return e.browserNotSupported || e.params.error ? {
239
+ loadingMsg: A,
240
+ errorMsg: k
241
+ } : {
242
+ loadingMsg: A,
243
+ errorMsg: ""
244
+ };
245
+ };
246
+ function resolvePromise(e, k, A) {
247
+ e.promises[k] && (e.promises[k].resolve(A), delete e.promises[k]);
78
248
  }
79
- function getSide(e) {
80
- return e.split("-")[0];
249
+ function rejectPromise(e, k, A) {
250
+ e.promises[k] && (e.promises[k].reject(A), delete e.promises[k]);
81
251
  }
82
- function getAlignment(e) {
83
- return e.split("-")[1];
252
+ function containerStyles(e) {
253
+ let k = {};
254
+ return e.params.loaderBackground && !e.iframeLoaded && (k.background = e.params.loaderBackground), k;
84
255
  }
85
- function getOppositeAxis(e) {
86
- return e === "x" ? "y" : "x";
256
+ function containerLoaderStyles(e) {
257
+ let k = e.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height, A = e.params.itemEmbedding && k !== "auto";
258
+ return {
259
+ display: e.iframeLoaded ? "none" : "",
260
+ height: `${A ? k : e.minHeight}px`
261
+ };
87
262
  }
88
- function getAxisLength(e) {
89
- return e === "y" ? "height" : "width";
263
+ function loaderStyles(e) {
264
+ let k = e.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
265
+ if (e.params.itemEmbedding) {
266
+ e.loaderSize = 24, e.borderWidth = 4, e.minHeight = 200;
267
+ let A = e.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width, j = e.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height, M = A !== "auto", N = j !== "auto";
268
+ return {
269
+ background: k,
270
+ width: M ? `${A}px` : "100%",
271
+ height: `${N ? j : "200"}px`,
272
+ "min-height": N ? "" : "200px"
273
+ };
274
+ }
275
+ return { background: k };
90
276
  }
91
- var yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
92
- function getSideAxis(e) {
93
- return yAxisSides.has(getSide(e)) ? "y" : "x";
277
+ function plStyles(e) {
278
+ let { loaderSpinnerColor: k, loaderSpinnerBackground: A } = DEFAULT_PARAMETERS, j = generateBorderStyle(e.borderWidth, e.params.loaderSpinnerColor || k), M = generateBorderStyle(e.borderWidth, e.params.loaderSpinnerBackground || A), N = `${e.loaderSize}px`;
279
+ return {
280
+ "border-top": j,
281
+ "border-right": j,
282
+ "border-bottom": M,
283
+ "border-left": M,
284
+ width: N,
285
+ height: N
286
+ };
94
287
  }
95
- function getAlignmentAxis(e) {
96
- return getOppositeAxis(getSideAxis(e));
288
+ function lcStyles(e) {
289
+ let k = e.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height, A = e.params.itemEmbedding && k !== "auto";
290
+ return { padding: `${e.params.itemId ? ((k) => `${(k - e.loaderSize - 32) / 2}px`)(A ? Number.parseInt(`${k}`, 10) : e.minHeight) : "128px"} 16px` };
97
291
  }
98
- function getAlignmentSides(e, k, A) {
99
- A === void 0 && (A = !1);
100
- let j = getAlignment(e), M = getAlignmentAxis(e), N = getAxisLength(M), P = M === "x" ? j === (A ? "end" : "start") ? "right" : "left" : j === "start" ? "bottom" : "top";
101
- return k.reference[N] > k.floating[N] && (P = getOppositePlacement(P)), [P, getOppositePlacement(P)];
102
- }
103
- function getExpandedPlacements(e) {
104
- let k = getOppositePlacement(e);
105
- return [
106
- getOppositeAlignmentPlacement(e),
107
- k,
108
- getOppositeAlignmentPlacement(k)
109
- ];
110
- }
111
- function getOppositeAlignmentPlacement(e) {
112
- return e.replace(/start|end/g, (e) => oppositeAlignmentMap[e]);
113
- }
114
- var lrPlacement = ["left", "right"], rlPlacement = ["right", "left"], tbPlacement = ["top", "bottom"], btPlacement = ["bottom", "top"];
115
- function getSideList(e, k, A) {
116
- switch (e) {
117
- case "top":
118
- case "bottom": return A ? k ? rlPlacement : lrPlacement : k ? lrPlacement : rlPlacement;
119
- case "left":
120
- case "right": return k ? tbPlacement : btPlacement;
121
- default: return [];
122
- }
123
- }
124
- function getOppositeAxisPlacements(e, k, A, j) {
125
- let M = getAlignment(e), N = getSideList(getSide(e), A === "start", j);
126
- return M && (N = N.map((e) => e + "-" + M), k && (N = N.concat(N.map(getOppositeAlignmentPlacement)))), N;
127
- }
128
- function getOppositePlacement(e) {
129
- return e.replace(/left|right|bottom|top/g, (e) => oppositeSideMap[e]);
130
- }
131
- function expandPaddingObject(e) {
132
- return {
133
- top: 0,
134
- right: 0,
135
- bottom: 0,
136
- left: 0,
137
- ...e
138
- };
139
- }
140
- function getPaddingObject(e) {
141
- return typeof e == "number" ? {
142
- top: e,
143
- right: e,
144
- bottom: e,
145
- left: e
146
- } : expandPaddingObject(e);
147
- }
148
- function rectToClientRect(e) {
149
- let { x: k, y: A, width: j, height: M } = e;
150
- return {
151
- width: j,
152
- height: M,
153
- top: A,
154
- left: k,
155
- right: k + j,
156
- bottom: A + M,
157
- x: k,
158
- y: A
159
- };
160
- }
161
- function computeCoordsFromPlacement(e, k, A) {
162
- let { reference: j, floating: M } = e, N = getSideAxis(k), P = getAlignmentAxis(k), F = getAxisLength(P), I = getSide(k), L = N === "y", R = j.x + j.width / 2 - M.width / 2, z = j.y + j.height / 2 - M.height / 2, B = j[F] / 2 - M[F] / 2, V;
163
- switch (I) {
164
- case "top":
165
- V = {
166
- x: R,
167
- y: j.y - M.height
168
- };
169
- break;
170
- case "bottom":
171
- V = {
172
- x: R,
173
- y: j.y + j.height
174
- };
175
- break;
176
- case "right":
177
- V = {
178
- x: j.x + j.width,
179
- y: z
180
- };
181
- break;
182
- case "left":
183
- V = {
184
- x: j.x - M.width,
185
- y: z
186
- };
187
- break;
188
- default: V = {
189
- x: j.x,
190
- y: j.y
191
- };
192
- }
193
- switch (getAlignment(k)) {
194
- case "start":
195
- V[P] -= B * (A && L ? -1 : 1);
196
- break;
197
- case "end":
198
- V[P] += B * (A && L ? -1 : 1);
199
- break;
200
- }
201
- return V;
202
- }
203
- var computePosition$1 = async (e, k, A) => {
204
- let { placement: j = "bottom", strategy: M = "absolute", middleware: N = [], platform: P } = A, F = N.filter(Boolean), I = await (P.isRTL == null ? void 0 : P.isRTL(k)), L = await P.getElementRects({
205
- reference: e,
206
- floating: k,
207
- strategy: M
208
- }), { x: R, y: z } = computeCoordsFromPlacement(L, j, I), B = j, V = {}, H = 0;
209
- for (let A = 0; A < F.length; A++) {
210
- let { name: N, fn: U } = F[A], { x: W, y: G, data: K, reset: q } = await U({
211
- x: R,
212
- y: z,
213
- initialPlacement: j,
214
- placement: B,
215
- strategy: M,
216
- middlewareData: V,
217
- rects: L,
218
- platform: P,
219
- elements: {
220
- reference: e,
221
- floating: k
222
- }
223
- });
224
- R = W ?? R, z = G ?? z, V = {
225
- ...V,
226
- [N]: {
227
- ...V[N],
228
- ...K
229
- }
230
- }, q && H <= 50 && (H++, typeof q == "object" && (q.placement && (B = q.placement), q.rects && (L = q.rects === !0 ? await P.getElementRects({
231
- reference: e,
232
- floating: k,
233
- strategy: M
234
- }) : q.rects), {x: R, y: z} = computeCoordsFromPlacement(L, B, I)), A = -1);
235
- }
236
- return {
237
- x: R,
238
- y: z,
239
- placement: B,
240
- strategy: M,
241
- middlewareData: V
242
- };
243
- };
244
- async function detectOverflow(e, k) {
245
- k === void 0 && (k = {});
246
- let { x: A, y: j, platform: M, rects: N, elements: P, strategy: F } = e, { boundary: I = "clippingAncestors", rootBoundary: L = "viewport", elementContext: R = "floating", altBoundary: z = !1, padding: B = 0 } = evaluate(k, e), V = getPaddingObject(B), H = P[z ? R === "floating" ? "reference" : "floating" : R], U = rectToClientRect(await M.getClippingRect({
247
- element: await (M.isElement == null ? void 0 : M.isElement(H)) ?? !0 ? H : H.contextElement || await (M.getDocumentElement == null ? void 0 : M.getDocumentElement(P.floating)),
248
- boundary: I,
249
- rootBoundary: L,
250
- strategy: F
251
- })), W = R === "floating" ? {
252
- x: A,
253
- y: j,
254
- width: N.floating.width,
255
- height: N.floating.height
256
- } : N.reference, G = await (M.getOffsetParent == null ? void 0 : M.getOffsetParent(P.floating)), K = await (M.isElement == null ? void 0 : M.isElement(G)) && await (M.getScale == null ? void 0 : M.getScale(G)) || {
257
- x: 1,
258
- y: 1
259
- }, q = rectToClientRect(M.convertOffsetParentRelativeRectToViewportRelativeRect ? await M.convertOffsetParentRelativeRectToViewportRelativeRect({
260
- elements: P,
261
- rect: W,
262
- offsetParent: G,
263
- strategy: F
264
- }) : W);
265
- return {
266
- top: (U.top - q.top + V.top) / K.y,
267
- bottom: (q.bottom - U.bottom + V.bottom) / K.y,
268
- left: (U.left - q.left + V.left) / K.x,
269
- right: (q.right - U.right + V.right) / K.x
270
- };
271
- }
272
- var flip$1 = function(e) {
273
- return e === void 0 && (e = {}), {
274
- name: "flip",
275
- options: e,
276
- async fn(k) {
277
- var A;
278
- let { placement: j, middlewareData: M, rects: N, initialPlacement: P, platform: F, elements: I } = k, { mainAxis: L = !0, crossAxis: R = !0, fallbackPlacements: z, fallbackStrategy: B = "bestFit", fallbackAxisSideDirection: V = "none", flipAlignment: H = !0, ...U } = evaluate(e, k);
279
- if ((A = M.arrow) != null && A.alignmentOffset) return {};
280
- let W = getSide(j), G = getSideAxis(P), K = getSide(P) === P, q = await (F.isRTL == null ? void 0 : F.isRTL(I.floating)), J = z || (K || !H ? [getOppositePlacement(P)] : getExpandedPlacements(P)), Y = V !== "none";
281
- !z && Y && J.push(...getOppositeAxisPlacements(P, H, V, q));
282
- let X = [P, ...J], Z = await detectOverflow(k, U), Q = [], $ = M.flip?.overflows || [];
283
- if (L && Q.push(Z[W]), R) {
284
- let e = getAlignmentSides(j, N, q);
285
- Q.push(Z[e[0]], Z[e[1]]);
286
- }
287
- if ($ = [...$, {
288
- placement: j,
289
- overflows: Q
290
- }], !Q.every((e) => e <= 0)) {
291
- let e = (M.flip?.index || 0) + 1, k = X[e];
292
- if (k && (!(R === "alignment" && G !== getSideAxis(k)) || $.every((e) => getSideAxis(e.placement) === G ? e.overflows[0] > 0 : !0))) return {
293
- data: {
294
- index: e,
295
- overflows: $
296
- },
297
- reset: { placement: k }
298
- };
299
- let A = $.filter((e) => e.overflows[0] <= 0).sort((e, k) => e.overflows[1] - k.overflows[1])[0]?.placement;
300
- if (!A) switch (B) {
301
- case "bestFit": {
302
- let e = $.filter((e) => {
303
- if (Y) {
304
- let k = getSideAxis(e.placement);
305
- return k === G || k === "y";
306
- }
307
- return !0;
308
- }).map((e) => [e.placement, e.overflows.filter((e) => e > 0).reduce((e, k) => e + k, 0)]).sort((e, k) => e[1] - k[1])[0]?.[0];
309
- e && (A = e);
310
- break;
311
- }
312
- case "initialPlacement":
313
- A = P;
314
- break;
315
- }
316
- if (j !== A) return { reset: { placement: A } };
317
- }
318
- return {};
319
- }
320
- };
321
- }, originSides = /* @__PURE__ */ new Set(["left", "top"]);
322
- async function convertValueToCoords(e, k) {
323
- let { placement: A, platform: j, elements: M } = e, N = await (j.isRTL == null ? void 0 : j.isRTL(M.floating)), P = getSide(A), F = getAlignment(A), I = getSideAxis(A) === "y", L = originSides.has(P) ? -1 : 1, R = N && I ? -1 : 1, z = evaluate(k, e), { mainAxis: B, crossAxis: V, alignmentAxis: H } = typeof z == "number" ? {
324
- mainAxis: z,
325
- crossAxis: 0,
326
- alignmentAxis: null
327
- } : {
328
- mainAxis: z.mainAxis || 0,
329
- crossAxis: z.crossAxis || 0,
330
- alignmentAxis: z.alignmentAxis
331
- };
332
- return F && typeof H == "number" && (V = F === "end" ? H * -1 : H), I ? {
333
- x: V * R,
334
- y: B * L
335
- } : {
336
- x: B * L,
337
- y: V * R
338
- };
339
- }
340
- var offset$1 = function(e) {
341
- return e === void 0 && (e = 0), {
342
- name: "offset",
343
- options: e,
344
- async fn(k) {
345
- var A;
346
- let { x: j, y: M, placement: N, middlewareData: P } = k, F = await convertValueToCoords(k, e);
347
- return N === P.offset?.placement && (A = P.arrow) != null && A.alignmentOffset ? {} : {
348
- x: j + F.x,
349
- y: M + F.y,
350
- data: {
351
- ...F,
352
- placement: N
353
- }
354
- };
355
- }
356
- };
357
- };
358
- function hasWindow() {
359
- return typeof window < "u";
360
- }
361
- function getNodeName(e) {
362
- return isNode(e) ? (e.nodeName || "").toLowerCase() : "#document";
363
- }
364
- function getWindow(e) {
365
- var k;
366
- return (e == null || (k = e.ownerDocument) == null ? void 0 : k.defaultView) || window;
367
- }
368
- function getDocumentElement(e) {
369
- return ((isNode(e) ? e.ownerDocument : e.document) || window.document)?.documentElement;
370
- }
371
- function isNode(e) {
372
- return hasWindow() ? e instanceof Node || e instanceof getWindow(e).Node : !1;
373
- }
374
- function isElement(e) {
375
- return hasWindow() ? e instanceof Element || e instanceof getWindow(e).Element : !1;
376
- }
377
- function isHTMLElement(e) {
378
- return hasWindow() ? e instanceof HTMLElement || e instanceof getWindow(e).HTMLElement : !1;
379
- }
380
- function isShadowRoot(e) {
381
- return !hasWindow() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof getWindow(e).ShadowRoot;
382
- }
383
- var invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
384
- function isOverflowElement(e) {
385
- let { overflow: k, overflowX: A, overflowY: j, display: M } = getComputedStyle$1(e);
386
- return /auto|scroll|overlay|hidden|clip/.test(k + j + A) && !invalidOverflowDisplayValues.has(M);
387
- }
388
- var tableElements = /* @__PURE__ */ new Set([
389
- "table",
390
- "td",
391
- "th"
392
- ]);
393
- function isTableElement(e) {
394
- return tableElements.has(getNodeName(e));
395
- }
396
- var topLayerSelectors = [":popover-open", ":modal"];
397
- function isTopLayer(e) {
398
- return topLayerSelectors.some((k) => {
399
- try {
400
- return e.matches(k);
401
- } catch {
402
- return !1;
403
- }
404
- });
405
- }
406
- var transformProperties = [
407
- "transform",
408
- "translate",
409
- "scale",
410
- "rotate",
411
- "perspective"
412
- ], willChangeValues = [
413
- "transform",
414
- "translate",
415
- "scale",
416
- "rotate",
417
- "perspective",
418
- "filter"
419
- ], containValues = [
420
- "paint",
421
- "layout",
422
- "strict",
423
- "content"
424
- ];
425
- function isContainingBlock(e) {
426
- let k = isWebKit(), A = isElement(e) ? getComputedStyle$1(e) : e;
427
- return transformProperties.some((e) => A[e] ? A[e] !== "none" : !1) || (A.containerType ? A.containerType !== "normal" : !1) || !k && (A.backdropFilter ? A.backdropFilter !== "none" : !1) || !k && (A.filter ? A.filter !== "none" : !1) || willChangeValues.some((e) => (A.willChange || "").includes(e)) || containValues.some((e) => (A.contain || "").includes(e));
428
- }
429
- function getContainingBlock(e) {
430
- let k = getParentNode(e);
431
- for (; isHTMLElement(k) && !isLastTraversableNode(k);) {
432
- if (isContainingBlock(k)) return k;
433
- if (isTopLayer(k)) return null;
434
- k = getParentNode(k);
435
- }
436
- return null;
437
- }
438
- function isWebKit() {
439
- return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
440
- }
441
- var lastTraversableNodeNames = /* @__PURE__ */ new Set([
442
- "html",
443
- "body",
444
- "#document"
445
- ]);
446
- function isLastTraversableNode(e) {
447
- return lastTraversableNodeNames.has(getNodeName(e));
448
- }
449
- function getComputedStyle$1(e) {
450
- return getWindow(e).getComputedStyle(e);
451
- }
452
- function getNodeScroll(e) {
453
- return isElement(e) ? {
454
- scrollLeft: e.scrollLeft,
455
- scrollTop: e.scrollTop
456
- } : {
457
- scrollLeft: e.scrollX,
458
- scrollTop: e.scrollY
459
- };
460
- }
461
- function getParentNode(e) {
462
- if (getNodeName(e) === "html") return e;
463
- let k = e.assignedSlot || e.parentNode || isShadowRoot(e) && e.host || getDocumentElement(e);
464
- return isShadowRoot(k) ? k.host : k;
465
- }
466
- function getNearestOverflowAncestor(e) {
467
- let k = getParentNode(e);
468
- return isLastTraversableNode(k) ? e.ownerDocument ? e.ownerDocument.body : e.body : isHTMLElement(k) && isOverflowElement(k) ? k : getNearestOverflowAncestor(k);
469
- }
470
- function getOverflowAncestors(e, k, A) {
471
- k === void 0 && (k = []), A === void 0 && (A = !0);
472
- let j = getNearestOverflowAncestor(e), M = j === e.ownerDocument?.body, N = getWindow(j);
473
- if (M) {
474
- let e = getFrameElement(N);
475
- return k.concat(N, N.visualViewport || [], isOverflowElement(j) ? j : [], e && A ? getOverflowAncestors(e) : []);
476
- }
477
- return k.concat(j, getOverflowAncestors(j, [], A));
478
- }
479
- function getFrameElement(e) {
480
- return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
481
- }
482
- function getCssDimensions(e) {
483
- let k = getComputedStyle$1(e), A = parseFloat(k.width) || 0, j = parseFloat(k.height) || 0, M = isHTMLElement(e), N = M ? e.offsetWidth : A, P = M ? e.offsetHeight : j, F = round(A) !== N || round(j) !== P;
484
- return F && (A = N, j = P), {
485
- width: A,
486
- height: j,
487
- $: F
488
- };
489
- }
490
- function unwrapElement(e) {
491
- return isElement(e) ? e : e.contextElement;
492
- }
493
- function getScale(e) {
494
- let k = unwrapElement(e);
495
- if (!isHTMLElement(k)) return createCoords(1);
496
- let A = k.getBoundingClientRect(), { width: j, height: M, $: N } = getCssDimensions(k), P = (N ? round(A.width) : A.width) / j, F = (N ? round(A.height) : A.height) / M;
497
- return (!P || !Number.isFinite(P)) && (P = 1), (!F || !Number.isFinite(F)) && (F = 1), {
498
- x: P,
499
- y: F
500
- };
501
- }
502
- var noOffsets = /* @__PURE__ */ createCoords(0);
503
- function getVisualOffsets(e) {
504
- let k = getWindow(e);
505
- return !isWebKit() || !k.visualViewport ? noOffsets : {
506
- x: k.visualViewport.offsetLeft,
507
- y: k.visualViewport.offsetTop
508
- };
509
- }
510
- function shouldAddVisualOffsets(e, k, A) {
511
- return k === void 0 && (k = !1), !A || k && A !== getWindow(e) ? !1 : k;
512
- }
513
- function getBoundingClientRect(e, k, A, j) {
514
- k === void 0 && (k = !1), A === void 0 && (A = !1);
515
- let M = e.getBoundingClientRect(), N = unwrapElement(e), P = createCoords(1);
516
- k && (j ? isElement(j) && (P = getScale(j)) : P = getScale(e));
517
- let F = shouldAddVisualOffsets(N, A, j) ? getVisualOffsets(N) : createCoords(0), I = (M.left + F.x) / P.x, L = (M.top + F.y) / P.y, R = M.width / P.x, z = M.height / P.y;
518
- if (N) {
519
- let e = getWindow(N), k = j && isElement(j) ? getWindow(j) : j, A = e, M = getFrameElement(A);
520
- for (; M && j && k !== A;) {
521
- let e = getScale(M), k = M.getBoundingClientRect(), j = getComputedStyle$1(M), N = k.left + (M.clientLeft + parseFloat(j.paddingLeft)) * e.x, P = k.top + (M.clientTop + parseFloat(j.paddingTop)) * e.y;
522
- I *= e.x, L *= e.y, R *= e.x, z *= e.y, I += N, L += P, A = getWindow(M), M = getFrameElement(A);
523
- }
524
- }
525
- return rectToClientRect({
526
- width: R,
527
- height: z,
528
- x: I,
529
- y: L
530
- });
531
- }
532
- function getWindowScrollBarX(e, k) {
533
- let A = getNodeScroll(e).scrollLeft;
534
- return k ? k.left + A : getBoundingClientRect(getDocumentElement(e)).left + A;
535
- }
536
- function getHTMLOffset(e, k) {
537
- let A = e.getBoundingClientRect();
538
- return {
539
- x: A.left + k.scrollLeft - getWindowScrollBarX(e, A),
540
- y: A.top + k.scrollTop
541
- };
542
- }
543
- function convertOffsetParentRelativeRectToViewportRelativeRect(e) {
544
- let { elements: k, rect: A, offsetParent: j, strategy: M } = e, N = M === "fixed", P = getDocumentElement(j), F = k ? isTopLayer(k.floating) : !1;
545
- if (j === P || F && N) return A;
546
- let I = {
547
- scrollLeft: 0,
548
- scrollTop: 0
549
- }, L = createCoords(1), R = createCoords(0), z = isHTMLElement(j);
550
- if ((z || !z && !N) && ((getNodeName(j) !== "body" || isOverflowElement(P)) && (I = getNodeScroll(j)), isHTMLElement(j))) {
551
- let e = getBoundingClientRect(j);
552
- L = getScale(j), R.x = e.x + j.clientLeft, R.y = e.y + j.clientTop;
553
- }
554
- let B = P && !z && !N ? getHTMLOffset(P, I) : createCoords(0);
555
- return {
556
- width: A.width * L.x,
557
- height: A.height * L.y,
558
- x: A.x * L.x - I.scrollLeft * L.x + R.x + B.x,
559
- y: A.y * L.y - I.scrollTop * L.y + R.y + B.y
560
- };
561
- }
562
- function getClientRects(e) {
563
- return Array.from(e.getClientRects());
564
- }
565
- function getDocumentRect(e) {
566
- let k = getDocumentElement(e), A = getNodeScroll(e), j = e.ownerDocument.body, M = max(k.scrollWidth, k.clientWidth, j.scrollWidth, j.clientWidth), N = max(k.scrollHeight, k.clientHeight, j.scrollHeight, j.clientHeight), P = -A.scrollLeft + getWindowScrollBarX(e), F = -A.scrollTop;
567
- return getComputedStyle$1(j).direction === "rtl" && (P += max(k.clientWidth, j.clientWidth) - M), {
568
- width: M,
569
- height: N,
570
- x: P,
571
- y: F
572
- };
573
- }
574
- var SCROLLBAR_MAX = 25;
575
- function getViewportRect(e, k) {
576
- let A = getWindow(e), j = getDocumentElement(e), M = A.visualViewport, N = j.clientWidth, P = j.clientHeight, F = 0, I = 0;
577
- if (M) {
578
- N = M.width, P = M.height;
579
- let e = isWebKit();
580
- (!e || e && k === "fixed") && (F = M.offsetLeft, I = M.offsetTop);
581
- }
582
- let L = getWindowScrollBarX(j);
583
- if (L <= 0) {
584
- let e = j.ownerDocument, k = e.body, A = getComputedStyle(k), M = e.compatMode === "CSS1Compat" && parseFloat(A.marginLeft) + parseFloat(A.marginRight) || 0, P = Math.abs(j.clientWidth - k.clientWidth - M);
585
- P <= SCROLLBAR_MAX && (N -= P);
586
- } else L <= SCROLLBAR_MAX && (N += L);
587
- return {
588
- width: N,
589
- height: P,
590
- x: F,
591
- y: I
592
- };
593
- }
594
- var absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
595
- function getInnerBoundingClientRect(e, k) {
596
- let A = getBoundingClientRect(e, !0, k === "fixed"), j = A.top + e.clientTop, M = A.left + e.clientLeft, N = isHTMLElement(e) ? getScale(e) : createCoords(1);
597
- return {
598
- width: e.clientWidth * N.x,
599
- height: e.clientHeight * N.y,
600
- x: M * N.x,
601
- y: j * N.y
602
- };
603
- }
604
- function getClientRectFromClippingAncestor(e, k, A) {
605
- let j;
606
- if (k === "viewport") j = getViewportRect(e, A);
607
- else if (k === "document") j = getDocumentRect(getDocumentElement(e));
608
- else if (isElement(k)) j = getInnerBoundingClientRect(k, A);
609
- else {
610
- let A = getVisualOffsets(e);
611
- j = {
612
- x: k.x - A.x,
613
- y: k.y - A.y,
614
- width: k.width,
615
- height: k.height
616
- };
617
- }
618
- return rectToClientRect(j);
619
- }
620
- function hasFixedPositionAncestor(e, k) {
621
- let A = getParentNode(e);
622
- return A === k || !isElement(A) || isLastTraversableNode(A) ? !1 : getComputedStyle$1(A).position === "fixed" || hasFixedPositionAncestor(A, k);
623
- }
624
- function getClippingElementAncestors(e, k) {
625
- let A = k.get(e);
626
- if (A) return A;
627
- let j = getOverflowAncestors(e, [], !1).filter((e) => isElement(e) && getNodeName(e) !== "body"), M = null, N = getComputedStyle$1(e).position === "fixed", P = N ? getParentNode(e) : e;
628
- for (; isElement(P) && !isLastTraversableNode(P);) {
629
- let k = getComputedStyle$1(P), A = isContainingBlock(P);
630
- !A && k.position === "fixed" && (M = null), (N ? !A && !M : !A && k.position === "static" && M && absoluteOrFixed.has(M.position) || isOverflowElement(P) && !A && hasFixedPositionAncestor(e, P)) ? j = j.filter((e) => e !== P) : M = k, P = getParentNode(P);
631
- }
632
- return k.set(e, j), j;
633
- }
634
- function getClippingRect(e) {
635
- let { element: k, boundary: A, rootBoundary: j, strategy: M } = e, N = [...A === "clippingAncestors" ? isTopLayer(k) ? [] : getClippingElementAncestors(k, this._c) : [].concat(A), j], P = N[0], F = N.reduce((e, A) => {
636
- let j = getClientRectFromClippingAncestor(k, A, M);
637
- return e.top = max(j.top, e.top), e.right = min(j.right, e.right), e.bottom = min(j.bottom, e.bottom), e.left = max(j.left, e.left), e;
638
- }, getClientRectFromClippingAncestor(k, P, M));
639
- return {
640
- width: F.right - F.left,
641
- height: F.bottom - F.top,
642
- x: F.left,
643
- y: F.top
644
- };
645
- }
646
- function getDimensions(e) {
647
- let { width: k, height: A } = getCssDimensions(e);
648
- return {
649
- width: k,
650
- height: A
651
- };
652
- }
653
- function getRectRelativeToOffsetParent(e, k, A) {
654
- let j = isHTMLElement(k), M = getDocumentElement(k), N = A === "fixed", P = getBoundingClientRect(e, !0, N, k), F = {
655
- scrollLeft: 0,
656
- scrollTop: 0
657
- }, I = createCoords(0);
658
- function L() {
659
- I.x = getWindowScrollBarX(M);
660
- }
661
- if (j || !j && !N) if ((getNodeName(k) !== "body" || isOverflowElement(M)) && (F = getNodeScroll(k)), j) {
662
- let e = getBoundingClientRect(k, !0, N, k);
663
- I.x = e.x + k.clientLeft, I.y = e.y + k.clientTop;
664
- } else M && L();
665
- N && !j && M && L();
666
- let R = M && !j && !N ? getHTMLOffset(M, F) : createCoords(0);
667
- return {
668
- x: P.left + F.scrollLeft - I.x - R.x,
669
- y: P.top + F.scrollTop - I.y - R.y,
670
- width: P.width,
671
- height: P.height
672
- };
673
- }
674
- function isStaticPositioned(e) {
675
- return getComputedStyle$1(e).position === "static";
676
- }
677
- function getTrueOffsetParent(e, k) {
678
- if (!isHTMLElement(e) || getComputedStyle$1(e).position === "fixed") return null;
679
- if (k) return k(e);
680
- let A = e.offsetParent;
681
- return getDocumentElement(e) === A && (A = A.ownerDocument.body), A;
682
- }
683
- function getOffsetParent(e, k) {
684
- let A = getWindow(e);
685
- if (isTopLayer(e)) return A;
686
- if (!isHTMLElement(e)) {
687
- let k = getParentNode(e);
688
- for (; k && !isLastTraversableNode(k);) {
689
- if (isElement(k) && !isStaticPositioned(k)) return k;
690
- k = getParentNode(k);
691
- }
692
- return A;
693
- }
694
- let j = getTrueOffsetParent(e, k);
695
- for (; j && isTableElement(j) && isStaticPositioned(j);) j = getTrueOffsetParent(j, k);
696
- return j && isLastTraversableNode(j) && isStaticPositioned(j) && !isContainingBlock(j) ? A : j || getContainingBlock(e) || A;
697
- }
698
- var getElementRects = async function(e) {
699
- let k = this.getOffsetParent || getOffsetParent, A = this.getDimensions, j = await A(e.floating);
700
- return {
701
- reference: getRectRelativeToOffsetParent(e.reference, await k(e.floating), e.strategy),
702
- floating: {
703
- x: 0,
704
- y: 0,
705
- width: j.width,
706
- height: j.height
707
- }
708
- };
709
- };
710
- function isRTL(e) {
711
- return getComputedStyle$1(e).direction === "rtl";
712
- }
713
- var platform = {
714
- convertOffsetParentRelativeRectToViewportRelativeRect,
715
- getDocumentElement,
716
- getClippingRect,
717
- getOffsetParent,
718
- getElementRects,
719
- getClientRects,
720
- getDimensions,
721
- getScale,
722
- isElement,
723
- isRTL
724
- };
725
- function rectsAreEqual(e, k) {
726
- return e.x === k.x && e.y === k.y && e.width === k.width && e.height === k.height;
727
- }
728
- function observeMove(e, k) {
729
- let A = null, j, M = getDocumentElement(e);
730
- function N() {
731
- var e;
732
- clearTimeout(j), (e = A) == null || e.disconnect(), A = null;
733
- }
734
- function P(F, I) {
735
- F === void 0 && (F = !1), I === void 0 && (I = 1), N();
736
- let L = e.getBoundingClientRect(), { left: R, top: z, width: B, height: V } = L;
737
- if (F || k(), !B || !V) return;
738
- let H = floor(z), U = floor(M.clientWidth - (R + B)), W = floor(M.clientHeight - (z + V)), G = floor(R), K = {
739
- rootMargin: -H + "px " + -U + "px " + -W + "px " + -G + "px",
740
- threshold: max(0, min(1, I)) || 1
741
- }, q = !0;
742
- function J(k) {
743
- let A = k[0].intersectionRatio;
744
- if (A !== I) {
745
- if (!q) return P();
746
- A ? P(!1, A) : j = setTimeout(() => {
747
- P(!1, 1e-7);
748
- }, 1e3);
749
- }
750
- A === 1 && !rectsAreEqual(L, e.getBoundingClientRect()) && P(), q = !1;
751
- }
752
- try {
753
- A = new IntersectionObserver(J, {
754
- ...K,
755
- root: M.ownerDocument
756
- });
757
- } catch {
758
- A = new IntersectionObserver(J, K);
759
- }
760
- A.observe(e);
761
- }
762
- return P(!0), N;
763
- }
764
- function autoUpdate(e, k, A, j) {
765
- j === void 0 && (j = {});
766
- let { ancestorScroll: M = !0, ancestorResize: N = !0, elementResize: P = typeof ResizeObserver == "function", layoutShift: F = typeof IntersectionObserver == "function", animationFrame: I = !1 } = j, L = unwrapElement(e), R = M || N ? [...L ? getOverflowAncestors(L) : [], ...getOverflowAncestors(k)] : [];
767
- R.forEach((e) => {
768
- M && e.addEventListener("scroll", A, { passive: !0 }), N && e.addEventListener("resize", A);
769
- });
770
- let z = L && F ? observeMove(L, A) : null, B = -1, V = null;
771
- P && (V = new ResizeObserver((e) => {
772
- let [j] = e;
773
- j && j.target === L && V && (V.unobserve(k), cancelAnimationFrame(B), B = requestAnimationFrame(() => {
774
- var e;
775
- (e = V) == null || e.observe(k);
776
- })), A();
777
- }), L && !I && V.observe(L), V.observe(k));
778
- let H, U = I ? getBoundingClientRect(e) : null;
779
- I && W();
780
- function W() {
781
- let k = getBoundingClientRect(e);
782
- U && !rectsAreEqual(U, k) && A(), U = k, H = requestAnimationFrame(W);
783
- }
784
- return A(), () => {
785
- var e;
786
- R.forEach((e) => {
787
- M && e.removeEventListener("scroll", A), N && e.removeEventListener("resize", A);
788
- }), z?.(), (e = V) == null || e.disconnect(), V = null, I && cancelAnimationFrame(H);
789
- };
790
- }
791
- var offset = offset$1, flip = flip$1, computePosition = (e, k, A) => {
792
- let j = /* @__PURE__ */ new Map(), M = {
793
- platform,
794
- ...A
795
- }, N = {
796
- ...M.platform,
797
- _c: j
798
- };
799
- return computePosition$1(e, k, {
800
- ...M,
801
- platform: N
802
- });
803
- };
804
- const _handleError = (e, k) => {
805
- let A = "The dashboard component encountered an error";
806
- typeof k?.dashboardId == "string" && (A += ` for dashboard with id ${k.dashboardId}`), typeof k?.dashboardSlug == "string" && (A += ` for dashboard with slug ${k.dashboardSlug}`), typeof k?.container == "string" && (A += ` in container ${k.container}`), e && (A += `:\n${e}`, console.warn(A));
807
- }, _browserCheck = (e) => {
808
- let k = !1, A = "", j = (document.body || document.documentElement).style, M = {
809
- svg: !!("createElementNS" in document && document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect),
810
- flexbox: j.webkitFlexWrap === "" || j.flexWrap === "",
811
- postMessage: !!window.postMessage
812
- };
813
- for (let j of [
814
- "svg",
815
- "flexbox",
816
- "postMessage"
817
- ]) M[j] || (k = !0, e.browserNotSupported = e.browserNotSupported || [], e.browserNotSupported.push(j), A += `Your browser does not support: ${j}\n`);
818
- let N = window.navigator.userAgent, P = N.includes("MSIE"), F = N.includes("Trident/");
819
- (P || F) && (k = !0, A = "IE is not supported."), k && _handleError(A);
820
- }, DEFAULT_PARAMETERS = {
821
- appServer: "https://app.luzmo.com/",
822
- apiHost: "https://api.luzmo.com/",
823
- dashboardId: null,
824
- dashboardSlug: null,
825
- container: null,
826
- key: null,
827
- token: null,
828
- language: "auto",
829
- editorLanguage: "auto",
830
- qeVersion: null,
831
- editMode: null,
832
- screenMode: null,
833
- switchScreenModeOnResize: !0,
834
- itemId: null,
835
- theme: "",
836
- mainColor: "",
837
- accentColor: "",
838
- itemDimensions: {
839
- width: "auto",
840
- height: "auto"
841
- },
842
- loaderBackground: "#f9f9f9",
843
- loaderFontColor: "#5a5a5a",
844
- loaderSpinnerColor: "rgba(255, 165, 0, 0.7)",
845
- loaderSpinnerBackground: "rgba(169, 169, 169, 0.14)",
846
- timezoneId: null,
847
- contextId: null
848
- }, EXTENTS = [
849
- {
850
- mode: "mobile",
851
- width: [150, 767]
852
- },
853
- {
854
- mode: "tablet",
855
- width: [768, 1199]
856
- },
857
- {
858
- mode: "desktop",
859
- width: [1200, 1599]
860
- },
861
- {
862
- mode: "largeScreen",
863
- width: [1600, 9999]
864
- },
865
- {
866
- mode: "fixed",
867
- width: []
868
- }
869
- ];
870
- var translations_default = {
871
- initializing: {
872
- en: "Initializing...",
873
- nl: "Laden...",
874
- fr: "Chargement...",
875
- de: "Initialisiere...",
876
- es: "Inicializando..."
877
- },
878
- errorDashboard: {
879
- en: "Oops, we could not load this dashboard!",
880
- nl: "Oeps, we konden het dashboard niet laden.",
881
- fr: "Le chargement a echoué.",
882
- de: "Hoppla, wir konnten dieses Dashboard nicht laden!",
883
- es: "¡Ups! No pudimos cargar este tablero."
884
- },
885
- errorItem: {
886
- en: "Oops, we could not load this item!",
887
- nl: "Oeps, we konden de grafiek niet laden.",
888
- fr: "Le chargement a echoué.",
889
- de: "Hoppla, wir konnten dieses Diagramm nicht laden!",
890
- es: "¡Ups! No pudimos cargar este elemento."
891
- }
892
- };
893
- const addTrailingSlash = (e) => e ? e.endsWith("/") ? e : `${e}/` : "", removeTrailingSlash = (e) => e ? e.endsWith("/") ? e.slice(0, -1) : e : "", formatDashboardList = (e, k, A, j) => {
894
- let M = (e, k) => {
895
- let A = e.users.find((e) => e.id === k.id), j = A && A.userAccessRight ? {
896
- flagRead: A.userAccessRight.flagRead,
897
- flagUse: A.userAccessRight.flagUse,
898
- flagModify: A.userAccessRight.flagModify,
899
- flagOwn: A.userAccessRight.flagOwn
900
- } : {
901
- flagRead: !1,
902
- flagUse: !1,
903
- flagModify: !1,
904
- flagOwn: !1
905
- }, M = e.groups.filter((e) => k.userGroups.includes(e.id) || e.public === !0).map((e) => {
906
- if (e.groupAccessRight) return e.groupAccessRight;
907
- });
908
- for (let e of M) !j.flagRead && e.flagRead && (j.flagRead = e.flagRead), !j.flagUse && e.flagUse && (j.flagUse = e.flagUse), !j.flagModify && e.flagModify && (j.flagModify = e.flagModify), !j.flagOwn && e.flagOwn && (j.flagOwn = e.flagOwn);
909
- let N = e.integrations?.length > 0 ? e.integrations.map((e) => {
910
- if (e.integrationAccessRight) return e.integrationAccessRight;
911
- }) : [];
912
- for (let e of N) !j.flagRead && e.flagRead && (j.flagRead = e.flagRead), !j.flagUse && e.flagUse && (j.flagUse = e.flagUse), !j.flagModify && e.flagModify && (j.flagModify = e.flagModify);
913
- return j;
914
- }, N = (e, k) => {
915
- if (e == null) return "";
916
- if (typeof e != "object" || Object.keys(e).length === 0) return typeof e == "object" && Object.keys(e).length === 0 ? "" : e;
917
- let A;
918
- return A = k && e[k] ? e[k] : e[Object.keys(e)[0]], A ??= "", A;
919
- }, P = [];
920
- for (let F of e) {
921
- let e = {
922
- accessibleBy: [],
923
- accessRights: M(F, A),
924
- id: F.id,
925
- modifiedAt: F.modified_at,
926
- name: N(F.name, j.language),
927
- slug: null,
928
- tags: F.tags.map((e) => e.tag).sort((e, k) => e.localeCompare(k))
929
- }, I = F.integrations.find((e) => e.id === k);
930
- I?.integrationAccessRight?.slug && (e.slug = I.integrationAccessRight.slug);
931
- let L = F.users.map((e) => ({
932
- model: "User",
933
- id: e.id,
934
- name: N(e.name, A.locale_id)
935
- })), R = F.groups.map((e) => ({
936
- model: "Group",
937
- id: e.id,
938
- name: N(e.name, A.locale_id) || {}
939
- })), z = F.integrations.map((e) => ({
940
- model: "Integration",
941
- id: e.id,
942
- name: N(e.name, A.locale_id) || {}
943
- }));
944
- e.accessibleBy = [
945
- ...L,
946
- ...R,
947
- ...z
948
- ], P.push(e);
949
- }
950
- return P;
951
- }, sanitizeUrl = (e) => {
952
- let k = /^(%20|\s)*(javascript|data)/im, A = /[^\u0020-\u007E]/gim, j = /^([^:]+):/gm, M = new Set([".", "/"]), N = (e) => M.has(e[0]);
953
- if (!e) return "about:blank";
954
- let P = e.replaceAll(A, "").trim();
955
- if (N(P)) return P;
956
- let F = P.match(j);
957
- if (!F) return P;
958
- let I = F[0];
959
- return k.test(I) ? "about:blank" : P;
960
- }, cloneDeep = (e) => JSON.parse(JSON.stringify(e));
961
- var isObject = (e) => e && typeof e == "object";
962
- const defaultsDeep = (e, k) => (Object.entries(k).forEach(([k, A]) => {
963
- k in e ? e[k] === void 0 ? e[k] = A : e[k] = isObject(A) ? defaultsDeep(e[k], A) : e[k] : e[k] = A;
964
- }), e), uuidv4 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g, function(e) {
965
- let k = Math.random() * 16 | 0;
966
- return (e == "x" ? k : k & 3 | 8).toString(16);
967
- }), createIframeUrl = (e) => {
968
- let k = [], { appServer: A, language: j, editorLanguage: M, qeVersion: N, loaderBackground: P, loaderSpinnerColor: F, loaderSpinnerBackground: I, loaderFontColor: L, screenMode: R, key: z, token: B, timezoneId: V, itemEmbedding: H, itemDimensions: U, dashboardId: W, dashboardSlug: G, itemId: K, theme: q, mainColor: J, accentColor: Y, editMode: X } = e.params;
969
- j && j !== "auto" && k.push(`language=${j}`), M && M !== "auto" && k.push(`editorLanguage=${M}`), N && k.push(`qe_version=${N}`), P && k.push(`ldrbg=${P}`), L && k.push(`ldrftclr=${L}`), F && k.push(`ldrspclr=${F}`), I && k.push(`ldrspbg=${I}`), q && k.push(`theme=${q}`), J && k.push(`mainColor=${J}`), Y && k.push(`accentColor=${Y}`), R && R !== "auto" && k.push("screenMode=&{screenMode}"), V && k.push("timezoneId=" + V), H && U && U.width && k.push("width=" + U.width), H && U && U.height && k.push("height=" + U.height), X && k.push("editMode=" + X);
970
- let Z = z && B ? "#" + z + ":" + B : "";
971
- return k.push("version=" + (e.libVersion || "0.0.0-unknown-luzmo")), sanitizeUrl(H ? `${A}i/${W || G}/${K}?${encodeURIComponent(k.join("&"))}${Z}` : `${A}i/${W || G}?${encodeURIComponent(k.join("&"))}${Z}`);
972
- }, getLoader = (e) => {
973
- let k;
974
- (e.params.error || e.browserNotSupported.length > 0) && (e.params.error = !0, e.browserNotSupported && (k = "Browser is not supported."));
975
- let A = translations_default.initializing[e.params.language] || translations_default.initializing.en;
976
- return e.browserNotSupported || e.params.error ? {
977
- loadingMsg: A,
978
- errorMsg: k
979
- } : {
980
- loadingMsg: A,
981
- errorMsg: ""
982
- };
983
- };
984
- function resolvePromise(e, k, A) {
985
- e.promises[k] && (e.promises[k].resolve(A), delete e.promises[k]);
986
- }
987
- function rejectPromise(e, k, A) {
988
- e.promises[k] && (e.promises[k].reject(A), delete e.promises[k]);
989
- }
990
- function containerStyles(e) {
991
- let k = {};
992
- return e.params.loaderBackground && !e.iframeLoaded && (k.background = e.params.loaderBackground), k;
993
- }
994
- function containerLoaderStyles(e) {
995
- let k = e.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height, A = e.params.itemEmbedding && k !== "auto";
996
- return {
997
- display: e.iframeLoaded ? "none" : "",
998
- height: `${A ? k : e.minHeight}px`
999
- };
1000
- }
1001
- function loaderStyles(e) {
1002
- let k = e.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
1003
- if (e.params.itemEmbedding) {
1004
- e.loaderSize = 24, e.borderWidth = 4, e.minHeight = 200;
1005
- let A = e.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width, j = e.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height, M = A !== "auto", N = j !== "auto";
1006
- return {
1007
- background: k,
1008
- width: M ? `${A}px` : "100%",
1009
- height: `${N ? j : "200"}px`,
1010
- "min-height": N ? "" : "200px"
1011
- };
1012
- }
1013
- return { background: k };
1014
- }
1015
- function plStyles(e) {
1016
- let { loaderSpinnerColor: k, loaderSpinnerBackground: A } = DEFAULT_PARAMETERS, j = generateBorderStyle(e.borderWidth, e.params.loaderSpinnerColor || k), M = generateBorderStyle(e.borderWidth, e.params.loaderSpinnerBackground || A), N = `${e.loaderSize}px`;
1017
- return {
1018
- "border-top": j,
1019
- "border-right": j,
1020
- "border-bottom": M,
1021
- "border-left": M,
1022
- width: N,
1023
- height: N
1024
- };
1025
- }
1026
- function lcStyles(e) {
1027
- let k = e.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height, A = e.params.itemEmbedding && k !== "auto";
1028
- return { padding: `${e.params.itemId ? ((k) => `${(k - e.loaderSize - 32) / 2}px`)(A ? Number.parseInt(`${k}`, 10) : e.minHeight) : "128px"} 16px` };
1029
- }
1030
- function calculateIframeStyles(e) {
1031
- let k = e.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height, A = e.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
1032
- e.params.itemEmbedding && k !== "auto" ? e.iframeHeight = `${k}px` : e.params.itemEmbedding ? e.iframeHeight = "200px" : ["editFull", "editLimited"].includes(e.params.editMode) ? e.iframeHeight = "100%" : e.iframeHeight = "400px", e.iframeWidth = e.params.itemEmbedding && A !== "auto" ? `${A}px` : "100%";
1033
- let j = {
1034
- height: e.iframeHeight,
1035
- width: e.iframeWidth
1036
- };
1037
- return e.iframeLoaded ? j.opacity = 1 : e.error ? (j.opacity = 1, j.width = "100%", j.height = "400px") : j.opacity = 0, j;
292
+ function calculateIframeStyles(e) {
293
+ let k = e.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height, A = e.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
294
+ e.params.itemEmbedding && k !== "auto" ? e.iframeHeight = `${k}px` : e.params.itemEmbedding ? e.iframeHeight = "200px" : ["editFull", "editLimited"].includes(e.params.editMode) ? e.iframeHeight = "100%" : e.iframeHeight = "400px", e.iframeWidth = e.params.itemEmbedding && A !== "auto" ? `${A}px` : "100%";
295
+ let j = {
296
+ height: e.iframeHeight,
297
+ width: e.iframeWidth
298
+ };
299
+ return e.iframeLoaded ? j.opacity = 1 : e.error ? (j.opacity = 1, j.width = "100%", j.height = "400px") : j.opacity = 0, j;
1038
300
  }
1039
301
  function generateBorderStyle(e, k) {
1040
302
  return `${e}px solid ${k}`;
@@ -1716,364 +978,1750 @@ var __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyD
1716
978
  let e = getLoader(this);
1717
979
  this._loaderMsg = e.loadingMsg, e.errorMsg && (this.browserError = !0, this.browserErrorMsg = e.errorMsg, this._displayError());
1718
980
  }
1719
- _displayError() {
1720
- this.dashboardError && (this._loaderStyles(), this.iframeStyle.opacity = 1), this.browserError && (this._containerStyle.display = "none");
981
+ _displayError() {
982
+ this.dashboardError && (this._loaderStyles(), this.iframeStyle.opacity = 1), this.browserError && (this._containerStyle.display = "none");
983
+ }
984
+ _calculateDimAfterDashboardLoaded() {
985
+ this.dashboardError = !1, this._loaderStyles(), _setCalculatedDimensions(this);
986
+ }
987
+ _loaderStyles() {
988
+ this._containerStyle = containerStyles(this), this._loaderStyle = loaderStyles(this), this._loadingCircleStyle = plStyles(this), this._containerLoaderStyle = containerLoaderStyles(this), this._lcStyle = lcStyles(this);
989
+ }
990
+ static get styles() {
991
+ return [dashboardStyles];
992
+ }
993
+ render() {
994
+ let e, k = html`
995
+ <div
996
+ class="luzmo-container-loader"
997
+ id="luzmo-container-loader-${this._containerId}"
998
+ style=${styleMap(this._containerLoaderStyle)}
999
+ >
1000
+ <div
1001
+ class="luzmo-loader"
1002
+ id="luzmo-loader-${this._containerId}"
1003
+ style=${styleMap(this._loaderStyle)}
1004
+ >
1005
+ <div
1006
+ class="luzmo-lc"
1007
+ style=${styleMap(this._lcStyle)}
1008
+ >
1009
+ <div
1010
+ class="luzmo-loading-circle"
1011
+ style=${styleMap(this._loadingCircleStyle)}
1012
+ ></div>
1013
+ ${this._itemEmbedding ? "" : html`
1014
+ <div
1015
+ class="luzmo-loading-message"
1016
+ style=${styleMap({ color: this.loaderFontColor })}
1017
+ >
1018
+ ${this._loaderMsg}
1019
+ </div>
1020
+ `}
1021
+ </div>
1022
+ </div>
1023
+ </div>
1024
+ `;
1025
+ return e = this.isWebComponentViewMode() ? this.isLibraryLoaded ? html`
1026
+ ${this.dashboardId || this.dashboardSlug ? html`
1027
+ <dashboard-component dashboard-id="${this.params.dashboardId}" app-server="${this.params.appServer}"
1028
+ api-host="${this.params.apiHost}"></dashboard-component>
1029
+ ` : html`
1030
+ <div id="luzmo-error-${this._containerId}">
1031
+ <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
1032
+ </div>
1033
+ `}
1034
+ ` : html`${k}` : html`
1035
+ ${this.dashboardId || this.dashboardSlug ? html`
1036
+ ${k}
1037
+ <iframe
1038
+ class="luzmo-embed-dashboard ${this.isWebComponentViewMode() ? "" : "luzmo-embed-dashboard-ede"}"
1039
+ id="${this._iframeId}"
1040
+ name="${this._iframeId}"
1041
+ style=${styleMap(this.iframeStyle)}
1042
+ src="${this._iframeUrl}"
1043
+ frameborder="0"
1044
+ ></iframe>
1045
+ ` : html`<!-- the dashboard will inititialize when you provide a dashboardSlug or a dashboardId -->`}
1046
+ ${this.browserError ? html`
1047
+ <div id="luzmo-error-${this._containerId}">
1048
+ <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
1049
+ </div>
1050
+ ` : ""}
1051
+ `, html`
1052
+ <div class="${luzmoEmbedContainerClass} ${this.isWebComponentViewMode() ? "" : `${luzmoEmbedContainerClass}-ede`}">
1053
+ <div
1054
+ class="dashboard-container"
1055
+ style=${styleMap(Object.assign({}, this._containerStyle, {
1056
+ width: this.iframeStyle.width ?? "100%",
1057
+ height: this.iframeStyle.height ?? "100%"
1058
+ }))}
1059
+ >
1060
+ ${e}
1061
+ </div>
1062
+ </div>
1063
+
1064
+ `;
1065
+ }
1066
+ getDashboards() {
1067
+ return new Promise((e) => e(luzmo_service_default._dashboardComponents));
1068
+ }
1069
+ getData(e) {
1070
+ return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.getData(e) : this.isWebComponentViewMode() ? Promise.reject() : getData(this, this.iframe, e);
1071
+ }
1072
+ getFilters() {
1073
+ return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.getFilters() : this.isWebComponentViewMode() ? Promise.reject() : getFilters(this, this.iframe);
1074
+ }
1075
+ setSelectedData(e, k) {
1076
+ return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.setSelectedData(e, k) : this.isWebComponentViewMode() ? Promise.reject() : setSelectedData(this, this.iframe, e, k);
1077
+ }
1078
+ setAuthorization(e, k) {
1079
+ return this.currentAuthKey = e, this.currentAuthToken = k, this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.setAuthorization(e, k) : this.isWebComponentViewMode() ? Promise.reject() : setAuthorization(this, this.iframe, e, k);
1080
+ }
1081
+ refreshData(e) {
1082
+ return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.refreshData(e) : this.isWebComponentViewMode() ? Promise.reject() : e ? refreshData(this, this.iframe, e) : refreshData(this, this.iframe);
1083
+ }
1084
+ reloadDashboard() {
1085
+ return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.reloadDashboard() : this.isWebComponentViewMode() ? Promise.reject() : reloadDashboard(this, this.iframe);
1086
+ }
1087
+ exportDashboard(e) {
1088
+ return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.exportDashboard(e) : this.isWebComponentViewMode() ? Promise.reject() : e ? exportDashboard(this, this.iframe, e) : exportDashboard(this, this.iframe);
1089
+ }
1090
+ getAccessibleDashboards() {
1091
+ return getAccessibleDashboards(this);
1092
+ }
1093
+ addFilters(e, k) {
1094
+ return this.dashboardReference.addFilters(e, k);
1095
+ }
1096
+ setEditMode(e) {
1097
+ return this.dashboardReference && e === "view" ? (this.editMode = "view", this.params.editMode = "view", this.initComponent(), Promise.resolve({
1098
+ type: "setEditMode",
1099
+ editMode: e
1100
+ })) : this.dashboardReference && ["editFull", "editLimited"].includes(e) ? (this.editMode = e, this.params.editMode = e, this.initComponent(), Promise.resolve({
1101
+ type: "setEditMode",
1102
+ editMode: e
1103
+ })) : this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.setEditMode(e) : this.isWebComponentViewMode() ? Promise.reject() : setEditMode(this, this.iframe, e);
1104
+ }
1105
+ setPreview(e) {
1106
+ return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.setPreview(e) : setPreview(this, this.iframe, e);
1107
+ }
1108
+ sendExportEmail(e, k, A) {
1109
+ return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.sendExportEmail(e, k, A) : this.isWebComponentViewMode() ? Promise.reject() : sendExportEmail(this, this.iframe, e, k, A);
1110
+ }
1111
+ isWebComponentViewMode() {
1112
+ return this.embedMode === "webComponent" && (this.params.editMode === "view" || this.params.editMode === void 0);
1113
+ }
1114
+ };
1115
+ __decorateClass([query(".dashboard-container")], LuzmoDashboard.prototype, "container", 2), __decorateClass([query(`.${luzmoEmbedContainerClass}`)], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2), __decorateClass([query("iframe")], LuzmoDashboard.prototype, "iframe", 2), __decorateClass([property()], LuzmoDashboard.prototype, "dashboardId", 2), __decorateClass([property()], LuzmoDashboard.prototype, "dashboardSlug", 2), __decorateClass([property()], LuzmoDashboard.prototype, "itemId", 2), __decorateClass([property()], LuzmoDashboard.prototype, "language", 2), __decorateClass([property()], LuzmoDashboard.prototype, "editorLanguage", 2), __decorateClass([property()], LuzmoDashboard.prototype, "qeVersion", 2), __decorateClass([property()], LuzmoDashboard.prototype, "screenMode", 2), __decorateClass([property({ converter: {
1116
+ fromAttribute: (e) => e === "true",
1117
+ toAttribute: String
1118
+ } })], LuzmoDashboard.prototype, "switchScreenModeOnResize", 2), __decorateClass([property()], LuzmoDashboard.prototype, "editMode", 2), __decorateClass([property()], LuzmoDashboard.prototype, "theme", 2), __decorateClass([property()], LuzmoDashboard.prototype, "mainColor", 2), __decorateClass([property()], LuzmoDashboard.prototype, "accentColor", 2), __decorateClass([property()], LuzmoDashboard.prototype, "authToken", 2), __decorateClass([property()], LuzmoDashboard.prototype, "authKey", 2), __decorateClass([property()], LuzmoDashboard.prototype, "loaderBackground", 2), __decorateClass([property()], LuzmoDashboard.prototype, "loaderFontColor", 2), __decorateClass([property()], LuzmoDashboard.prototype, "loaderSpinnerColor", 2), __decorateClass([property()], LuzmoDashboard.prototype, "loaderSpinnerBackground", 2), __decorateClass([property()], LuzmoDashboard.prototype, "appServer", 2), __decorateClass([property()], LuzmoDashboard.prototype, "timezoneId", 2), __decorateClass([property()], LuzmoDashboard.prototype, "apiHost", 2), __decorateClass([property({ type: Object })], LuzmoDashboard.prototype, "itemDimensions", 2), __decorateClass([property()], LuzmoDashboard.prototype, "embedMode", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_containerId", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_iframeId", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "params", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_iframeUrl", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "iframeLoaded", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "promises", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "iframeStyle", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_containerStyle", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_loaderStyle", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_lcStyle", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_loadingCircleStyle", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_containerLoaderStyle", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_loaderMsg", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "containerWidth", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "dimensions", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "currentScreenMode", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_itemEmbedding", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "browserError", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "browserErrorMsg", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "dashboardError", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "browserNotSupported", 2), __decorateClass([property()], LuzmoDashboard.prototype, "libVersion", 2), __decorateClass([state()], LuzmoDashboard.prototype, "isLibraryLoaded", 2), __decorateClass([state()], LuzmoDashboard.prototype, "dashboardReference", 2), __decorateClass([state()], LuzmoDashboard.prototype, "currentAuthKey", 2), __decorateClass([state()], LuzmoDashboard.prototype, "currentAuthToken", 2), __decorateClass([state()], LuzmoDashboard.prototype, "isInitCalled", 2);
1119
+ var LuzmoEmbedDashboard = class extends LuzmoDashboard {};
1120
+ customElements.get("luzmo-embed-dashboard") || customElements.define("luzmo-embed-dashboard", LuzmoEmbedDashboard);
1121
+ var dashboardContentsVersion = "0.1.99", vizItemRemote = "VizItemApp", LuzmoBaseVizItem = class extends LitElement {
1122
+ constructor() {
1123
+ super(...arguments), this.appServer = "https://app.luzmo.com", this.apiHost = "https://api.luzmo.com", this.slots = [], this.version = version + "-wc-luzmo", this.dashboardContentsVersion = dashboardContentsVersion, this.libVersion = version + "-wc-luzmo", this.postInitCallQueue = [];
1124
+ }
1125
+ static {
1126
+ this.styles = css`
1127
+ :host {
1128
+ display: block;
1129
+ width: 100%;
1130
+ height: 100%;
1131
+ }
1132
+
1133
+ luzmo-embed-viz-item {
1134
+ width: 100%;
1135
+ height: 1000%;
1136
+ display: block;
1137
+ }
1138
+ `;
1139
+ }
1140
+ createRenderRoot() {
1141
+ return this.style.display || (this.style.display = "block"), this.style.height || (this.style.height = "100%"), this.style.width || (this.style.width = "100%"), this;
1142
+ }
1143
+ canInitializeVizItem() {
1144
+ return !!(this.type || this.dashboardId && this.itemId);
1145
+ }
1146
+ getFilters() {
1147
+ return this.chartElement.getFilters();
1148
+ }
1149
+ export(e = "png") {
1150
+ return this.chartElement.export(e);
1151
+ }
1152
+ getData() {
1153
+ return this.chartElement.getData();
1154
+ }
1155
+ refreshData() {
1156
+ return this.chartElement.refreshData();
1157
+ }
1158
+ setSelectedData(e) {
1159
+ return this.chartElement.setSelectedData(void 0, e);
1160
+ }
1161
+ setAuthorization(e, k) {
1162
+ return this.chartElement.setAuthorization(e, k);
1163
+ }
1164
+ attributeChangedCallback(e, k, A) {
1165
+ super.attributeChangedCallback(e, k, A), e === "selecteddata" && (this.chartElement ? this.setSelectedData(JSON.parse(A ?? "{}")) : this.postInitCallQueue.push([this.setSelectedData, [JSON.parse(A ?? "{}")]]));
1166
+ }
1167
+ async firstUpdated(e) {
1168
+ super.firstUpdated(e), this.canInitializeVizItem() && (await loadLibrary(this.appServer, vizItemRemote), this.createAndAppendElement());
1169
+ }
1170
+ createAndAppendElement() {
1171
+ this.chartElement || (this.chartElement = document.createElement("chart-component"), this.chartElement.setAttribute("embedding-mode", "chart"), this.chartElement.style.height = "100%", this.chartElement.style.width = "100%", this.chartElement.style.display = "block", this.chartElement.addEventListener("load", (e) => this.dispatchEvent(new CustomEvent("load", e))), this.chartElement.addEventListener("rendered", (e) => {
1172
+ if (this.postInitCallQueue?.length > 0) for (let e of this.postInitCallQueue) e[0].bind(this)(...e[1]);
1173
+ else this.selectedData && this.setSelectedData(this.selectedData);
1174
+ this.dispatchEvent(new CustomEvent("rendered", e));
1175
+ }), this.chartElement.addEventListener("changedFilters", (e) => this.dispatchEvent(new CustomEvent("changedFilters", e))), this.chartElement.addEventListener("exported", (e) => this.dispatchEvent(new CustomEvent("exported", e))), this.chartElement.addEventListener("customEvent", (e) => this.dispatchEvent(new CustomEvent("customEvent", e))), this.updateVizItemProperties(), this.renderRoot.append(this.chartElement));
1176
+ }
1177
+ updateVizItemProperties() {
1178
+ if (this.chartElement) for (let e in libraryTypeToWebComponentTypeMapping) {
1179
+ let k = this[e];
1180
+ if (k) {
1181
+ let A = ["appServer", "apiHost"].includes(e) ? removeTrailingSlash(k) : k;
1182
+ this.chartElement.setAttribute(libraryTypeToWebComponentTypeMapping[e], typeof A == "object" ? JSON.stringify(A) : A);
1183
+ }
1184
+ }
1185
+ }
1186
+ async updated(e) {
1187
+ if (this.chartElement) for (let [k] of e.entries()) {
1188
+ let e = libraryTypeToWebComponentTypeMapping[k] ?? k, A = typeof this[k] == "object" ? JSON.stringify(this[k]) : this[k]?.toString() ?? this[k];
1189
+ this.chartElement.setAttribute(e, A);
1190
+ }
1191
+ else this.canInitializeVizItem() && (await loadLibrary(this.appServer, vizItemRemote), this.createAndAppendElement());
1192
+ }
1193
+ render() {
1194
+ return html` `;
1195
+ }
1196
+ };
1197
+ __decorateClass([property()], LuzmoBaseVizItem.prototype, "appServer", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "apiHost", 2), __decorateClass([property({ type: Array })], LuzmoBaseVizItem.prototype, "slots", 2), __decorateClass([property({ type: Object })], LuzmoBaseVizItem.prototype, "options", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "type", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "authKey", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "authToken", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "version", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "contextId", 2), __decorateClass([property({ converter: (e) => {
1198
+ try {
1199
+ return JSON.parse(e);
1200
+ } catch {
1201
+ return e;
1202
+ }
1203
+ } })], LuzmoBaseVizItem.prototype, "canFilter", 2), __decorateClass([property({ type: Array })], LuzmoBaseVizItem.prototype, "filters", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "dashboardId", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "itemId", 2), __decorateClass([property({ type: Object })], LuzmoBaseVizItem.prototype, "selectedData", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "dashboardContentsVersion", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "libVersion", 2);
1204
+ var LuzmoEmbedVizItem = class extends LuzmoBaseVizItem {};
1205
+ customElements.get("luzmo-embed-viz-item") || customElements.define("luzmo-embed-viz-item", LuzmoEmbedVizItem);
1206
+ var inputMap = {
1207
+ aiEndpoint: "ai-endpoint",
1208
+ appServer: "app-server",
1209
+ apiHost: "api-host",
1210
+ options: "options",
1211
+ initialSuggestionsDatasetId: "initialSuggestionsDatasetId",
1212
+ authKey: "auth-key",
1213
+ authToken: "auth-token",
1214
+ version: "version",
1215
+ libVersion: "lib-version",
1216
+ aydHost: "ayd-host",
1217
+ availableDatasets: "available-datasets"
1218
+ }, embedChatTag = "luzmo-iq-embed-chat", chatComponentTag = "luzmo-iq-chat-component", LuzmoIQEmbedChatComponent = class extends LitElement {
1219
+ constructor() {
1220
+ super(...arguments), this.appServer = "https://app.luzmo.com", this.apiHost = "https://api.luzmo.com", this.version = version + "-wc-luzmo", this.libVersion = version + "-wc-luzmo", this.remoteEntryServer = "http://localhost:4202/", this.aydHost = "https://ayd.luzmo.com/";
1221
+ }
1222
+ static {
1223
+ this.styles = css`
1224
+ :host {
1225
+ display: block;
1226
+ width: 100%;
1227
+ height: 100%;
1228
+ }
1229
+ `;
1230
+ }
1231
+ createRenderRoot() {
1232
+ return this;
1233
+ }
1234
+ async firstUpdated(e) {
1235
+ super.firstUpdated(e), await loadLibrary(this.calculatedAppServer, "IQApp"), this.createAndAppendElement();
1236
+ }
1237
+ get calculatedAppServer() {
1238
+ return this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer;
1721
1239
  }
1722
- _calculateDimAfterDashboardLoaded() {
1723
- this.dashboardError = !1, this._loaderStyles(), _setCalculatedDimensions(this);
1240
+ createAndAppendElement() {
1241
+ this.chartElement || (this.chartElement = document.createElement(chatComponentTag), this.chartElement.addEventListener("load", (e) => this.dispatchEvent(new CustomEvent("load", e))), this.updateVizItemProperties(), this.renderRoot.append(this.chartElement));
1724
1242
  }
1725
- _loaderStyles() {
1726
- this._containerStyle = containerStyles(this), this._loaderStyle = loaderStyles(this), this._loadingCircleStyle = plStyles(this), this._containerLoaderStyle = containerLoaderStyles(this), this._lcStyle = lcStyles(this);
1243
+ updateVizItemProperties() {
1244
+ if (this.chartElement) for (let e in inputMap) {
1245
+ let k = this[e];
1246
+ if (k) {
1247
+ let A = [
1248
+ "appServer",
1249
+ "apiHost",
1250
+ "aydHost"
1251
+ ].includes(e) ? removeTrailingSlash(k) : k;
1252
+ this.chartElement.setAttribute(inputMap[e], typeof A == "object" ? JSON.stringify(A) : A);
1253
+ }
1254
+ }
1727
1255
  }
1728
- static get styles() {
1729
- return [dashboardStyles];
1256
+ async updated(e) {
1257
+ if (this.chartElement) for (let [k] of e.entries()) {
1258
+ let e = inputMap[k] ?? k, A = typeof this[k] == "object" ? JSON.stringify(this[k]) : this[k]?.toString() ?? this[k];
1259
+ this.chartElement.setAttribute(e, A);
1260
+ }
1261
+ else await loadLibrary(this.calculatedAppServer, "IQApp"), this.createAndAppendElement();
1730
1262
  }
1731
1263
  render() {
1732
- let e, k = html`
1733
- <div
1734
- class="luzmo-container-loader"
1735
- id="luzmo-container-loader-${this._containerId}"
1736
- style=${styleMap(this._containerLoaderStyle)}
1737
- >
1738
- <div
1739
- class="luzmo-loader"
1740
- id="luzmo-loader-${this._containerId}"
1741
- style=${styleMap(this._loaderStyle)}
1742
- >
1743
- <div
1744
- class="luzmo-lc"
1745
- style=${styleMap(this._lcStyle)}
1746
- >
1747
- <div
1748
- class="luzmo-loading-circle"
1749
- style=${styleMap(this._loadingCircleStyle)}
1750
- ></div>
1751
- ${this._itemEmbedding ? "" : html`
1752
- <div
1753
- class="luzmo-loading-message"
1754
- style=${styleMap({ color: this.loaderFontColor })}
1755
- >
1756
- ${this._loaderMsg}
1757
- </div>
1758
- `}
1759
- </div>
1760
- </div>
1761
- </div>
1762
- `;
1763
- return e = this.isWebComponentViewMode() ? this.isLibraryLoaded ? html`
1764
- ${this.dashboardId || this.dashboardSlug ? html`
1765
- <dashboard-component dashboard-id="${this.params.dashboardId}" app-server="${this.params.appServer}"
1766
- api-host="${this.params.apiHost}"></dashboard-component>
1767
- ` : html`
1768
- <div id="luzmo-error-${this._containerId}">
1769
- <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
1770
- </div>
1771
- `}
1772
- ` : html`${k}` : html`
1773
- ${this.dashboardId || this.dashboardSlug ? html`
1774
- ${k}
1775
- <iframe
1776
- class="luzmo-embed-dashboard ${this.isWebComponentViewMode() ? "" : "luzmo-embed-dashboard-ede"}"
1777
- id="${this._iframeId}"
1778
- name="${this._iframeId}"
1779
- style=${styleMap(this.iframeStyle)}
1780
- src="${this._iframeUrl}"
1781
- frameborder="0"
1782
- ></iframe>
1783
- ` : html`<!-- the dashboard will inititialize when you provide a dashboardSlug or a dashboardId -->`}
1784
- ${this.browserError ? html`
1785
- <div id="luzmo-error-${this._containerId}">
1786
- <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
1787
- </div>
1788
- ` : ""}
1789
- `, html`
1790
- <div class="${luzmoEmbedContainerClass} ${this.isWebComponentViewMode() ? "" : `${luzmoEmbedContainerClass}-ede`}">
1791
- <div
1792
- class="dashboard-container"
1793
- style=${styleMap(Object.assign({}, this._containerStyle, {
1794
- width: this.iframeStyle.width ?? "100%",
1795
- height: this.iframeStyle.height ?? "100%"
1796
- }))}
1797
- >
1798
- ${e}
1799
- </div>
1800
- </div>
1801
-
1802
- `;
1264
+ return html``;
1803
1265
  }
1804
- getDashboards() {
1805
- return new Promise((e) => e(luzmo_service_default._dashboardComponents));
1266
+ connectedCallback() {
1267
+ super.connectedCallback();
1268
+ let e = document.querySelector(embedChatTag);
1269
+ if (!e) return;
1270
+ let k = new MutationObserver(() => {
1271
+ let A = e.querySelector("*[slot=\"custom-chat-widget-content\"]");
1272
+ if (!A) return;
1273
+ let j = e.querySelector(chatComponentTag);
1274
+ j && (j.append(A), k.disconnect());
1275
+ });
1276
+ k.observe(e, {
1277
+ childList: !0,
1278
+ subtree: !0
1279
+ });
1806
1280
  }
1807
- getData(e) {
1808
- return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.getData(e) : this.isWebComponentViewMode() ? Promise.reject() : getData(this, this.iframe, e);
1281
+ };
1282
+ __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "appServer", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "apiHost", 2), __decorateClass([property({ type: Object })], LuzmoIQEmbedChatComponent.prototype, "options", 2), __decorateClass([property({ type: String })], LuzmoIQEmbedChatComponent.prototype, "initialSuggestionsDatasetId", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "aiEndpoint", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "authKey", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "authToken", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "version", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "libVersion", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "remoteEntryServer", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "aydHost", 2), __decorateClass([property({ type: Array })], LuzmoIQEmbedChatComponent.prototype, "availableDatasets", 2), customElements.get(embedChatTag) || customElements.define(embedChatTag, LuzmoIQEmbedChatComponent);
1283
+ var inputMap2 = {
1284
+ aiEndPoint: "ai-end-point",
1285
+ appServer: "app-server",
1286
+ apiHost: "api-host",
1287
+ options: "options",
1288
+ authKey: "auth-key",
1289
+ authToken: "auth-token",
1290
+ version: "version",
1291
+ libVersion: "lib-version",
1292
+ messages: "messages"
1293
+ }, componentTag = "luzmo-iq-embed-answer", LuzmoIQEmbedAnswerComponent = class extends LitElement {
1294
+ constructor() {
1295
+ super(...arguments), this.appServer = "https://app.luzmo.com", this.apiHost = "https://api.luzmo.com", this.version = version + "-wc-luzmo", this.libVersion = version + "-wc-luzmo", this.remoteEntryServer = "http://localhost:4202";
1809
1296
  }
1810
- getFilters() {
1811
- return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.getFilters() : this.isWebComponentViewMode() ? Promise.reject() : getFilters(this, this.iframe);
1297
+ static {
1298
+ this.styles = css`
1299
+ :host {
1300
+ display: block;
1301
+ width: 100%;
1302
+ height: 100%;
1303
+ }
1304
+ `;
1812
1305
  }
1813
- setSelectedData(e, k) {
1814
- return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.setSelectedData(e, k) : this.isWebComponentViewMode() ? Promise.reject() : setSelectedData(this, this.iframe, e, k);
1306
+ createRenderRoot() {
1307
+ return this;
1815
1308
  }
1816
- setAuthorization(e, k) {
1817
- return this.currentAuthKey = e, this.currentAuthToken = k, this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.setAuthorization(e, k) : this.isWebComponentViewMode() ? Promise.reject() : setAuthorization(this, this.iframe, e, k);
1309
+ async firstUpdated(e) {
1310
+ super.firstUpdated(e), await loadLibrary(this.calculatedAppServer, "IQApp"), this.createAndAppendElement();
1818
1311
  }
1819
- refreshData(e) {
1820
- return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.refreshData(e) : this.isWebComponentViewMode() ? Promise.reject() : e ? refreshData(this, this.iframe, e) : refreshData(this, this.iframe);
1312
+ get calculatedAppServer() {
1313
+ return this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer;
1821
1314
  }
1822
- reloadDashboard() {
1823
- return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.reloadDashboard() : this.isWebComponentViewMode() ? Promise.reject() : reloadDashboard(this, this.iframe);
1315
+ createAndAppendElement() {
1316
+ this.chartElement || (this.chartElement = document.createElement("luzmo-iq-answer-component"), this.chartElement.addEventListener("addQuestion", (e) => this.dispatchEvent(new CustomEvent("addQuestion", e))), this.chartElement.addEventListener("addAnswer", (e) => this.dispatchEvent(new CustomEvent("addAnswer", e))), this.updateVizItemProperties(), this.renderRoot.append(this.chartElement));
1824
1317
  }
1825
- exportDashboard(e) {
1826
- return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.exportDashboard(e) : this.isWebComponentViewMode() ? Promise.reject() : e ? exportDashboard(this, this.iframe, e) : exportDashboard(this, this.iframe);
1318
+ updateVizItemProperties() {
1319
+ if (this.chartElement) for (let e in inputMap2) {
1320
+ let k = this[e];
1321
+ if (k) {
1322
+ let A = ["appServer", "apiHost"].includes(e) ? removeTrailingSlash(k) : k;
1323
+ this.chartElement.setAttribute(inputMap2[e], typeof A == "object" ? JSON.stringify(A) : A);
1324
+ }
1325
+ }
1827
1326
  }
1828
- getAccessibleDashboards() {
1829
- return getAccessibleDashboards(this);
1327
+ async updated(e) {
1328
+ if (this.chartElement) for (let [k] of e.entries()) {
1329
+ let e = inputMap2[k] ?? k, A = typeof this[k] == "object" ? JSON.stringify(this[k]) : this[k]?.toString() ?? this[k];
1330
+ this.chartElement.setAttribute(e, A);
1331
+ }
1332
+ else await loadLibrary(this.calculatedAppServer, "IQApp"), this.createAndAppendElement();
1830
1333
  }
1831
- addFilters(e, k) {
1832
- return this.dashboardReference.addFilters(e, k);
1334
+ render() {
1335
+ return html` `;
1833
1336
  }
1834
- setEditMode(e) {
1835
- return this.dashboardReference && e === "view" ? (this.editMode = "view", this.params.editMode = "view", this.initComponent(), Promise.resolve({
1836
- type: "setEditMode",
1837
- editMode: e
1838
- })) : this.dashboardReference && ["editFull", "editLimited"].includes(e) ? (this.editMode = e, this.params.editMode = e, this.initComponent(), Promise.resolve({
1839
- type: "setEditMode",
1840
- editMode: e
1841
- })) : this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.setEditMode(e) : this.isWebComponentViewMode() ? Promise.reject() : setEditMode(this, this.iframe, e);
1337
+ };
1338
+ __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "appServer", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "apiHost", 2), __decorateClass([property({ type: Object })], LuzmoIQEmbedAnswerComponent.prototype, "options", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "aiEndPoint", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "authKey", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "authToken", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "messages", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "version", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "libVersion", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "remoteEntryServer", 2), customElements.get(componentTag) || customElements.define(componentTag, LuzmoIQEmbedAnswerComponent), LitElement.disableWarning?.("change-in-update");
1339
+ var gridstack_min_default = ".grid-stack{position:relative}.grid-stack-rtl{direction:ltr}.grid-stack-rtl>.grid-stack-item{direction:rtl}.grid-stack-placeholder>.placeholder-content{background-color:#0000001a;width:auto;margin:0;position:absolute;z-index:0!important}.grid-stack>.grid-stack-item{width:var(--gs-column-width);height:var(--gs-cell-height);padding:0;position:absolute;top:0;left:0}.grid-stack>.grid-stack-item>.grid-stack-item-content{width:auto;margin:0;position:absolute;overflow:hidden auto}.grid-stack>.grid-stack-item.size-to-content:not(.size-to-content-max)>.grid-stack-item-content{overflow-y:hidden}.grid-stack>.grid-stack-item>.grid-stack-item-content,.grid-stack>.grid-stack-placeholder>.placeholder-content{top:var(--gs-item-margin-top);right:var(--gs-item-margin-right);bottom:var(--gs-item-margin-bottom);left:var(--gs-item-margin-left)}.grid-stack-item>.ui-resizable-handle{-ms-touch-action:none;touch-action:none;font-size:.1px;display:block;position:absolute}.grid-stack-item.ui-resizable-autohide>.ui-resizable-handle,.grid-stack-item.ui-resizable-disabled>.ui-resizable-handle{display:none}.grid-stack-item>.ui-resizable-ne,.grid-stack-item>.ui-resizable-nw,.grid-stack-item>.ui-resizable-se,.grid-stack-item>.ui-resizable-sw{background-image:url(\"data:image/svg+xml;utf8,<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" fill=\\\"none\\\" stroke=\\\"%23666\\\" stroke-linecap=\\\"round\\\" stroke-linejoin=\\\"round\\\" stroke-width=\\\"2\\\" viewBox=\\\"0 0 20 20\\\"><path d=\\\"m10 3 2 2H8l2-2v14l-2-2h4l-2 2\\\"/></svg>\");background-position:50%;background-repeat:no-repeat}.grid-stack-item>.ui-resizable-ne,.grid-stack-item>.ui-resizable-sw{transform:rotate(45deg)}.grid-stack-item>.ui-resizable-nw,.grid-stack-item>.ui-resizable-se{transform:rotate(-45deg)}.grid-stack-item>.ui-resizable-nw{cursor:nw-resize;width:20px;height:20px;top:var(--gs-item-margin-top);left:var(--gs-item-margin-left)}.grid-stack-item>.ui-resizable-n{cursor:n-resize;height:10px;top:var(--gs-item-margin-top);left:25px;right:25px}.grid-stack-item>.ui-resizable-ne{cursor:ne-resize;width:20px;height:20px;top:var(--gs-item-margin-top);right:var(--gs-item-margin-right)}.grid-stack-item>.ui-resizable-e{cursor:e-resize;width:10px;top:15px;bottom:15px;right:var(--gs-item-margin-right)}.grid-stack-item>.ui-resizable-se{cursor:se-resize;width:20px;height:20px;bottom:var(--gs-item-margin-bottom);right:var(--gs-item-margin-right)}.grid-stack-item>.ui-resizable-s{cursor:s-resize;height:10px;left:25px;bottom:var(--gs-item-margin-bottom);right:25px}.grid-stack-item>.ui-resizable-sw{cursor:sw-resize;width:20px;height:20px;bottom:var(--gs-item-margin-bottom);left:var(--gs-item-margin-left)}.grid-stack-item>.ui-resizable-w{cursor:w-resize;width:10px;top:15px;bottom:15px;left:var(--gs-item-margin-left)}.grid-stack-item.ui-draggable-dragging>.ui-resizable-handle{display:none!important}.grid-stack-item.ui-draggable-dragging{will-change:left,top}.grid-stack-item.ui-resizable-resizing{will-change:width,height}.ui-draggable-dragging,.ui-resizable-resizing{z-index:10000}.ui-draggable-dragging>.grid-stack-item-content,.ui-resizable-resizing>.grid-stack-item-content{opacity:.8;box-shadow:1px 4px 6px #0003}.grid-stack-animate,.grid-stack-animate .grid-stack-item{transition:left .3s,top .3s,height .3s,width .3s}.grid-stack-animate .grid-stack-item.grid-stack-placeholder,.grid-stack-animate .grid-stack-item.ui-draggable-dragging,.grid-stack-animate .grid-stack-item.ui-resizable-resizing{transition:left,top,height,width}.grid-stack>.grid-stack-item[gs-y=\"0\"]{top:0}.grid-stack>.grid-stack-item[gs-x=\"0\"]{left:0}", lockAction = {
1340
+ icon: luzmoLockOutline,
1341
+ label: "Lock",
1342
+ tooltip: "Lock",
1343
+ action: "lock",
1344
+ type: "toggle"
1345
+ }, editAction = {
1346
+ icon: luzmoPencil,
1347
+ label: "Edit",
1348
+ tooltip: "Edit",
1349
+ action: "edit",
1350
+ type: "toggle"
1351
+ }, editDataAction = {
1352
+ icon: luzmoTable,
1353
+ label: "Edit data",
1354
+ tooltip: "Data",
1355
+ action: "edit-data",
1356
+ type: "toggle"
1357
+ }, editOptionsAction = {
1358
+ icon: luzmoCog,
1359
+ label: "Edit options",
1360
+ tooltip: "Options",
1361
+ action: "edit-options",
1362
+ type: "toggle"
1363
+ }, editFiltersAction = {
1364
+ icon: luzmoFilterOutline,
1365
+ label: "Edit filters",
1366
+ tooltip: "Filters",
1367
+ action: "edit-filters",
1368
+ type: "toggle"
1369
+ }, cloneAction = {
1370
+ icon: luzmoClone,
1371
+ label: "Clone",
1372
+ tooltip: "Clone",
1373
+ action: "clone",
1374
+ type: "button"
1375
+ }, deleteAction = {
1376
+ icon: luzmoTrashOutline,
1377
+ label: "Delete",
1378
+ tooltip: "Delete",
1379
+ action: "delete",
1380
+ type: "button"
1381
+ };
1382
+ const generateActionsMenu = (e) => {
1383
+ if (!e) return;
1384
+ let k = [];
1385
+ return k = structuredClone(e).map((e) => {
1386
+ if (e.type === "group") return e.actions = e.actions ?? [], e.actions = e.actions.map((e) => {
1387
+ if (typeof e == "string" && [
1388
+ "lock",
1389
+ "filters",
1390
+ "edit",
1391
+ "edit-data",
1392
+ "edit-options",
1393
+ "edit-filters",
1394
+ "delete",
1395
+ "clone"
1396
+ ].includes(e)) return {
1397
+ delete: { ...deleteAction },
1398
+ filters: { ...editFiltersAction },
1399
+ clone: { ...cloneAction },
1400
+ edit: { ...editAction },
1401
+ "edit-data": { ...editDataAction },
1402
+ "edit-options": { ...editOptionsAction },
1403
+ "edit-filters": { ...editFiltersAction },
1404
+ lock: { ...lockAction }
1405
+ }[e];
1406
+ if (typeof e == "object") return e.icon = e.icon ?? luzmoCircle, e.label = e.label ?? e.action, e.tooltip = e.tooltip ?? e.label ?? e.action, e.type = ["toggle", "button"].includes(e.type ?? "") ? e.type : "button", e;
1407
+ }).filter(Boolean), e;
1408
+ }).filter(Boolean), k;
1409
+ }, defaultActionsMenu = () => [{
1410
+ type: "group",
1411
+ actions: [
1412
+ { ...editDataAction },
1413
+ { ...editOptionsAction },
1414
+ { ...cloneAction }
1415
+ ]
1416
+ }, {
1417
+ type: "group",
1418
+ actions: [{ ...deleteAction }]
1419
+ }];
1420
+ var grid_item_actions_menu_module_default = ":host{--luzmo-action-button-content-color-default:var(--luzmo-grid-item-action-button-content-color-default,#fff);--luzmo-action-button-content-color-hover:var(--luzmo-grid-item-action-button-content-color-hover,#fff);--luzmo-action-button-content-color-down:var(--luzmo-grid-item-action-button-content-color-down,#fff);--luzmo-action-button-content-color-focus:var(--luzmo-grid-item-action-button-content-color-focus,#fff);--luzmo-action-button-background-color-default:var(--luzmo-grid-item-action-button-background-color-default,#333);--luzmo-action-button-background-color-hover:var(--luzmo-grid-item-action-button-background-color-hover,#444);--luzmo-action-button-background-color-down:var(--luzmo-grid-item-action-button-background-color-down,#555);--luzmo-action-button-background-color-focus:var(--luzmo-grid-item-action-button-background-color-focus,#666);--grid-item-actions-flex-direction:column;display:block}.action-buttons{gap:var(--luzmo-grid-item-action-group-gap,.5rem);flex-direction:var(--luzmo-grid-item-actions-flex-direction,var(--grid-item-actions-flex-direction));outline:none;display:flex}.action-button[selected]{--luzmo-action-button-background-color-default:var(--luzmo-primary);--luzmo-action-button-background-color-hover:var(--luzmo-primary-hover);--luzmo-action-button-background-color-down:var(--luzmo-primary-down);--luzmo-action-button-background-color-focus:var(--luzmo-primary-focus);--luzmo-action-button-content-color-default:var(--luzmo-primary-inverse-color);--luzmo-action-button-content-color-hover:var(--luzmo-primary-inverse-color);--luzmo-action-button-content-color-down:var(--luzmo-primary-inverse-color);--luzmo-action-button-content-color-focus:var(--luzmo-primary-inverse-color)}:host .action-buttons{--luzmo-action-button-content-color-default:var(--luzmo-grid-item-action-button-content-color-default,#fff);--luzmo-action-button-content-color-hover:var(--luzmo-grid-item-action-button-content-color-hover,#fff);--luzmo-action-button-content-color-down:var(--luzmo-grid-item-action-button-content-color-down,#fff);--luzmo-action-button-content-color-focus:var(--luzmo-grid-item-action-button-content-color-focus,#fff);--luzmo-action-button-background-color-default:var(--luzmo-grid-item-action-button-background-color-default,#333);--luzmo-action-button-background-color-hover:var(--luzmo-grid-item-action-button-background-color-hover,#444);--luzmo-action-button-background-color-down:var(--luzmo-grid-item-action-button-background-color-down,#555);--luzmo-action-button-background-color-focus:var(--luzmo-grid-item-action-button-background-color-focus,#666)}.delete-button{--luzmo-action-button-background-color-hover:var(--luzmo-grid-item-delete-button-background-color-hover,var(--luzmo-negative-color));--luzmo-action-button-content-color-hover:var(--luzmo-grid-item-delete-button-content-color-hover,#fff);--luzmo-action-button-background-color-focus:var(--luzmo-grid-item-delete-button-background-color-focus,var(--luzmo-negative-color-focus));--luzmo-action-button-content-color-focus:var(--luzmo-grid-item-delete-button-content-color-focus,#fff);--luzmo-action-button-background-color-down:var(--luzmo-grid-item-delete-button-background-color-down,var(--luzmo-negative-color-down));--luzmo-action-button-content-color-down:var(--luzmo-grid-item-delete-button-content-color-down,#fff)}:host([placement=top-start]),:host([placement=top]),:host([placement=top-end]),:host([placement=bottom-start]),:host([placement=bottom]),:host([placement=bottom-end]){--grid-item-actions-flex-direction:row}", LuzmoGridItemActionsMenu = class extends LocalizedMixin(LuzmoElement) {
1421
+ constructor(...e) {
1422
+ super(...e), this.placement = "right-start", this.actions = defaultActionsMenu();
1842
1423
  }
1843
- setPreview(e) {
1844
- return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.setPreview(e) : setPreview(this, this.iframe, e);
1424
+ static get styles() {
1425
+ return [unsafeCSS(grid_item_actions_menu_module_default)];
1845
1426
  }
1846
- sendExportEmail(e, k, A) {
1847
- return this.isWebComponentViewMode() && this.dashboardReference ? this.dashboardReference.sendExportEmail(e, k, A) : this.isWebComponentViewMode() ? Promise.reject() : sendExportEmail(this, this.iframe, e, k, A);
1427
+ get isVertical() {
1428
+ return this.placement.includes("left") || this.placement.includes("right");
1848
1429
  }
1849
- isWebComponentViewMode() {
1850
- return this.embedMode === "webComponent" && (this.params.editMode === "view" || this.params.editMode === void 0);
1430
+ _dispatchAction(e) {
1431
+ this.dispatchEvent(new CustomEvent("luzmo-grid-item-action", {
1432
+ bubbles: !0,
1433
+ composed: !0,
1434
+ detail: {
1435
+ action: e.action,
1436
+ type: e.type,
1437
+ active: e.active
1438
+ }
1439
+ }));
1851
1440
  }
1852
- };
1853
- __decorateClass([query(".dashboard-container")], LuzmoDashboard.prototype, "container", 2), __decorateClass([query(`.${luzmoEmbedContainerClass}`)], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2), __decorateClass([query("iframe")], LuzmoDashboard.prototype, "iframe", 2), __decorateClass([property()], LuzmoDashboard.prototype, "dashboardId", 2), __decorateClass([property()], LuzmoDashboard.prototype, "dashboardSlug", 2), __decorateClass([property()], LuzmoDashboard.prototype, "itemId", 2), __decorateClass([property()], LuzmoDashboard.prototype, "language", 2), __decorateClass([property()], LuzmoDashboard.prototype, "editorLanguage", 2), __decorateClass([property()], LuzmoDashboard.prototype, "qeVersion", 2), __decorateClass([property()], LuzmoDashboard.prototype, "screenMode", 2), __decorateClass([property({ converter: {
1854
- fromAttribute: (e) => e === "true",
1855
- toAttribute: String
1856
- } })], LuzmoDashboard.prototype, "switchScreenModeOnResize", 2), __decorateClass([property()], LuzmoDashboard.prototype, "editMode", 2), __decorateClass([property()], LuzmoDashboard.prototype, "theme", 2), __decorateClass([property()], LuzmoDashboard.prototype, "mainColor", 2), __decorateClass([property()], LuzmoDashboard.prototype, "accentColor", 2), __decorateClass([property()], LuzmoDashboard.prototype, "authToken", 2), __decorateClass([property()], LuzmoDashboard.prototype, "authKey", 2), __decorateClass([property()], LuzmoDashboard.prototype, "loaderBackground", 2), __decorateClass([property()], LuzmoDashboard.prototype, "loaderFontColor", 2), __decorateClass([property()], LuzmoDashboard.prototype, "loaderSpinnerColor", 2), __decorateClass([property()], LuzmoDashboard.prototype, "loaderSpinnerBackground", 2), __decorateClass([property()], LuzmoDashboard.prototype, "appServer", 2), __decorateClass([property()], LuzmoDashboard.prototype, "timezoneId", 2), __decorateClass([property()], LuzmoDashboard.prototype, "apiHost", 2), __decorateClass([property({ type: Object })], LuzmoDashboard.prototype, "itemDimensions", 2), __decorateClass([property()], LuzmoDashboard.prototype, "embedMode", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_containerId", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_iframeId", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "params", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_iframeUrl", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "iframeLoaded", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "promises", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "iframeStyle", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_containerStyle", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_loaderStyle", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_lcStyle", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_loadingCircleStyle", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_containerLoaderStyle", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_loaderMsg", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "containerWidth", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "dimensions", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "currentScreenMode", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "_itemEmbedding", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "browserError", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "browserErrorMsg", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "dashboardError", 2), __decorateClass([property({ attribute: !1 })], LuzmoDashboard.prototype, "browserNotSupported", 2), __decorateClass([property()], LuzmoDashboard.prototype, "libVersion", 2), __decorateClass([state()], LuzmoDashboard.prototype, "isLibraryLoaded", 2), __decorateClass([state()], LuzmoDashboard.prototype, "dashboardReference", 2), __decorateClass([state()], LuzmoDashboard.prototype, "currentAuthKey", 2), __decorateClass([state()], LuzmoDashboard.prototype, "currentAuthToken", 2), __decorateClass([state()], LuzmoDashboard.prototype, "isInitCalled", 2);
1857
- var LuzmoEmbedDashboard = class extends LuzmoDashboard {};
1858
- customElements.get("luzmo-embed-dashboard") || customElements.define("luzmo-embed-dashboard", LuzmoEmbedDashboard);
1859
- var dashboardContentsVersion = "0.1.99", vizItemRemote = "VizItemApp", LuzmoBaseVizItem = class extends LitElement {
1860
- constructor() {
1861
- super(...arguments), this.appServer = "https://app.luzmo.com", this.apiHost = "https://api.luzmo.com", this.slots = [], this.version = version + "-wc-luzmo", this.dashboardContentsVersion = dashboardContentsVersion, this.libVersion = version + "-wc-luzmo", this.postInitCallQueue = [];
1441
+ _handleActionClick(e) {
1442
+ e.type === "toggle" && (e.active = !e.active, this.actions.forEach((k) => {
1443
+ k.actions?.forEach((k) => {
1444
+ e !== k && k.active && (k.active = !1);
1445
+ });
1446
+ })), this._dispatchAction(e), this.requestUpdate();
1862
1447
  }
1863
- static {
1864
- this.styles = css`
1865
- :host {
1866
- display: block;
1867
- width: 100%;
1868
- height: 100%;
1869
- }
1870
-
1871
- luzmo-embed-viz-item {
1872
- width: 100%;
1873
- height: 1000%;
1874
- display: block;
1875
- }
1876
- `;
1448
+ clearActiveToggles() {
1449
+ this.actions = this.actions.map((e) => ({
1450
+ ...e,
1451
+ actions: e.actions?.map((e) => (e.type === "toggle" && (e.active = !1), e)) ?? []
1452
+ }));
1877
1453
  }
1878
- createRenderRoot() {
1879
- return this.style.display || (this.style.display = "block"), this.style.height || (this.style.height = "100%"), this.style.width || (this.style.width = "100%"), this;
1454
+ focus() {
1455
+ let e = this.shadowRoot?.querySelectorAll("luzmo-action-button[toggles]");
1456
+ e && e[0]?.focus();
1880
1457
  }
1881
- canInitializeVizItem() {
1882
- return !!(this.type || this.dashboardId && this.itemId);
1458
+ _generateActionButton(e) {
1459
+ let k = {
1460
+ Data: msg("Data", { desc: "Grid item action tooltip" }),
1461
+ Options: msg("Options", { desc: "Grid item action tooltip" }),
1462
+ Clone: msg("Clone", { desc: "Grid item action tooltip" }),
1463
+ Delete: msg("Delete", { desc: "Grid item action tooltip" }),
1464
+ Edit: msg("Edit", { desc: "Grid item action tooltip" }),
1465
+ Lock: msg("Lock", { desc: "Grid item action tooltip" }),
1466
+ Filters: msg("Filters", { desc: "Grid item action tooltip" })
1467
+ };
1468
+ return html`
1469
+ <luzmo-action-button
1470
+ class="${e.action}-button action-button"
1471
+ .label=${e.label}
1472
+ ?toggles=${e.type === "toggle"}
1473
+ ?selected=${e.type === "toggle" && e.active}
1474
+ @click=${this._handleActionClick.bind(this, e)}
1475
+ >
1476
+ <luzmo-icon slot="icon" .icon=${e.icon} size="s"></luzmo-icon>
1477
+ ${e.tooltip ? html`
1478
+ <luzmo-tooltip
1479
+ self-managed
1480
+ delayed
1481
+ placement=${this.placement?.includes("right") ? "right" : this.placement?.includes("left") ? "left" : this.placement?.includes("bottom") ? "bottom" : this.placement?.includes("top") ? "top" : "right"}
1482
+ >
1483
+ ${k[e.tooltip] ?? e.tooltip}
1484
+ </luzmo-tooltip>
1485
+ ` : ""}
1486
+ </luzmo-action-button>
1487
+ `;
1883
1488
  }
1884
- getFilters() {
1885
- return this.chartElement.getFilters();
1489
+ _generateActionGroup(e) {
1490
+ let k = e?.actions?.map((e) => this._generateActionButton(e)) ?? [];
1491
+ return k.length > 0 ? html`
1492
+ <luzmo-action-group ?vertical=${this.isVertical} compact
1493
+ >${k}</luzmo-action-group
1494
+ >
1495
+ ` : html`
1496
+
1497
+ `;
1886
1498
  }
1887
- export(e = "png") {
1888
- return this.chartElement.export(e);
1499
+ render() {
1500
+ return html`
1501
+ <div class="action-buttons" tabindex="0">${this.actions.map((e) => this._generateActionGroup(e))}</div>
1502
+ `;
1889
1503
  }
1890
- getData() {
1891
- return this.chartElement.getData();
1504
+ };
1505
+ __decorate([property({
1506
+ type: String,
1507
+ reflect: !0
1508
+ })], LuzmoGridItemActionsMenu.prototype, "placement", void 0), __decorate([property({ type: Array })], LuzmoGridItemActionsMenu.prototype, "actions", void 0), LuzmoGridItemActionsMenu = __decorate([localized()], LuzmoGridItemActionsMenu);
1509
+ var grid_module_default = ":host{width:100%;display:block}.grid-stack{width:100%;min-height:var(--luzmo-grid-min-height);background:var(--luzmo-grid-background,var(--grid-background,var(--luzmo-background-color)));position:relative}.grid-stack[has-active-item] .grid-stack-item:not([active])>.grid-stack-item-content,.grid-stack[has-active-item] .grid-stack-item:not([active])>.grid-item-actions-popover{opacity:.5}.grid-stack .grid-stack-item[active]>.ui-resizable-handle,.grid-stack .grid-stack-item[active].ui-resizable-autohide>.ui-resizable-handle{display:block}.grid-stack .grid-stack-item.ui-resizable-resizing,.grid-stack .grid-stack-item.ui-resizable-resizing>.grid-stack-item-content{opacity:var(--luzmo-grid-item-resizing-opacity,.8)!important}.grid-item-drag-handle{color:var(--luzmo-grid-item-drag-handle-color,#000);top:var(--luzmo-grid-item-drag-handle-position-top,0);left:var(--luzmo-grid-item-drag-handle-position-left,0);right:var(--luzmo-grid-item-drag-handle-position-right,auto);bottom:var(--luzmo-grid-item-drag-handle-position-bottom,auto);padding:var(--luzmo-grid-item-drag-handle-padding,.5rem);z-index:var(--luzmo-grid-item-drag-handle-z-index,3);cursor:var(--luzmo-grid-item-drag-handle-cursor,move);position:absolute}.grid-stack[dark-background] .grid-item-drag-handle{color:var(--luzmo-grid-item-drag-handle-color,#fff)}.grid-stack .grid-stack-item .grid-stack-item-content{border-radius:var(--luzmo-grid-item-border-radius,var(--grid-item-border-radius,4px));background:var(--luzmo-grid-item-background,var(--grid-item-background,transparent));box-shadow:var(--luzmo-grid-item-box-shadow,var(--grid-item-box-shadow,none));border-style:var(--luzmo-grid-item-border-style,none);border-color:var(--luzmo-grid-item-border-color,transparent);-webkit-backdrop-filter:var(--luzmo-grid-item-backdrop-filter,none);backdrop-filter:var(--luzmo-grid-item-backdrop-filter,none);overflow:hidden}.grid-stack .grid-stack-item:not(.has-luzmo-viz-item) .grid-stack-item-content{border-style:var(--luzmo-grid-item-border-style,var(--grid-item-border-style,none));border-color:var(--luzmo-grid-item-border-color,var(--grid-item-border-color,transparent));border-width:var(--luzmo-grid-item-border-width,var(--grid-item-border-width,0));border-top-width:var(--luzmo-grid-item-border-top-width,var(--grid-item-border-top-width,0));border-right-width:var(--luzmo-grid-item-border-right-width,var(--grid-item-border-right-width,0));border-bottom-width:var(--luzmo-grid-item-border-bottom-width,var(--grid-item-border-bottom-width,0));border-left-width:var(--luzmo-grid-item-border-left-width,var(--grid-item-border-left-width,0))}.grid-stack .grid-stack-placeholder>.placeholder-content{border-radius:var(--grid-item-border-radius,4px)}:host .grid-stack-item[active]>.ui-resizable-handle,:host .grid-stack-item:hover>.ui-resizable-handle{z-index:var(--luzmo-grid-resize-handle-z-index,100);background:var(--luzmo-grid-resize-handle-background,#fff);border-radius:var(--luzmo-grid-resize-handle-border-radius,3px);opacity:var(--luzmo-grid-resize-handle-opacity,0);transition:var(--luzmo-grid-resize-handle-transition,opacity .2s ease);box-shadow:0 0 6px #0000001a,0 0 2px #000000bf;display:block!important;position:absolute!important}:host .grid-stack[dark-background]>.grid-stack-item[active]>.ui-resizable-handle,:host .grid-stack[dark-background]>.grid-stack-item:hover>.ui-resizable-handle{background:var(--luzmo-grid-resize-handle-background,#333);box-shadow:0 0 6px #ffffff1a,0 0 2px #ffffffbf}:host .grid-stack-item[active]>.ui-resizable-handle,:host .grid-stack-item:hover>.ui-resizable-handle{opacity:var(--luzmo-grid-resize-handle-opacity-hover,1)}:host .grid-stack-item>.ui-resizable-handle:hover{opacity:var(--luzmo-grid-resize-handle-opacity-active,1);background:var(--luzmo-grid-resize-handle-background-hover,var(--luzmo-background-color-highlight))}:host .grid-stack-item>.ui-resizable-n,:host .grid-stack-item>.ui-resizable-s{height:var(--luzmo-grid-resize-handle-edge-size,8px);width:var(--luzmo-grid-resize-handle-side-size,18px);left:calc(50% - var(--luzmo-grid-resize-handle-side-size,18px)/2)}:host .grid-stack-item>.ui-resizable-n{cursor:n-resize;top:calc(var(--luzmo-grid-resize-handle-edge-offset,-4px) + var(--gs-item-margin-top,0px))}:host .grid-stack-item>.ui-resizable-s{cursor:s-resize;bottom:calc(var(--luzmo-grid-resize-handle-edge-offset,-4px) + var(--gs-item-margin-bottom,0px))}:host .grid-stack-item>.ui-resizable-e,:host .grid-stack-item>.ui-resizable-w{width:var(--luzmo-grid-resize-handle-edge-size,8px);height:var(--luzmo-grid-resize-handle-side-size,18px);top:calc(50% - var(--luzmo-grid-resize-handle-side-size,18px)/2)}:host .grid-stack-item>.ui-resizable-e{cursor:e-resize;right:calc(var(--luzmo-grid-resize-handle-edge-offset,-4px) + var(--gs-item-margin-right,0px))}:host .grid-stack-item>.ui-resizable-w{cursor:w-resize;left:calc(var(--luzmo-grid-resize-handle-edge-offset,-4px) + var(--gs-item-margin-left,0px))}:host .grid-stack-item>.ui-resizable-ne,:host .grid-stack-item>.ui-resizable-nw,:host .grid-stack-item>.ui-resizable-se,:host .grid-stack-item>.ui-resizable-sw{width:var(--luzmo-grid-resize-handle-corner-size,12px);height:var(--luzmo-grid-resize-handle-corner-size,12px);background-image:none;transform:none}:host .grid-stack-item>.ui-resizable-ne{cursor:ne-resize;top:calc(var(--luzmo-grid-resize-handle-edge-offset,-6px) + var(--gs-item-margin-top,0px));right:calc(var(--luzmo-grid-resize-handle-edge-offset,-6px) + var(--gs-item-margin-right,0px))}:host .grid-stack-item>.ui-resizable-nw{cursor:nw-resize;top:calc(var(--luzmo-grid-resize-handle-edge-offset,-6px) + var(--gs-item-margin-top,0px));left:calc(var(--luzmo-grid-resize-handle-edge-offset,-6px) + var(--gs-item-margin-left,0px))}:host .grid-stack-item>.ui-resizable-se{cursor:se-resize;right:calc(var(--luzmo-grid-resize-handle-corner-offset,-4px) + var(--gs-item-margin-right,0px));bottom:calc(var(--luzmo-grid-resize-handle-corner-offset,-4px) + var(--gs-item-margin-bottom,0px))}:host .grid-stack-item>.ui-resizable-sw{cursor:sw-resize;left:calc(var(--luzmo-grid-resize-handle-corner-offset,-4px) + var(--gs-item-margin-left,0px));bottom:calc(var(--luzmo-grid-resize-handle-corner-offset,-4px) + var(--gs-item-margin-bottom,0px))}:host .grid-stack-item>.ui-resizable-resizing .ui-resizable-handle{background:var(--luzmo-grid-resize-handle-background-active,var(--luzmo-background-color-highlight));opacity:1!important}.grid-item-actions-popover{z-index:2;background:0 0;border:none;outline:none;margin:0;padding:0;position:absolute;overflow:visible}luzmo-grid-item-actions-menu{padding:var(--luzmo-grid-item-actions-padding,var(--grid-item-actions-padding))}.dimensions-hint-popover{font-size:var(--luzmo-grid-item-dimensions-hint-font-size,var(--luzmo-font-size-xs,10px));font-family:var(--luzmo-grid-item-dimensions-hint-font-family,var(--luzmo-font-family,inherit));border-width:var(--luzmo-grid-item-dimensions-hint-border-width,var(--luzmo-border-width));border-style:solid;border-color:var(--luzmo-grid-item-dimensions-hint-border-color,var(--luzmo-border-color));border-radius:var(--luzmo-grid-item-dimensions-hint-border-radius,var(--luzmo-border-radius));padding:var(--luzmo-grid-item-dimensions-hint-padding,var(--luzmo-spacing-1)var(--luzmo-spacing-2));z-index:3;background:var(--luzmo-grid-item-dimensions-hint-background,var(--luzmo-background-color));color:var(--luzmo-grid-item-dimensions-hint-color,var(--luzmo-font-color));pointer-events:none;outline:none;margin:0;position:absolute;overflow:visible}luzmo-grid-item-actions-menu{--grid-item-actions-padding:0 .75rem}luzmo-grid-item-actions-menu[placement=top-start],luzmo-grid-item-actions-menu[placement=top],luzmo-grid-item-actions-menu[placement=top-end],luzmo-grid-item-actions-menu[placement=bottom-start],luzmo-grid-item-actions-menu[placement=bottom],luzmo-grid-item-actions-menu[placement=bottom-end]{--grid-item-actions-padding:.75rem 0}.grid-stack-item:focus-visible{outline:none}.grid-stack-item:focus-visible .grid-stack-item-content:after{content:\"\";border:var(--luzmo-indicator-width)solid var(--luzmo-indicator-color,var(--luzmo-primary));box-sizing:border-box;border-radius:var(--luzmo-grid-item-border-radius,var(--grid-item-border-radius,4px));z-index:2;width:100%;height:100%;position:absolute;top:0;left:0}";
1510
+ const updateLuzmoVizItemsLanguage = (e, k) => {
1511
+ e.forEach((e) => {
1512
+ let A = e.querySelector("luzmo-embed-viz-item");
1513
+ A && (A.options = {
1514
+ ...A.options,
1515
+ locale: k
1516
+ });
1517
+ });
1518
+ }, createGridItemActionDetail = ({ action: e, actionType: k, active: A, items: j, element: M, itemId: N, item: P, deletedId: F, originalElement: I }) => ({
1519
+ action: e,
1520
+ actionType: k,
1521
+ active: A,
1522
+ items: j,
1523
+ element: M,
1524
+ id: N,
1525
+ type: P?.type,
1526
+ slots: P?.slots,
1527
+ options: P?.options,
1528
+ filters: P?.filters ?? [],
1529
+ ...F && { deletedId: F },
1530
+ ...I && { originalElement: I }
1531
+ }), dispatchGridItemActionEvent = ({ target: e, action: k, actionType: A, active: j, items: M, element: N, itemId: P, item: F, deletedId: I, originalElement: L }) => {
1532
+ e.dispatchEvent(new CustomEvent("luzmo-grid-item-action", {
1533
+ detail: createGridItemActionDetail({
1534
+ action: k,
1535
+ actionType: A,
1536
+ active: j,
1537
+ items: M,
1538
+ element: N,
1539
+ itemId: P,
1540
+ item: F,
1541
+ deletedId: I,
1542
+ originalElement: L
1543
+ }),
1544
+ bubbles: !0,
1545
+ composed: !0,
1546
+ cancelable: !0
1547
+ }));
1548
+ }, dispatchGridLifecycleEvent = ({ target: e, eventName: k, detail: A }) => {
1549
+ e.dispatchEvent(new CustomEvent(k, {
1550
+ detail: A,
1551
+ bubbles: !0,
1552
+ composed: !0
1553
+ }));
1554
+ };
1555
+ var asElement = (e) => e instanceof Element ? e : void 0;
1556
+ const getGridItemElementFromTarget = (e) => asElement(e)?.closest(".grid-stack-item"), shouldRemovePopoverOnMouseout = ({ event: e, gridItem: k }) => asElement(e.relatedTarget)?.closest(".grid-item-actions-popover") ? !1 : !k.hasAttribute("active"), applyGridItemFocus = ({ event: e, focusedItemElement: k, removeItemActionsMenuPopover: A }) => {
1557
+ let j = getGridItemElementFromTarget(e.target);
1558
+ return j ? (k && k !== j && (k.removeAttribute("focused"), A(k)), j.setAttribute("focused", "true"), j) : k;
1559
+ }, clearGridItemFocus = ({ event: e, focusedItemElement: k, removeItemActionsMenuPopover: A }) => k ? asElement(e.relatedTarget)?.closest("luzmo-grid-item-actions-menu") ? {
1560
+ focusedItemElement: k,
1561
+ shouldFocusGrid: !1
1562
+ } : (k.removeAttribute("focused"), A(k), {
1563
+ focusedItemElement: void 0,
1564
+ shouldFocusGrid: !0
1565
+ }) : {
1566
+ focusedItemElement: void 0,
1567
+ shouldFocusGrid: !1
1568
+ }, resolveGridItemForDelete = (e, k) => getGridItemElementFromTarget(e.target) ?? k, cleanupActiveGridItem = ({ item: e, activeItemElement: k, gridElement: A, removeItemActionsMenuPopover: j }) => {
1569
+ if (e.removeAttribute("active"), j(e), k === e) {
1570
+ A.removeAttribute("has-active-item");
1571
+ return;
1892
1572
  }
1893
- refreshData() {
1894
- return this.chartElement.refreshData();
1573
+ return k;
1574
+ }, handleGridAction = ({ event: e, gridElement: k, items: A, state: j, cleanupActiveItem: M, dispatchItemActionEvent: N, handleDeleteItem: P, handleCloneItem: F, createItemActionsMenuPopover: I }) => {
1575
+ e.stopPropagation();
1576
+ let L = e.detail, R = e.target?.closest(".grid-stack-item");
1577
+ if (!R) return j;
1578
+ let z = R.getAttribute("gs-id"), B = A.find((e) => e.id === z);
1579
+ if (L.type === "toggle" && L.action === j.activeItemActionToggle && R === j.activeItemElement) return j.activeItemElement = void 0, j.activeItemActionToggle = void 0, k.removeAttribute("has-active-item"), R.removeAttribute("active"), M(R), z && N(L.action, L.type, !1, R, z, B), j;
1580
+ if (["delete", "clone"].includes(L.action) || (k.querySelectorAll(".grid-stack-item").forEach((e) => {
1581
+ e !== R && M(e);
1582
+ }), L.type === "toggle" ? (j.activeItemElement = R, j.activeItemActionToggle = L.action, k.setAttribute("has-active-item", "true"), R.setAttribute("active", "true"), I(R, L.action)) : j.activeItemElement && j.activeItemElement !== R && (j.activeItemElement = void 0, j.activeItemActionToggle = void 0), z && N(L.action, L.type, L.active, R, z, B)), L.action === "delete") {
1583
+ let k = j.activeItemElement === R;
1584
+ return P(e), z && N(L.action, L.type, L.active, R, z, B, z), k ? {
1585
+ activeItemElement: void 0,
1586
+ activeItemActionToggle: void 0
1587
+ } : j;
1588
+ } else L.action === "clone" && F(e);
1589
+ return j;
1590
+ }, handleGridClick = ({ event: e, gridElement: k, hostElement: A, items: j, activeItemActionToggle: M, cleanupActiveItem: N, dispatchItemActionEvent: P }) => {
1591
+ let F = e.composedPath();
1592
+ if (!F.includes(k) && !F.includes(A)) return { activeItemActionToggle: M };
1593
+ let I = k.querySelector(".grid-stack-item[active]");
1594
+ if (!I || F.includes(I)) return { activeItemActionToggle: M };
1595
+ let L = I.querySelector(".grid-item-actions-popover");
1596
+ if (L && F.includes(L)) return { activeItemActionToggle: M };
1597
+ let R = I.getAttribute("gs-id"), z = j.find((e) => e.id === R);
1598
+ return N(I), M && R && P(M, "toggle", !1, I, R, z), { activeItemActionToggle: void 0 };
1599
+ }, triggerGridItemAction = ({ gridElement: e, items: k, gridItemData: A, itemId: j, action: M, options: N, state: P, cleanupActiveItem: F, dispatchItemActionEvent: I, createItemActionsMenuPopover: L }) => {
1600
+ if (!A?.element) return {
1601
+ result: void 0,
1602
+ state: P
1603
+ };
1604
+ let R = A.element, z = A.item, B = M === P.activeItemActionToggle && R === P.activeItemElement, V = N?.active ?? !B;
1605
+ if (N?.active !== void 0 && V === B) return {
1606
+ result: B,
1607
+ state: P
1608
+ };
1609
+ if (!V) return P.activeItemElement = void 0, P.activeItemActionToggle = void 0, e.removeAttribute("has-active-item"), R.removeAttribute("active"), F(R), I(M, "toggle", !1, R, j, z), {
1610
+ result: !1,
1611
+ state: P
1612
+ };
1613
+ if (P.activeItemElement && P.activeItemElement !== R) {
1614
+ let e = P.activeItemElement.getAttribute("gs-id"), A = k.find((k) => k.id === e), j = P.activeItemActionToggle, M = P.activeItemElement;
1615
+ F(P.activeItemElement), P.activeItemElement = void 0, P.activeItemActionToggle = void 0, j && e && A && I(j, "toggle", !1, M, e, A);
1895
1616
  }
1896
- setSelectedData(e) {
1897
- return this.chartElement.setSelectedData(void 0, e);
1617
+ return P.activeItemElement = R, P.activeItemActionToggle = M, e.setAttribute("has-active-item", "true"), R.setAttribute("active", "true"), L(R, M), I(M, "toggle", !0, R, j, z), {
1618
+ result: !0,
1619
+ state: P
1620
+ };
1621
+ }, deactivateGridItems = ({ gridElement: e, items: k, state: A, cleanupActiveItem: j, dispatchItemActionEvent: M }) => {
1622
+ let N = 0;
1623
+ if (A.activeItemElement && A.activeItemActionToggle) {
1624
+ let P = A.activeItemElement.getAttribute("gs-id"), F = k.find((e) => e.id === P), I = A.activeItemActionToggle, L = A.activeItemElement;
1625
+ j(A.activeItemElement), A.activeItemElement = void 0, A.activeItemActionToggle = void 0, e.removeAttribute("has-active-item"), I && P && F && (M(I, "toggle", !1, L, P, F), N++);
1898
1626
  }
1899
- setAuthorization(e, k) {
1900
- return this.chartElement.setAuthorization(e, k);
1627
+ return {
1628
+ deactivatedCount: N,
1629
+ state: A
1630
+ };
1631
+ };
1632
+ var DEFAULT_ITEM_POSITION = {
1633
+ sizeX: 1,
1634
+ sizeY: 1,
1635
+ col: 0,
1636
+ row: 0
1637
+ };
1638
+ const normalizeGridItems = (e, k) => {
1639
+ e.forEach((e) => {
1640
+ e.id = e.id ?? k(), e.canFilter = e.canFilter ?? "all";
1641
+ });
1642
+ }, ensureGridItemId = (e, k) => (e.id = e.id ?? k(), e.id), buildGridWidgetOptions = (e, k) => ({
1643
+ id: k,
1644
+ x: e?.position?.col ?? 0,
1645
+ y: e?.position?.row ?? 0,
1646
+ w: e?.position?.sizeX ?? 1,
1647
+ h: e?.position?.sizeY ?? 1
1648
+ }), createGridItemFromInput = (e, k) => ({
1649
+ ...structuredClone(e),
1650
+ id: k,
1651
+ position: structuredClone(e.position) ?? { ...DEFAULT_ITEM_POSITION },
1652
+ canFilter: e.canFilter ?? "all"
1653
+ }), createOrphanGridItemElement = (e) => {
1654
+ let k = document.createElement("div");
1655
+ return k.className = "luzmo-grid-item has-luzmo-viz-item", k.setAttribute("luzmo-grid-item-id", e), k.setAttribute("orphan", "true"), k.setAttribute("tabindex", "0"), k.setAttribute("role", "row"), k.innerHTML = "<div class=\"grid-stack-item-content\" role=\"gridcell\"></div>", k;
1656
+ }, readGridItemPosition = (e) => ({
1657
+ sizeX: Number.parseInt(e.getAttribute("gs-w") ?? "1", 10),
1658
+ sizeY: Number.parseInt(e.getAttribute("gs-h") ?? "1", 10),
1659
+ col: Number.parseInt(e.getAttribute("gs-x") ?? "0", 10),
1660
+ row: Number.parseInt(e.getAttribute("gs-y") ?? "0", 10)
1661
+ }), findGridItemElementById = (e, k) => {
1662
+ if (k) {
1663
+ for (let A of e) if (A.getAttribute("luzmo-grid-item-id") === k) return A;
1664
+ }
1665
+ }, mapGridItems = (e, k) => e.map((e) => {
1666
+ let A = {
1667
+ item: e,
1668
+ element: k.querySelector(`[gs-id="${e.id}"]`)
1669
+ }, j = A.element?.querySelector("luzmo-embed-viz-item");
1670
+ return j && (A.luzmoElement = j), A;
1671
+ }), addGridItem = ({ newItem: e, gridElement: k, grid: A, createId: j }) => {
1672
+ let M = createGridItemFromInput(e, j()), N = createOrphanGridItemElement(M.id);
1673
+ k.append(N);
1674
+ let P = {
1675
+ x: M.position?.col ?? 0,
1676
+ y: M.position?.row ?? 0,
1677
+ w: M.position?.sizeX ?? 1,
1678
+ h: M.position?.sizeY ?? 1,
1679
+ autoPosition: !0,
1680
+ id: M.id
1681
+ }, F = A?.makeWidget(N, P);
1682
+ return F && (M.position = readGridItemPosition(F)), {
1683
+ item: M,
1684
+ element: N
1685
+ };
1686
+ }, removeGridItemById = ({ id: e, grid: k, items: A, getGridItemById: j, removeItemActionsMenuPopover: M, activeItemElement: N, cleanupActiveItem: P }) => {
1687
+ if (!e) return {
1688
+ activeItemElement: N,
1689
+ focusedItemElement: void 0
1690
+ };
1691
+ let F = j(e)?.element;
1692
+ F && k && k.removeWidget(F);
1693
+ let I = A.findIndex((k) => k.id === e);
1694
+ I !== -1 && A.splice(I, 1), F && M(F);
1695
+ let L = N;
1696
+ return F && N === F && (P(F), L = void 0), {
1697
+ activeItemElement: L,
1698
+ focusedItemElement: void 0
1699
+ };
1700
+ }, handleCloneItem = ({ event: e, hasGrid: k, items: A, createId: j, addGridItem: M, dispatchItemActionEvent: N }) => {
1701
+ let P = e.target.closest(".grid-stack-item");
1702
+ if (!P || !k) return;
1703
+ let F = P.getAttribute("gs-id");
1704
+ if (!F) return;
1705
+ let I = A.find((e) => e.id === F);
1706
+ if (!I) return;
1707
+ let L = j(), R = {
1708
+ ...structuredClone(I),
1709
+ id: L
1710
+ }, z = M(R), B = e.detail;
1711
+ N("clone", B?.type ?? "button", B?.active ?? !1, z, L, R, void 0, P);
1712
+ };
1713
+ var min = Math.min, max = Math.max, round = Math.round, floor = Math.floor, createCoords = (e) => ({
1714
+ x: e,
1715
+ y: e
1716
+ }), oppositeSideMap = {
1717
+ left: "right",
1718
+ right: "left",
1719
+ bottom: "top",
1720
+ top: "bottom"
1721
+ }, oppositeAlignmentMap = {
1722
+ start: "end",
1723
+ end: "start"
1724
+ };
1725
+ function evaluate(e, k) {
1726
+ return typeof e == "function" ? e(k) : e;
1727
+ }
1728
+ function getSide(e) {
1729
+ return e.split("-")[0];
1730
+ }
1731
+ function getAlignment(e) {
1732
+ return e.split("-")[1];
1733
+ }
1734
+ function getOppositeAxis(e) {
1735
+ return e === "x" ? "y" : "x";
1736
+ }
1737
+ function getAxisLength(e) {
1738
+ return e === "y" ? "height" : "width";
1739
+ }
1740
+ var yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
1741
+ function getSideAxis(e) {
1742
+ return yAxisSides.has(getSide(e)) ? "y" : "x";
1743
+ }
1744
+ function getAlignmentAxis(e) {
1745
+ return getOppositeAxis(getSideAxis(e));
1746
+ }
1747
+ function getAlignmentSides(e, k, A) {
1748
+ A === void 0 && (A = !1);
1749
+ let j = getAlignment(e), M = getAlignmentAxis(e), N = getAxisLength(M), P = M === "x" ? j === (A ? "end" : "start") ? "right" : "left" : j === "start" ? "bottom" : "top";
1750
+ return k.reference[N] > k.floating[N] && (P = getOppositePlacement(P)), [P, getOppositePlacement(P)];
1751
+ }
1752
+ function getExpandedPlacements(e) {
1753
+ let k = getOppositePlacement(e);
1754
+ return [
1755
+ getOppositeAlignmentPlacement(e),
1756
+ k,
1757
+ getOppositeAlignmentPlacement(k)
1758
+ ];
1759
+ }
1760
+ function getOppositeAlignmentPlacement(e) {
1761
+ return e.replace(/start|end/g, (e) => oppositeAlignmentMap[e]);
1762
+ }
1763
+ var lrPlacement = ["left", "right"], rlPlacement = ["right", "left"], tbPlacement = ["top", "bottom"], btPlacement = ["bottom", "top"];
1764
+ function getSideList(e, k, A) {
1765
+ switch (e) {
1766
+ case "top":
1767
+ case "bottom": return A ? k ? rlPlacement : lrPlacement : k ? lrPlacement : rlPlacement;
1768
+ case "left":
1769
+ case "right": return k ? tbPlacement : btPlacement;
1770
+ default: return [];
1901
1771
  }
1902
- attributeChangedCallback(e, k, A) {
1903
- super.attributeChangedCallback(e, k, A), e === "selecteddata" && (this.chartElement ? this.setSelectedData(JSON.parse(A ?? "{}")) : this.postInitCallQueue.push([this.setSelectedData, [JSON.parse(A ?? "{}")]]));
1772
+ }
1773
+ function getOppositeAxisPlacements(e, k, A, j) {
1774
+ let M = getAlignment(e), N = getSideList(getSide(e), A === "start", j);
1775
+ return M && (N = N.map((e) => e + "-" + M), k && (N = N.concat(N.map(getOppositeAlignmentPlacement)))), N;
1776
+ }
1777
+ function getOppositePlacement(e) {
1778
+ return e.replace(/left|right|bottom|top/g, (e) => oppositeSideMap[e]);
1779
+ }
1780
+ function expandPaddingObject(e) {
1781
+ return {
1782
+ top: 0,
1783
+ right: 0,
1784
+ bottom: 0,
1785
+ left: 0,
1786
+ ...e
1787
+ };
1788
+ }
1789
+ function getPaddingObject(e) {
1790
+ return typeof e == "number" ? {
1791
+ top: e,
1792
+ right: e,
1793
+ bottom: e,
1794
+ left: e
1795
+ } : expandPaddingObject(e);
1796
+ }
1797
+ function rectToClientRect(e) {
1798
+ let { x: k, y: A, width: j, height: M } = e;
1799
+ return {
1800
+ width: j,
1801
+ height: M,
1802
+ top: A,
1803
+ left: k,
1804
+ right: k + j,
1805
+ bottom: A + M,
1806
+ x: k,
1807
+ y: A
1808
+ };
1809
+ }
1810
+ function computeCoordsFromPlacement(e, k, A) {
1811
+ let { reference: j, floating: M } = e, N = getSideAxis(k), P = getAlignmentAxis(k), F = getAxisLength(P), I = getSide(k), L = N === "y", R = j.x + j.width / 2 - M.width / 2, z = j.y + j.height / 2 - M.height / 2, B = j[F] / 2 - M[F] / 2, V;
1812
+ switch (I) {
1813
+ case "top":
1814
+ V = {
1815
+ x: R,
1816
+ y: j.y - M.height
1817
+ };
1818
+ break;
1819
+ case "bottom":
1820
+ V = {
1821
+ x: R,
1822
+ y: j.y + j.height
1823
+ };
1824
+ break;
1825
+ case "right":
1826
+ V = {
1827
+ x: j.x + j.width,
1828
+ y: z
1829
+ };
1830
+ break;
1831
+ case "left":
1832
+ V = {
1833
+ x: j.x - M.width,
1834
+ y: z
1835
+ };
1836
+ break;
1837
+ default: V = {
1838
+ x: j.x,
1839
+ y: j.y
1840
+ };
1904
1841
  }
1905
- async firstUpdated(e) {
1906
- super.firstUpdated(e), this.canInitializeVizItem() && (await loadLibrary(this.appServer, vizItemRemote), this.createAndAppendElement());
1842
+ switch (getAlignment(k)) {
1843
+ case "start":
1844
+ V[P] -= B * (A && L ? -1 : 1);
1845
+ break;
1846
+ case "end":
1847
+ V[P] += B * (A && L ? -1 : 1);
1848
+ break;
1907
1849
  }
1908
- createAndAppendElement() {
1909
- this.chartElement || (this.chartElement = document.createElement("chart-component"), this.chartElement.setAttribute("embedding-mode", "chart"), this.chartElement.style.height = "100%", this.chartElement.style.width = "100%", this.chartElement.style.display = "block", this.chartElement.addEventListener("load", (e) => this.dispatchEvent(new CustomEvent("load", e))), this.chartElement.addEventListener("rendered", (e) => {
1910
- if (this.postInitCallQueue?.length > 0) for (let e of this.postInitCallQueue) e[0].bind(this)(...e[1]);
1911
- else this.selectedData && this.setSelectedData(this.selectedData);
1912
- this.dispatchEvent(new CustomEvent("rendered", e));
1913
- }), this.chartElement.addEventListener("changedFilters", (e) => this.dispatchEvent(new CustomEvent("changedFilters", e))), this.chartElement.addEventListener("exported", (e) => this.dispatchEvent(new CustomEvent("exported", e))), this.chartElement.addEventListener("customEvent", (e) => this.dispatchEvent(new CustomEvent("customEvent", e))), this.updateVizItemProperties(), this.renderRoot.append(this.chartElement));
1850
+ return V;
1851
+ }
1852
+ var computePosition$1 = async (e, k, A) => {
1853
+ let { placement: j = "bottom", strategy: M = "absolute", middleware: N = [], platform: P } = A, F = N.filter(Boolean), I = await (P.isRTL == null ? void 0 : P.isRTL(k)), L = await P.getElementRects({
1854
+ reference: e,
1855
+ floating: k,
1856
+ strategy: M
1857
+ }), { x: R, y: z } = computeCoordsFromPlacement(L, j, I), B = j, V = {}, H = 0;
1858
+ for (let A = 0; A < F.length; A++) {
1859
+ let { name: N, fn: U } = F[A], { x: W, y: G, data: K, reset: q } = await U({
1860
+ x: R,
1861
+ y: z,
1862
+ initialPlacement: j,
1863
+ placement: B,
1864
+ strategy: M,
1865
+ middlewareData: V,
1866
+ rects: L,
1867
+ platform: P,
1868
+ elements: {
1869
+ reference: e,
1870
+ floating: k
1871
+ }
1872
+ });
1873
+ R = W ?? R, z = G ?? z, V = {
1874
+ ...V,
1875
+ [N]: {
1876
+ ...V[N],
1877
+ ...K
1878
+ }
1879
+ }, q && H <= 50 && (H++, typeof q == "object" && (q.placement && (B = q.placement), q.rects && (L = q.rects === !0 ? await P.getElementRects({
1880
+ reference: e,
1881
+ floating: k,
1882
+ strategy: M
1883
+ }) : q.rects), {x: R, y: z} = computeCoordsFromPlacement(L, B, I)), A = -1);
1914
1884
  }
1915
- updateVizItemProperties() {
1916
- if (this.chartElement) for (let e in libraryTypeToWebComponentTypeMapping) {
1917
- let k = this[e];
1918
- if (k) {
1919
- let A = ["appServer", "apiHost"].includes(e) ? removeTrailingSlash(k) : k;
1920
- this.chartElement.setAttribute(libraryTypeToWebComponentTypeMapping[e], typeof A == "object" ? JSON.stringify(A) : A);
1885
+ return {
1886
+ x: R,
1887
+ y: z,
1888
+ placement: B,
1889
+ strategy: M,
1890
+ middlewareData: V
1891
+ };
1892
+ };
1893
+ async function detectOverflow(e, k) {
1894
+ k === void 0 && (k = {});
1895
+ let { x: A, y: j, platform: M, rects: N, elements: P, strategy: F } = e, { boundary: I = "clippingAncestors", rootBoundary: L = "viewport", elementContext: R = "floating", altBoundary: z = !1, padding: B = 0 } = evaluate(k, e), V = getPaddingObject(B), H = P[z ? R === "floating" ? "reference" : "floating" : R], U = rectToClientRect(await M.getClippingRect({
1896
+ element: await (M.isElement == null ? void 0 : M.isElement(H)) ?? !0 ? H : H.contextElement || await (M.getDocumentElement == null ? void 0 : M.getDocumentElement(P.floating)),
1897
+ boundary: I,
1898
+ rootBoundary: L,
1899
+ strategy: F
1900
+ })), W = R === "floating" ? {
1901
+ x: A,
1902
+ y: j,
1903
+ width: N.floating.width,
1904
+ height: N.floating.height
1905
+ } : N.reference, G = await (M.getOffsetParent == null ? void 0 : M.getOffsetParent(P.floating)), K = await (M.isElement == null ? void 0 : M.isElement(G)) && await (M.getScale == null ? void 0 : M.getScale(G)) || {
1906
+ x: 1,
1907
+ y: 1
1908
+ }, q = rectToClientRect(M.convertOffsetParentRelativeRectToViewportRelativeRect ? await M.convertOffsetParentRelativeRectToViewportRelativeRect({
1909
+ elements: P,
1910
+ rect: W,
1911
+ offsetParent: G,
1912
+ strategy: F
1913
+ }) : W);
1914
+ return {
1915
+ top: (U.top - q.top + V.top) / K.y,
1916
+ bottom: (q.bottom - U.bottom + V.bottom) / K.y,
1917
+ left: (U.left - q.left + V.left) / K.x,
1918
+ right: (q.right - U.right + V.right) / K.x
1919
+ };
1920
+ }
1921
+ var flip$1 = function(e) {
1922
+ return e === void 0 && (e = {}), {
1923
+ name: "flip",
1924
+ options: e,
1925
+ async fn(k) {
1926
+ var A;
1927
+ let { placement: j, middlewareData: M, rects: N, initialPlacement: P, platform: F, elements: I } = k, { mainAxis: L = !0, crossAxis: R = !0, fallbackPlacements: z, fallbackStrategy: B = "bestFit", fallbackAxisSideDirection: V = "none", flipAlignment: H = !0, ...U } = evaluate(e, k);
1928
+ if ((A = M.arrow) != null && A.alignmentOffset) return {};
1929
+ let W = getSide(j), G = getSideAxis(P), K = getSide(P) === P, q = await (F.isRTL == null ? void 0 : F.isRTL(I.floating)), J = z || (K || !H ? [getOppositePlacement(P)] : getExpandedPlacements(P)), Y = V !== "none";
1930
+ !z && Y && J.push(...getOppositeAxisPlacements(P, H, V, q));
1931
+ let X = [P, ...J], Z = await detectOverflow(k, U), Q = [], $ = M.flip?.overflows || [];
1932
+ if (L && Q.push(Z[W]), R) {
1933
+ let e = getAlignmentSides(j, N, q);
1934
+ Q.push(Z[e[0]], Z[e[1]]);
1935
+ }
1936
+ if ($ = [...$, {
1937
+ placement: j,
1938
+ overflows: Q
1939
+ }], !Q.every((e) => e <= 0)) {
1940
+ let e = (M.flip?.index || 0) + 1, k = X[e];
1941
+ if (k && (!(R === "alignment" && G !== getSideAxis(k)) || $.every((e) => getSideAxis(e.placement) === G ? e.overflows[0] > 0 : !0))) return {
1942
+ data: {
1943
+ index: e,
1944
+ overflows: $
1945
+ },
1946
+ reset: { placement: k }
1947
+ };
1948
+ let A = $.filter((e) => e.overflows[0] <= 0).sort((e, k) => e.overflows[1] - k.overflows[1])[0]?.placement;
1949
+ if (!A) switch (B) {
1950
+ case "bestFit": {
1951
+ let e = $.filter((e) => {
1952
+ if (Y) {
1953
+ let k = getSideAxis(e.placement);
1954
+ return k === G || k === "y";
1955
+ }
1956
+ return !0;
1957
+ }).map((e) => [e.placement, e.overflows.filter((e) => e > 0).reduce((e, k) => e + k, 0)]).sort((e, k) => e[1] - k[1])[0]?.[0];
1958
+ e && (A = e);
1959
+ break;
1960
+ }
1961
+ case "initialPlacement":
1962
+ A = P;
1963
+ break;
1964
+ }
1965
+ if (j !== A) return { reset: { placement: A } };
1921
1966
  }
1967
+ return {};
1922
1968
  }
1923
- }
1924
- async updated(e) {
1925
- if (this.chartElement) for (let [k] of e.entries()) {
1926
- let e = libraryTypeToWebComponentTypeMapping[k] ?? k, A = typeof this[k] == "object" ? JSON.stringify(this[k]) : this[k]?.toString() ?? this[k];
1927
- this.chartElement.setAttribute(e, A);
1969
+ };
1970
+ }, originSides = /* @__PURE__ */ new Set(["left", "top"]);
1971
+ async function convertValueToCoords(e, k) {
1972
+ let { placement: A, platform: j, elements: M } = e, N = await (j.isRTL == null ? void 0 : j.isRTL(M.floating)), P = getSide(A), F = getAlignment(A), I = getSideAxis(A) === "y", L = originSides.has(P) ? -1 : 1, R = N && I ? -1 : 1, z = evaluate(k, e), { mainAxis: B, crossAxis: V, alignmentAxis: H } = typeof z == "number" ? {
1973
+ mainAxis: z,
1974
+ crossAxis: 0,
1975
+ alignmentAxis: null
1976
+ } : {
1977
+ mainAxis: z.mainAxis || 0,
1978
+ crossAxis: z.crossAxis || 0,
1979
+ alignmentAxis: z.alignmentAxis
1980
+ };
1981
+ return F && typeof H == "number" && (V = F === "end" ? H * -1 : H), I ? {
1982
+ x: V * R,
1983
+ y: B * L
1984
+ } : {
1985
+ x: B * L,
1986
+ y: V * R
1987
+ };
1988
+ }
1989
+ var offset$1 = function(e) {
1990
+ return e === void 0 && (e = 0), {
1991
+ name: "offset",
1992
+ options: e,
1993
+ async fn(k) {
1994
+ var A;
1995
+ let { x: j, y: M, placement: N, middlewareData: P } = k, F = await convertValueToCoords(k, e);
1996
+ return N === P.offset?.placement && (A = P.arrow) != null && A.alignmentOffset ? {} : {
1997
+ x: j + F.x,
1998
+ y: M + F.y,
1999
+ data: {
2000
+ ...F,
2001
+ placement: N
2002
+ }
2003
+ };
2004
+ }
2005
+ };
2006
+ };
2007
+ function hasWindow() {
2008
+ return typeof window < "u";
2009
+ }
2010
+ function getNodeName(e) {
2011
+ return isNode(e) ? (e.nodeName || "").toLowerCase() : "#document";
2012
+ }
2013
+ function getWindow(e) {
2014
+ var k;
2015
+ return (e == null || (k = e.ownerDocument) == null ? void 0 : k.defaultView) || window;
2016
+ }
2017
+ function getDocumentElement(e) {
2018
+ return ((isNode(e) ? e.ownerDocument : e.document) || window.document)?.documentElement;
2019
+ }
2020
+ function isNode(e) {
2021
+ return hasWindow() ? e instanceof Node || e instanceof getWindow(e).Node : !1;
2022
+ }
2023
+ function isElement(e) {
2024
+ return hasWindow() ? e instanceof Element || e instanceof getWindow(e).Element : !1;
2025
+ }
2026
+ function isHTMLElement(e) {
2027
+ return hasWindow() ? e instanceof HTMLElement || e instanceof getWindow(e).HTMLElement : !1;
2028
+ }
2029
+ function isShadowRoot(e) {
2030
+ return !hasWindow() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof getWindow(e).ShadowRoot;
2031
+ }
2032
+ var invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
2033
+ function isOverflowElement(e) {
2034
+ let { overflow: k, overflowX: A, overflowY: j, display: M } = getComputedStyle$1(e);
2035
+ return /auto|scroll|overlay|hidden|clip/.test(k + j + A) && !invalidOverflowDisplayValues.has(M);
2036
+ }
2037
+ var tableElements = /* @__PURE__ */ new Set([
2038
+ "table",
2039
+ "td",
2040
+ "th"
2041
+ ]);
2042
+ function isTableElement(e) {
2043
+ return tableElements.has(getNodeName(e));
2044
+ }
2045
+ var topLayerSelectors = [":popover-open", ":modal"];
2046
+ function isTopLayer(e) {
2047
+ return topLayerSelectors.some((k) => {
2048
+ try {
2049
+ return e.matches(k);
2050
+ } catch {
2051
+ return !1;
1928
2052
  }
1929
- else this.canInitializeVizItem() && (await loadLibrary(this.appServer, vizItemRemote), this.createAndAppendElement());
1930
- }
1931
- render() {
1932
- return html` `;
1933
- }
1934
- };
1935
- __decorateClass([property()], LuzmoBaseVizItem.prototype, "appServer", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "apiHost", 2), __decorateClass([property({ type: Array })], LuzmoBaseVizItem.prototype, "slots", 2), __decorateClass([property({ type: Object })], LuzmoBaseVizItem.prototype, "options", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "type", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "authKey", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "authToken", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "version", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "contextId", 2), __decorateClass([property({ converter: (e) => {
1936
- try {
1937
- return JSON.parse(e);
1938
- } catch {
1939
- return e;
2053
+ });
2054
+ }
2055
+ var transformProperties = [
2056
+ "transform",
2057
+ "translate",
2058
+ "scale",
2059
+ "rotate",
2060
+ "perspective"
2061
+ ], willChangeValues = [
2062
+ "transform",
2063
+ "translate",
2064
+ "scale",
2065
+ "rotate",
2066
+ "perspective",
2067
+ "filter"
2068
+ ], containValues = [
2069
+ "paint",
2070
+ "layout",
2071
+ "strict",
2072
+ "content"
2073
+ ];
2074
+ function isContainingBlock(e) {
2075
+ let k = isWebKit(), A = isElement(e) ? getComputedStyle$1(e) : e;
2076
+ return transformProperties.some((e) => A[e] ? A[e] !== "none" : !1) || (A.containerType ? A.containerType !== "normal" : !1) || !k && (A.backdropFilter ? A.backdropFilter !== "none" : !1) || !k && (A.filter ? A.filter !== "none" : !1) || willChangeValues.some((e) => (A.willChange || "").includes(e)) || containValues.some((e) => (A.contain || "").includes(e));
2077
+ }
2078
+ function getContainingBlock(e) {
2079
+ let k = getParentNode(e);
2080
+ for (; isHTMLElement(k) && !isLastTraversableNode(k);) {
2081
+ if (isContainingBlock(k)) return k;
2082
+ if (isTopLayer(k)) return null;
2083
+ k = getParentNode(k);
1940
2084
  }
1941
- } })], LuzmoBaseVizItem.prototype, "canFilter", 2), __decorateClass([property({ type: Array })], LuzmoBaseVizItem.prototype, "filters", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "dashboardId", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "itemId", 2), __decorateClass([property({ type: Object })], LuzmoBaseVizItem.prototype, "selectedData", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "dashboardContentsVersion", 2), __decorateClass([property()], LuzmoBaseVizItem.prototype, "libVersion", 2);
1942
- var LuzmoEmbedVizItem = class extends LuzmoBaseVizItem {};
1943
- customElements.get("luzmo-embed-viz-item") || customElements.define("luzmo-embed-viz-item", LuzmoEmbedVizItem);
1944
- var inputMap = {
1945
- aiEndpoint: "ai-endpoint",
1946
- appServer: "app-server",
1947
- apiHost: "api-host",
1948
- options: "options",
1949
- initialSuggestionsDatasetId: "initialSuggestionsDatasetId",
1950
- authKey: "auth-key",
1951
- authToken: "auth-token",
1952
- version: "version",
1953
- libVersion: "lib-version",
1954
- aydHost: "ayd-host",
1955
- availableDatasets: "available-datasets"
1956
- }, embedChatTag = "luzmo-iq-embed-chat", chatComponentTag = "luzmo-iq-chat-component", LuzmoIQEmbedChatComponent = class extends LitElement {
1957
- constructor() {
1958
- super(...arguments), this.appServer = "https://app.luzmo.com", this.apiHost = "https://api.luzmo.com", this.version = version + "-wc-luzmo", this.libVersion = version + "-wc-luzmo", this.remoteEntryServer = "http://localhost:4202/", this.aydHost = "https://ayd.luzmo.com/";
2085
+ return null;
2086
+ }
2087
+ function isWebKit() {
2088
+ return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
2089
+ }
2090
+ var lastTraversableNodeNames = /* @__PURE__ */ new Set([
2091
+ "html",
2092
+ "body",
2093
+ "#document"
2094
+ ]);
2095
+ function isLastTraversableNode(e) {
2096
+ return lastTraversableNodeNames.has(getNodeName(e));
2097
+ }
2098
+ function getComputedStyle$1(e) {
2099
+ return getWindow(e).getComputedStyle(e);
2100
+ }
2101
+ function getNodeScroll(e) {
2102
+ return isElement(e) ? {
2103
+ scrollLeft: e.scrollLeft,
2104
+ scrollTop: e.scrollTop
2105
+ } : {
2106
+ scrollLeft: e.scrollX,
2107
+ scrollTop: e.scrollY
2108
+ };
2109
+ }
2110
+ function getParentNode(e) {
2111
+ if (getNodeName(e) === "html") return e;
2112
+ let k = e.assignedSlot || e.parentNode || isShadowRoot(e) && e.host || getDocumentElement(e);
2113
+ return isShadowRoot(k) ? k.host : k;
2114
+ }
2115
+ function getNearestOverflowAncestor(e) {
2116
+ let k = getParentNode(e);
2117
+ return isLastTraversableNode(k) ? e.ownerDocument ? e.ownerDocument.body : e.body : isHTMLElement(k) && isOverflowElement(k) ? k : getNearestOverflowAncestor(k);
2118
+ }
2119
+ function getOverflowAncestors(e, k, A) {
2120
+ k === void 0 && (k = []), A === void 0 && (A = !0);
2121
+ let j = getNearestOverflowAncestor(e), M = j === e.ownerDocument?.body, N = getWindow(j);
2122
+ if (M) {
2123
+ let e = getFrameElement(N);
2124
+ return k.concat(N, N.visualViewport || [], isOverflowElement(j) ? j : [], e && A ? getOverflowAncestors(e) : []);
1959
2125
  }
1960
- static {
1961
- this.styles = css`
1962
- :host {
1963
- display: block;
1964
- width: 100%;
1965
- height: 100%;
1966
- }
1967
- `;
2126
+ return k.concat(j, getOverflowAncestors(j, [], A));
2127
+ }
2128
+ function getFrameElement(e) {
2129
+ return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
2130
+ }
2131
+ function getCssDimensions(e) {
2132
+ let k = getComputedStyle$1(e), A = parseFloat(k.width) || 0, j = parseFloat(k.height) || 0, M = isHTMLElement(e), N = M ? e.offsetWidth : A, P = M ? e.offsetHeight : j, F = round(A) !== N || round(j) !== P;
2133
+ return F && (A = N, j = P), {
2134
+ width: A,
2135
+ height: j,
2136
+ $: F
2137
+ };
2138
+ }
2139
+ function unwrapElement(e) {
2140
+ return isElement(e) ? e : e.contextElement;
2141
+ }
2142
+ function getScale(e) {
2143
+ let k = unwrapElement(e);
2144
+ if (!isHTMLElement(k)) return createCoords(1);
2145
+ let A = k.getBoundingClientRect(), { width: j, height: M, $: N } = getCssDimensions(k), P = (N ? round(A.width) : A.width) / j, F = (N ? round(A.height) : A.height) / M;
2146
+ return (!P || !Number.isFinite(P)) && (P = 1), (!F || !Number.isFinite(F)) && (F = 1), {
2147
+ x: P,
2148
+ y: F
2149
+ };
2150
+ }
2151
+ var noOffsets = /* @__PURE__ */ createCoords(0);
2152
+ function getVisualOffsets(e) {
2153
+ let k = getWindow(e);
2154
+ return !isWebKit() || !k.visualViewport ? noOffsets : {
2155
+ x: k.visualViewport.offsetLeft,
2156
+ y: k.visualViewport.offsetTop
2157
+ };
2158
+ }
2159
+ function shouldAddVisualOffsets(e, k, A) {
2160
+ return k === void 0 && (k = !1), !A || k && A !== getWindow(e) ? !1 : k;
2161
+ }
2162
+ function getBoundingClientRect(e, k, A, j) {
2163
+ k === void 0 && (k = !1), A === void 0 && (A = !1);
2164
+ let M = e.getBoundingClientRect(), N = unwrapElement(e), P = createCoords(1);
2165
+ k && (j ? isElement(j) && (P = getScale(j)) : P = getScale(e));
2166
+ let F = shouldAddVisualOffsets(N, A, j) ? getVisualOffsets(N) : createCoords(0), I = (M.left + F.x) / P.x, L = (M.top + F.y) / P.y, R = M.width / P.x, z = M.height / P.y;
2167
+ if (N) {
2168
+ let e = getWindow(N), k = j && isElement(j) ? getWindow(j) : j, A = e, M = getFrameElement(A);
2169
+ for (; M && j && k !== A;) {
2170
+ let e = getScale(M), k = M.getBoundingClientRect(), j = getComputedStyle$1(M), N = k.left + (M.clientLeft + parseFloat(j.paddingLeft)) * e.x, P = k.top + (M.clientTop + parseFloat(j.paddingTop)) * e.y;
2171
+ I *= e.x, L *= e.y, R *= e.x, z *= e.y, I += N, L += P, A = getWindow(M), M = getFrameElement(A);
2172
+ }
1968
2173
  }
1969
- createRenderRoot() {
1970
- return this;
2174
+ return rectToClientRect({
2175
+ width: R,
2176
+ height: z,
2177
+ x: I,
2178
+ y: L
2179
+ });
2180
+ }
2181
+ function getWindowScrollBarX(e, k) {
2182
+ let A = getNodeScroll(e).scrollLeft;
2183
+ return k ? k.left + A : getBoundingClientRect(getDocumentElement(e)).left + A;
2184
+ }
2185
+ function getHTMLOffset(e, k) {
2186
+ let A = e.getBoundingClientRect();
2187
+ return {
2188
+ x: A.left + k.scrollLeft - getWindowScrollBarX(e, A),
2189
+ y: A.top + k.scrollTop
2190
+ };
2191
+ }
2192
+ function convertOffsetParentRelativeRectToViewportRelativeRect(e) {
2193
+ let { elements: k, rect: A, offsetParent: j, strategy: M } = e, N = M === "fixed", P = getDocumentElement(j), F = k ? isTopLayer(k.floating) : !1;
2194
+ if (j === P || F && N) return A;
2195
+ let I = {
2196
+ scrollLeft: 0,
2197
+ scrollTop: 0
2198
+ }, L = createCoords(1), R = createCoords(0), z = isHTMLElement(j);
2199
+ if ((z || !z && !N) && ((getNodeName(j) !== "body" || isOverflowElement(P)) && (I = getNodeScroll(j)), isHTMLElement(j))) {
2200
+ let e = getBoundingClientRect(j);
2201
+ L = getScale(j), R.x = e.x + j.clientLeft, R.y = e.y + j.clientTop;
1971
2202
  }
1972
- async firstUpdated(e) {
1973
- super.firstUpdated(e), await loadLibrary(this.calculatedAppServer, "IQApp"), this.createAndAppendElement();
2203
+ let B = P && !z && !N ? getHTMLOffset(P, I) : createCoords(0);
2204
+ return {
2205
+ width: A.width * L.x,
2206
+ height: A.height * L.y,
2207
+ x: A.x * L.x - I.scrollLeft * L.x + R.x + B.x,
2208
+ y: A.y * L.y - I.scrollTop * L.y + R.y + B.y
2209
+ };
2210
+ }
2211
+ function getClientRects(e) {
2212
+ return Array.from(e.getClientRects());
2213
+ }
2214
+ function getDocumentRect(e) {
2215
+ let k = getDocumentElement(e), A = getNodeScroll(e), j = e.ownerDocument.body, M = max(k.scrollWidth, k.clientWidth, j.scrollWidth, j.clientWidth), N = max(k.scrollHeight, k.clientHeight, j.scrollHeight, j.clientHeight), P = -A.scrollLeft + getWindowScrollBarX(e), F = -A.scrollTop;
2216
+ return getComputedStyle$1(j).direction === "rtl" && (P += max(k.clientWidth, j.clientWidth) - M), {
2217
+ width: M,
2218
+ height: N,
2219
+ x: P,
2220
+ y: F
2221
+ };
2222
+ }
2223
+ var SCROLLBAR_MAX = 25;
2224
+ function getViewportRect(e, k) {
2225
+ let A = getWindow(e), j = getDocumentElement(e), M = A.visualViewport, N = j.clientWidth, P = j.clientHeight, F = 0, I = 0;
2226
+ if (M) {
2227
+ N = M.width, P = M.height;
2228
+ let e = isWebKit();
2229
+ (!e || e && k === "fixed") && (F = M.offsetLeft, I = M.offsetTop);
1974
2230
  }
1975
- get calculatedAppServer() {
1976
- return this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer;
2231
+ let L = getWindowScrollBarX(j);
2232
+ if (L <= 0) {
2233
+ let e = j.ownerDocument, k = e.body, A = getComputedStyle(k), M = e.compatMode === "CSS1Compat" && parseFloat(A.marginLeft) + parseFloat(A.marginRight) || 0, P = Math.abs(j.clientWidth - k.clientWidth - M);
2234
+ P <= SCROLLBAR_MAX && (N -= P);
2235
+ } else L <= SCROLLBAR_MAX && (N += L);
2236
+ return {
2237
+ width: N,
2238
+ height: P,
2239
+ x: F,
2240
+ y: I
2241
+ };
2242
+ }
2243
+ var absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
2244
+ function getInnerBoundingClientRect(e, k) {
2245
+ let A = getBoundingClientRect(e, !0, k === "fixed"), j = A.top + e.clientTop, M = A.left + e.clientLeft, N = isHTMLElement(e) ? getScale(e) : createCoords(1);
2246
+ return {
2247
+ width: e.clientWidth * N.x,
2248
+ height: e.clientHeight * N.y,
2249
+ x: M * N.x,
2250
+ y: j * N.y
2251
+ };
2252
+ }
2253
+ function getClientRectFromClippingAncestor(e, k, A) {
2254
+ let j;
2255
+ if (k === "viewport") j = getViewportRect(e, A);
2256
+ else if (k === "document") j = getDocumentRect(getDocumentElement(e));
2257
+ else if (isElement(k)) j = getInnerBoundingClientRect(k, A);
2258
+ else {
2259
+ let A = getVisualOffsets(e);
2260
+ j = {
2261
+ x: k.x - A.x,
2262
+ y: k.y - A.y,
2263
+ width: k.width,
2264
+ height: k.height
2265
+ };
1977
2266
  }
1978
- createAndAppendElement() {
1979
- this.chartElement || (this.chartElement = document.createElement(chatComponentTag), this.chartElement.addEventListener("load", (e) => this.dispatchEvent(new CustomEvent("load", e))), this.updateVizItemProperties(), this.renderRoot.append(this.chartElement));
2267
+ return rectToClientRect(j);
2268
+ }
2269
+ function hasFixedPositionAncestor(e, k) {
2270
+ let A = getParentNode(e);
2271
+ return A === k || !isElement(A) || isLastTraversableNode(A) ? !1 : getComputedStyle$1(A).position === "fixed" || hasFixedPositionAncestor(A, k);
2272
+ }
2273
+ function getClippingElementAncestors(e, k) {
2274
+ let A = k.get(e);
2275
+ if (A) return A;
2276
+ let j = getOverflowAncestors(e, [], !1).filter((e) => isElement(e) && getNodeName(e) !== "body"), M = null, N = getComputedStyle$1(e).position === "fixed", P = N ? getParentNode(e) : e;
2277
+ for (; isElement(P) && !isLastTraversableNode(P);) {
2278
+ let k = getComputedStyle$1(P), A = isContainingBlock(P);
2279
+ !A && k.position === "fixed" && (M = null), (N ? !A && !M : !A && k.position === "static" && M && absoluteOrFixed.has(M.position) || isOverflowElement(P) && !A && hasFixedPositionAncestor(e, P)) ? j = j.filter((e) => e !== P) : M = k, P = getParentNode(P);
1980
2280
  }
1981
- updateVizItemProperties() {
1982
- if (this.chartElement) for (let e in inputMap) {
1983
- let k = this[e];
1984
- if (k) {
1985
- let A = [
1986
- "appServer",
1987
- "apiHost",
1988
- "aydHost"
1989
- ].includes(e) ? removeTrailingSlash(k) : k;
1990
- this.chartElement.setAttribute(inputMap[e], typeof A == "object" ? JSON.stringify(A) : A);
1991
- }
1992
- }
2281
+ return k.set(e, j), j;
2282
+ }
2283
+ function getClippingRect(e) {
2284
+ let { element: k, boundary: A, rootBoundary: j, strategy: M } = e, N = [...A === "clippingAncestors" ? isTopLayer(k) ? [] : getClippingElementAncestors(k, this._c) : [].concat(A), j], P = N[0], F = N.reduce((e, A) => {
2285
+ let j = getClientRectFromClippingAncestor(k, A, M);
2286
+ return e.top = max(j.top, e.top), e.right = min(j.right, e.right), e.bottom = min(j.bottom, e.bottom), e.left = max(j.left, e.left), e;
2287
+ }, getClientRectFromClippingAncestor(k, P, M));
2288
+ return {
2289
+ width: F.right - F.left,
2290
+ height: F.bottom - F.top,
2291
+ x: F.left,
2292
+ y: F.top
2293
+ };
2294
+ }
2295
+ function getDimensions(e) {
2296
+ let { width: k, height: A } = getCssDimensions(e);
2297
+ return {
2298
+ width: k,
2299
+ height: A
2300
+ };
2301
+ }
2302
+ function getRectRelativeToOffsetParent(e, k, A) {
2303
+ let j = isHTMLElement(k), M = getDocumentElement(k), N = A === "fixed", P = getBoundingClientRect(e, !0, N, k), F = {
2304
+ scrollLeft: 0,
2305
+ scrollTop: 0
2306
+ }, I = createCoords(0);
2307
+ function L() {
2308
+ I.x = getWindowScrollBarX(M);
1993
2309
  }
1994
- async updated(e) {
1995
- if (this.chartElement) for (let [k] of e.entries()) {
1996
- let e = inputMap[k] ?? k, A = typeof this[k] == "object" ? JSON.stringify(this[k]) : this[k]?.toString() ?? this[k];
1997
- this.chartElement.setAttribute(e, A);
2310
+ if (j || !j && !N) if ((getNodeName(k) !== "body" || isOverflowElement(M)) && (F = getNodeScroll(k)), j) {
2311
+ let e = getBoundingClientRect(k, !0, N, k);
2312
+ I.x = e.x + k.clientLeft, I.y = e.y + k.clientTop;
2313
+ } else M && L();
2314
+ N && !j && M && L();
2315
+ let R = M && !j && !N ? getHTMLOffset(M, F) : createCoords(0);
2316
+ return {
2317
+ x: P.left + F.scrollLeft - I.x - R.x,
2318
+ y: P.top + F.scrollTop - I.y - R.y,
2319
+ width: P.width,
2320
+ height: P.height
2321
+ };
2322
+ }
2323
+ function isStaticPositioned(e) {
2324
+ return getComputedStyle$1(e).position === "static";
2325
+ }
2326
+ function getTrueOffsetParent(e, k) {
2327
+ if (!isHTMLElement(e) || getComputedStyle$1(e).position === "fixed") return null;
2328
+ if (k) return k(e);
2329
+ let A = e.offsetParent;
2330
+ return getDocumentElement(e) === A && (A = A.ownerDocument.body), A;
2331
+ }
2332
+ function getOffsetParent(e, k) {
2333
+ let A = getWindow(e);
2334
+ if (isTopLayer(e)) return A;
2335
+ if (!isHTMLElement(e)) {
2336
+ let k = getParentNode(e);
2337
+ for (; k && !isLastTraversableNode(k);) {
2338
+ if (isElement(k) && !isStaticPositioned(k)) return k;
2339
+ k = getParentNode(k);
1998
2340
  }
1999
- else await loadLibrary(this.calculatedAppServer, "IQApp"), this.createAndAppendElement();
2000
- }
2001
- render() {
2002
- return html``;
2003
- }
2004
- connectedCallback() {
2005
- super.connectedCallback();
2006
- let e = document.querySelector(embedChatTag);
2007
- if (!e) return;
2008
- let k = new MutationObserver(() => {
2009
- let A = e.querySelector("*[slot=\"custom-chat-widget-content\"]");
2010
- if (!A) return;
2011
- let j = e.querySelector(chatComponentTag);
2012
- j && (j.append(A), k.disconnect());
2013
- });
2014
- k.observe(e, {
2015
- childList: !0,
2016
- subtree: !0
2017
- });
2341
+ return A;
2018
2342
  }
2343
+ let j = getTrueOffsetParent(e, k);
2344
+ for (; j && isTableElement(j) && isStaticPositioned(j);) j = getTrueOffsetParent(j, k);
2345
+ return j && isLastTraversableNode(j) && isStaticPositioned(j) && !isContainingBlock(j) ? A : j || getContainingBlock(e) || A;
2346
+ }
2347
+ var getElementRects = async function(e) {
2348
+ let k = this.getOffsetParent || getOffsetParent, A = this.getDimensions, j = await A(e.floating);
2349
+ return {
2350
+ reference: getRectRelativeToOffsetParent(e.reference, await k(e.floating), e.strategy),
2351
+ floating: {
2352
+ x: 0,
2353
+ y: 0,
2354
+ width: j.width,
2355
+ height: j.height
2356
+ }
2357
+ };
2019
2358
  };
2020
- __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "appServer", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "apiHost", 2), __decorateClass([property({ type: Object })], LuzmoIQEmbedChatComponent.prototype, "options", 2), __decorateClass([property({ type: String })], LuzmoIQEmbedChatComponent.prototype, "initialSuggestionsDatasetId", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "aiEndpoint", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "authKey", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "authToken", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "version", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "libVersion", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "remoteEntryServer", 2), __decorateClass([property()], LuzmoIQEmbedChatComponent.prototype, "aydHost", 2), __decorateClass([property({ type: Array })], LuzmoIQEmbedChatComponent.prototype, "availableDatasets", 2), customElements.get(embedChatTag) || customElements.define(embedChatTag, LuzmoIQEmbedChatComponent);
2021
- var inputMap2 = {
2022
- aiEndPoint: "ai-end-point",
2023
- appServer: "app-server",
2024
- apiHost: "api-host",
2025
- options: "options",
2026
- authKey: "auth-key",
2027
- authToken: "auth-token",
2028
- version: "version",
2029
- libVersion: "lib-version",
2030
- messages: "messages"
2031
- }, componentTag = "luzmo-iq-embed-answer", LuzmoIQEmbedAnswerComponent = class extends LitElement {
2032
- constructor() {
2033
- super(...arguments), this.appServer = "https://app.luzmo.com", this.apiHost = "https://api.luzmo.com", this.version = version + "-wc-luzmo", this.libVersion = version + "-wc-luzmo", this.remoteEntryServer = "http://localhost:4202";
2034
- }
2035
- static {
2036
- this.styles = css`
2037
- :host {
2038
- display: block;
2039
- width: 100%;
2040
- height: 100%;
2041
- }
2042
- `;
2043
- }
2044
- createRenderRoot() {
2045
- return this;
2046
- }
2047
- async firstUpdated(e) {
2048
- super.firstUpdated(e), await loadLibrary(this.calculatedAppServer, "IQApp"), this.createAndAppendElement();
2049
- }
2050
- get calculatedAppServer() {
2051
- return this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer;
2052
- }
2053
- createAndAppendElement() {
2054
- this.chartElement || (this.chartElement = document.createElement("luzmo-iq-answer-component"), this.chartElement.addEventListener("addQuestion", (e) => this.dispatchEvent(new CustomEvent("addQuestion", e))), this.chartElement.addEventListener("addAnswer", (e) => this.dispatchEvent(new CustomEvent("addAnswer", e))), this.updateVizItemProperties(), this.renderRoot.append(this.chartElement));
2359
+ function isRTL(e) {
2360
+ return getComputedStyle$1(e).direction === "rtl";
2361
+ }
2362
+ var platform = {
2363
+ convertOffsetParentRelativeRectToViewportRelativeRect,
2364
+ getDocumentElement,
2365
+ getClippingRect,
2366
+ getOffsetParent,
2367
+ getElementRects,
2368
+ getClientRects,
2369
+ getDimensions,
2370
+ getScale,
2371
+ isElement,
2372
+ isRTL
2373
+ };
2374
+ function rectsAreEqual(e, k) {
2375
+ return e.x === k.x && e.y === k.y && e.width === k.width && e.height === k.height;
2376
+ }
2377
+ function observeMove(e, k) {
2378
+ let A = null, j, M = getDocumentElement(e);
2379
+ function N() {
2380
+ var e;
2381
+ clearTimeout(j), (e = A) == null || e.disconnect(), A = null;
2055
2382
  }
2056
- updateVizItemProperties() {
2057
- if (this.chartElement) for (let e in inputMap2) {
2058
- let k = this[e];
2059
- if (k) {
2060
- let A = ["appServer", "apiHost"].includes(e) ? removeTrailingSlash(k) : k;
2061
- this.chartElement.setAttribute(inputMap2[e], typeof A == "object" ? JSON.stringify(A) : A);
2383
+ function P(F, I) {
2384
+ F === void 0 && (F = !1), I === void 0 && (I = 1), N();
2385
+ let L = e.getBoundingClientRect(), { left: R, top: z, width: B, height: V } = L;
2386
+ if (F || k(), !B || !V) return;
2387
+ let H = floor(z), U = floor(M.clientWidth - (R + B)), W = floor(M.clientHeight - (z + V)), G = floor(R), K = {
2388
+ rootMargin: -H + "px " + -U + "px " + -W + "px " + -G + "px",
2389
+ threshold: max(0, min(1, I)) || 1
2390
+ }, q = !0;
2391
+ function J(k) {
2392
+ let A = k[0].intersectionRatio;
2393
+ if (A !== I) {
2394
+ if (!q) return P();
2395
+ A ? P(!1, A) : j = setTimeout(() => {
2396
+ P(!1, 1e-7);
2397
+ }, 1e3);
2062
2398
  }
2399
+ A === 1 && !rectsAreEqual(L, e.getBoundingClientRect()) && P(), q = !1;
2400
+ }
2401
+ try {
2402
+ A = new IntersectionObserver(J, {
2403
+ ...K,
2404
+ root: M.ownerDocument
2405
+ });
2406
+ } catch {
2407
+ A = new IntersectionObserver(J, K);
2063
2408
  }
2409
+ A.observe(e);
2064
2410
  }
2065
- async updated(e) {
2066
- if (this.chartElement) for (let [k] of e.entries()) {
2067
- let e = inputMap2[k] ?? k, A = typeof this[k] == "object" ? JSON.stringify(this[k]) : this[k]?.toString() ?? this[k];
2068
- this.chartElement.setAttribute(e, A);
2411
+ return P(!0), N;
2412
+ }
2413
+ function autoUpdate(e, k, A, j) {
2414
+ j === void 0 && (j = {});
2415
+ let { ancestorScroll: M = !0, ancestorResize: N = !0, elementResize: P = typeof ResizeObserver == "function", layoutShift: F = typeof IntersectionObserver == "function", animationFrame: I = !1 } = j, L = unwrapElement(e), R = M || N ? [...L ? getOverflowAncestors(L) : [], ...getOverflowAncestors(k)] : [];
2416
+ R.forEach((e) => {
2417
+ M && e.addEventListener("scroll", A, { passive: !0 }), N && e.addEventListener("resize", A);
2418
+ });
2419
+ let z = L && F ? observeMove(L, A) : null, B = -1, V = null;
2420
+ P && (V = new ResizeObserver((e) => {
2421
+ let [j] = e;
2422
+ j && j.target === L && V && (V.unobserve(k), cancelAnimationFrame(B), B = requestAnimationFrame(() => {
2423
+ var e;
2424
+ (e = V) == null || e.observe(k);
2425
+ })), A();
2426
+ }), L && !I && V.observe(L), V.observe(k));
2427
+ let H, U = I ? getBoundingClientRect(e) : null;
2428
+ I && W();
2429
+ function W() {
2430
+ let k = getBoundingClientRect(e);
2431
+ U && !rectsAreEqual(U, k) && A(), U = k, H = requestAnimationFrame(W);
2432
+ }
2433
+ return A(), () => {
2434
+ var e;
2435
+ R.forEach((e) => {
2436
+ M && e.removeEventListener("scroll", A), N && e.removeEventListener("resize", A);
2437
+ }), z?.(), (e = V) == null || e.disconnect(), V = null, I && cancelAnimationFrame(H);
2438
+ };
2439
+ }
2440
+ var offset = offset$1, flip = flip$1, computePosition = (e, k, A) => {
2441
+ let j = /* @__PURE__ */ new Map(), M = {
2442
+ platform,
2443
+ ...A
2444
+ }, N = {
2445
+ ...M.platform,
2446
+ _c: j
2447
+ };
2448
+ return computePosition$1(e, k, {
2449
+ ...M,
2450
+ platform: N
2451
+ });
2452
+ }, cleanupCallbacks = /* @__PURE__ */ new WeakMap();
2453
+ const setPopoverCleanup = (e, k) => {
2454
+ clearPopoverCleanup(e), cleanupCallbacks.set(e, k);
2455
+ }, clearPopoverCleanup = (e) => {
2456
+ let k = cleanupCallbacks.get(e);
2457
+ k && (k(), cleanupCallbacks.delete(e));
2458
+ }, createItemActionsMenuPopover = ({ element: e, activeAction: k, getGridItemById: A, placementItemActionsMenu: j, renderOverlayContent: M, removeItemActionsMenuPopover: N }) => {
2459
+ let P = e.querySelector(".grid-item-actions-popover"), F = e.querySelector(".grid-stack-item-content"), I = A(e.getAttribute("gs-id") ?? "");
2460
+ if (k && P && (N(e), P = null), !P) {
2461
+ let A = document.createDocumentFragment();
2462
+ render(M(I?.item, k), A), P = A.querySelector(".grid-item-actions-popover"), e.append(P);
2463
+ }
2464
+ let R = autoUpdate(F, P, async () => {
2465
+ let { x: e, y: k } = await computePosition(F, P, {
2466
+ placement: I?.item?.placementActionsMenu ?? j ?? "right-start",
2467
+ middleware: [offset(0), flip({ crossAxis: !1 })]
2468
+ });
2469
+ P.style.left = `${e}px`, P.style.top = `${k}px`;
2470
+ });
2471
+ setPopoverCleanup(P, R), P.matches(":popover-open") || P.showPopover();
2472
+ }, removeItemActionsMenuPopover = (e) => {
2473
+ let k = e.querySelector(".grid-item-actions-popover");
2474
+ k && (clearPopoverCleanup(k), k.matches(":popover-open") && k.hidePopover(), k.remove());
2475
+ }, isGridArrowKey = (e) => e === "ArrowLeft" || e === "ArrowRight" || e === "ArrowUp" || e === "ArrowDown", getGridKeyboardUpdate = ({ key: e, node: k, maxColumns: A, shiftKey: j, ctrlKey: M, metaKey: N }) => {
2476
+ let P = {
2477
+ ArrowLeft: {
2478
+ move: { x: k.x - 1 },
2479
+ resize: {
2480
+ x: k.x - 1,
2481
+ w: k.w + 1
2482
+ },
2483
+ shrink: { w: k.w - 1 },
2484
+ canMove: k.x > 0,
2485
+ canResize: k.x > 0,
2486
+ canShrink: k.w > 1
2487
+ },
2488
+ ArrowRight: {
2489
+ move: { x: k.x + 1 },
2490
+ resize: { w: k.w + 1 },
2491
+ shrink: {
2492
+ x: k.x + 1,
2493
+ w: k.w - 1
2494
+ },
2495
+ canMove: k.x < A - k.w,
2496
+ canResize: k.x + k.w < A,
2497
+ canShrink: k.w > 1
2498
+ },
2499
+ ArrowUp: {
2500
+ move: { y: k.y - 1 },
2501
+ resize: {
2502
+ y: k.y - 1,
2503
+ h: k.h + 1
2504
+ },
2505
+ shrink: { h: k.h - 1 },
2506
+ canMove: k.y > 0,
2507
+ canResize: k.y > 0,
2508
+ canShrink: k.h > 1
2509
+ },
2510
+ ArrowDown: {
2511
+ move: { y: k.y + 1 },
2512
+ resize: { h: k.h + 1 },
2513
+ shrink: {
2514
+ y: k.y + 1,
2515
+ h: k.h - 1
2516
+ },
2517
+ canMove: !0,
2518
+ canResize: !0,
2519
+ canShrink: k.h > 1
2069
2520
  }
2070
- else await loadLibrary(this.calculatedAppServer, "IQApp"), this.createAndAppendElement();
2071
- }
2072
- render() {
2073
- return html` `;
2521
+ }[e];
2522
+ if (j && P.canResize) return P.resize;
2523
+ if ((M || N) && P.canShrink) return P.shrink;
2524
+ if (P.canMove) return P.move;
2525
+ }, handleGridKeyDown = ({ event: e, viewMode: k, focusedItemElement: A, activeItemElement: j, gridElement: M, grid: N, columns: P, handleDeleteItem: F, removeItemActionsMenuPopover: I, createItemActionsMenuPopover: L }) => {
2526
+ if (k) return {
2527
+ focusedItemElement: A,
2528
+ activeItemElement: j
2529
+ };
2530
+ let R = A, z = j;
2531
+ if (e.key === "Delete" && A) F(new Event("delete")), R = void 0, j === A && (z = void 0);
2532
+ else if (e.key === "Escape" && A) A.removeAttribute("focused"), I(A), R = void 0, M.focus();
2533
+ else if (e.key === "Enter" && A) e.preventDefault(), e.stopPropagation(), j && (j.removeAttribute("active"), M.removeAttribute("has-active-item"), I(j), z = void 0), M.querySelectorAll(".grid-stack-item").forEach((e) => {
2534
+ e !== A && I(e);
2535
+ }), L(A), requestAnimationFrame(() => {
2536
+ let e = A.querySelector("luzmo-grid-item-actions-menu");
2537
+ e && e.focus();
2538
+ });
2539
+ else if (A && N && isGridArrowKey(e.key)) {
2540
+ e.preventDefault(), e.stopPropagation();
2541
+ let k = A.gridstackNode;
2542
+ if (!k) return {
2543
+ focusedItemElement: R,
2544
+ activeItemElement: z
2545
+ };
2546
+ let j = getGridKeyboardUpdate({
2547
+ key: e.key,
2548
+ node: k,
2549
+ maxColumns: P,
2550
+ shiftKey: e.shiftKey,
2551
+ ctrlKey: e.ctrlKey,
2552
+ metaKey: e.metaKey
2553
+ });
2554
+ j && N.update(A, j);
2074
2555
  }
2556
+ return {
2557
+ focusedItemElement: R,
2558
+ activeItemElement: z
2559
+ };
2560
+ };
2561
+ var DEFAULT_MARGIN = 16, DEFAULT_HINT_OFFSET = 10, getRGBA = (e, k) => k >= 1 ? `rgba(${e.r},${e.g},${e.b},1)` : k <= 0 ? `rgba(${e.r},${e.g},${e.b},0)` : `rgba(${e.r},${e.g},${e.b},${k})`;
2562
+ const resolveGridTheme = async ({ theme: e, currentTheme: k }) => e?.type === "custom" ? structuredClone(e) : e?.id && systemThemeIds.includes(e.id) && k?.id !== e.id ? {
2563
+ ...await getTheme(e.id),
2564
+ id: e.id
2565
+ } : e?.id && k?.id !== e.id || !e && k ? k : await getTheme("default"), getGridHalfMargins = (e) => [(e?.margins?.[0] ?? DEFAULT_MARGIN) / 2, (e?.margins?.[1] ?? DEFAULT_MARGIN) / 2], getDimensionsHintOffset = (e) => DEFAULT_HINT_OFFSET - (e?.margins?.[0] ?? DEFAULT_HINT_OFFSET), getGridBoxShadow = (e) => {
2566
+ let k = e?.boxShadow;
2567
+ if (!k) return "";
2568
+ let j = new Color(k.color), M = {
2569
+ r: Math.round(j.srgb.r * 255),
2570
+ g: Math.round(j.srgb.g * 255),
2571
+ b: Math.round(j.srgb.b * 255)
2572
+ }, N = e?.margins?.[0] ?? DEFAULT_MARGIN, P = Math.min(N / 10, 2);
2573
+ return k.size === "none" ? "none" : k.size === "S" ? `0 ${P * 2}px ${P * 4}px ${getRGBA(M, .16)}, 0 ${P * 2}px ${P * 4}px ${getRGBA(M, .23)}` : k.size === "M" ? `0 ${P * 8}px ${P * 16}px ${getRGBA(M, .19)}, 0 ${P * 4}px ${P * 4}px ${getRGBA(M, .23)}` : k.size === "L" ? `0 ${P * 12}px ${P * 24}px ${getRGBA(M, .25)}, 0 ${P * 8}px ${P * 8}px ${getRGBA(M, .22)}` : "";
2574
+ }, getGridCssVariables = (e) => {
2575
+ let k = getGridBoxShadow(e);
2576
+ return new Map([
2577
+ ["--grid-font-family", e?.font?.fontFamily],
2578
+ ["--grid-background", e?.background],
2579
+ ["--grid-item-box-shadow", k],
2580
+ ["--grid-item-background", e?.itemsBackground],
2581
+ ["--grid-item-border-color", e?.borders?.["border-color"]],
2582
+ ["--grid-item-border-style", e?.borders?.["border-style"]],
2583
+ ["--grid-item-border-radius", e?.borders?.["border-radius"]],
2584
+ ["--grid-item-border-width", `${e?.borders?.["border-top-width"]}`],
2585
+ ["--grid-item-border-top-width", e?.borders?.["border-top-width"]],
2586
+ ["--grid-item-border-right-width", e?.borders?.["border-right-width"]],
2587
+ ["--grid-item-border-bottom-width", e?.borders?.["border-bottom-width"]],
2588
+ ["--grid-item-border-left-width", e?.borders?.["border-left-width"]]
2589
+ ]);
2590
+ }, isGridDarkBackground = (e) => {
2591
+ let k = e?.itemsBackground ?? e?.background;
2592
+ return k ? new Color(k).luminance < .5 : !1;
2593
+ }, applyThemeProperties = (e, k) => {
2594
+ k && getGridCssVariables(k).forEach((k, A) => {
2595
+ k ? e.setProperty(A, k) : e.removeProperty(A);
2596
+ });
2597
+ };
2598
+ var buildGridActionsMenu = ({ item: e, defaultItemActionsMenu: k, activeAction: A }) => {
2599
+ let j = generateActionsMenu(e?.actionsMenu) ?? generateActionsMenu(k) ?? defaultActionsMenu();
2600
+ return !itemTypes.find((k) => k.type === e?.type)?.containsData && !e?.actionsMenu && !k && (j = j.map((e) => ({
2601
+ ...e,
2602
+ actions: e.actions?.filter((e) => e.action !== "edit-data")
2603
+ }))), A && (j = j.map((e) => ({
2604
+ ...e,
2605
+ actions: e.actions?.map((e) => ({
2606
+ ...e,
2607
+ active: e.action === A ? !0 : e.active
2608
+ }))
2609
+ }))), j;
2610
+ };
2611
+ const renderOverlayContent = ({ item: e, activeAction: k, defaultItemActionsMenu: A, placementItemActionsMenu: j, language: M, handleAction: N }) => html`
2612
+ <div class="grid-item-actions-popover" popover="manual">
2613
+ <luzmo-grid-item-actions-menu
2614
+ .actions=${buildGridActionsMenu({
2615
+ item: e,
2616
+ defaultItemActionsMenu: A,
2617
+ activeAction: k
2618
+ })}
2619
+ placement=${e?.placementActionsMenu ?? j ?? "right-start"}
2620
+ .language=${M}
2621
+ @luzmo-grid-item-action=${N}
2622
+ >
2623
+ </luzmo-grid-item-actions-menu>
2624
+ </div>
2625
+ `, renderGridItem = ({ item: e, index: k, initialized: A, viewMode: j, contentLanguage: M, fullTheme: N, appServer: P, apiHost: F, authKey: L, authToken: R, handleMouseover: z, handleMouseout: B, handleFocus: V, handleBlur: H }) => {
2626
+ let U = {
2627
+ ...e.options,
2628
+ locale: M
2629
+ };
2630
+ U.theme ||= N?.id ? { id: N.id } : structuredClone(N);
2631
+ let W = !j;
2632
+ return html`
2633
+ <div
2634
+ class="luzmo-grid-item has-luzmo-viz-item"
2635
+ luzmo-grid-item-id=${e.id ?? ""}
2636
+ tabindex="0"
2637
+ role="row"
2638
+ @mouseover=${z}
2639
+ @mouseout=${B}
2640
+ @focus=${V}
2641
+ @blur=${H}
2642
+ >
2643
+ <div
2644
+ class="grid-stack-item-content"
2645
+ role="gridcell"
2646
+ aria-label="Grid item ${k + 1}"
2647
+ >
2648
+ ${A ? html` ${W ? html`
2649
+ <div class="grid-item-drag-handle">
2650
+ <luzmo-icon .icon=${luzmoArrows} size="s"></luzmo-icon>
2651
+ </div>
2652
+ ` : html`
2653
+
2654
+ `}
2655
+ <luzmo-embed-viz-item
2656
+ .appServer=${P}
2657
+ .apiHost=${F}
2658
+ .authKey=${L}
2659
+ .authToken=${R}
2660
+ .type=${e.type}
2661
+ .slots=${e.slots}
2662
+ .options=${U}
2663
+ .filters=${e.filters}
2664
+ .language=${M}
2665
+ .canFilter=${e.canFilter ?? "all"}
2666
+ ></luzmo-embed-viz-item>` : html`
2667
+
2668
+ `}
2669
+ </div>
2670
+ </div>
2671
+ `;
2672
+ }, renderGridItems = ({ items: e, initialized: k, viewMode: A, contentLanguage: j, fullTheme: M, appServer: N, apiHost: P, authKey: F, authToken: I, renderItem: L }) => repeat(e, (e) => e.id, (e, R) => guard([
2673
+ e,
2674
+ k,
2675
+ A,
2676
+ j,
2677
+ M,
2678
+ N,
2679
+ P,
2680
+ F,
2681
+ I
2682
+ ], () => L(e, R))), renderGrid = ({ items: e, initialized: k, viewMode: A, contentLanguage: j, fullTheme: M, appServer: N, apiHost: P, authKey: F, authToken: L, columns: R, ensureGridItemId: z, handleMouseover: B, handleMouseout: V, handleFocus: H, handleBlur: U }) => {
2683
+ e.forEach((e) => {
2684
+ z(e);
2685
+ });
2686
+ let W = renderGridItems({
2687
+ items: e,
2688
+ initialized: k,
2689
+ viewMode: A,
2690
+ contentLanguage: j,
2691
+ fullTheme: M,
2692
+ appServer: N,
2693
+ apiHost: P,
2694
+ authKey: F,
2695
+ authToken: L,
2696
+ renderItem: (e, I) => renderGridItem({
2697
+ item: e,
2698
+ index: I,
2699
+ initialized: k,
2700
+ viewMode: A,
2701
+ contentLanguage: j,
2702
+ fullTheme: M,
2703
+ appServer: N,
2704
+ apiHost: P,
2705
+ authKey: F,
2706
+ authToken: L,
2707
+ handleMouseover: B,
2708
+ handleMouseout: V,
2709
+ handleFocus: H,
2710
+ handleBlur: U
2711
+ })
2712
+ });
2713
+ return html`
2714
+ <div
2715
+ ?dark-background=${k ? isGridDarkBackground(M) : !1}
2716
+ class="grid-stack"
2717
+ data-grid-columns=${R}
2718
+ role="grid"
2719
+ aria-label="Dashboard grid"
2720
+ >
2721
+ ${W}
2722
+ </div>
2723
+ `;
2075
2724
  };
2076
- __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "appServer", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "apiHost", 2), __decorateClass([property({ type: Object })], LuzmoIQEmbedAnswerComponent.prototype, "options", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "aiEndPoint", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "authKey", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "authToken", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "messages", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "version", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "libVersion", 2), __decorateClass([property()], LuzmoIQEmbedAnswerComponent.prototype, "remoteEntryServer", 2), customElements.get(componentTag) || customElements.define(componentTag, LuzmoIQEmbedAnswerComponent), LitElement.disableWarning?.("change-in-update");
2077
2725
  var Utils = class e {
2078
2726
  static getElements(e, k = document) {
2079
2727
  if (typeof e == "string") {
@@ -4054,289 +4702,210 @@ var DDDroppable = class extends DDBaseImplement {
4054
4702
  }
4055
4703
  static _itemRemoving(e, k) {
4056
4704
  if (!e) return;
4057
- let A = e ? e.gridstackNode : void 0;
4058
- !A?.grid || e.classList.contains(A.grid.opts.removableOptions.decline) || (k ? A._isAboutToRemove = !0 : delete A._isAboutToRemove, k ? e.classList.add("grid-stack-item-removing") : e.classList.remove("grid-stack-item-removing"));
4059
- }
4060
- _setupRemoveDrop() {
4061
- if (typeof this.opts.removable != "string") return this;
4062
- let k = document.querySelector(this.opts.removable);
4063
- return k && !this.opts.staticGrid && !dd.isDroppable(k) && dd.droppable(k, this.opts.removableOptions).on(k, "dropover", (k, A) => e._itemRemoving(A, !0)).on(k, "dropout", (k, A) => e._itemRemoving(A, !1)), this;
4064
- }
4065
- prepareDragDrop(e, k = !1) {
4066
- let A = e?.gridstackNode;
4067
- if (!A) return;
4068
- let j = A.noMove || this.opts.disableDrag, M = A.noResize || this.opts.disableResize, N = this.opts.staticGrid || j && M;
4069
- if ((k || N) && (A._initDD && (this._removeDD(e), delete A._initDD), N && e.classList.add("ui-draggable-disabled", "ui-resizable-disabled"), !k)) return this;
4070
- if (!A._initDD) {
4071
- let k, j, M = (M, N) => {
4072
- this.triggerEvent(M, M.target), k = this.cellWidth(), j = this.getCellHeight(!0), this._onStartMoving(e, M, N, A, k, j);
4073
- }, N = (M, N) => {
4074
- this._dragOrResize(e, M, N, A, k, j);
4075
- }, P = (k) => {
4076
- this.placeholder.remove(), delete this.placeholder.gridstackNode, delete A._moving, delete A._resizing, delete A._event, delete A._lastTried;
4077
- let j = A.w !== A._orig.w, M = k.target;
4078
- if (!(!M.gridstackNode || M.gridstackNode.grid !== this)) {
4079
- if (A.el = M, A._isAboutToRemove) {
4080
- let j = e.gridstackNode.grid;
4081
- j._gsEventHandler[k.type] && j._gsEventHandler[k.type](k, M), j.engine.nodes.push(A), j.removeWidget(e, !0, !0);
4082
- } else Utils.removePositioningStyles(M), A._temporaryRemoved ? (this._writePosAttr(M, A), this.engine.addNode(A)) : this._writePosAttr(M, A), this.triggerEvent(k, M);
4083
- this._extraDragRow = 0, this._updateContainerHeight(), this._triggerChangeEvent(), this.engine.endUpdate(), k.type === "resizestop" && (Number.isInteger(A.sizeToContent) && (A.sizeToContent = A.h), this.resizeToContentCheck(j, A));
4084
- }
4085
- };
4086
- dd.draggable(e, {
4087
- start: M,
4088
- stop: P,
4089
- drag: N
4090
- }).resizable(e, {
4091
- start: M,
4092
- stop: P,
4093
- resize: N
4094
- }), A._initDD = !0;
4095
- }
4096
- return dd.draggable(e, j ? "disable" : "enable").resizable(e, M ? "disable" : "enable"), this;
4097
- }
4098
- _onStartMoving(e, k, A, j, M, N) {
4099
- if (this.engine.cleanNodes().beginUpdate(j), this._writePosAttr(this.placeholder, j), this.el.appendChild(this.placeholder), this.placeholder.gridstackNode = j, j.grid?.el) this.dragTransform = Utils.getValuesFromTransformedElement(e);
4100
- else if (this.placeholder && this.placeholder.closest(".grid-stack")) {
4101
- let e = this.placeholder.closest(".grid-stack");
4102
- this.dragTransform = Utils.getValuesFromTransformedElement(e);
4103
- } else this.dragTransform = {
4104
- xScale: 1,
4105
- xOffset: 0,
4106
- yScale: 1,
4107
- yOffset: 0
4108
- };
4109
- if (j.el = this.placeholder, j._lastUiPosition = A.position, j._prevYPix = A.position.top, j._moving = k.type === "dragstart", j._resizing = k.type === "resizestart", delete j._lastTried, k.type === "dropover" && j._temporaryRemoved && (this.engine.addNode(j), j._moving = !0), this.engine.cacheRects(M, N, this.opts.marginTop, this.opts.marginRight, this.opts.marginBottom, this.opts.marginLeft), k.type === "resizestart") {
4110
- let k = this.getColumn() - j.x, A = (this.opts.maxRow || 2 ** 53 - 1) - j.y;
4111
- dd.resizable(e, "option", "minWidth", M * Math.min(j.minW || 1, k)).resizable(e, "option", "minHeight", N * Math.min(j.minH || 1, A)).resizable(e, "option", "maxWidth", M * Math.min(j.maxW || 2 ** 53 - 1, k)).resizable(e, "option", "maxWidthMoveLeft", M * Math.min(j.maxW || 2 ** 53 - 1, j.x + j.w)).resizable(e, "option", "maxHeight", N * Math.min(j.maxH || 2 ** 53 - 1, A)).resizable(e, "option", "maxHeightMoveUp", N * Math.min(j.maxH || 2 ** 53 - 1, j.y + j.h));
4112
- }
4113
- }
4114
- _dragOrResize(e, k, A, j, M, N) {
4115
- let P = { ...j._orig }, F, I = this.opts.marginLeft, L = this.opts.marginRight, R = this.opts.marginTop, z = this.opts.marginBottom, B = Math.round(N * .1), V = Math.round(M * .1);
4116
- if (I = Math.min(I, V), L = Math.min(L, V), R = Math.min(R, B), z = Math.min(z, B), k.type === "drag") {
4117
- if (j._temporaryRemoved) return;
4118
- let k = A.position.top - j._prevYPix;
4119
- j._prevYPix = A.position.top, this.opts.draggable.scroll !== !1 && Utils.updateScrollPosition(e, A.position, k);
4120
- let F = A.position.left + (A.position.left > j._lastUiPosition.left ? -L : I), B = A.position.top + (A.position.top > j._lastUiPosition.top ? -z : R);
4121
- P.x = Math.round(F / M), P.y = Math.round(B / N);
4122
- let V = this._extraDragRow;
4123
- if (this.engine.collide(j, P)) {
4124
- let e = this.getRow(), k = Math.max(0, P.y + j.h - e);
4125
- this.opts.maxRow && e + k > this.opts.maxRow && (k = Math.max(0, this.opts.maxRow - e)), this._extraDragRow = k;
4126
- } else this._extraDragRow = 0;
4127
- if (this._extraDragRow !== V && this._updateContainerHeight(), j.x === P.x && j.y === P.y) return;
4128
- } else if (k.type === "resize") {
4129
- if (P.x < 0 || (Utils.updateScrollResize(k, e, N), P.w = Math.round((A.size.width - I) / M), P.h = Math.round((A.size.height - R) / N), j.w === P.w && j.h === P.h) || j._lastTried && j._lastTried.w === P.w && j._lastTried.h === P.h) return;
4130
- let L = A.position.left + I, z = A.position.top + R;
4131
- P.x = Math.round(L / M), P.y = Math.round(z / N), F = !0;
4132
- }
4133
- j._event = k, j._lastTried = P;
4134
- let H = {
4135
- x: A.position.left + I,
4136
- y: A.position.top + R,
4137
- w: (A.size ? A.size.width : j.w * M) - I - L,
4138
- h: (A.size ? A.size.height : j.h * N) - R - z
4139
- };
4140
- if (this.engine.moveNodeCheck(j, {
4141
- ...P,
4142
- cellWidth: M,
4143
- cellHeight: N,
4144
- rect: H,
4145
- resizing: F
4146
- })) {
4147
- j._lastUiPosition = A.position, this.engine.cacheRects(M, N, R, L, z, I), delete j._skipDown, F && j.subGrid && j.subGrid.onResize(), this._extraDragRow = 0, this._updateContainerHeight();
4148
- let e = k.target;
4149
- j._sidebarOrig || this._writePosAttr(e, j), this.triggerEvent(k, e);
4150
- }
4151
- }
4152
- triggerEvent(e, k) {
4153
- let A = this;
4154
- for (; A.parentGridNode;) A = A.parentGridNode.grid;
4155
- A._gsEventHandler[e.type] && A._gsEventHandler[e.type](e, k);
4156
- }
4157
- _leave(k, A) {
4158
- A ||= k;
4159
- let j = A.gridstackNode;
4160
- if (!j || (A.style.transform = A.style.transformOrigin = null, dd.off(k, "drag"), j._temporaryRemoved)) return;
4161
- j._temporaryRemoved = !0, this.engine.removeNode(j), j.el = j._isExternal && A ? A : k;
4162
- let M = j._sidebarOrig;
4163
- j._isExternal && this.engine.cleanupNode(j), j._sidebarOrig = M, this.opts.removable === !0 && e._itemRemoving(k, !0), k._gridstackNodeOrig ? (k.gridstackNode = k._gridstackNodeOrig, delete k._gridstackNodeOrig) : j._isExternal && this.engine.restoreInitial();
4164
- }
4165
- };
4166
- GridStack.renderCB = (e, k) => {
4167
- e && k?.content && (e.textContent = k.content);
4168
- }, GridStack.resizeToContentParent = ".grid-stack-item-content", GridStack.Utils = Utils, GridStack.Engine = GridStackEngine, GridStack.GDRev = "12.4.2";
4169
- var gridstack_min_default = ".grid-stack{position:relative}.grid-stack-rtl{direction:ltr}.grid-stack-rtl>.grid-stack-item{direction:rtl}.grid-stack-placeholder>.placeholder-content{background-color:#0000001a;width:auto;margin:0;position:absolute;z-index:0!important}.grid-stack>.grid-stack-item{width:var(--gs-column-width);height:var(--gs-cell-height);padding:0;position:absolute;top:0;left:0}.grid-stack>.grid-stack-item>.grid-stack-item-content{width:auto;margin:0;position:absolute;overflow:hidden auto}.grid-stack>.grid-stack-item.size-to-content:not(.size-to-content-max)>.grid-stack-item-content{overflow-y:hidden}.grid-stack>.grid-stack-item>.grid-stack-item-content,.grid-stack>.grid-stack-placeholder>.placeholder-content{top:var(--gs-item-margin-top);right:var(--gs-item-margin-right);bottom:var(--gs-item-margin-bottom);left:var(--gs-item-margin-left)}.grid-stack-item>.ui-resizable-handle{-ms-touch-action:none;touch-action:none;font-size:.1px;display:block;position:absolute}.grid-stack-item.ui-resizable-autohide>.ui-resizable-handle,.grid-stack-item.ui-resizable-disabled>.ui-resizable-handle{display:none}.grid-stack-item>.ui-resizable-ne,.grid-stack-item>.ui-resizable-nw,.grid-stack-item>.ui-resizable-se,.grid-stack-item>.ui-resizable-sw{background-image:url(\"data:image/svg+xml;utf8,<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" fill=\\\"none\\\" stroke=\\\"%23666\\\" stroke-linecap=\\\"round\\\" stroke-linejoin=\\\"round\\\" stroke-width=\\\"2\\\" viewBox=\\\"0 0 20 20\\\"><path d=\\\"m10 3 2 2H8l2-2v14l-2-2h4l-2 2\\\"/></svg>\");background-position:50%;background-repeat:no-repeat}.grid-stack-item>.ui-resizable-ne,.grid-stack-item>.ui-resizable-sw{transform:rotate(45deg)}.grid-stack-item>.ui-resizable-nw,.grid-stack-item>.ui-resizable-se{transform:rotate(-45deg)}.grid-stack-item>.ui-resizable-nw{cursor:nw-resize;width:20px;height:20px;top:var(--gs-item-margin-top);left:var(--gs-item-margin-left)}.grid-stack-item>.ui-resizable-n{cursor:n-resize;height:10px;top:var(--gs-item-margin-top);left:25px;right:25px}.grid-stack-item>.ui-resizable-ne{cursor:ne-resize;width:20px;height:20px;top:var(--gs-item-margin-top);right:var(--gs-item-margin-right)}.grid-stack-item>.ui-resizable-e{cursor:e-resize;width:10px;top:15px;bottom:15px;right:var(--gs-item-margin-right)}.grid-stack-item>.ui-resizable-se{cursor:se-resize;width:20px;height:20px;bottom:var(--gs-item-margin-bottom);right:var(--gs-item-margin-right)}.grid-stack-item>.ui-resizable-s{cursor:s-resize;height:10px;left:25px;bottom:var(--gs-item-margin-bottom);right:25px}.grid-stack-item>.ui-resizable-sw{cursor:sw-resize;width:20px;height:20px;bottom:var(--gs-item-margin-bottom);left:var(--gs-item-margin-left)}.grid-stack-item>.ui-resizable-w{cursor:w-resize;width:10px;top:15px;bottom:15px;left:var(--gs-item-margin-left)}.grid-stack-item.ui-draggable-dragging>.ui-resizable-handle{display:none!important}.grid-stack-item.ui-draggable-dragging{will-change:left,top}.grid-stack-item.ui-resizable-resizing{will-change:width,height}.ui-draggable-dragging,.ui-resizable-resizing{z-index:10000}.ui-draggable-dragging>.grid-stack-item-content,.ui-resizable-resizing>.grid-stack-item-content{opacity:.8;box-shadow:1px 4px 6px #0003}.grid-stack-animate,.grid-stack-animate .grid-stack-item{transition:left .3s,top .3s,height .3s,width .3s}.grid-stack-animate .grid-stack-item.grid-stack-placeholder,.grid-stack-animate .grid-stack-item.ui-draggable-dragging,.grid-stack-animate .grid-stack-item.ui-resizable-resizing{transition:left,top,height,width}.grid-stack>.grid-stack-item[gs-y=\"0\"]{top:0}.grid-stack>.grid-stack-item[gs-x=\"0\"]{left:0}", lockAction = {
4170
- icon: luzmoLockOutline,
4171
- label: "Lock",
4172
- tooltip: "Lock",
4173
- action: "lock",
4174
- type: "toggle"
4175
- }, editAction = {
4176
- icon: luzmoPencil,
4177
- label: "Edit",
4178
- tooltip: "Edit",
4179
- action: "edit",
4180
- type: "toggle"
4181
- }, editDataAction = {
4182
- icon: luzmoTable,
4183
- label: "Edit data",
4184
- tooltip: "Data",
4185
- action: "edit-data",
4186
- type: "toggle"
4187
- }, editOptionsAction = {
4188
- icon: luzmoCog,
4189
- label: "Edit options",
4190
- tooltip: "Options",
4191
- action: "edit-options",
4192
- type: "toggle"
4193
- }, editFiltersAction = {
4194
- icon: luzmoFilterOutline,
4195
- label: "Edit filters",
4196
- tooltip: "Filters",
4197
- action: "edit-filters",
4198
- type: "toggle"
4199
- }, cloneAction = {
4200
- icon: luzmoClone,
4201
- label: "Clone",
4202
- tooltip: "Clone",
4203
- action: "clone",
4204
- type: "button"
4205
- }, deleteAction = {
4206
- icon: luzmoTrashOutline,
4207
- label: "Delete",
4208
- tooltip: "Delete",
4209
- action: "delete",
4210
- type: "button"
4211
- };
4212
- const generateActionsMenu = (e) => {
4213
- if (!e) return;
4214
- let k = [];
4215
- return k = structuredClone(e).map((e) => {
4216
- if (e.type === "group") return e.actions = e.actions ?? [], e.actions = e.actions.map((e) => {
4217
- if (typeof e == "string" && [
4218
- "lock",
4219
- "filters",
4220
- "edit",
4221
- "edit-data",
4222
- "edit-options",
4223
- "edit-filters",
4224
- "delete",
4225
- "clone"
4226
- ].includes(e)) return {
4227
- delete: { ...deleteAction },
4228
- filters: { ...editFiltersAction },
4229
- clone: { ...cloneAction },
4230
- edit: { ...editAction },
4231
- "edit-data": { ...editDataAction },
4232
- "edit-options": { ...editOptionsAction },
4233
- "edit-filters": { ...editFiltersAction },
4234
- lock: { ...lockAction }
4235
- }[e];
4236
- if (typeof e == "object") return e.icon = e.icon ?? luzmoCircle, e.label = e.label ?? e.action, e.tooltip = e.tooltip ?? e.label ?? e.action, e.type = ["toggle", "button"].includes(e.type ?? "") ? e.type : "button", e;
4237
- }).filter(Boolean), e;
4238
- }).filter(Boolean), k;
4239
- }, defaultActionsMenu = () => [{
4240
- type: "group",
4241
- actions: [
4242
- { ...editDataAction },
4243
- { ...editOptionsAction },
4244
- { ...cloneAction }
4245
- ]
4246
- }, {
4247
- type: "group",
4248
- actions: [{ ...deleteAction }]
4249
- }];
4250
- var grid_item_actions_menu_module_default = ":host{--luzmo-action-button-content-color-default:var(--luzmo-grid-item-action-button-content-color-default,#fff);--luzmo-action-button-content-color-hover:var(--luzmo-grid-item-action-button-content-color-hover,#fff);--luzmo-action-button-content-color-down:var(--luzmo-grid-item-action-button-content-color-down,#fff);--luzmo-action-button-content-color-focus:var(--luzmo-grid-item-action-button-content-color-focus,#fff);--luzmo-action-button-background-color-default:var(--luzmo-grid-item-action-button-background-color-default,#333);--luzmo-action-button-background-color-hover:var(--luzmo-grid-item-action-button-background-color-hover,#444);--luzmo-action-button-background-color-down:var(--luzmo-grid-item-action-button-background-color-down,#555);--luzmo-action-button-background-color-focus:var(--luzmo-grid-item-action-button-background-color-focus,#666);--grid-item-actions-flex-direction:column;display:block}.action-buttons{gap:var(--luzmo-grid-item-action-group-gap,.5rem);flex-direction:var(--luzmo-grid-item-actions-flex-direction,var(--grid-item-actions-flex-direction));outline:none;display:flex}.action-button[selected]{--luzmo-action-button-background-color-default:var(--luzmo-primary);--luzmo-action-button-background-color-hover:var(--luzmo-primary-hover);--luzmo-action-button-background-color-down:var(--luzmo-primary-down);--luzmo-action-button-background-color-focus:var(--luzmo-primary-focus);--luzmo-action-button-content-color-default:var(--luzmo-primary-inverse-color);--luzmo-action-button-content-color-hover:var(--luzmo-primary-inverse-color);--luzmo-action-button-content-color-down:var(--luzmo-primary-inverse-color);--luzmo-action-button-content-color-focus:var(--luzmo-primary-inverse-color)}:host .action-buttons{--luzmo-action-button-content-color-default:var(--luzmo-grid-item-action-button-content-color-default,#fff);--luzmo-action-button-content-color-hover:var(--luzmo-grid-item-action-button-content-color-hover,#fff);--luzmo-action-button-content-color-down:var(--luzmo-grid-item-action-button-content-color-down,#fff);--luzmo-action-button-content-color-focus:var(--luzmo-grid-item-action-button-content-color-focus,#fff);--luzmo-action-button-background-color-default:var(--luzmo-grid-item-action-button-background-color-default,#333);--luzmo-action-button-background-color-hover:var(--luzmo-grid-item-action-button-background-color-hover,#444);--luzmo-action-button-background-color-down:var(--luzmo-grid-item-action-button-background-color-down,#555);--luzmo-action-button-background-color-focus:var(--luzmo-grid-item-action-button-background-color-focus,#666)}.delete-button{--luzmo-action-button-background-color-hover:var(--luzmo-grid-item-delete-button-background-color-hover,var(--luzmo-negative-color));--luzmo-action-button-content-color-hover:var(--luzmo-grid-item-delete-button-content-color-hover,#fff);--luzmo-action-button-background-color-focus:var(--luzmo-grid-item-delete-button-background-color-focus,var(--luzmo-negative-color-focus));--luzmo-action-button-content-color-focus:var(--luzmo-grid-item-delete-button-content-color-focus,#fff);--luzmo-action-button-background-color-down:var(--luzmo-grid-item-delete-button-background-color-down,var(--luzmo-negative-color-down));--luzmo-action-button-content-color-down:var(--luzmo-grid-item-delete-button-content-color-down,#fff)}:host([placement=top-start]),:host([placement=top]),:host([placement=top-end]),:host([placement=bottom-start]),:host([placement=bottom]),:host([placement=bottom-end]){--grid-item-actions-flex-direction:row}", LuzmoGridItemActionsMenu = class extends LocalizedMixin(LuzmoElement) {
4251
- constructor(...e) {
4252
- super(...e), this.placement = "right-start", this.actions = defaultActionsMenu();
4253
- }
4254
- static get styles() {
4255
- return [unsafeCSS(grid_item_actions_menu_module_default)];
4256
- }
4257
- get isVertical() {
4258
- return this.placement.includes("left") || this.placement.includes("right");
4259
- }
4260
- _dispatchAction(e) {
4261
- this.dispatchEvent(new CustomEvent("luzmo-grid-item-action", {
4262
- bubbles: !0,
4263
- composed: !0,
4264
- detail: {
4265
- action: e.action,
4266
- type: e.type,
4267
- active: e.active
4268
- }
4269
- }));
4270
- }
4271
- _handleActionClick(e) {
4272
- e.type === "toggle" && (e.active = !e.active, this.actions.forEach((k) => {
4273
- k.actions?.forEach((k) => {
4274
- e !== k && k.active && (k.active = !1);
4275
- });
4276
- })), this._dispatchAction(e), this.requestUpdate();
4705
+ let A = e ? e.gridstackNode : void 0;
4706
+ !A?.grid || e.classList.contains(A.grid.opts.removableOptions.decline) || (k ? A._isAboutToRemove = !0 : delete A._isAboutToRemove, k ? e.classList.add("grid-stack-item-removing") : e.classList.remove("grid-stack-item-removing"));
4277
4707
  }
4278
- clearActiveToggles() {
4279
- this.actions = this.actions.map((e) => ({
4280
- ...e,
4281
- actions: e.actions?.map((e) => (e.type === "toggle" && (e.active = !1), e)) ?? []
4282
- }));
4708
+ _setupRemoveDrop() {
4709
+ if (typeof this.opts.removable != "string") return this;
4710
+ let k = document.querySelector(this.opts.removable);
4711
+ return k && !this.opts.staticGrid && !dd.isDroppable(k) && dd.droppable(k, this.opts.removableOptions).on(k, "dropover", (k, A) => e._itemRemoving(A, !0)).on(k, "dropout", (k, A) => e._itemRemoving(A, !1)), this;
4283
4712
  }
4284
- focus() {
4285
- let e = this.shadowRoot?.querySelectorAll("luzmo-action-button[toggles]");
4286
- e && e[0]?.focus();
4713
+ prepareDragDrop(e, k = !1) {
4714
+ let A = e?.gridstackNode;
4715
+ if (!A) return;
4716
+ let j = A.noMove || this.opts.disableDrag, M = A.noResize || this.opts.disableResize, N = this.opts.staticGrid || j && M;
4717
+ if ((k || N) && (A._initDD && (this._removeDD(e), delete A._initDD), N && e.classList.add("ui-draggable-disabled", "ui-resizable-disabled"), !k)) return this;
4718
+ if (!A._initDD) {
4719
+ let k, j, M = (M, N) => {
4720
+ this.triggerEvent(M, M.target), k = this.cellWidth(), j = this.getCellHeight(!0), this._onStartMoving(e, M, N, A, k, j);
4721
+ }, N = (M, N) => {
4722
+ this._dragOrResize(e, M, N, A, k, j);
4723
+ }, P = (k) => {
4724
+ this.placeholder.remove(), delete this.placeholder.gridstackNode, delete A._moving, delete A._resizing, delete A._event, delete A._lastTried;
4725
+ let j = A.w !== A._orig.w, M = k.target;
4726
+ if (!(!M.gridstackNode || M.gridstackNode.grid !== this)) {
4727
+ if (A.el = M, A._isAboutToRemove) {
4728
+ let j = e.gridstackNode.grid;
4729
+ j._gsEventHandler[k.type] && j._gsEventHandler[k.type](k, M), j.engine.nodes.push(A), j.removeWidget(e, !0, !0);
4730
+ } else Utils.removePositioningStyles(M), A._temporaryRemoved ? (this._writePosAttr(M, A), this.engine.addNode(A)) : this._writePosAttr(M, A), this.triggerEvent(k, M);
4731
+ this._extraDragRow = 0, this._updateContainerHeight(), this._triggerChangeEvent(), this.engine.endUpdate(), k.type === "resizestop" && (Number.isInteger(A.sizeToContent) && (A.sizeToContent = A.h), this.resizeToContentCheck(j, A));
4732
+ }
4733
+ };
4734
+ dd.draggable(e, {
4735
+ start: M,
4736
+ stop: P,
4737
+ drag: N
4738
+ }).resizable(e, {
4739
+ start: M,
4740
+ stop: P,
4741
+ resize: N
4742
+ }), A._initDD = !0;
4743
+ }
4744
+ return dd.draggable(e, j ? "disable" : "enable").resizable(e, M ? "disable" : "enable"), this;
4287
4745
  }
4288
- _generateActionButton(e) {
4289
- let k = {
4290
- Data: msg("Data", { desc: "Grid item action tooltip" }),
4291
- Options: msg("Options", { desc: "Grid item action tooltip" }),
4292
- Clone: msg("Clone", { desc: "Grid item action tooltip" }),
4293
- Delete: msg("Delete", { desc: "Grid item action tooltip" }),
4294
- Edit: msg("Edit", { desc: "Grid item action tooltip" }),
4295
- Lock: msg("Lock", { desc: "Grid item action tooltip" }),
4296
- Filters: msg("Filters", { desc: "Grid item action tooltip" })
4746
+ _onStartMoving(e, k, A, j, M, N) {
4747
+ if (this.engine.cleanNodes().beginUpdate(j), this._writePosAttr(this.placeholder, j), this.el.appendChild(this.placeholder), this.placeholder.gridstackNode = j, j.grid?.el) this.dragTransform = Utils.getValuesFromTransformedElement(e);
4748
+ else if (this.placeholder && this.placeholder.closest(".grid-stack")) {
4749
+ let e = this.placeholder.closest(".grid-stack");
4750
+ this.dragTransform = Utils.getValuesFromTransformedElement(e);
4751
+ } else this.dragTransform = {
4752
+ xScale: 1,
4753
+ xOffset: 0,
4754
+ yScale: 1,
4755
+ yOffset: 0
4297
4756
  };
4298
- return html`
4299
- <luzmo-action-button
4300
- class="${e.action}-button action-button"
4301
- .label=${e.label}
4302
- ?toggles=${e.type === "toggle"}
4303
- ?selected=${e.type === "toggle" && e.active}
4304
- @click=${this._handleActionClick.bind(this, e)}
4305
- >
4306
- <luzmo-icon slot="icon" .icon=${e.icon} size="s"></luzmo-icon>
4307
- ${e.tooltip ? html`
4308
- <luzmo-tooltip
4309
- self-managed
4310
- delayed
4311
- placement=${this.placement?.includes("right") ? "right" : this.placement?.includes("left") ? "left" : this.placement?.includes("bottom") ? "bottom" : this.placement?.includes("top") ? "top" : "right"}
4312
- >
4313
- ${k[e.tooltip] ?? e.tooltip}
4314
- </luzmo-tooltip>
4315
- ` : ""}
4316
- </luzmo-action-button>
4317
- `;
4757
+ if (j.el = this.placeholder, j._lastUiPosition = A.position, j._prevYPix = A.position.top, j._moving = k.type === "dragstart", j._resizing = k.type === "resizestart", delete j._lastTried, k.type === "dropover" && j._temporaryRemoved && (this.engine.addNode(j), j._moving = !0), this.engine.cacheRects(M, N, this.opts.marginTop, this.opts.marginRight, this.opts.marginBottom, this.opts.marginLeft), k.type === "resizestart") {
4758
+ let k = this.getColumn() - j.x, A = (this.opts.maxRow || 2 ** 53 - 1) - j.y;
4759
+ dd.resizable(e, "option", "minWidth", M * Math.min(j.minW || 1, k)).resizable(e, "option", "minHeight", N * Math.min(j.minH || 1, A)).resizable(e, "option", "maxWidth", M * Math.min(j.maxW || 2 ** 53 - 1, k)).resizable(e, "option", "maxWidthMoveLeft", M * Math.min(j.maxW || 2 ** 53 - 1, j.x + j.w)).resizable(e, "option", "maxHeight", N * Math.min(j.maxH || 2 ** 53 - 1, A)).resizable(e, "option", "maxHeightMoveUp", N * Math.min(j.maxH || 2 ** 53 - 1, j.y + j.h));
4760
+ }
4318
4761
  }
4319
- _generateActionGroup(e) {
4320
- let k = e?.actions?.map((e) => this._generateActionButton(e)) ?? [];
4321
- return k.length > 0 ? html`
4322
- <luzmo-action-group ?vertical=${this.isVertical} compact
4323
- >${k}</luzmo-action-group
4324
- >
4325
- ` : html`
4326
-
4327
- `;
4762
+ _dragOrResize(e, k, A, j, M, N) {
4763
+ let P = { ...j._orig }, F, I = this.opts.marginLeft, L = this.opts.marginRight, R = this.opts.marginTop, z = this.opts.marginBottom, B = Math.round(N * .1), V = Math.round(M * .1);
4764
+ if (I = Math.min(I, V), L = Math.min(L, V), R = Math.min(R, B), z = Math.min(z, B), k.type === "drag") {
4765
+ if (j._temporaryRemoved) return;
4766
+ let k = A.position.top - j._prevYPix;
4767
+ j._prevYPix = A.position.top, this.opts.draggable.scroll !== !1 && Utils.updateScrollPosition(e, A.position, k);
4768
+ let F = A.position.left + (A.position.left > j._lastUiPosition.left ? -L : I), B = A.position.top + (A.position.top > j._lastUiPosition.top ? -z : R);
4769
+ P.x = Math.round(F / M), P.y = Math.round(B / N);
4770
+ let V = this._extraDragRow;
4771
+ if (this.engine.collide(j, P)) {
4772
+ let e = this.getRow(), k = Math.max(0, P.y + j.h - e);
4773
+ this.opts.maxRow && e + k > this.opts.maxRow && (k = Math.max(0, this.opts.maxRow - e)), this._extraDragRow = k;
4774
+ } else this._extraDragRow = 0;
4775
+ if (this._extraDragRow !== V && this._updateContainerHeight(), j.x === P.x && j.y === P.y) return;
4776
+ } else if (k.type === "resize") {
4777
+ if (P.x < 0 || (Utils.updateScrollResize(k, e, N), P.w = Math.round((A.size.width - I) / M), P.h = Math.round((A.size.height - R) / N), j.w === P.w && j.h === P.h) || j._lastTried && j._lastTried.w === P.w && j._lastTried.h === P.h) return;
4778
+ let L = A.position.left + I, z = A.position.top + R;
4779
+ P.x = Math.round(L / M), P.y = Math.round(z / N), F = !0;
4780
+ }
4781
+ j._event = k, j._lastTried = P;
4782
+ let H = {
4783
+ x: A.position.left + I,
4784
+ y: A.position.top + R,
4785
+ w: (A.size ? A.size.width : j.w * M) - I - L,
4786
+ h: (A.size ? A.size.height : j.h * N) - R - z
4787
+ };
4788
+ if (this.engine.moveNodeCheck(j, {
4789
+ ...P,
4790
+ cellWidth: M,
4791
+ cellHeight: N,
4792
+ rect: H,
4793
+ resizing: F
4794
+ })) {
4795
+ j._lastUiPosition = A.position, this.engine.cacheRects(M, N, R, L, z, I), delete j._skipDown, F && j.subGrid && j.subGrid.onResize(), this._extraDragRow = 0, this._updateContainerHeight();
4796
+ let e = k.target;
4797
+ j._sidebarOrig || this._writePosAttr(e, j), this.triggerEvent(k, e);
4798
+ }
4328
4799
  }
4329
- render() {
4330
- return html`
4331
- <div class="action-buttons" tabindex="0">${this.actions.map((e) => this._generateActionGroup(e))}</div>
4332
- `;
4800
+ triggerEvent(e, k) {
4801
+ let A = this;
4802
+ for (; A.parentGridNode;) A = A.parentGridNode.grid;
4803
+ A._gsEventHandler[e.type] && A._gsEventHandler[e.type](e, k);
4804
+ }
4805
+ _leave(k, A) {
4806
+ A ||= k;
4807
+ let j = A.gridstackNode;
4808
+ if (!j || (A.style.transform = A.style.transformOrigin = null, dd.off(k, "drag"), j._temporaryRemoved)) return;
4809
+ j._temporaryRemoved = !0, this.engine.removeNode(j), j.el = j._isExternal && A ? A : k;
4810
+ let M = j._sidebarOrig;
4811
+ j._isExternal && this.engine.cleanupNode(j), j._sidebarOrig = M, this.opts.removable === !0 && e._itemRemoving(k, !0), k._gridstackNodeOrig ? (k.gridstackNode = k._gridstackNodeOrig, delete k._gridstackNodeOrig) : j._isExternal && this.engine.restoreInitial();
4333
4812
  }
4334
4813
  };
4335
- __decorate([property({
4336
- type: String,
4337
- reflect: !0
4338
- })], LuzmoGridItemActionsMenu.prototype, "placement", void 0), __decorate([property({ type: Array })], LuzmoGridItemActionsMenu.prototype, "actions", void 0), LuzmoGridItemActionsMenu = __decorate([localized()], LuzmoGridItemActionsMenu);
4339
- var grid_module_default = ":host{width:100%;display:block}.grid-stack{width:100%;min-height:var(--luzmo-grid-min-height);background:var(--luzmo-grid-background,var(--grid-background,var(--luzmo-background-color)));position:relative}.grid-stack[has-active-item] .grid-stack-item:not([active])>.grid-stack-item-content,.grid-stack[has-active-item] .grid-stack-item:not([active])>.grid-item-actions-popover{opacity:.5}.grid-stack .grid-stack-item[active]>.ui-resizable-handle,.grid-stack .grid-stack-item[active].ui-resizable-autohide>.ui-resizable-handle{display:block}.grid-stack .grid-stack-item.ui-resizable-resizing,.grid-stack .grid-stack-item.ui-resizable-resizing>.grid-stack-item-content{opacity:var(--luzmo-grid-item-resizing-opacity,.8)!important}.grid-item-drag-handle{color:var(--luzmo-grid-item-drag-handle-color,#000);top:var(--luzmo-grid-item-drag-handle-position-top,0);left:var(--luzmo-grid-item-drag-handle-position-left,0);right:var(--luzmo-grid-item-drag-handle-position-right,auto);bottom:var(--luzmo-grid-item-drag-handle-position-bottom,auto);padding:var(--luzmo-grid-item-drag-handle-padding,.5rem);z-index:var(--luzmo-grid-item-drag-handle-z-index,3);cursor:var(--luzmo-grid-item-drag-handle-cursor,move);position:absolute}.grid-stack[dark-background] .grid-item-drag-handle{color:var(--luzmo-grid-item-drag-handle-color,#fff)}.grid-stack .grid-stack-item .grid-stack-item-content{border-radius:var(--luzmo-grid-item-border-radius,var(--grid-item-border-radius,4px));background:var(--luzmo-grid-item-background,var(--grid-item-background,transparent));box-shadow:var(--luzmo-grid-item-box-shadow,var(--grid-item-box-shadow,none));border-style:var(--luzmo-grid-item-border-style,none);border-color:var(--luzmo-grid-item-border-color,transparent);-webkit-backdrop-filter:var(--luzmo-grid-item-backdrop-filter,none);backdrop-filter:var(--luzmo-grid-item-backdrop-filter,none);overflow:hidden}.grid-stack .grid-stack-item:not(.has-luzmo-viz-item) .grid-stack-item-content{border-style:var(--luzmo-grid-item-border-style,var(--grid-item-border-style,none));border-color:var(--luzmo-grid-item-border-color,var(--grid-item-border-color,transparent));border-width:var(--luzmo-grid-item-border-width,var(--grid-item-border-width,0));border-top-width:var(--luzmo-grid-item-border-top-width,var(--grid-item-border-top-width,0));border-right-width:var(--luzmo-grid-item-border-right-width,var(--grid-item-border-right-width,0));border-bottom-width:var(--luzmo-grid-item-border-bottom-width,var(--grid-item-border-bottom-width,0));border-left-width:var(--luzmo-grid-item-border-left-width,var(--grid-item-border-left-width,0))}.grid-stack .grid-stack-placeholder>.placeholder-content{border-radius:var(--grid-item-border-radius,4px)}:host .grid-stack-item[active]>.ui-resizable-handle,:host .grid-stack-item:hover>.ui-resizable-handle{z-index:var(--luzmo-grid-resize-handle-z-index,100);background:var(--luzmo-grid-resize-handle-background,#fff);border-radius:var(--luzmo-grid-resize-handle-border-radius,3px);opacity:var(--luzmo-grid-resize-handle-opacity,0);transition:var(--luzmo-grid-resize-handle-transition,opacity .2s ease);box-shadow:0 0 6px #0000001a,0 0 2px #000000bf;display:block!important;position:absolute!important}:host .grid-stack[dark-background]>.grid-stack-item[active]>.ui-resizable-handle,:host .grid-stack[dark-background]>.grid-stack-item:hover>.ui-resizable-handle{background:var(--luzmo-grid-resize-handle-background,#333);box-shadow:0 0 6px #ffffff1a,0 0 2px #ffffffbf}:host .grid-stack-item[active]>.ui-resizable-handle,:host .grid-stack-item:hover>.ui-resizable-handle{opacity:var(--luzmo-grid-resize-handle-opacity-hover,1)}:host .grid-stack-item>.ui-resizable-handle:hover{opacity:var(--luzmo-grid-resize-handle-opacity-active,1);background:var(--luzmo-grid-resize-handle-background-hover,var(--luzmo-background-color-highlight))}:host .grid-stack-item>.ui-resizable-n,:host .grid-stack-item>.ui-resizable-s{height:var(--luzmo-grid-resize-handle-edge-size,8px);width:var(--luzmo-grid-resize-handle-side-size,18px);left:calc(50% - var(--luzmo-grid-resize-handle-side-size,18px)/2)}:host .grid-stack-item>.ui-resizable-n{cursor:n-resize;top:calc(var(--luzmo-grid-resize-handle-edge-offset,-4px) + var(--gs-item-margin-top,0px))}:host .grid-stack-item>.ui-resizable-s{cursor:s-resize;bottom:calc(var(--luzmo-grid-resize-handle-edge-offset,-4px) + var(--gs-item-margin-bottom,0px))}:host .grid-stack-item>.ui-resizable-e,:host .grid-stack-item>.ui-resizable-w{width:var(--luzmo-grid-resize-handle-edge-size,8px);height:var(--luzmo-grid-resize-handle-side-size,18px);top:calc(50% - var(--luzmo-grid-resize-handle-side-size,18px)/2)}:host .grid-stack-item>.ui-resizable-e{cursor:e-resize;right:calc(var(--luzmo-grid-resize-handle-edge-offset,-4px) + var(--gs-item-margin-right,0px))}:host .grid-stack-item>.ui-resizable-w{cursor:w-resize;left:calc(var(--luzmo-grid-resize-handle-edge-offset,-4px) + var(--gs-item-margin-left,0px))}:host .grid-stack-item>.ui-resizable-ne,:host .grid-stack-item>.ui-resizable-nw,:host .grid-stack-item>.ui-resizable-se,:host .grid-stack-item>.ui-resizable-sw{width:var(--luzmo-grid-resize-handle-corner-size,12px);height:var(--luzmo-grid-resize-handle-corner-size,12px);background-image:none;transform:none}:host .grid-stack-item>.ui-resizable-ne{cursor:ne-resize;top:calc(var(--luzmo-grid-resize-handle-edge-offset,-6px) + var(--gs-item-margin-top,0px));right:calc(var(--luzmo-grid-resize-handle-edge-offset,-6px) + var(--gs-item-margin-right,0px))}:host .grid-stack-item>.ui-resizable-nw{cursor:nw-resize;top:calc(var(--luzmo-grid-resize-handle-edge-offset,-6px) + var(--gs-item-margin-top,0px));left:calc(var(--luzmo-grid-resize-handle-edge-offset,-6px) + var(--gs-item-margin-left,0px))}:host .grid-stack-item>.ui-resizable-se{cursor:se-resize;right:calc(var(--luzmo-grid-resize-handle-corner-offset,-4px) + var(--gs-item-margin-right,0px));bottom:calc(var(--luzmo-grid-resize-handle-corner-offset,-4px) + var(--gs-item-margin-bottom,0px))}:host .grid-stack-item>.ui-resizable-sw{cursor:sw-resize;left:calc(var(--luzmo-grid-resize-handle-corner-offset,-4px) + var(--gs-item-margin-left,0px));bottom:calc(var(--luzmo-grid-resize-handle-corner-offset,-4px) + var(--gs-item-margin-bottom,0px))}:host .grid-stack-item>.ui-resizable-resizing .ui-resizable-handle{background:var(--luzmo-grid-resize-handle-background-active,var(--luzmo-background-color-highlight));opacity:1!important}.grid-item-actions-popover{z-index:2;background:0 0;border:none;outline:none;margin:0;padding:0;position:absolute;overflow:visible}luzmo-grid-item-actions-menu{padding:var(--luzmo-grid-item-actions-padding,var(--grid-item-actions-padding))}.dimensions-hint-popover{font-size:var(--luzmo-grid-item-dimensions-hint-font-size,var(--luzmo-font-size-xs,10px));font-family:var(--luzmo-grid-item-dimensions-hint-font-family,var(--luzmo-font-family,inherit));border-width:var(--luzmo-grid-item-dimensions-hint-border-width,var(--luzmo-border-width));border-style:solid;border-color:var(--luzmo-grid-item-dimensions-hint-border-color,var(--luzmo-border-color));border-radius:var(--luzmo-grid-item-dimensions-hint-border-radius,var(--luzmo-border-radius));padding:var(--luzmo-grid-item-dimensions-hint-padding,var(--luzmo-spacing-1)var(--luzmo-spacing-2));z-index:3;background:var(--luzmo-grid-item-dimensions-hint-background,var(--luzmo-background-color));color:var(--luzmo-grid-item-dimensions-hint-color,var(--luzmo-font-color));pointer-events:none;outline:none;margin:0;position:absolute;overflow:visible}luzmo-grid-item-actions-menu{--grid-item-actions-padding:0 .75rem}luzmo-grid-item-actions-menu[placement=top-start],luzmo-grid-item-actions-menu[placement=top],luzmo-grid-item-actions-menu[placement=top-end],luzmo-grid-item-actions-menu[placement=bottom-start],luzmo-grid-item-actions-menu[placement=bottom],luzmo-grid-item-actions-menu[placement=bottom-end]{--grid-item-actions-padding:.75rem 0}.grid-stack-item:focus-visible{outline:none}.grid-stack-item:focus-visible .grid-stack-item-content:after{content:\"\";border:var(--luzmo-indicator-width)solid var(--luzmo-indicator-color,var(--luzmo-primary));box-sizing:border-box;border-radius:var(--luzmo-grid-item-border-radius,var(--grid-item-border-radius,4px));z-index:2;width:100%;height:100%;position:absolute;top:0;left:0}", getRGBA = (e, k) => k >= 1 ? `rgba(${e.r},${e.g},${e.b},1)` : k <= 0 ? `rgba(${e.r},${e.g},${e.b},0)` : `rgba(${e.r},${e.g},${e.b},${k})`, LuzmoGrid = class extends LuzmoElement {
4814
+ GridStack.renderCB = (e, k) => {
4815
+ e && k?.content && (e.textContent = k.content);
4816
+ }, GridStack.resizeToContentParent = ".grid-stack-item-content", GridStack.Utils = Utils, GridStack.Engine = GridStackEngine, GridStack.GDRev = "12.4.2";
4817
+ const initializeGridStack = ({ gridElement: e, gridItemElements: k, items: A, columns: j, rowHeight: M, viewMode: N, fullTheme: P, onCreateOrUpdateDimensionsHint: F, onRemoveDimensionsHint: I, onChange: L }) => {
4818
+ let [R, z] = getGridHalfMargins(P), B = {
4819
+ column: j,
4820
+ cellHeight: M,
4821
+ marginTop: R,
4822
+ marginLeft: z,
4823
+ marginRight: z,
4824
+ marginBottom: R,
4825
+ animate: !0,
4826
+ auto: !1,
4827
+ float: !1,
4828
+ removable: !1,
4829
+ acceptWidgets: !0,
4830
+ disableDrag: N,
4831
+ disableResize: N,
4832
+ minRow: 1,
4833
+ resizable: { handles: [
4834
+ "n",
4835
+ "ne",
4836
+ "e",
4837
+ "se",
4838
+ "s",
4839
+ "sw",
4840
+ "w",
4841
+ "nw"
4842
+ ].join(", ") },
4843
+ handle: ".grid-item-drag-handle"
4844
+ }, V = GridStack.init(B, e);
4845
+ return V.batchUpdate(), k.forEach((e) => {
4846
+ let k = e.getAttribute("luzmo-grid-item-id"), j = buildGridWidgetOptions(A.find((e) => e.id === k), k ?? void 0);
4847
+ V.makeWidget(e, j);
4848
+ }), V.batchUpdate(!1), V.on("resizestart", (e, k) => {
4849
+ F(k, k.getAttribute("gs-w") ?? "", k.getAttribute("gs-h") ?? "");
4850
+ }), V.on("resize", (e, k) => {
4851
+ F(k, k.getAttribute("gs-w") ?? "", k.getAttribute("gs-h") ?? "");
4852
+ }), V.on("resizestop", (e, k) => {
4853
+ I(k);
4854
+ }), V.on("change", (e, k) => {
4855
+ L(k);
4856
+ }), V;
4857
+ }, applyGridStackChanges = (e, k) => {
4858
+ k.forEach((k) => {
4859
+ if (!k?.id) return;
4860
+ let A = e.findIndex((e) => e.id === k.id);
4861
+ A !== -1 && (e[A] = {
4862
+ ...e[A],
4863
+ position: {
4864
+ sizeX: k.w ?? 1,
4865
+ sizeY: k.h ?? 1,
4866
+ row: k.y ?? 0,
4867
+ col: k.x ?? 0
4868
+ }
4869
+ });
4870
+ });
4871
+ }, createOrUpdateDimensionsHint = ({ element: e, numberOfColumns: k, numberOfRows: A, offsetHint: j }) => {
4872
+ let M = e.querySelector(".dimensions-hint-popover");
4873
+ if (M) {
4874
+ M.style.display = k.length > 0 && A.length > 0 ? "block" : "none", M.textContent = `${k} × ${A}`;
4875
+ return;
4876
+ }
4877
+ let N = document.createElement("div");
4878
+ N.className = "dimensions-hint-popover", N.setAttribute("popover", "hint"), N.style.display = k.length > 0 && A.length > 0 ? "block" : "none", N.textContent = `${k} × ${A}`, e.append(N), setPopoverCleanup(N, autoUpdate(e, N, async () => {
4879
+ let { x: k, y: A } = await computePosition(e, N, {
4880
+ placement: "bottom",
4881
+ middleware: [offset(j), flip()]
4882
+ });
4883
+ N.style.left = `${k}px`, N.style.top = `${A}px`;
4884
+ })), N.matches(":popover-open") || N.showPopover();
4885
+ }, removeDimensionsHint = (e) => {
4886
+ let k = e.querySelector(".dimensions-hint-popover");
4887
+ k && (clearPopoverCleanup(k), k.matches(":popover-open") && k.hidePopover(), k.remove());
4888
+ }, syncGridItems = ({ initialized: e, grid: k, hasItemsChanged: A, hasItemAdded: j, gridItemElements: M, items: N, gridElement: P }) => {
4889
+ if (!e || !k || !A && !j) return j;
4890
+ let F = M;
4891
+ return j && (M.forEach((e) => {
4892
+ e.hasAttribute("orphan") && e.remove();
4893
+ }), F = P.querySelectorAll(".luzmo-grid-item")), k.setAnimation(!1), k.batchUpdate(), k.removeAll(!1), N.forEach((e) => {
4894
+ let A = findGridItemElementById(F, e.id);
4895
+ A && k.makeWidget(A, buildGridWidgetOptions(e, e.id));
4896
+ }), k.batchUpdate(!1), k.setAnimation(!0), !1;
4897
+ }, applyViewModeChange = ({ initialized: e, grid: k, hasViewModeChanged: A, viewMode: j, previousViewMode: M, activeItemElement: N, gridElement: P, cleanupActiveItem: F }) => {
4898
+ if (!e || !k || !A || j === M) return N;
4899
+ if (j) {
4900
+ if (k.disable(), N) {
4901
+ F(N), P.removeAttribute("has-active-item");
4902
+ return;
4903
+ }
4904
+ return N;
4905
+ }
4906
+ return k.enable(), N;
4907
+ };
4908
+ var LuzmoGrid = class extends LuzmoElement {
4340
4909
  constructor(...e) {
4341
4910
  super(...e), this.appServer = "https://app.luzmo.com/", this.apiHost = "https://api.luzmo.com", this.language = "en", this.contentLanguage = "en", this.columns = 48, this.rowHeight = 16, this.viewMode = !1, this.placementItemActionsMenu = "right-start", this.items = [], this.renderers = {}, this._initialized = !1, this.defaultRenderer = (e) => html`
4342
4911
  <div class="grid-item-content">
@@ -4344,306 +4913,209 @@ var grid_module_default = ":host{width:100%;display:block}.grid-stack{width:100%
4344
4913
  </div>
4345
4914
  `, this._hasItemAdded = !1, this._handleMouseout = (e) => {
4346
4915
  if (this.viewMode) return;
4347
- let k = e.target.closest(".grid-stack-item");
4348
- k && (e.relatedTarget?.closest(".grid-item-actions-popover") || k.hasAttribute("active") || this._removeItemActionsMenuPopover(k));
4916
+ let k = getGridItemElementFromTarget(e.target);
4917
+ k && shouldRemovePopoverOnMouseout({
4918
+ event: e,
4919
+ gridItem: k
4920
+ }) && this._removeItemActionsMenuPopover(k);
4349
4921
  }, this._handleKeyDown = (e) => {
4350
- if (!this.viewMode) {
4351
- if (e.key === "Delete" && this._focusedItemElement) this._handleDeleteItem(new Event("delete"));
4352
- else if (e.key === "Escape" && this._focusedItemElement) this._focusedItemElement.removeAttribute("focused"), this._removeItemActionsMenuPopover(this._focusedItemElement), this._focusedItemElement = void 0, this._gridElement.focus();
4353
- else if (e.key === "Enter" && this._focusedItemElement) e.preventDefault(), e.stopPropagation(), this._activeItemElement &&= (this._activeItemElement.removeAttribute("active"), this._gridElement.removeAttribute("has-active-item"), this._removeItemActionsMenuPopover(this._activeItemElement), void 0), this._gridElement.querySelectorAll(".grid-stack-item").forEach((e) => {
4354
- e !== this._focusedItemElement && this._removeItemActionsMenuPopover(e);
4355
- }), this._createItemActionsMenuPopover(this._focusedItemElement), requestAnimationFrame(() => {
4356
- let e = this._focusedItemElement?.querySelector("luzmo-grid-item-actions-menu");
4357
- e && e.focus();
4358
- });
4359
- else if (this._focusedItemElement && this._grid && [
4360
- "ArrowLeft",
4361
- "ArrowRight",
4362
- "ArrowUp",
4363
- "ArrowDown"
4364
- ].includes(e.key)) {
4365
- e.preventDefault(), e.stopPropagation();
4366
- let k = this._focusedItemElement.gridstackNode;
4367
- if (!k) return;
4368
- let A = this.columns ?? 48, j = {
4369
- ArrowLeft: {
4370
- move: { x: k.x - 1 },
4371
- resize: {
4372
- x: k.x - 1,
4373
- w: k.w + 1
4374
- },
4375
- shrink: { w: k.w - 1 },
4376
- canMove: k.x > 0,
4377
- canResize: k.x > 0,
4378
- canShrink: k.w > 1
4379
- },
4380
- ArrowRight: {
4381
- move: { x: k.x + 1 },
4382
- resize: { w: k.w + 1 },
4383
- shrink: {
4384
- x: k.x + 1,
4385
- w: k.w - 1
4386
- },
4387
- canMove: k.x < A - k.w,
4388
- canResize: k.x + k.w < A,
4389
- canShrink: k.w > 1
4390
- },
4391
- ArrowUp: {
4392
- move: { y: k.y - 1 },
4393
- resize: {
4394
- y: k.y - 1,
4395
- h: k.h + 1
4396
- },
4397
- shrink: { h: k.h - 1 },
4398
- canMove: k.y > 0,
4399
- canResize: k.y > 0,
4400
- canShrink: k.h > 1
4401
- },
4402
- ArrowDown: {
4403
- move: { y: k.y + 1 },
4404
- resize: { h: k.h + 1 },
4405
- shrink: {
4406
- y: k.y + 1,
4407
- h: k.h - 1
4408
- },
4409
- canMove: !0,
4410
- canResize: !0,
4411
- canShrink: k.h > 1
4412
- }
4413
- }[e.key], M = null;
4414
- e.shiftKey && j.canResize ? M = j.resize : (e.ctrlKey || e.metaKey) && j.canShrink ? M = j.shrink : j.canMove && (M = j.move), M && this._grid.update(this._focusedItemElement, M);
4415
- }
4416
- }
4922
+ let k = handleGridKeyDown({
4923
+ event: e,
4924
+ viewMode: this.viewMode,
4925
+ focusedItemElement: this._focusedItemElement,
4926
+ activeItemElement: this._activeItemElement,
4927
+ gridElement: this._gridElement,
4928
+ grid: this._grid,
4929
+ columns: this.columns ?? 48,
4930
+ handleDeleteItem: this._handleDeleteItem,
4931
+ removeItemActionsMenuPopover: this._removeItemActionsMenuPopover.bind(this),
4932
+ createItemActionsMenuPopover: this._createItemActionsMenuPopover.bind(this)
4933
+ });
4934
+ this._focusedItemElement = k.focusedItemElement, this._activeItemElement = k.activeItemElement;
4417
4935
  }, this._handleFocus = (e) => {
4418
- let k = e.target.closest(".grid-stack-item");
4419
- k && (this._focusedItemElement && this._focusedItemElement !== k && (this._focusedItemElement.removeAttribute("focused"), this._removeItemActionsMenuPopover(this._focusedItemElement)), this._focusedItemElement = k, k.setAttribute("focused", "true"));
4936
+ this._focusedItemElement = applyGridItemFocus({
4937
+ event: e,
4938
+ focusedItemElement: this._focusedItemElement,
4939
+ removeItemActionsMenuPopover: this._removeItemActionsMenuPopover.bind(this)
4940
+ });
4420
4941
  }, this._handleBlur = (e) => {
4421
- this._focusedItemElement && (e.relatedTarget?.closest("luzmo-grid-item-actions-menu") || (this._focusedItemElement.removeAttribute("focused"), this._removeItemActionsMenuPopover(this._focusedItemElement), this._focusedItemElement = void 0, this._gridElement.focus()));
4942
+ let k = clearGridItemFocus({
4943
+ event: e,
4944
+ focusedItemElement: this._focusedItemElement,
4945
+ removeItemActionsMenuPopover: this._removeItemActionsMenuPopover.bind(this)
4946
+ });
4947
+ this._focusedItemElement = k.focusedItemElement, k.shouldFocusGrid && this._gridElement.focus();
4422
4948
  }, this._handleGridClick = (e) => {
4423
- let k = e.composedPath();
4424
- if (!k.includes(this._gridElement) && !k.includes(this)) return;
4425
- let A = this._gridElement.querySelector(".grid-stack-item[active]");
4426
- if (!A || k.includes(A)) return;
4427
- let j = A.querySelector(".grid-item-actions-popover");
4428
- if (j && k.includes(j)) return;
4429
- let M = this._activeItemActionToggle, N = A.getAttribute("gs-id"), P = this.items.find((e) => e.id === N);
4430
- this._cleanupActiveItem(A), M && N && this._dispatchItemActionEvent(M, "toggle", !1, A, N, P), this._activeItemActionToggle = void 0;
4949
+ this._activeItemActionToggle = handleGridClick({
4950
+ event: e,
4951
+ gridElement: this._gridElement,
4952
+ hostElement: this,
4953
+ items: this.items,
4954
+ activeItemActionToggle: this._activeItemActionToggle,
4955
+ cleanupActiveItem: this._cleanupActiveItem.bind(this),
4956
+ dispatchItemActionEvent: this._dispatchItemActionEvent.bind(this)
4957
+ }).activeItemActionToggle;
4431
4958
  }, this._handleAction = (e) => {
4432
- e.stopPropagation();
4433
- let k = e.detail, A = e.target?.closest(".grid-stack-item");
4434
- if (!A) return;
4435
- let j = A.getAttribute("gs-id"), M = this.items.find((e) => e.id === j);
4436
- if (k.type === "toggle" && k.action === this._activeItemActionToggle && A === this._activeItemElement) {
4437
- this._activeItemElement = void 0, this._activeItemActionToggle = void 0, this._gridElement?.removeAttribute("has-active-item"), A.removeAttribute("active"), this._cleanupActiveItem(A), j && this._dispatchItemActionEvent(k.action, k.type, !1, A, j, M);
4438
- return;
4439
- }
4440
- ["delete", "clone"].includes(k.action) || (this._gridElement.querySelectorAll(".grid-stack-item").forEach((e) => {
4441
- e !== A && this._cleanupActiveItem(e);
4442
- }), k.type === "toggle" && (this._activeItemElement = A, this._activeItemActionToggle = k.action, this._gridElement.setAttribute("has-active-item", "true"), A.setAttribute("active", "true"), this._createItemActionsMenuPopover(A, k.action)), j && this._dispatchItemActionEvent(k.action, k.type, k.active, A, j, M)), k.action === "delete" ? (this._handleDeleteItem(e), j && this._dispatchItemActionEvent(k.action, k.type, k.active, A, j, M, j)) : k.action === "clone" && this._handleCloneItem(e);
4959
+ let k = handleGridAction({
4960
+ event: e,
4961
+ gridElement: this._gridElement,
4962
+ items: this.items,
4963
+ state: {
4964
+ activeItemElement: this._activeItemElement,
4965
+ activeItemActionToggle: this._activeItemActionToggle
4966
+ },
4967
+ cleanupActiveItem: this._cleanupActiveItem.bind(this),
4968
+ dispatchItemActionEvent: this._dispatchItemActionEvent.bind(this),
4969
+ handleDeleteItem: this._handleDeleteItem,
4970
+ handleCloneItem: this._handleCloneItem,
4971
+ createItemActionsMenuPopover: this._createItemActionsMenuPopover.bind(this)
4972
+ });
4973
+ this._activeItemElement = k.activeItemElement, this._activeItemActionToggle = k.activeItemActionToggle;
4443
4974
  }, this._handleDeleteItem = (e) => {
4444
- let k = e.target?.closest(".grid-stack-item") || this._focusedItemElement;
4975
+ let k = resolveGridItemForDelete(e, this._focusedItemElement);
4445
4976
  k && this.removeGridItemById(k.getAttribute("gs-id") || "");
4446
4977
  }, this._handleCloneItem = (e) => {
4447
- let k = e.target.closest(".grid-stack-item");
4448
- if (!k || !this._grid) return;
4449
- let A = k.getAttribute("gs-id");
4450
- if (!A) return;
4451
- let j = this.items.find((e) => e.id === A);
4452
- if (!j) return;
4453
- let M = v4_default(), N = {
4454
- ...structuredClone(j),
4455
- id: M
4456
- }, P = this.addGridItem(N), F = e.detail;
4457
- this._dispatchItemActionEvent("clone", F?.type ?? "button", F?.active ?? !1, P, M, N, void 0, k);
4978
+ handleCloneItem({
4979
+ event: e,
4980
+ hasGrid: !!this._grid,
4981
+ items: this.items,
4982
+ createId: v4_default,
4983
+ addGridItem: this.addGridItem.bind(this),
4984
+ dispatchItemActionEvent: this._dispatchItemActionEvent.bind(this)
4985
+ });
4458
4986
  };
4459
4987
  }
4460
4988
  static get styles() {
4461
4989
  return [unsafeCSS(gridstack_min_default), unsafeCSS(grid_module_default)];
4462
4990
  }
4463
4991
  async _loadTheme(e) {
4464
- e?.type === "custom" ? this._fullTheme = structuredClone(e) : e?.id && systemThemeIds.includes(e.id) && this._fullTheme?.id !== e.id ? (this._fullTheme = await getTheme(e.id), this._fullTheme.id = e.id) : e?.id && this._fullTheme?.id !== e.id || !e && this._fullTheme || (this._fullTheme = await getTheme("default")), this._initialized && this._updateThemeProperties(), !this._initialized && this._gridElement && await requestAnimationFrame(() => {
4465
- this._initializeGrid();
4466
- }), this._grid && this._grid?.margin([(this.theme?.margins?.[0] ?? 16) / 2, (this.theme?.margins?.[1] ?? 16) / 2].join(" ")), this.requestUpdate();
4992
+ let k = this._initialized;
4993
+ if (this._fullTheme = await resolveGridTheme({
4994
+ theme: e,
4995
+ currentTheme: this._fullTheme
4996
+ }), this._initialized && applyThemeProperties(this.style, this._fullTheme), !this._initialized && this._gridElement && await new Promise((e) => {
4997
+ requestAnimationFrame(() => {
4998
+ this._initializeGrid(), e();
4999
+ });
5000
+ }), this._grid) {
5001
+ let [e, k] = getGridHalfMargins(this.theme);
5002
+ this._grid.margin([e, k].join(" "));
5003
+ }
5004
+ k && this.requestUpdate();
4467
5005
  }
4468
5006
  firstUpdated() {
4469
- document.addEventListener("click", this._handleGridClick), this.addEventListener("keydown", this._handleKeyDown), this._loadTheme(this.theme);
5007
+ document.addEventListener("click", this._handleGridClick), this.addEventListener("keydown", this._handleKeyDown);
4470
5008
  }
4471
5009
  disconnectedCallback() {
4472
5010
  super.disconnectedCallback(), this._cleanup(), document.removeEventListener("click", this._handleGridClick), this.removeEventListener("keydown", this._handleKeyDown);
4473
5011
  }
4474
5012
  willUpdate(e) {
4475
- super.willUpdate(e), e.has("_initialized") && (this._updateThemeProperties(), this._initialized && this._grid && this._fullTheme?.margins && this._grid?.margin([(this._fullTheme?.margins?.[0] ?? 16) / 2, (this._fullTheme?.margins?.[1] ?? 16) / 2].join(" ")));
5013
+ if (super.willUpdate(e), e.has("_initialized") && (applyThemeProperties(this.style, this._fullTheme), this._initialized && this._grid && this._fullTheme?.margins)) {
5014
+ let [e, k] = getGridHalfMargins(this._fullTheme);
5015
+ this._grid.margin([e, k].join(" "));
5016
+ }
4476
5017
  }
4477
5018
  updated(e) {
4478
5019
  super.updated(e);
4479
5020
  let k = e.has("contentLanguage"), A = e.has("viewMode"), j = e.has("items"), M = e.has("theme");
4480
- this.items.forEach((e) => {
4481
- e.id = e.id ?? v4_default(), e.canFilter = e.canFilter ?? "all";
4482
- }), this._initialized && this._grid && (j || this._hasItemAdded) && (this._hasItemAdded && this._gridItemElements.forEach((e) => {
4483
- e.hasAttribute("orphan") && e.remove();
4484
- }), this._hasItemAdded = !1, this._grid?.setAnimation(!1), this._grid?.batchUpdate(), this._grid?.removeAll(!1), this.items.forEach((e) => {
4485
- let k = [...this._gridItemElements].find((k) => k.getAttribute("luzmo-grid-item-id") === e.id);
4486
- k && this._grid?.makeWidget(k, {
4487
- x: e?.position?.col ?? 0,
4488
- y: e?.position?.row ?? 0,
4489
- w: e?.position?.sizeX ?? 1,
4490
- h: e?.position?.sizeY ?? 1,
4491
- id: e.id
4492
- });
4493
- }), this._grid?.batchUpdate(!1), this._grid?.setAnimation(!0)), k && this._updateLuzmoVizItemsLanguage(), this._initialized && this._grid && A && this.viewMode !== e.get("viewMode") && (this.viewMode ? (this._grid.disable(), this._activeItemElement && (this._cleanupActiveItem(this._activeItemElement), this._activeItemElement = void 0, this._gridElement.removeAttribute("has-active-item"))) : this._grid.enable()), M && this._loadTheme(this.theme);
4494
- }
4495
- _updateLuzmoVizItemsLanguage() {
4496
- this._gridItemElements.forEach((e) => {
4497
- let k = e.querySelector("luzmo-embed-viz-item");
4498
- k && (k.options = {
4499
- ...k.options,
4500
- locale: this.contentLanguage
4501
- });
4502
- });
5021
+ normalizeGridItems(this.items, v4_default), this._hasItemAdded = syncGridItems({
5022
+ initialized: this._initialized,
5023
+ grid: this._grid,
5024
+ hasItemsChanged: j,
5025
+ hasItemAdded: this._hasItemAdded,
5026
+ gridItemElements: this._gridItemElements,
5027
+ items: this.items,
5028
+ gridElement: this._gridElement
5029
+ }), k && updateLuzmoVizItemsLanguage(this._gridItemElements, this.contentLanguage), this._activeItemElement = applyViewModeChange({
5030
+ initialized: this._initialized,
5031
+ grid: this._grid,
5032
+ hasViewModeChanged: A,
5033
+ viewMode: this.viewMode,
5034
+ previousViewMode: e.get("viewMode"),
5035
+ activeItemElement: this._activeItemElement,
5036
+ gridElement: this._gridElement,
5037
+ cleanupActiveItem: this._cleanupActiveItem.bind(this)
5038
+ }), (M || !this._fullTheme && !this._initialized) && this._loadTheme(this.theme);
4503
5039
  }
4504
5040
  _handleMouseover(e) {
4505
5041
  if (this.viewMode) return;
4506
- let k = e.target.closest(".grid-stack-item");
5042
+ let k = getGridItemElementFromTarget(e.target);
4507
5043
  k && this._createItemActionsMenuPopover(k);
4508
5044
  }
4509
5045
  _cleanupActiveItem(e) {
4510
- e.removeAttribute("active"), this._activeItemElement === e && (this._activeItemElement = void 0, this._gridElement.removeAttribute("has-active-item")), this._removeItemActionsMenuPopover(e);
5046
+ this._activeItemElement = cleanupActiveGridItem({
5047
+ item: e,
5048
+ activeItemElement: this._activeItemElement,
5049
+ gridElement: this._gridElement,
5050
+ removeItemActionsMenuPopover: this._removeItemActionsMenuPopover.bind(this)
5051
+ });
4511
5052
  }
4512
5053
  _dispatchItemActionEvent(e, k, A, j, M, N, P, F) {
4513
- this.dispatchEvent(new CustomEvent("luzmo-grid-item-action", {
4514
- detail: {
4515
- action: e,
4516
- actionType: k,
4517
- active: A,
4518
- items: this.items,
4519
- element: j,
4520
- id: M,
4521
- type: N?.type,
4522
- slots: N?.slots,
4523
- options: N?.options,
4524
- filters: N?.filters ?? [],
4525
- ...P && { deletedId: P },
4526
- ...F && { originalElement: F }
4527
- },
4528
- bubbles: !0,
4529
- composed: !0,
4530
- cancelable: !0
4531
- }));
5054
+ dispatchGridItemActionEvent({
5055
+ target: this,
5056
+ action: e,
5057
+ actionType: k,
5058
+ active: A,
5059
+ items: this.items,
5060
+ element: j,
5061
+ itemId: M,
5062
+ item: N,
5063
+ deletedId: P,
5064
+ originalElement: F
5065
+ });
4532
5066
  }
4533
5067
  _cleanup() {
4534
5068
  for (let e of this._gridItemElements) this._cleanupActiveItem(e);
4535
5069
  this._grid &&= (this._grid.destroy(), void 0), this._initialized = !1;
4536
5070
  }
4537
5071
  _initializeGrid() {
4538
- if (this._initialized || !this._gridElement) return;
4539
- let e = {
4540
- column: this.columns ?? 48,
4541
- cellHeight: this.rowHeight ?? 16,
4542
- marginTop: (this._fullTheme?.margins?.[0] ?? 16) / 2,
4543
- marginLeft: (this._fullTheme?.margins?.[1] ?? 16) / 2,
4544
- marginRight: (this._fullTheme?.margins?.[1] ?? 16) / 2,
4545
- marginBottom: (this._fullTheme?.margins?.[0] ?? 16) / 2,
4546
- animate: !0,
4547
- auto: !1,
4548
- float: !1,
4549
- removable: !1,
4550
- acceptWidgets: !0,
4551
- disableDrag: this.viewMode,
4552
- disableResize: this.viewMode,
4553
- minRow: 1,
4554
- resizable: { handles: [
4555
- "n",
4556
- "ne",
4557
- "e",
4558
- "se",
4559
- "s",
4560
- "sw",
4561
- "w",
4562
- "nw"
4563
- ].join(", ") },
4564
- handle: ".grid-item-drag-handle"
4565
- };
4566
- this._grid = GridStack.init(e, this._gridElement), this._grid.batchUpdate(), this._gridItemElements.forEach((e) => {
4567
- let k = e.getAttribute("luzmo-grid-item-id"), A = this.items.find((e) => e.id === k), j = {
4568
- id: k,
4569
- x: A?.position?.col ?? 0,
4570
- y: A?.position?.row ?? 0,
4571
- w: A?.position?.sizeX ?? 1,
4572
- h: A?.position?.sizeY ?? 1
4573
- };
4574
- this._grid?.makeWidget(e, j);
4575
- }), this._grid.batchUpdate(!1), this._initialized = !0, this._grid.on("resizestart", (e, k) => {
4576
- let A = k.getAttribute("gs-w") ?? "", j = k.getAttribute("gs-h") ?? "";
4577
- this._createOrUpdateDimensionsHint(k, A, j);
4578
- }), this._grid.on("resize", (e, k) => {
4579
- let A = k.getAttribute("gs-w") ?? "", j = k.getAttribute("gs-h") ?? "";
4580
- this._createOrUpdateDimensionsHint(k, A, j);
4581
- }), this._grid.on("resizestop", (e, k) => {
4582
- this._removeDimensionsHint(k);
4583
- }), this._grid.on("change", (e, k) => {
4584
- k.forEach((e) => {
4585
- if (!e?.id) return;
4586
- let k = this.items.findIndex((k) => k.id === e.id);
4587
- k !== -1 && (this.items[k] = {
4588
- ...this.items[k],
4589
- position: {
4590
- sizeX: e.w ?? 1,
4591
- sizeY: e.h ?? 1,
4592
- row: e.y ?? 0,
4593
- col: e.x ?? 0
5072
+ this._initialized || !this._gridElement || (this._grid = initializeGridStack({
5073
+ gridElement: this._gridElement,
5074
+ gridItemElements: this._gridItemElements,
5075
+ items: this.items,
5076
+ columns: this.columns ?? 48,
5077
+ rowHeight: this.rowHeight ?? 16,
5078
+ viewMode: this.viewMode,
5079
+ fullTheme: this._fullTheme,
5080
+ onCreateOrUpdateDimensionsHint: this._createOrUpdateDimensionsHint.bind(this),
5081
+ onRemoveDimensionsHint: this._removeDimensionsHint.bind(this),
5082
+ onChange: (e) => {
5083
+ applyGridStackChanges(this.items, e), dispatchGridLifecycleEvent({
5084
+ target: this,
5085
+ eventName: "luzmo-grid-changed",
5086
+ detail: {
5087
+ element: this._gridElement,
5088
+ grid: this._grid,
5089
+ items: this.items
4594
5090
  }
4595
5091
  });
4596
- }), this.dispatchEvent(new CustomEvent("luzmo-grid-changed", {
4597
- detail: {
4598
- element: this._gridElement,
4599
- grid: this._grid,
4600
- items: this.items
4601
- },
4602
- bubbles: !0,
4603
- composed: !0
4604
- }));
4605
- }), this.dispatchEvent(new CustomEvent("luzmo-grid-ready", {
5092
+ }
5093
+ }), this._initialized = !0, dispatchGridLifecycleEvent({
5094
+ target: this,
5095
+ eventName: "luzmo-grid-ready",
4606
5096
  detail: {
4607
5097
  element: this._gridElement,
4608
5098
  grid: this._grid,
4609
5099
  items: this.items
4610
- },
4611
- bubbles: !0,
4612
- composed: !0
5100
+ }
4613
5101
  }));
4614
5102
  }
4615
5103
  _createOrUpdateDimensionsHint(e, k, A) {
4616
- let j = e.querySelector(".dimensions-hint-popover");
4617
- if (j) {
4618
- j.style.display = k.length > 0 && A.length > 0 ? "block" : "none", j.textContent = `${k} × ${A}`;
4619
- return;
4620
- }
4621
- let M = document.createElement("div");
4622
- M.className = "dimensions-hint-popover", M.setAttribute("popover", "hint"), M.style.display = k.length > 0 && A.length > 0 ? "block" : "none", M.textContent = `${k} × ${A}`, e.append(M);
4623
- let N = 10 - (this.theme?.margins?.[0] ?? 10);
4624
- M._cleanup = autoUpdate(e, M, async () => {
4625
- let { x: k, y: A } = await computePosition(e, M, {
4626
- placement: "bottom",
4627
- middleware: [offset(N), flip()]
4628
- });
4629
- M.style.left = `${k}px`, M.style.top = `${A}px`;
4630
- }), M.matches(":popover-open") || M.showPopover();
5104
+ createOrUpdateDimensionsHint({
5105
+ element: e,
5106
+ numberOfColumns: k,
5107
+ numberOfRows: A,
5108
+ offsetHint: getDimensionsHintOffset(this.theme)
5109
+ });
4631
5110
  }
4632
5111
  _removeDimensionsHint(e) {
4633
- let k = e.querySelector(".dimensions-hint-popover");
4634
- k && (k._cleanup && (k._cleanup(), delete k._cleanup), k.matches(":popover-open") && k.hidePopover(), k.remove());
5112
+ removeDimensionsHint(e);
4635
5113
  }
4636
5114
  get grid() {
4637
5115
  return this._grid;
4638
5116
  }
4639
5117
  get gridItems() {
4640
- return this.items.map((e) => {
4641
- let k = {
4642
- item: e,
4643
- element: this._gridElement.querySelector(`[gs-id="${e.id}"]`)
4644
- }, A = k.element?.querySelector("luzmo-embed-viz-item");
4645
- return A && (k.luzmoElement = A), k;
4646
- });
5118
+ return mapGridItems(this.items, this._gridElement);
4647
5119
  }
4648
5120
  registerRenderer(e, k) {
4649
5121
  this.renderers = {
@@ -4652,124 +5124,61 @@ var grid_module_default = ":host{width:100%;display:block}.grid-stack{width:100%
4652
5124
  };
4653
5125
  }
4654
5126
  _renderOverlayContent(e, k) {
4655
- let A = generateActionsMenu(e?.actionsMenu) ?? generateActionsMenu(this.defaultItemActionsMenu) ?? defaultActionsMenu();
4656
- return !itemTypes.find((k) => k.type === e?.type)?.containsData && !e?.actionsMenu && !this.defaultItemActionsMenu && (A = A.map((e) => ({
4657
- ...e,
4658
- actions: e.actions?.filter((e) => e.action !== "edit-data")
4659
- }))), k && (A = A.map((e) => ({
4660
- ...e,
4661
- actions: e.actions?.map((e) => ({
4662
- ...e,
4663
- active: e.action === k ? !0 : e.active
4664
- }))
4665
- }))), html`
4666
- <div class="grid-item-actions-popover" popover="manual">
4667
- <luzmo-grid-item-actions-menu
4668
- .actions=${A}
4669
- placement=${e?.placementActionsMenu ?? this.placementItemActionsMenu ?? "right-start"}
4670
- .language=${this.language}
4671
- @luzmo-grid-item-action=${this._handleAction}
4672
- >
4673
- </luzmo-grid-item-actions-menu>
4674
- </div>
4675
- `;
5127
+ return renderOverlayContent({
5128
+ item: e,
5129
+ activeAction: k,
5130
+ defaultItemActionsMenu: this.defaultItemActionsMenu,
5131
+ placementItemActionsMenu: this.placementItemActionsMenu,
5132
+ language: this.language,
5133
+ handleAction: this._handleAction
5134
+ });
4676
5135
  }
4677
5136
  _createItemActionsMenuPopover(e, k) {
4678
- let A = e.querySelector(".grid-item-actions-popover"), j = e.querySelector(".grid-stack-item-content"), M = this.getGridItemById(e.getAttribute("gs-id") ?? "");
4679
- if (k && A && (this._removeItemActionsMenuPopover(e), A = null), !A) {
4680
- let j = document.createDocumentFragment();
4681
- render(this._renderOverlayContent(M?.item, k), j), A = j.querySelector(".grid-item-actions-popover"), e.append(A);
4682
- }
4683
- let N = autoUpdate(j, A, async () => {
4684
- let { x: e, y: k } = await computePosition(j, A, {
4685
- placement: M?.item?.placementActionsMenu ?? this.placementItemActionsMenu ?? "right-start",
4686
- middleware: [offset(0), flip({ crossAxis: !1 })]
4687
- });
4688
- A.style.left = `${e}px`, A.style.top = `${k}px`;
5137
+ createItemActionsMenuPopover({
5138
+ element: e,
5139
+ activeAction: k,
5140
+ getGridItemById: this.getGridItemById.bind(this),
5141
+ placementItemActionsMenu: this.placementItemActionsMenu,
5142
+ renderOverlayContent: this._renderOverlayContent.bind(this),
5143
+ removeItemActionsMenuPopover: this._removeItemActionsMenuPopover.bind(this)
4689
5144
  });
4690
- A._cleanup = N, A.matches(":popover-open") || A.showPopover();
4691
5145
  }
4692
5146
  _removeItemActionsMenuPopover(e) {
4693
- let k = e.querySelector(".grid-item-actions-popover");
4694
- k && (k._cleanup && (k._cleanup(), delete k._cleanup), k.matches(":popover-open") && k.hidePopover(), k.remove());
4695
- }
4696
- _updateThemeProperties() {
4697
- if (!this._fullTheme) return;
4698
- let e = this._fullTheme.boxShadow, k = "";
4699
- if (e) {
4700
- let j = new Color(e.color), M = {
4701
- r: Math.round(j.srgb.r * 255),
4702
- g: Math.round(j.srgb.g * 255),
4703
- b: Math.round(j.srgb.b * 255)
4704
- }, N = this._fullTheme.margins?.[0] ?? 16, P = Math.min(N / 10, 2);
4705
- e.size === "none" ? k = "none" : e.size === "S" ? k = `0 ${P * 2}px ${P * 4}px ${getRGBA(M, .16)}, 0 ${P * 2}px ${P * 4}px ${getRGBA(M, .23)}` : e.size === "M" ? k = `0 ${P * 8}px ${P * 16}px ${getRGBA(M, .19)}, 0 ${P * 4}px ${P * 4}px ${getRGBA(M, .23)}` : e.size === "L" && (k = `0 ${P * 12}px ${P * 24}px ${getRGBA(M, .25)}, 0 ${P * 8}px ${P * 8}px ${getRGBA(M, .22)}`);
4706
- }
4707
- new Map([
4708
- ["--grid-font-family", this._fullTheme?.font?.fontFamily],
4709
- ["--grid-background", this._fullTheme?.background],
4710
- ["--grid-item-box-shadow", k],
4711
- ["--grid-item-background", this._fullTheme?.itemsBackground],
4712
- ["--grid-item-border-color", this._fullTheme?.borders?.["border-color"]],
4713
- ["--grid-item-border-style", this._fullTheme?.borders?.["border-style"]],
4714
- ["--grid-item-border-radius", this._fullTheme?.borders?.["border-radius"]],
4715
- ["--grid-item-border-width", `${this._fullTheme?.borders?.["border-top-width"]}`],
4716
- ["--grid-item-border-top-width", this._fullTheme?.borders?.["border-top-width"]],
4717
- ["--grid-item-border-right-width", this._fullTheme?.borders?.["border-right-width"]],
4718
- ["--grid-item-border-bottom-width", this._fullTheme?.borders?.["border-bottom-width"]],
4719
- ["--grid-item-border-left-width", this._fullTheme?.borders?.["border-left-width"]]
4720
- ]).forEach((e, k) => {
4721
- e ? this.style.setProperty(k, e) : this.style.removeProperty(k);
4722
- });
5147
+ removeItemActionsMenuPopover(e);
4723
5148
  }
4724
5149
  getGridItemById(e) {
4725
5150
  return this.gridItems.find((k) => k.item.id === e);
4726
5151
  }
4727
5152
  addGridItem(e) {
4728
5153
  !this._initialized && this._gridElement && console.warn("Grid is not initialized, wait for grid-ready event");
4729
- let k = v4_default(), A = {
4730
- ...structuredClone(e),
4731
- id: k,
4732
- position: structuredClone(e?.position) ?? {
4733
- sizeX: 1,
4734
- sizeY: 1,
4735
- col: 0,
4736
- row: 0
4737
- },
4738
- canFilter: e.canFilter ?? "all"
4739
- }, j = this._renderItem(A, this.items.length), M = document.createDocumentFragment();
4740
- render(j, M, { host: this }), this._gridElement.append(M);
4741
- let N = this._gridElement.querySelector(`[luzmo-grid-item-id="${A.id}"]`);
4742
- N.setAttribute("orphan", "true");
4743
- let P = {
4744
- x: A.position?.col ?? 0,
4745
- y: A.position?.row ?? 0,
4746
- w: A.position?.sizeX ?? 1,
4747
- h: A.position?.sizeY ?? 1,
4748
- autoPosition: !0,
4749
- id: A.id
4750
- }, F = this._grid?.makeWidget(N, P);
4751
- return F && (A.position = {
4752
- sizeX: Number.parseInt(F.getAttribute("gs-w") ?? "1", 10),
4753
- sizeY: Number.parseInt(F.getAttribute("gs-h") ?? "1", 10),
4754
- col: Number.parseInt(F.getAttribute("gs-x") ?? "0", 10),
4755
- row: Number.parseInt(F.getAttribute("gs-y") ?? "0", 10)
4756
- }), this.items.push(A), this._hasItemAdded = !0, this._activeItemElement && this._cleanupActiveItem(this._activeItemElement), requestAnimationFrame(() => {
4757
- let e = N.getBoundingClientRect();
4758
- (e.bottom > window.innerHeight || e.top < 0) && N.scrollIntoView({
5154
+ let { item: k, element: A } = addGridItem({
5155
+ newItem: e,
5156
+ gridElement: this._gridElement,
5157
+ grid: this._grid,
5158
+ createId: v4_default
5159
+ });
5160
+ return this.items.push(k), this._hasItemAdded = !0, this._activeItemElement && this._cleanupActiveItem(this._activeItemElement), this.requestUpdate(), requestAnimationFrame(() => {
5161
+ let e = A.getBoundingClientRect();
5162
+ (e.bottom > window.innerHeight || e.top < 0) && A.scrollIntoView({
4759
5163
  behavior: "smooth",
4760
5164
  block: "center"
4761
5165
  });
4762
- }), N;
5166
+ }), A;
4763
5167
  }
4764
5168
  removeGridItem(e) {
4765
5169
  this.removeGridItemById(e?.id ?? "");
4766
5170
  }
4767
5171
  removeGridItemById(e) {
4768
- if (!e) return;
4769
- let k = this.getGridItemById(e)?.element;
4770
- k && this._grid && (this._grid.removeWidget(k), this._focusedItemElement = void 0);
4771
- let A = this.items.findIndex((k) => k.id === e);
4772
- A !== -1 && this.items.splice(A, 1), this._removeItemActionsMenuPopover(k), k && this._activeItemElement === k && this._cleanupActiveItem(k);
5172
+ let k = removeGridItemById({
5173
+ id: e,
5174
+ grid: this._grid,
5175
+ items: this.items,
5176
+ getGridItemById: this.getGridItemById.bind(this),
5177
+ removeItemActionsMenuPopover: this._removeItemActionsMenuPopover.bind(this),
5178
+ activeItemElement: this._activeItemElement,
5179
+ cleanupActiveItem: this._cleanupActiveItem.bind(this)
5180
+ });
5181
+ this._activeItemElement = k.activeItemElement, this._focusedItemElement = k.focusedItemElement;
4773
5182
  }
4774
5183
  async triggerItemAction(e, k, A) {
4775
5184
  await this.updateComplete;
@@ -4778,87 +5187,54 @@ var grid_module_default = ":host{width:100%;display:block}.grid-stack{width:100%
4778
5187
  console.warn(`Grid item with id "${e}" not found`);
4779
5188
  return;
4780
5189
  }
4781
- let M = j.element, N = j.item, P = k === this._activeItemActionToggle && M === this._activeItemElement, F = A?.active ?? !P;
4782
- if (A?.active !== void 0 && F === P) return P;
4783
- if (!F) return this._activeItemElement = void 0, this._activeItemActionToggle = void 0, this._gridElement?.removeAttribute("has-active-item"), M.removeAttribute("active"), this._cleanupActiveItem(M), this._dispatchItemActionEvent(k, "toggle", !1, M, e, N), !1;
4784
- if (this._activeItemElement && this._activeItemElement !== M) {
4785
- let e = this._activeItemElement.getAttribute("gs-id"), k = this.items.find((k) => k.id === e), A = this._activeItemActionToggle, j = this._activeItemElement;
4786
- this._cleanupActiveItem(this._activeItemElement), this._activeItemElement = void 0, this._activeItemActionToggle = void 0, A && e && k && this._dispatchItemActionEvent(A, "toggle", !1, j, e, k);
4787
- }
4788
- return this._activeItemElement = M, this._activeItemActionToggle = k, this._gridElement.setAttribute("has-active-item", "true"), M.setAttribute("active", "true"), this._createItemActionsMenuPopover(M, k), this._dispatchItemActionEvent(k, "toggle", !0, M, e, N), !0;
5190
+ let M = triggerGridItemAction({
5191
+ gridElement: this._gridElement,
5192
+ items: this.items,
5193
+ gridItemData: j,
5194
+ itemId: e,
5195
+ action: k,
5196
+ options: A,
5197
+ state: {
5198
+ activeItemElement: this._activeItemElement,
5199
+ activeItemActionToggle: this._activeItemActionToggle
5200
+ },
5201
+ cleanupActiveItem: this._cleanupActiveItem.bind(this),
5202
+ dispatchItemActionEvent: this._dispatchItemActionEvent.bind(this),
5203
+ createItemActionsMenuPopover: this._createItemActionsMenuPopover.bind(this)
5204
+ });
5205
+ return this._activeItemElement = M.state.activeItemElement, this._activeItemActionToggle = M.state.activeItemActionToggle, M.result;
4789
5206
  }
4790
5207
  deactivateItems() {
4791
- let e = 0;
4792
- if (this._activeItemElement && this._activeItemActionToggle) {
4793
- let k = this._activeItemElement.getAttribute("gs-id"), A = this.items.find((e) => e.id === k), j = this._activeItemActionToggle, M = this._activeItemElement;
4794
- this._cleanupActiveItem(this._activeItemElement), this._activeItemElement = void 0, this._activeItemActionToggle = void 0, this._gridElement?.removeAttribute("has-active-item"), j && k && A && (this._dispatchItemActionEvent(j, "toggle", !1, M, k, A), e++);
4795
- }
4796
- return e;
4797
- }
4798
- _renderItem(e, k) {
4799
- let A = {
4800
- ...e.options,
4801
- locale: this.contentLanguage
4802
- };
4803
- A.theme ||= this._fullTheme?.id ? { id: this._fullTheme.id } : structuredClone(this._fullTheme);
4804
- let j = !this.viewMode;
4805
- return html`
4806
- <div
4807
- class="luzmo-grid-item has-luzmo-viz-item"
4808
- luzmo-grid-item-id=${e.id ?? v4_default()}
4809
- tabindex="0"
4810
- role="row"
4811
- @mouseover=${this._handleMouseover}
4812
- @mouseout=${this._handleMouseout}
4813
- @focus=${this._handleFocus}
4814
- @blur=${this._handleBlur}
4815
- >
4816
- <div
4817
- class="grid-stack-item-content"
4818
- role="gridcell"
4819
- aria-label="Grid item ${k + 1}"
4820
- >
4821
- ${this._initialized ? html` ${j ? html`
4822
- <div class="grid-item-drag-handle">
4823
- <luzmo-icon .icon=${luzmoArrows} size="s"></luzmo-icon>
4824
- </div>
4825
- ` : html`
4826
-
4827
- `}
4828
- <luzmo-embed-viz-item
4829
- .appServer=${this.appServer}
4830
- .apiHost=${this.apiHost}
4831
- .authKey=${this.authKey}
4832
- .authToken=${this.authToken}
4833
- .type=${e.type}
4834
- .slots=${e.slots}
4835
- .options=${A}
4836
- .filters=${e.filters}
4837
- .language=${this.contentLanguage}
4838
- .canFilter=${e.canFilter ?? "all"}
4839
- ></luzmo-embed-viz-item>` : html`
4840
-
4841
- `}
4842
- </div>
4843
- </div>
4844
- `;
5208
+ let e = deactivateGridItems({
5209
+ gridElement: this._gridElement,
5210
+ items: this.items,
5211
+ state: {
5212
+ activeItemElement: this._activeItemElement,
5213
+ activeItemActionToggle: this._activeItemActionToggle
5214
+ },
5215
+ cleanupActiveItem: this._cleanupActiveItem.bind(this),
5216
+ dispatchItemActionEvent: this._dispatchItemActionEvent.bind(this)
5217
+ });
5218
+ return this._activeItemElement = e.state.activeItemElement, this._activeItemActionToggle = e.state.activeItemActionToggle, e.deactivatedCount;
4845
5219
  }
4846
5220
  _renderGrid() {
4847
- this.items.forEach((e) => {
4848
- e.id = e.id ?? v4_default();
5221
+ return renderGrid({
5222
+ items: this.items,
5223
+ initialized: this._initialized,
5224
+ viewMode: this.viewMode,
5225
+ contentLanguage: this.contentLanguage,
5226
+ fullTheme: this._fullTheme,
5227
+ appServer: this.appServer,
5228
+ apiHost: this.apiHost,
5229
+ authKey: this.authKey,
5230
+ authToken: this.authToken,
5231
+ columns: this.columns ?? 48,
5232
+ ensureGridItemId: (e) => ensureGridItemId(e, v4_default),
5233
+ handleMouseover: this._handleMouseover.bind(this),
5234
+ handleMouseout: this._handleMouseout,
5235
+ handleFocus: this._handleFocus,
5236
+ handleBlur: this._handleBlur
4849
5237
  });
4850
- let e = repeat(this.items, (e) => e.id, (e, k) => this._renderItem(e, k)), k = !1;
4851
- return this._initialized && (this._fullTheme?.itemsBackground || this._fullTheme?.background) && (k = new Color(this._fullTheme.itemsBackground ?? this._fullTheme.background).luminance < .5), html`
4852
- <div
4853
- ?dark-background=${k}
4854
- class="grid-stack"
4855
- data-grid-columns=${this.columns ?? 48}
4856
- role="grid"
4857
- aria-label="Dashboard grid"
4858
- >
4859
- ${e}
4860
- </div>
4861
- `;
4862
5238
  }
4863
5239
  render() {
4864
5240
  return this._renderGrid();