@aintela/bi 0.2.0 → 0.2.1

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 (45) hide show
  1. package/dist/GridCardPlaceHolder-DVVT3pqn.js +25 -0
  2. package/dist/GridCardPlaceHolder-DVVT3pqn.js.map +1 -0
  3. package/dist/GridLayout-BgPzzPiP.js +349 -0
  4. package/dist/GridLayout-BgPzzPiP.js.map +1 -0
  5. package/dist/ScriptDashboardViewerVertical-DKaHcL1o.js +713 -0
  6. package/dist/ScriptDashboardViewerVertical-DKaHcL1o.js.map +1 -0
  7. package/dist/biModuleSurface-dtnpBMtT.js +34 -0
  8. package/dist/biModuleSurface-dtnpBMtT.js.map +1 -0
  9. package/dist/cards.js +13 -12
  10. package/dist/cards.js.map +1 -1
  11. package/dist/composer.js +37 -37
  12. package/dist/filterFactory-Ysv0FOQ2.js +285 -0
  13. package/dist/filterFactory-Ysv0FOQ2.js.map +1 -0
  14. package/dist/filters.js +11 -10
  15. package/dist/filters.js.map +1 -1
  16. package/dist/grid.js +19 -16
  17. package/dist/grid.js.map +1 -1
  18. package/dist/index-7p-ogAPK.js +3631 -0
  19. package/dist/index-7p-ogAPK.js.map +1 -0
  20. package/dist/index-BRx4bRbe.js +73 -0
  21. package/dist/index-BRx4bRbe.js.map +1 -0
  22. package/dist/index-CPHaT2or.js +13 -0
  23. package/dist/index-CPHaT2or.js.map +1 -0
  24. package/dist/{index-wtSLspPh.js → index-DeiweWw8.js} +348 -368
  25. package/dist/index-DeiweWw8.js.map +1 -0
  26. package/dist/index-Dz2ulBiy.js +137 -0
  27. package/dist/index-Dz2ulBiy.js.map +1 -0
  28. package/dist/index.js +225 -218
  29. package/dist/index.js.map +1 -1
  30. package/dist/runtime/version.d.ts +1 -1
  31. package/dist/runtime.js +14 -13
  32. package/dist/runtime.js.map +1 -1
  33. package/dist/useContainerRectangle-D464wPFX.js +27 -0
  34. package/dist/useContainerRectangle-D464wPFX.js.map +1 -0
  35. package/dist/{version-DnqajORq.js → version-BgIpi4UM.js} +20 -19
  36. package/dist/{version-DnqajORq.js.map → version-BgIpi4UM.js.map} +1 -1
  37. package/dist/viewer.js +1 -1
  38. package/package.json +1 -1
  39. package/dist/index-C6JQ6770.js +0 -4545
  40. package/dist/index-C6JQ6770.js.map +0 -1
  41. package/dist/index-D7tVPX8d.js +0 -347
  42. package/dist/index-D7tVPX8d.js.map +0 -1
  43. package/dist/index-DGyvUtY3.js +0 -494
  44. package/dist/index-DGyvUtY3.js.map +0 -1
  45. package/dist/index-wtSLspPh.js.map +0 -1
@@ -0,0 +1,713 @@
1
+ var We = Object.defineProperty;
2
+ var s = (e, l) => We(e, "name", { value: l, configurable: !0 });
3
+ import * as Ee from "react/jsx-runtime";
4
+ import { jsx as r, jsxs as c, Fragment as ye } from "react/jsx-runtime";
5
+ import * as Te from "react";
6
+ import { useState as W, useRef as ee, useCallback as He, useMemo as F, useEffect as le, useLayoutEffect as pe } from "react";
7
+ import { RebaseEdit as Be, Schedule as Re, ImportExportOutlined as Le, CloseOutlined as be } from "@mui/icons-material";
8
+ import { Stack as k, Box as w, Typography as f, Button as ce, CircularProgress as te, Slider as ze, IconButton as we, Alert as se, Snackbar as Ce, useTheme as Oe, LinearProgress as Fe } from "@mui/material";
9
+ import * as je from "@mui/material/styles";
10
+ import { alpha as Ne } from "@mui/material/styles";
11
+ import { G as De, e as Ae } from "./GridLayout-BgPzzPiP.js";
12
+ import { a as Se } from "./DashboardParametersContext-Clv--79U.js";
13
+ import { a as Ge } from "./ChartCardDefaultsContext-Cl5T25H0.js";
14
+ import { isSubAgentTerminalStatus as ve } from "@aintela/chat/models";
15
+ import { a as $e } from "./BiClientProvider-CWJochvi.js";
16
+ import * as _e from "react-dom";
17
+ import * as Ve from "react-dom/client";
18
+ import * as Ze from "@emotion/react";
19
+ import * as qe from "@emotion/styled";
20
+ import * as Ue from "dayjs";
21
+ import { d as Je } from "./filterFactory-Ysv0FOQ2.js";
22
+ import { u as Xe } from "./useContainerRectangle-D464wPFX.js";
23
+ const Ye = {
24
+ Generic: "custom",
25
+ Métrica: "kpi",
26
+ Tabela: "table",
27
+ Gráfico: "chart",
28
+ Mapa: "iframe",
29
+ Árvore: "chart",
30
+ Medidor: "chart"
31
+ };
32
+ function Ie(e, l) {
33
+ var n;
34
+ const t = ((n = l == null ? void 0 : l.cards) == null ? void 0 : n.find((o) => o.i === e.key)) ?? null, a = (t == null ? void 0 : t.name) !== e.title ? t == null ? void 0 : t.name : e.title, i = (t == null ? void 0 : t.specificType) !== e.specificType ? t == null ? void 0 : t.specificType : e.specificType, d = (t == null ? void 0 : t.category) !== e.category ? t == null ? void 0 : t.category : e.category;
35
+ return { title: a, specificType: i, category: d };
36
+ }
37
+ s(Ie, "resolveCardMetadata");
38
+ const me = /* @__PURE__ */ new Set();
39
+ let ue = {}, ie = null;
40
+ function vt(e, l) {
41
+ for (const t of e) me.add(t);
42
+ l && (ue = { ...ue, ...l }), ie = null;
43
+ }
44
+ s(vt, "seedHostModules");
45
+ function bt() {
46
+ return [...me];
47
+ }
48
+ s(bt, "getRegisteredSpecifiers");
49
+ async function ke() {
50
+ if (ie) return ie;
51
+ const [e, l, t] = await Promise.all([
52
+ import("@mui/material"),
53
+ import("@mui/icons-material"),
54
+ import("recharts")
55
+ ]), { getBiModuleSurface: a } = await import("./biModuleSurface-dtnpBMtT.js"), i = a(), d = {
56
+ react: Te,
57
+ "react/jsx-runtime": Ee,
58
+ "react-dom": _e,
59
+ "react-dom/client": Ve,
60
+ "@mui/material": e,
61
+ "@mui/icons-material": l,
62
+ "@mui/material/styles": je,
63
+ "@emotion/react": Ze,
64
+ "@emotion/styled": qe,
65
+ recharts: t,
66
+ dayjs: Ue,
67
+ ...ue
68
+ };
69
+ for (const n of me) d[n] = i;
70
+ return ie = d, d;
71
+ }
72
+ s(ke, "getHostModules");
73
+ const Qe = 6, R = /* @__PURE__ */ new Map();
74
+ function Ke(e) {
75
+ let l = 2166136261;
76
+ for (let t = 0; t < e.length; t++)
77
+ l ^= e.charCodeAt(t), l = Math.imul(l, 16777619);
78
+ return `${(l >>> 0).toString(36)}:${e.length}`;
79
+ }
80
+ s(Ke, "hashBundleCode");
81
+ function wt() {
82
+ R.clear(), ie = null;
83
+ }
84
+ s(wt, "clearBundleCaches");
85
+ async function et(e, l) {
86
+ const t = await ke(), a = Ke(e);
87
+ if (l) {
88
+ const o = R.get(l);
89
+ if (o && o.hash === a)
90
+ return R.delete(l), R.set(l, o), o.module;
91
+ }
92
+ const i = { exports: {} }, d = /* @__PURE__ */ s((o) => {
93
+ const h = t[o];
94
+ if (h !== void 0) return h;
95
+ for (const [C, v] of Object.entries(t))
96
+ if (o.startsWith(C + "/") && v && typeof v == "object") {
97
+ const y = v[o.slice(C.length + 1)];
98
+ if (y !== void 0) return { default: y, __esModule: !0 };
99
+ }
100
+ throw new Error(`Dashboard bundle requires unknown module: "${o}". Register it with registerBiModules({ specifiers | extraHostModules }).`);
101
+ }, "requireShim");
102
+ new Function("require", "module", "exports", e)(d, i, i.exports);
103
+ const n = i.exports.default ?? i.exports;
104
+ if (l && (R.delete(l), R.set(l, { hash: a, module: n }), R.size > Qe)) {
105
+ const o = R.keys().next().value;
106
+ o !== void 0 && R.delete(o);
107
+ }
108
+ return n;
109
+ }
110
+ s(et, "evaluateDashboardBundle");
111
+ async function tt(e, l, t) {
112
+ const [a] = await Promise.all([e.fetchDashboardBundle(l, t), ke()]);
113
+ return et(a, `${l}::${t}`);
114
+ }
115
+ s(tt, "loadDashboardBundle");
116
+ async function it(e, l, t) {
117
+ const a = await tt(e, l, t), i = new a();
118
+ return {
119
+ instance: i,
120
+ cards: [...i.getCardsList()],
121
+ style: i.getDashboardStyle()
122
+ };
123
+ }
124
+ s(it, "instantiateDashboardBundle");
125
+ function Pe(e) {
126
+ var fe, ge, xe;
127
+ const l = $e(), t = e.client ?? l;
128
+ if (!t)
129
+ throw new Error("[@aintela/bi] useDashboardBundle needs a BiClient: pass `client` or mount <BiClientProvider>.");
130
+ const a = t, [i, d] = W(e.dashboard), n = e.dashboard ?? i, o = ee(e.onDashloadLoaded);
131
+ o.current = e.onDashloadLoaded;
132
+ const h = ee(e.onFiltersChanged);
133
+ h.current = e.onFiltersChanged;
134
+ const [C, v] = W(null), [y, j] = W(null), [T, H] = W(!1), [N, m] = W(null), D = e.isPrintPreview ?? !1, [A, P] = W(e.parameters ?? {}), L = He((u, b) => {
135
+ P((p) => {
136
+ var O;
137
+ if (!b || Array.isArray(b) && b.length === 0) {
138
+ const { [u]: at, ...Me } = p;
139
+ return Me;
140
+ }
141
+ const S = { ...p, [u]: b };
142
+ return (O = h.current) == null || O.call(h, S), S;
143
+ });
144
+ }, []), G = JSON.stringify(e.parameters ?? {}), $ = F(
145
+ () => ({ ...e.parameters ?? {} }),
146
+ [G]
147
+ ), B = F(
148
+ () => ({ onChange: L, parameters: $, readonly: D }),
149
+ [$, D, L]
150
+ );
151
+ le(() => {
152
+ P((u) => ({ ...u, ...$ }));
153
+ }, [$]);
154
+ const M = e.dashboardId ?? (n == null ? void 0 : n.id), Z = ee(null), [de] = Xe(Z, 0, 0, `${M}-${(n == null ? void 0 : n.id) ?? "pending"}`), [re, ne] = W({ open: !1, message: "", severity: "success" }), [g, Y] = W(null), _ = (fe = e.dashboardWaiting) == null ? void 0 : fe.subAgentId, E = !!_, q = !E || ve(g == null ? void 0 : g.status), U = (g == null ? void 0 : g.status) === "Failed" || (g == null ? void 0 : g.status) === "Cancelled", Q = ((ge = e.dashboardWaiting) == null ? void 0 : ge.sessionId) ?? (n == null ? void 0 : n.originalSessionId) ?? void 0, K = (xe = e.dashboardWaiting) == null ? void 0 : xe.pollIntervalMs;
155
+ le(() => {
156
+ if (!E || !_ || !Q) {
157
+ Y(null);
158
+ return;
159
+ }
160
+ const u = Math.max(K ?? 0, 1e4);
161
+ let b = !1, p = null;
162
+ const S = /* @__PURE__ */ s(async () => {
163
+ try {
164
+ const O = await a.getSubAgentStatus(Q, _);
165
+ if (b || (Y(O), O && ve(O.status))) return;
166
+ } catch (O) {
167
+ if (b) return;
168
+ console.error("Failed to poll sub-agent status:", O);
169
+ }
170
+ b || (p = setTimeout(S, u));
171
+ }, "poll");
172
+ return S(), () => {
173
+ b = !0, p && clearTimeout(p);
174
+ };
175
+ }, [E, _, Q, K, a]), le(() => {
176
+ let u = !1;
177
+ async function b() {
178
+ var p;
179
+ if (!e.dashboard && M)
180
+ try {
181
+ const S = await a.getDashboard(M);
182
+ if (u) return;
183
+ d(S), (p = o.current) == null || p.call(o, S);
184
+ } catch (S) {
185
+ u || m(S instanceof Error ? S.message : "Failed to load dashboard");
186
+ }
187
+ }
188
+ return s(b, "loadMetadata"), b(), () => {
189
+ u = !0;
190
+ };
191
+ }, [M, e.dashboard, a]);
192
+ const ae = e.codeGeneration, V = n == null ? void 0 : n.id, x = n == null ? void 0 : n.jsFileName, I = n == null ? void 0 : n.originalSessionId;
193
+ le(() => {
194
+ let u = !1;
195
+ async function b() {
196
+ if (!(E && !q)) {
197
+ if (E && U) {
198
+ H(!1), m((g == null ? void 0 : g.error) ?? "A geração do dashboard falhou.");
199
+ return;
200
+ }
201
+ if (!(!M && !V)) {
202
+ if (V !== void 0 && !I) {
203
+ console.error("Dashboard has no originalSessionId"), m("Dashboard has no originalSessionId");
204
+ return;
205
+ }
206
+ m(null), H(!0);
207
+ try {
208
+ const p = x ?? `${V ?? M}.js`;
209
+ if (!I) return;
210
+ const S = await it(a, I, p);
211
+ if (u) return;
212
+ v(S.cards), j(S.style);
213
+ } catch (p) {
214
+ u || (console.error(p instanceof Error ? p.message : "Failed to load dashboard"), m(p instanceof Error ? p.message : "Failed to load dashboard"));
215
+ } finally {
216
+ u || H(!1);
217
+ }
218
+ }
219
+ }
220
+ }
221
+ return s(b, "loadBundle"), b(), () => {
222
+ u = !0;
223
+ };
224
+ }, [M, V, x, I, E, q, U, ae, a]);
225
+ const J = F(() => {
226
+ var u;
227
+ return n ? (u = n.filters) == null ? void 0 : u.map((b) => Je(n.id, b, B)) : null;
228
+ }, [n, B]), z = e.editable ?? !1, X = F(() => {
229
+ if (n != null && n.cards)
230
+ return [...n.cards];
231
+ }, [n == null ? void 0 : n.cards]), oe = F(() => {
232
+ if (X)
233
+ return X.map((u) => ({ ...u, isResizable: z, isDraggable: !0 }));
234
+ }, [X, z]);
235
+ return {
236
+ dashboard: n,
237
+ cards: C,
238
+ style: y,
239
+ loading: T,
240
+ error: N,
241
+ setError: m,
242
+ filters: J,
243
+ filterOptions: B,
244
+ stateParameters: A,
245
+ handleParameterChange: L,
246
+ containerRef: Z,
247
+ containerWidth: de,
248
+ rawLayoutDefinition: X,
249
+ layoutDefinition: oe,
250
+ effectiveDashboardId: M,
251
+ isPrintPreview: D,
252
+ snackbar: re,
253
+ setSnackbar: ne,
254
+ subAgentStatus: g,
255
+ isSubAgentTracked: E,
256
+ subAgentDone: q,
257
+ subAgentFailed: U
258
+ };
259
+ }
260
+ s(Pe, "useDashboardBundle");
261
+ const rt = /* @__PURE__ */ s(({ subAgent: e }) => {
262
+ const l = Oe(), t = e == null ? void 0 : e.todoList, a = (t == null ? void 0 : t.items) ?? [], i = a.filter((v) => v.status === "Completed").length, d = a.length, n = t == null ? void 0 : t.percentComplete, o = typeof n == "number" && Number.isFinite(n) ? n : d > 0 ? i / d : 0, h = Math.max(0, Math.min(100, o * 100)), C = d > 0 || h > 0;
263
+ return /* @__PURE__ */ r(
264
+ w,
265
+ {
266
+ sx: {
267
+ position: "relative",
268
+ width: "100%",
269
+ zIndex: 1500,
270
+ display: "flex",
271
+ flexDirection: "column",
272
+ alignItems: "center",
273
+ justifyContent: "center",
274
+ gap: 2,
275
+ px: 4,
276
+ minHeight: "300px",
277
+ backgroundColor: Ne(l.palette.background.default, 0.85),
278
+ backdropFilter: "blur(2px)"
279
+ },
280
+ children: /* @__PURE__ */ c(k, { spacing: 2, alignItems: "center", sx: { width: "100%", maxWidth: 480 }, children: [
281
+ /* @__PURE__ */ r(f, { variant: "h6", sx: { color: "text.primary", textAlign: "center" }, children: "Aguardando a geração do dashboard" }),
282
+ (e == null ? void 0 : e.name) && /* @__PURE__ */ r(f, { variant: "body2", sx: { color: "text.secondary", textAlign: "center" }, children: e.name }),
283
+ /* @__PURE__ */ c(w, { sx: { width: "100%" }, children: [
284
+ /* @__PURE__ */ r(Fe, { variant: C ? "determinate" : "indeterminate", value: C ? h : void 0, sx: { height: 10, borderRadius: 5 } }),
285
+ /* @__PURE__ */ c(k, { direction: "row", justifyContent: "space-between", sx: { mt: 1 }, children: [
286
+ /* @__PURE__ */ r(f, { variant: "caption", sx: { color: "text.secondary" }, children: d > 0 ? `${i} de ${d} tarefas` : "Inicializando..." }),
287
+ /* @__PURE__ */ r(f, { variant: "caption", sx: { color: "text.primary", fontWeight: 600 }, children: `${h.toFixed(1)}%` })
288
+ ] })
289
+ ] })
290
+ ] })
291
+ }
292
+ );
293
+ }, "SubAgentWaitingOverlay"), he = 520, nt = /* @__PURE__ */ s(({ showPre: e, preContent: l, finalContent: t }) => {
294
+ const [a, i] = W(() => e ? "pre" : "final"), d = ee(null), n = ee(null);
295
+ return pe(() => {
296
+ if (a === "pre" && !e) {
297
+ const o = d.current, h = (o == null ? void 0 : o.offsetHeight) ?? 0;
298
+ o && h > 0 && (o.style.height = `${h}px`), i("arriving");
299
+ } else if (a !== "pre" && e) {
300
+ const o = d.current;
301
+ o && (o.style.height = "", o.style.transition = ""), i("pre");
302
+ }
303
+ }, [a, e]), pe(() => {
304
+ if (a !== "arriving") return;
305
+ const o = d.current, h = n.current;
306
+ if (!o || !h) return;
307
+ const C = h.offsetHeight;
308
+ o.offsetHeight, o.style.transition = `height ${he}ms cubic-bezier(0.16, 1, 0.3, 1)`, o.style.height = `${C}px`;
309
+ const v = window.setTimeout(() => {
310
+ const y = d.current;
311
+ y && (y.style.height = "", y.style.transition = ""), i("final");
312
+ }, he + 40);
313
+ return () => window.clearTimeout(v);
314
+ }, [a]), /* @__PURE__ */ c(
315
+ w,
316
+ {
317
+ ref: d,
318
+ sx: {
319
+ position: "relative",
320
+ overflow: a === "final" ? "auto" : "hidden",
321
+ width: "100%",
322
+ flex: 1,
323
+ minHeight: 0,
324
+ "@keyframes dashboardArriveGrow": {
325
+ "0%": { opacity: 0, transform: "scale(0.97)" },
326
+ "100%": { opacity: 1, transform: "scale(1)" }
327
+ }
328
+ },
329
+ children: [
330
+ (a === "pre" || a === "arriving") && /* @__PURE__ */ r(
331
+ "div",
332
+ {
333
+ style: {
334
+ position: a === "arriving" ? "absolute" : "relative",
335
+ top: 0,
336
+ left: 0,
337
+ right: 0,
338
+ opacity: a === "arriving" ? 0 : 1,
339
+ transition: a === "arriving" ? "opacity 360ms ease-out" : "none",
340
+ pointerEvents: a === "arriving" ? "none" : "auto",
341
+ width: "100%"
342
+ },
343
+ children: l
344
+ },
345
+ "pre-layer"
346
+ ),
347
+ (a === "arriving" || a === "final") && /* @__PURE__ */ r(
348
+ w,
349
+ {
350
+ ref: n,
351
+ sx: {
352
+ width: "100%",
353
+ animation: a === "arriving" ? `dashboardArriveGrow ${he}ms 60ms cubic-bezier(0.16, 1, 0.3, 1) both` : "none",
354
+ "@media (prefers-reduced-motion: reduce)": { animation: "none" }
355
+ },
356
+ children: t
357
+ },
358
+ "content-layer"
359
+ )
360
+ ]
361
+ }
362
+ );
363
+ }, "DashboardBodyTransition"), Ct = /* @__PURE__ */ s((e) => {
364
+ var K, ae, V;
365
+ const l = e.useClassicHeader ?? !1, t = e.editable ?? !1, a = Pe({
366
+ client: e.client,
367
+ dashboardId: e.dashboardId,
368
+ parameters: e.parameters,
369
+ dashboard: e.dashboard,
370
+ dashboardWaiting: e.dashboardWaiting,
371
+ codeGeneration: e.codeGeneration,
372
+ onDashloadLoaded: e.onDashloadLoaded,
373
+ onFiltersChanged: e.onFiltersChanged,
374
+ editable: t,
375
+ isPrintPreview: e.isPrintPreview
376
+ }), {
377
+ dashboard: i,
378
+ cards: d,
379
+ style: n,
380
+ loading: o,
381
+ error: h,
382
+ setError: C,
383
+ filters: v,
384
+ filterOptions: y,
385
+ stateParameters: j,
386
+ containerRef: T,
387
+ containerWidth: H,
388
+ layoutDefinition: N,
389
+ effectiveDashboardId: m,
390
+ isPrintPreview: D,
391
+ snackbar: A,
392
+ setSnackbar: P,
393
+ subAgentStatus: L,
394
+ isSubAgentTracked: G,
395
+ subAgentDone: $
396
+ } = a, [B, M] = W(!1), [Z, de] = W(1.03), re = (i == null ? void 0 : i.isDatasetParameterized) ?? !1, ne = F(() => D || !e.isAdmin || !re ? null : e.datasetOverrideControl ?? null, [D, e.isAdmin, re, e.datasetOverrideControl]), g = e.onExportPdf ? async () => {
397
+ if (i) {
398
+ M(!0);
399
+ try {
400
+ await e.onExportPdf({ dashboard: i, parameters: j, datasetOverride: e.datasetOverride });
401
+ } catch (x) {
402
+ C(x instanceof Error ? x.message : "PDF export failed");
403
+ } finally {
404
+ M(!1);
405
+ }
406
+ }
407
+ } : void 0, Y = !!e.onEdit, _ = !!e.onSchedule && !y.readonly, E = e.headerRender ? e.headerRender({
408
+ name: i == null ? void 0 : i.name,
409
+ iconName: i == null ? void 0 : i.muiIconName,
410
+ dashboard: i ?? null,
411
+ filters: v ?? null,
412
+ hasFilters: (((K = i == null ? void 0 : i.filters) == null ? void 0 : K.length) ?? 0) > 0,
413
+ onExportPdf: g,
414
+ onSchedule: e.onSchedule,
415
+ onEdit: e.onEdit,
416
+ exporting: B,
417
+ readonly: !!y.readonly,
418
+ canEdit: Y,
419
+ canSchedule: _,
420
+ datasetOverrideControl: ne
421
+ }) : l ? /* @__PURE__ */ c(ye, { children: [
422
+ /* @__PURE__ */ r(k, { direction: "row", gap: 0, sx: { padding: "5px", marginLeft: "10px", display: "inline-flex", color: "text.secondary", alignItems: "center", marginBottom: "10px", minWidth: "100%" }, children: /* @__PURE__ */ c(w, { sx: { display: "inline-flex", flexWrap: "wrap", minWidth: "100%", alignItems: "center" }, children: [
423
+ /* @__PURE__ */ c(w, { sx: { display: "inline-flex", width: "50%", alignItems: "center", gap: 1 }, children: [
424
+ /* @__PURE__ */ r("span", { className: "material-icons", style: { maxWidth: "24px" }, children: (i == null ? void 0 : i.muiIconName) ?? "dashboard" }),
425
+ /* @__PURE__ */ r(f, { component: "h2", variant: "h6", sx: { m: 0, color: "text.primary" }, children: (i == null ? void 0 : i.name) ?? "" }),
426
+ ne
427
+ ] }),
428
+ /* @__PURE__ */ c(k, { direction: "row", gap: 3, sx: { width: "50%", display: "inline-flex", pr: 2, justifyContent: "right", alignItems: "center" }, children: [
429
+ Y && /* @__PURE__ */ r(ce, { onClick: e.onEdit, size: "small", disabled: B, variant: "outlined", sx: { maxWidth: "200px", p: 1 }, children: /* @__PURE__ */ c(k, { direction: "row", gap: 0.5, alignItems: "center", children: [
430
+ /* @__PURE__ */ r(f, { variant: "body2", children: "Edit" }),
431
+ /* @__PURE__ */ r(Be, { fontSize: "small", sx: { ml: 1 } })
432
+ ] }) }),
433
+ !y.readonly && /* @__PURE__ */ c(ye, { children: [
434
+ _ && /* @__PURE__ */ r(ce, { onClick: e.onSchedule, size: "small", variant: "outlined", sx: { maxHeight: "45px", maxWidth: "200px", p: 1 }, children: /* @__PURE__ */ c(k, { direction: "row", gap: 0.5, alignItems: "center", sx: { maxHeight: "30px" }, children: [
435
+ /* @__PURE__ */ r(f, { variant: "body2", children: e.scheduleLabel ?? "Agendar" }),
436
+ /* @__PURE__ */ r(Re, { sx: { ml: 1, fontSize: "16px" }, fontSize: "small" })
437
+ ] }) }),
438
+ g && /* @__PURE__ */ r(ce, { onClick: g, size: "small", disabled: B, variant: "outlined", sx: { maxHeight: "45px", maxWidth: "200px", p: 1 }, children: /* @__PURE__ */ c(k, { direction: "row", gap: 0.5, alignItems: "center", sx: { maxHeight: "30px" }, children: [
439
+ /* @__PURE__ */ r(f, { variant: "body2", children: B ? "Gerando PDF..." : "Exportar PDF" }),
440
+ B ? /* @__PURE__ */ r(te, { size: 16, sx: { ml: 1 } }) : /* @__PURE__ */ r(Le, { sx: { ml: 1, fontSize: "16px" }, fontSize: "small" })
441
+ ] }) })
442
+ ] })
443
+ ] })
444
+ ] }) }),
445
+ (((V = i == null ? void 0 : i.filters) == null ? void 0 : V.length) ?? 0) > 0 && /* @__PURE__ */ r(
446
+ k,
447
+ {
448
+ direction: "row",
449
+ gap: 2,
450
+ sx: {
451
+ flexWrap: "wrap",
452
+ width: "100%",
453
+ paddingTop: y.readonly ? "10px" : "20px",
454
+ paddingBottom: "10px",
455
+ paddingRight: "10px",
456
+ justifyContent: "flex-end",
457
+ alignItems: "flex-start",
458
+ backgroundColor: "action.hover"
459
+ },
460
+ children: v
461
+ }
462
+ )
463
+ ] }) : (((ae = i == null ? void 0 : i.filters) == null ? void 0 : ae.length) ?? 0) > 0 ? /* @__PURE__ */ r(k, { direction: "row", gap: 2, sx: { flexWrap: "wrap", minWidth: "100%", px: 1.25, py: 1, justifyContent: "flex-end", alignItems: "flex-start" }, children: v }) : null, q = /* @__PURE__ */ s((x, I, J) => {
464
+ var z;
465
+ t && (!I || !J || (z = e.onLayoutCommit) == null || z.call(e, x, I, J));
466
+ }, "commitUserLayoutEdit"), U = F(() => {
467
+ if (!d) return;
468
+ const x = (i == null ? void 0 : i.layoutType) ?? "Boxed";
469
+ return d.map((I) => {
470
+ var oe;
471
+ const { title: J, specificType: z, category: X } = Ie(I, i);
472
+ return /* @__PURE__ */ r(
473
+ De,
474
+ {
475
+ dragLocked: e.dragLocked ?? !1,
476
+ viewType: x,
477
+ zoomLevel: 1,
478
+ header: { title: J ?? "", icon: z ? (oe = e.resolveCardIcon) == null ? void 0 : oe.call(e, z) : void 0 },
479
+ color: Ye[X ?? "Generic"],
480
+ children: I.element
481
+ },
482
+ I.key
483
+ );
484
+ });
485
+ }, [d, i, e.dragLocked, e.resolveCardIcon]);
486
+ if (!i && m)
487
+ return /* @__PURE__ */ c(w, { sx: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", height: "100%", width: "100%", gap: 2 }, children: [
488
+ /* @__PURE__ */ r(te, {}),
489
+ /* @__PURE__ */ r(f, { color: "text.secondary", children: "Loading dashboard..." })
490
+ ] });
491
+ if (!i) return null;
492
+ const Q = (e.showZoomControl ?? !0) && !D;
493
+ return /* @__PURE__ */ r(Ge, { palette: e.chartPalette, rotateBasePerChart: !0, children: /* @__PURE__ */ r(
494
+ Se,
495
+ {
496
+ values: {
497
+ dashboardId: i.id ?? m ?? "",
498
+ parameters: j,
499
+ refreshTick: e.llmRenderCount ?? 0,
500
+ datasetOverride: e.datasetOverride
501
+ },
502
+ children: /* @__PURE__ */ c(
503
+ k,
504
+ {
505
+ ref: /* @__PURE__ */ s((x) => {
506
+ T.current = !T.current && x ? x : T.current;
507
+ }, "ref"),
508
+ className: "bi-dashboard-viewer",
509
+ sx: {
510
+ height: D ? "100vh" : e.height ?? "100%",
511
+ minHeight: "300px",
512
+ display: "inline-flex",
513
+ backgroundColor: "background.default",
514
+ color: "text.primary",
515
+ overflow: "hidden",
516
+ width: "100%",
517
+ maxWidth: D ? "1000px" : "100%",
518
+ "& .grid-card::after": { borderRight: "none", borderBottom: "none" },
519
+ "& .cardDragHandle": { display: "none" }
520
+ },
521
+ children: [
522
+ /* @__PURE__ */ c("div", { style: { position: "relative", padding: 0, width: "100%", left: -3, height: "100%", maxHeight: "100%", display: "flex", flexDirection: "column", alignItems: "flex-start" }, children: [
523
+ Q && /* @__PURE__ */ c(
524
+ w,
525
+ {
526
+ sx: {
527
+ position: "absolute",
528
+ left: "8px",
529
+ bottom: "50px",
530
+ zIndex: 1e3,
531
+ display: "inline-flex",
532
+ alignItems: "center",
533
+ gap: 1,
534
+ px: 1.25,
535
+ py: 0.75,
536
+ borderRadius: 999,
537
+ backgroundColor: "background.paper",
538
+ border: "1px solid",
539
+ borderColor: "divider",
540
+ boxShadow: 4,
541
+ minWidth: 180
542
+ },
543
+ children: [
544
+ /* @__PURE__ */ r(f, { variant: "caption", sx: { color: "text.secondary", textTransform: "uppercase", letterSpacing: 0.6, fontWeight: 500 }, children: "Zoom" }),
545
+ /* @__PURE__ */ r(
546
+ ze,
547
+ {
548
+ value: Z,
549
+ onChange: /* @__PURE__ */ s((x, I) => de(I), "onChange"),
550
+ min: 0.3,
551
+ max: 2,
552
+ step: 0.01,
553
+ sx: { flex: 1, minWidth: 80, color: "primary.main", height: 3, py: "12px !important", "& .MuiSlider-thumb": { width: 12, height: 12, boxShadow: "none" }, "& .MuiSlider-rail": { opacity: 0.25 } }
554
+ }
555
+ ),
556
+ /* @__PURE__ */ c(f, { variant: "caption", sx: { color: "text.primary", fontFamily: "monospace", minWidth: 32, textAlign: "right", fontVariantNumeric: "tabular-nums" }, children: [
557
+ Math.round(Z * 100),
558
+ "%"
559
+ ] })
560
+ ]
561
+ }
562
+ ),
563
+ E && /* @__PURE__ */ r(k, { direction: "row", gap: 0, sx: { display: "inline-flex", minWidth: "100%", flexWrap: "wrap", alignItems: "flex-start", mt: 1, flexShrink: 0 }, children: E }),
564
+ h && /* @__PURE__ */ c(w, { sx: { p: 1, position: "relative", width: "100%" }, children: [
565
+ /* @__PURE__ */ r(we, { size: "small", onClick: /* @__PURE__ */ s(() => C(null), "onClick"), sx: { position: "absolute", right: 10, top: 10 }, children: /* @__PURE__ */ r(be, { fontSize: "small" }) }),
566
+ /* @__PURE__ */ c(se, { severity: "error", children: [
567
+ /* @__PURE__ */ r(f, { variant: "subtitle1", fontWeight: "bold", children: "Dashboard load failed" }),
568
+ /* @__PURE__ */ r(f, { variant: "body2", children: h })
569
+ ] })
570
+ ] }),
571
+ /* @__PURE__ */ r(
572
+ nt,
573
+ {
574
+ showPre: G && !$ || o || H === 0 || !N || !U,
575
+ preContent: G && !$ ? /* @__PURE__ */ r(rt, { subAgent: L }) : o ? /* @__PURE__ */ c(w, { sx: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", height: "100%", minHeight: 300, width: "100%", gap: 2 }, children: [
576
+ /* @__PURE__ */ r(te, {}),
577
+ /* @__PURE__ */ r(f, { color: "text.secondary", children: "Loading dashboard..." })
578
+ ] }) : null,
579
+ finalContent: /* @__PURE__ */ c("div", { id: "renderedDashboard", style: { paddingTop: 2, alignContent: "center", minHeight: "100vh", overflow: "auto", width: "100%" }, children: [
580
+ /* @__PURE__ */ r(
581
+ Ae,
582
+ {
583
+ rowAwareResize: { defaultOn: !0 },
584
+ config: { rows: [] },
585
+ cols: { lg: 10, md: 8, sm: 4, xs: 4, xxs: 4 },
586
+ breakpoints: { lg: 920, md: 600, sm: 400, xs: 400, xxs: 0 },
587
+ zoomLevel: Z,
588
+ responsive: !1,
589
+ rowHeight: D ? 18 : 20,
590
+ dragLocked: e.dragLocked ?? !1,
591
+ rowMultiplier: 1,
592
+ maxRows: 200,
593
+ onResizeStop: q,
594
+ onDragStop: q,
595
+ manualWidth: H,
596
+ layouts: N,
597
+ children: U
598
+ }
599
+ ),
600
+ n
601
+ ] })
602
+ }
603
+ )
604
+ ] }),
605
+ /* @__PURE__ */ r(Ce, { open: A.open, autoHideDuration: 4e3, onClose: /* @__PURE__ */ s(() => P((x) => ({ ...x, open: !1 })), "onClose"), anchorOrigin: { vertical: "bottom", horizontal: "center" }, children: /* @__PURE__ */ r(se, { onClose: /* @__PURE__ */ s(() => P((x) => ({ ...x, open: !1 })), "onClose"), severity: A.severity, variant: "filled", children: A.message }) })
606
+ ]
607
+ }
608
+ )
609
+ }
610
+ ) });
611
+ }, "ScriptDashboardViewer"), Dt = /* @__PURE__ */ s((e) => {
612
+ const l = Pe({
613
+ client: e.client,
614
+ dashboardId: e.dashboardId,
615
+ parameters: e.parameters,
616
+ dashboard: e.dashboard,
617
+ dashboardWaiting: e.dashboardWaiting,
618
+ codeGeneration: e.codeGeneration,
619
+ onDashloadLoaded: e.onDashloadLoaded,
620
+ onFiltersChanged: e.onFiltersChanged,
621
+ isPrintPreview: e.isPrintPreview
622
+ }), { dashboard: t, cards: a, loading: i, error: d, setError: n, stateParameters: o, containerRef: h, containerWidth: C, layoutDefinition: v, effectiveDashboardId: y, isPrintPreview: j, snackbar: T, setSnackbar: H } = l, N = F(() => {
623
+ if (!a) return;
624
+ const m = (t == null ? void 0 : t.layoutType) ?? "Boxed";
625
+ return a.map((D) => {
626
+ var G;
627
+ const { title: A, specificType: P } = Ie(D, t), L = P === "MetricComparison" || P === "Gauge" || P == null;
628
+ return /* @__PURE__ */ r(
629
+ w,
630
+ {
631
+ sx: {
632
+ height: L ? "160px" : "250px",
633
+ maxWidth: "100%",
634
+ mx: 0.5,
635
+ borderBottom: (t == null ? void 0 : t.layoutType) === "Naked" ? "1px solid" : "unset",
636
+ borderColor: "divider"
637
+ },
638
+ children: /* @__PURE__ */ r(De, { dragLocked: !0, noBorder: !0, viewType: m, zoomLevel: L ? 0.9 : 0.7, header: { title: A ?? "", icon: P ? (G = e.resolveCardIcon) == null ? void 0 : G.call(e, P) : void 0 }, children: D.element })
639
+ },
640
+ D.key
641
+ );
642
+ });
643
+ }, [a, t, e.resolveCardIcon]);
644
+ return !t && y ? /* @__PURE__ */ c(w, { sx: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", height: "100%", width: "100%", gap: 2 }, children: [
645
+ /* @__PURE__ */ r(te, {}),
646
+ /* @__PURE__ */ r(f, { color: "text.secondary", children: "Loading dashboard..." })
647
+ ] }) : t ? /* @__PURE__ */ c(
648
+ k,
649
+ {
650
+ ref: /* @__PURE__ */ s((m) => {
651
+ h.current = !h.current && m ? m : h.current;
652
+ }, "ref"),
653
+ className: "bi-dashboard-viewer-vertical",
654
+ sx: {
655
+ height: j ? "100vh" : e.height ?? "unset",
656
+ display: "inline-flex",
657
+ backgroundColor: "background.default",
658
+ color: "text.primary",
659
+ minHeight: "300px",
660
+ overflow: "auto",
661
+ width: "100%",
662
+ maxWidth: j ? "1000px" : "100%",
663
+ "& .grid-card::after": { borderRight: "none", borderBottom: "none" },
664
+ "& .cardDragHandle": { display: "none" }
665
+ },
666
+ children: [
667
+ /* @__PURE__ */ c("div", { style: { position: "relative", width: "100%", height: "100%", maxHeight: "100%", display: "flex", flexDirection: "column", alignItems: "flex-start" }, children: [
668
+ i && /* @__PURE__ */ c(w, { sx: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", height: "100%", width: "100%", gap: 2 }, children: [
669
+ /* @__PURE__ */ r(te, {}),
670
+ /* @__PURE__ */ r(f, { color: "text.secondary", children: "Loading dashboard..." })
671
+ ] }),
672
+ d && /* @__PURE__ */ c(w, { sx: { p: 1, position: "relative", width: "100%" }, children: [
673
+ /* @__PURE__ */ r(we, { size: "small", onClick: /* @__PURE__ */ s(() => n(null), "onClick"), sx: { position: "absolute", right: 10, top: 10 }, children: /* @__PURE__ */ r(be, { fontSize: "small" }) }),
674
+ /* @__PURE__ */ c(se, { severity: "error", children: [
675
+ /* @__PURE__ */ r(f, { variant: "subtitle1", fontWeight: "bold", children: "Dashboard load failed" }),
676
+ /* @__PURE__ */ r(f, { variant: "body2", children: d })
677
+ ] })
678
+ ] }),
679
+ !i && C !== 0 && v && N && /* @__PURE__ */ r(
680
+ Se,
681
+ {
682
+ values: {
683
+ dashboardId: t.id ?? y ?? "",
684
+ parameters: o ?? {},
685
+ refreshTick: e.llmRenderCount ?? 0,
686
+ datasetOverride: e.datasetOverride
687
+ },
688
+ children: /* @__PURE__ */ r(k, { sx: { width: "100%" }, gap: 1, children: N })
689
+ }
690
+ ),
691
+ /* @__PURE__ */ r(w, { sx: { minHeight: "70px", minWidth: "100%" } })
692
+ ] }),
693
+ /* @__PURE__ */ r(Ce, { open: T.open, autoHideDuration: 4e3, onClose: /* @__PURE__ */ s(() => H((m) => ({ ...m, open: !1 })), "onClose"), anchorOrigin: { vertical: "bottom", horizontal: "center" }, children: /* @__PURE__ */ r(se, { onClose: /* @__PURE__ */ s(() => H((m) => ({ ...m, open: !1 })), "onClose"), severity: T.severity, variant: "filled", children: T.message }) })
694
+ ]
695
+ }
696
+ ) : null;
697
+ }, "ScriptDashboardViewerVertical");
698
+ export {
699
+ Ye as C,
700
+ Ct as S,
701
+ Dt as a,
702
+ bt as b,
703
+ wt as c,
704
+ et as e,
705
+ ke as g,
706
+ Ke as h,
707
+ it as i,
708
+ tt as l,
709
+ Ie as r,
710
+ vt as s,
711
+ Pe as u
712
+ };
713
+ //# sourceMappingURL=ScriptDashboardViewerVertical-DKaHcL1o.js.map