@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,3631 @@
1
+ var ni = Object.defineProperty;
2
+ var a = (e, n) => ni(e, "name", { value: n, configurable: !0 });
3
+ import { jsx as t, jsxs as y, Fragment as we } from "react/jsx-runtime";
4
+ import Be, { useState as L, useEffect as q, useContext as Qe, createContext as qt, useMemo as ze, useRef as te, forwardRef as Ct, useCallback as Y, useImperativeHandle as Jt } from "react";
5
+ import { useStore as Xt } from "zustand";
6
+ import { useShallow as ii } from "zustand/react/shallow";
7
+ import { a as et } from "./BiClientProvider-CWJochvi.js";
8
+ import { createStore as ai } from "zustand/vanilla";
9
+ import { C as Oe, S as _e, a as oi } from "./ScriptDashboardViewerVertical-DKaHcL1o.js";
10
+ import v from "@mui/material/Box";
11
+ import { SpeedOutlined as Zt, GridViewOutlined as Qt, MapOutlined as ri, BarChartOutlined as ut, TableChartOutlined as en, TagOutlined as tn, DashboardOutlined as wt, ManageSearchOutlined as li, CalendarTodayOutlined as si, DateRangeOutlined as di, TimelineOutlined as ci, BubbleChartOutlined as hi, DonutLargeOutlined as pi, ScatterPlotOutlined as ui, PieChartOutlined as mi, MultilineChartOutlined as fi, StackedBarChartOutlined as gi, StackedLineChartOutlined as xi, AreaChartOutlined as yi, AlignHorizontalLeftOutlined as bi, ShowChartOutlined as Si, TableRowsOutlined as vi, HeatPumpOutlined as Ci, ViewColumnOutlined as wi, DeleteOutline as nn, CheckCircle as Ti, Pending as Di, ViewQuiltOutlined as ki, BorderClearOutlined as Ii, DragIndicatorOutlined as zi, AddOutlined as Oi, ArrowDropDownOutlined as mt, FilterListOutlined as Pi, PreviewRounded as Ei, FolderOpenOutlined as $i, ArrowBack as Ai, NoteAddOutlined as Mi, SaveOutlined as _i, RefreshOutlined as an, StartRounded as Ri, Close as Fi, Add as Ni, InsertDriveFileOutlined as Bi, Fullscreen as Li } from "@mui/icons-material";
12
+ import { Box as W, Stack as ce, IconButton as Pe, CircularProgress as ft, Typography as ae, Popper as We, Grow as Ve, Paper as Re, ClickAwayListener as je, MenuList as gt, Divider as Ue, MenuItem as Ee, ListItemIcon as Ke, ListItemText as Ye, TextField as Fe, Tooltip as ke, Switch as xt, ToggleButtonGroup as on, ToggleButton as qe, Button as _t, Menu as Gi, Select as Rt, Grid as Je } from "@mui/material";
13
+ import { alpha as Ce, useTheme as he } from "@mui/material/styles";
14
+ import "react-grid-layout/css/styles.css";
15
+ import { e as Hi } from "./GridLayout-BgPzzPiP.js";
16
+ import { G as Wi } from "./GridCardPlaceHolder-DVVT3pqn.js";
17
+ import { useEnvironment as rn, DashboardIcon as De, PanelIcon as Le, CloseIcon as Tt, PromptV2 as Vi, PlusIcon as yt, SearchIcon as ji, useAiChatSessionStore as Ui, useAiChatServices as Ki, ChevronIcon as Yi, EnvironmentProvider as qi, InertEnvironmentProvider as Ji, useEnvironmentOptional as Xi } from "@aintela/chat/components";
18
+ import Ft from "@mui/material/Stack";
19
+ import { AnimatePresence as tt, motion as se, useReducedMotion as Zi } from "framer-motion";
20
+ import ln from "@mui/material/Dialog";
21
+ import Se from "@mui/material/IconButton";
22
+ import ue from "@mui/material/Tooltip";
23
+ import ee from "@mui/material/Typography";
24
+ import Nt from "@mui/material/Divider";
25
+ import lt from "@mui/material/ListItemIcon";
26
+ import st from "@mui/material/ListItemText";
27
+ import dt from "@mui/material/MenuItem";
28
+ import Bt from "@mui/material/MenuList";
29
+ import Lt from "@mui/material/Popover";
30
+ import Gt from "@mui/material/ToggleButton";
31
+ import Qi from "@mui/material/ToggleButtonGroup";
32
+ import ea from "@mui/icons-material/EditOutlined";
33
+ import { createPortal as ta } from "react-dom";
34
+ function $e(e) {
35
+ if (!(e != null && e.trim())) return "_";
36
+ const n = e.normalize("NFD").replace(new RegExp("\\p{Mn}", "gu"), "").replace(new RegExp("(?<=[a-zA-Z0-9_$])[^a-zA-Z0-9_$]+([a-zA-Z_$])", "g"), (i, l) => l.toUpperCase()).replace(/[^a-zA-Z0-9_$]+/g, "");
37
+ return n ? /^\d/.test(n) ? `_${n}` : n : "_";
38
+ }
39
+ a($e, "sanitizeToJsVariable");
40
+ function Ie() {
41
+ const e = typeof globalThis.crypto < "u" ? globalThis.crypto : void 0;
42
+ if (e && typeof e.randomUUID == "function") return e.randomUUID();
43
+ let n = "";
44
+ for (let i = 0; i < 32; i++) n += Math.floor(Math.random() * 16).toString(16);
45
+ return n;
46
+ }
47
+ a(Ie, "randomId");
48
+ const nt = 300;
49
+ function Dt(e) {
50
+ if (!e) return;
51
+ const n = Object.values(e).filter((i) => i && i.trim().length > 0);
52
+ if (n.length !== 0)
53
+ return n.map((i) => `- ${i}`).join(`
54
+ `);
55
+ }
56
+ a(Dt, "joinClientSideChanges");
57
+ const ve = [
58
+ { label: "Métrica (Comparação)", category: "Métrica", specificType: "MetricComparison" },
59
+ { label: "Tabela (Auto)", category: "Tabela", specificType: "TableAuto" },
60
+ { label: "Tabela (Com barras)", category: "Tabela", specificType: "TableBars" },
61
+ { label: "Tabela (Com mapa de calor)", category: "Tabela", specificType: "TableHeatmap" },
62
+ { label: "Tabela (Grande)", category: "Tabela", specificType: "TableLarge" },
63
+ { label: "Gráfico (Auto)", category: "Gráfico", specificType: "ChartAuto" },
64
+ { label: "Gráfico (Linhas)", category: "Gráfico", specificType: "ChartLine" },
65
+ { label: "Gráfico (Barras) (H)", category: "Gráfico", specificType: "ChartBarH" },
66
+ { label: "Gráfico (Barras) (V)", category: "Gráfico", specificType: "ChartBarV" },
67
+ { label: "Gráfico (Area)", category: "Gráfico", specificType: "ChartArea" },
68
+ { label: "Gráfico (Area Empilhada)", category: "Gráfico", specificType: "ChartStackedArea" },
69
+ { label: "Gráfico (Barras Empilhadas)", category: "Gráfico", specificType: "ChartStackedBar" },
70
+ { label: "Gráfico (Combo)", category: "Gráfico", specificType: "ChartCombo" },
71
+ { label: "Gráfico (Pizza)", category: "Gráfico", specificType: "ChartPie" },
72
+ { label: "Gráfico (Donnut)", category: "Gráfico", specificType: "ChartDonut" },
73
+ { label: "Mapa (Bubbles)", category: "Mapa", specificType: "MapBubbles" },
74
+ { label: "Mapa (Conexões)", category: "Mapa", specificType: "MapConnections" },
75
+ { label: "Árvore (Distribuição)", category: "Árvore", specificType: "Treemap" },
76
+ { label: "Medidor (Gauge)", category: "Medidor", specificType: "Gauge" }
77
+ ];
78
+ function it(e = ve) {
79
+ return e.reduce((n, i) => {
80
+ var l;
81
+ return (n[l = i.category] ?? (n[l] = [])).push(i), n;
82
+ }, {});
83
+ }
84
+ a(it, "groupCardCatalog");
85
+ const kt = [
86
+ { label: "Período (Date Range)", filterType: "DateRangePicker" },
87
+ { label: "Data (Date Picker)", filterType: "DatePicker" },
88
+ { label: "Auto Complete", filterType: "AutoComplete" }
89
+ ], na = /* @__PURE__ */ a((e, n) => e.actionDescription == n.actionDescription && e.category == n.category && e.name == n.name && e.color == n.color && e.specificType == n.specificType, "sketchCardItemComparer"), ia = /* @__PURE__ */ a((e, n) => JSON.stringify(e) == JSON.stringify(n), "sketchFilterComparer");
90
+ function bt(e) {
91
+ var r;
92
+ const n = /* @__PURE__ */ new Set();
93
+ let i = !1;
94
+ for (const o of e.cards ?? [])
95
+ o.todoItem = void 0, n.has(o.name) ? i = !0 : n.add(o.name);
96
+ let l = null;
97
+ return i && (l = "Os nomes dos cards precisam ser únicos"), (((r = e.cards) == null ? void 0 : r.length) ?? 0) == 0 && (l = "Inclua pelo menos um card no rascunho"), l;
98
+ }
99
+ a(bt, "validateSketch");
100
+ const aa = 20;
101
+ function sn(e) {
102
+ var x, b, g;
103
+ const n = [];
104
+ let i = 0, l = 0, r = 0, o = 0;
105
+ for (const d of e.config) {
106
+ const { size: C, height: s, card: u } = d, m = Math.max(1, Math.round((s ?? nt) / aa));
107
+ i + C > 12 && (i = 0, l += r, r = 0);
108
+ let c = d.description, p = d.name, f = d.specificType, _ = d.id, B;
109
+ if (Be.isValidElement(u)) {
110
+ const G = u.props ?? {};
111
+ c = c ?? G.description ?? "", p = p ?? G.name, _ = _ ?? G.id ?? $e(`${p ?? ""}${o}`), f = f ?? G.specificType, B = G.category ?? ((x = ve.find((z) => z.specificType === f)) == null ? void 0 : x.category);
112
+ } else {
113
+ if (p === void 0 && f === void 0)
114
+ continue;
115
+ _ = _ ?? $e(`${p}${o}`), B = (b = ve.find((G) => G.specificType === f)) == null ? void 0 : b.category;
116
+ }
117
+ n.push({
118
+ i: _ ?? "not_defined",
119
+ x: i,
120
+ y: l,
121
+ w: C,
122
+ h: m,
123
+ name: p ?? ((g = ve.find((G) => G.specificType === f)) == null ? void 0 : g.label),
124
+ actionDescription: c,
125
+ specificType: f,
126
+ category: B
127
+ }), i += C, r = Math.max(r, m), o++;
128
+ }
129
+ return {
130
+ id: e.id,
131
+ name: e.name,
132
+ cards: n,
133
+ filters: e.filters ?? []
134
+ };
135
+ }
136
+ a(sn, "padConfigToDashboard");
137
+ function dn(e) {
138
+ return typeof e == "object" && e !== null && "config" in e && Array.isArray(e.config);
139
+ }
140
+ a(dn, "isSimplePadDefinition");
141
+ function oa(e) {
142
+ return Oe[e] ?? Oe.Generic;
143
+ }
144
+ a(oa, "categoryPrefix");
145
+ const Xe = "llm-env-highlight-active";
146
+ function cn() {
147
+ return typeof document > "u" ? null : document;
148
+ }
149
+ a(cn, "defaultRoot");
150
+ function Ht(e) {
151
+ return typeof CSS < "u" && CSS.escape ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
152
+ }
153
+ a(Ht, "escapeCssValue");
154
+ function hn(e) {
155
+ return e.startsWith(".") || e.startsWith("#") || e.startsWith("[") || e.includes(" ") || e.includes(":") || e.includes(">");
156
+ }
157
+ a(hn, "looksLikeSelector");
158
+ function pn(e) {
159
+ var r, o, x;
160
+ const n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ a((b) => {
161
+ const g = Ht(b);
162
+ n.add(`[data-env-id="${g}"]`), n.add(`[data-env-key="${g}"]`), n.add(`[data-env-name="${g}"]`), n.add(`#${g}`), n.add(`.${g}`);
163
+ }, "appendByIdentifier"), l = /* @__PURE__ */ a((b) => {
164
+ b.split(/\s+/).map((g) => g.trim()).filter(Boolean).forEach((g) => n.add(`.${Ht(g)}`));
165
+ }, "appendByClassName");
166
+ if (typeof e == "string") {
167
+ const b = e.trim();
168
+ return b ? (hn(b) ? n.add(b) : i(b), [...n]) : [];
169
+ }
170
+ return (r = e.selector) != null && r.trim() && n.add(e.selector.trim()), (o = e.className) != null && o.trim() && l(e.className), (x = e.identifier) != null && x.trim() && i(e.identifier.trim()), [...n];
171
+ }
172
+ a(pn, "toSelectorList");
173
+ function Ze(e, n = cn()) {
174
+ if (!n) return { selectors: [], elements: [] };
175
+ const i = pn(e), l = /* @__PURE__ */ new Set();
176
+ return i.forEach((r) => {
177
+ try {
178
+ n.querySelectorAll(r).forEach((o) => l.add(o));
179
+ } catch (o) {
180
+ console.warn("[@aintela/bi composer] Invalid selector:", r, o);
181
+ }
182
+ }), { selectors: i, elements: [...l] };
183
+ }
184
+ a(Ze, "resolveEnvironmentElements");
185
+ function It(e) {
186
+ const n = e.getBoundingClientRect();
187
+ if (!(n.width > 0 && n.height > 0)) return !1;
188
+ if (typeof window > "u" || !window.getComputedStyle) return !0;
189
+ const i = window.getComputedStyle(e);
190
+ return i.display !== "none" && i.visibility !== "hidden";
191
+ }
192
+ a(It, "isElementVisible");
193
+ function un(e, n = !1) {
194
+ if (e.length === 0) return null;
195
+ if (n) return e[0];
196
+ for (const i of e) if (It(i)) return i;
197
+ return e[0];
198
+ }
199
+ a(un, "pickBestElement");
200
+ function zt(e, n = cn()) {
201
+ const { elements: i } = Ze(e, n);
202
+ for (const l of i) if (It(l)) return l;
203
+ return null;
204
+ }
205
+ a(zt, "resolveGuideElement");
206
+ const mn = /* @__PURE__ */ new Set([
207
+ "dashboardpad-add-card",
208
+ "dashboardpad-add-card-dropdown",
209
+ "dashboardpad-add-filter",
210
+ "dashboard-pad-layout-toggle",
211
+ "dashboard-pad-layout-boxed",
212
+ "dashboard-pad-layout-naked"
213
+ ]), fn = /* @__PURE__ */ new Set([
214
+ "llm-env-card",
215
+ "llm-env-filter",
216
+ "llm-env-layout-toggle",
217
+ "llm-env-card-sketch",
218
+ "llm-env-card-sketch-wrapper",
219
+ "llm-env-filter-sketch"
220
+ ]), ra = /^[0-9a-fA-F]{8,}(-[0-9a-fA-F]{4,})+$/;
221
+ function gn(e) {
222
+ const n = /* @__PURE__ */ a((l) => {
223
+ const r = l.trim();
224
+ return r ? mn.has(r) ? !0 : ra.test(r) : !1;
225
+ }, "checkId"), i = /* @__PURE__ */ a((l) => l.split(/\s+/).filter(Boolean).some((r) => fn.has(r)), "checkClass");
226
+ if (typeof e == "string") {
227
+ const l = e.trim();
228
+ return hn(l) ? !1 : n(l);
229
+ }
230
+ return !!(e.identifier && n(e.identifier) || e.className && i(e.className));
231
+ }
232
+ a(gn, "targetSuggestsPadInternal");
233
+ function xn(e) {
234
+ return e.some((n) => gn(n.target));
235
+ }
236
+ a(xn, "guideStepsRequireSketch");
237
+ const yn = /* @__PURE__ */ a(({ entry: e, onHover: n }) => {
238
+ var i;
239
+ return /* @__PURE__ */ t(
240
+ v,
241
+ {
242
+ onClick: /* @__PURE__ */ a(() => {
243
+ var l;
244
+ return (l = e.source) == null ? void 0 : l.click();
245
+ }, "onClick"),
246
+ onMouseOver: /* @__PURE__ */ a(() => n == null ? void 0 : n(e.sourceSelector), "onMouseOver"),
247
+ sx: { "& :hover": { cursor: "pointer" } },
248
+ children: /* @__PURE__ */ t(
249
+ "div",
250
+ {
251
+ style: { width: `${e.width}px`, height: `${e.height}px` },
252
+ dangerouslySetInnerHTML: { __html: ((i = e.html) == null ? void 0 : i.replaceAll(Xe, "")) ?? "" }
253
+ }
254
+ )
255
+ }
256
+ );
257
+ }, "ClonedComponent");
258
+ function bn(e) {
259
+ const {
260
+ cards: n,
261
+ filters: i,
262
+ layoutType: l,
263
+ remarks: r,
264
+ userPrompt: o,
265
+ grid_definition: x,
266
+ updated_grid_definition: b,
267
+ filter_components: g,
268
+ // Parameterised-dataset fields live on `Dashboard.Draft` server-side;
269
+ // at the top level the deserialiser drops them on the floor.
270
+ isDatasetParameterized: d,
271
+ defaultDatasetName: C,
272
+ clientSideChanges: s,
273
+ ...u
274
+ } = e;
275
+ return {
276
+ ...u,
277
+ draft: {
278
+ cards: n ?? [],
279
+ filters: i ?? [],
280
+ remarks: r,
281
+ userPrompt: o,
282
+ layoutType: l,
283
+ grid_definition: x ?? null,
284
+ updated_grid_definition: b ?? null,
285
+ filter_components: g ?? [],
286
+ isDatasetParameterized: d ?? !1,
287
+ defaultDatasetName: C
288
+ }
289
+ };
290
+ }
291
+ a(bn, "toDraftPayload");
292
+ function Ne(e) {
293
+ const n = e ?? {}, i = n.draft ?? n.committed;
294
+ return {
295
+ ...n,
296
+ cards: (i == null ? void 0 : i.cards) ?? n.cards ?? [],
297
+ filters: (i == null ? void 0 : i.filters) ?? n.filters ?? [],
298
+ remarks: (i == null ? void 0 : i.remarks) ?? n.remarks,
299
+ userPrompt: (i == null ? void 0 : i.userPrompt) ?? n.userPrompt,
300
+ layoutType: (i == null ? void 0 : i.layoutType) ?? n.layoutType,
301
+ grid_definition: (i == null ? void 0 : i.gridDefinition) ?? (i == null ? void 0 : i.grid_definition) ?? n.grid_definition ?? null,
302
+ updated_grid_definition: (i == null ? void 0 : i.upadatedGridDefinition) ?? (i == null ? void 0 : i.updated_grid_definition) ?? n.updated_grid_definition ?? null,
303
+ filter_components: (i == null ? void 0 : i.filterComponents) ?? (i == null ? void 0 : i.filter_components) ?? n.filter_components ?? [],
304
+ isDatasetParameterized: (i == null ? void 0 : i.isDatasetParameterized) ?? n.isDatasetParameterized,
305
+ defaultDatasetName: (i == null ? void 0 : i.defaultDatasetName) ?? n.defaultDatasetName
306
+ };
307
+ }
308
+ a(Ne, "fromUpsertResponse");
309
+ async function at(e, n) {
310
+ const i = await e.upsertDashboard(bn(n));
311
+ return Ne(i);
312
+ }
313
+ a(at, "upsertDashboardDraft");
314
+ async function Ot(e, n, i) {
315
+ return at(e, {
316
+ name: (i == null ? void 0 : i.name) ?? "Sem título",
317
+ filters: (i == null ? void 0 : i.filters) ?? [],
318
+ cards: (i == null ? void 0 : i.cards) ?? [],
319
+ ...i,
320
+ id: void 0,
321
+ originalSessionId: n
322
+ });
323
+ }
324
+ a(Ot, "createDashboardDraft");
325
+ const Sn = 3e3, vn = 800, Cn = 500, la = 1800;
326
+ function wn(e = {}) {
327
+ const n = e.viewerCommitDebounceMs ?? Sn, i = e.draftSaveDebounceMs ?? vn, l = e.onDraftSaveError ?? ((r) => console.warn("[@aintela/bi composer] draft save failed:", r));
328
+ return ai()((r, o) => {
329
+ const x = /* @__PURE__ */ a(async () => {
330
+ const s = o()._client, u = o().dashboardDefinition;
331
+ if (!s || !(u != null && u.id) || !u.originalSessionId) return;
332
+ const m = at(s, u).then(() => {
333
+ }).catch(l);
334
+ r({ _draftSavePromise: m }), await m, r((c) => c._draftSavePromise === m ? { _draftSavePromise: null } : {});
335
+ }, "_saveDraft"), b = /* @__PURE__ */ a(() => {
336
+ const s = o()._draftSaveTimer;
337
+ s && clearTimeout(s);
338
+ const u = setTimeout(() => {
339
+ x();
340
+ }, i);
341
+ r({ _draftSaveTimer: u });
342
+ }, "_scheduleDraftSave"), g = /* @__PURE__ */ a(() => {
343
+ if (o().turnOpen) return;
344
+ const s = o()._viewerCommitTimer;
345
+ s && clearTimeout(s);
346
+ const u = setTimeout(() => {
347
+ if (o().turnOpen) return;
348
+ const m = o().dashboardDefinition;
349
+ r((c) => ({ publishedDashboard: m, llmCounter: c.llmCounter + 1, _viewerCommitTimer: null }));
350
+ }, n);
351
+ r({ _viewerCommitTimer: u });
352
+ }, "_scheduleViewerCommit"), d = /* @__PURE__ */ a(() => {
353
+ const s = o()._viewerCommitTimer;
354
+ s && (clearTimeout(s), r({ _viewerCommitTimer: null }));
355
+ }, "_cancelViewerCommit"), C = /* @__PURE__ */ a(async (s) => {
356
+ var B;
357
+ await Promise.resolve();
358
+ const u = o().dashboardDefinition, m = o().currentSessionId || null, c = o().turnOpen, p = s.id;
359
+ if (!c && (u != null && u.id) && p && u.id === p && (((B = u.cards) == null ? void 0 : B.length) ?? 0) > 0)
360
+ return;
361
+ const f = dn(s) ? sn(s) : { ...s };
362
+ f.originalSessionId = m;
363
+ const _ = {
364
+ ...u,
365
+ ...f,
366
+ id: p ?? (u == null ? void 0 : u.id),
367
+ originalSessionId: f.originalSessionId,
368
+ jsFileName: f.jsFileName ?? (u == null ? void 0 : u.jsFileName),
369
+ name: f.name || (u == null ? void 0 : u.name) || "",
370
+ layoutType: "Naked"
371
+ };
372
+ o().updateDashboard(_), r((G) => ({ viewType: "Sketch", llmCounter: G.llmCounter + 1, agentPulseTick: G.agentPulseTick + 1 }));
373
+ }, "internalUpdateDashboardPad");
374
+ return {
375
+ dashboardDefinition: null,
376
+ publishedDashboard: null,
377
+ lastSentDashboard: null,
378
+ dashboardId: null,
379
+ viewType: "Sketch",
380
+ scriptLoadOnMount: !1,
381
+ renderGeneration: 0,
382
+ turnOpen: !1,
383
+ currentSessionId: null,
384
+ llmCounter: 0,
385
+ agentPulseTick: 0,
386
+ todosByCardKey: {},
387
+ sketchExpanded: !1,
388
+ hasCompletedOnce: !1,
389
+ producedDashboardId: null,
390
+ viewport: { width: 0, height: 0 },
391
+ guideSteps: null,
392
+ guideOptions: null,
393
+ _client: e.client ?? null,
394
+ _draftSaveTimer: null,
395
+ _draftSavePromise: null,
396
+ _viewerCommitTimer: null,
397
+ _guideShowTimer: null,
398
+ setClient: /* @__PURE__ */ a((s) => r({ _client: s }), "setClient"),
399
+ flushDraft: /* @__PURE__ */ a(async () => {
400
+ const s = o()._draftSaveTimer;
401
+ s && (clearTimeout(s), r({ _draftSaveTimer: null }));
402
+ const u = o()._draftSavePromise;
403
+ u && await u, await x();
404
+ }, "flushDraft"),
405
+ ingestToolEvent: /* @__PURE__ */ a((s, u) => {
406
+ if (s === "dashboardGenerated") {
407
+ const m = o().dashboardDefinition, c = {
408
+ ...m,
409
+ name: (m == null ? void 0 : m.name) || "Untitled",
410
+ jsFileName: u
411
+ };
412
+ d(), r((p) => ({
413
+ dashboardDefinition: c,
414
+ publishedDashboard: c,
415
+ lastSentDashboard: c,
416
+ viewType: "Generated",
417
+ scriptLoadOnMount: !1,
418
+ renderGeneration: p.renderGeneration + 1,
419
+ llmCounter: p.llmCounter + 1,
420
+ agentPulseTick: p.agentPulseTick + 1
421
+ })), b();
422
+ return;
423
+ }
424
+ if (s === "todolistUpdated")
425
+ try {
426
+ const m = JSON.parse(u);
427
+ r((c) => {
428
+ const p = { ...c.todosByCardKey };
429
+ let f = !1;
430
+ for (const _ of m.items ?? [])
431
+ p[_.key] = { todo: _, turnOpen: c.turnOpen }, f = !0;
432
+ return f ? { todosByCardKey: p } : {};
433
+ });
434
+ } catch {
435
+ console.warn("[@aintela/bi composer] Failed to parse todolistUpdated:", u);
436
+ }
437
+ }, "ingestToolEvent"),
438
+ setTurnOpen: /* @__PURE__ */ a((s) => r({ turnOpen: s }), "setTurnOpen"),
439
+ onTurnOpened: /* @__PURE__ */ a(() => r({ turnOpen: !0, viewType: "Sketch" }), "onTurnOpened"),
440
+ onTurnClosed: /* @__PURE__ */ a(() => {
441
+ r({ turnOpen: !1, todosByCardKey: {} }), b();
442
+ }, "onTurnClosed"),
443
+ setDashboardId: /* @__PURE__ */ a((s) => r({ dashboardId: s }), "setDashboardId"),
444
+ setCurrentSessionId: /* @__PURE__ */ a((s) => r({ currentSessionId: s }), "setCurrentSessionId"),
445
+ setViewType: /* @__PURE__ */ a((s) => r({ viewType: s }), "setViewType"),
446
+ updateDashboard: /* @__PURE__ */ a((s) => {
447
+ if (!s) {
448
+ d(), r({ dashboardDefinition: null, publishedDashboard: null, lastSentDashboard: null });
449
+ return;
450
+ }
451
+ const m = { ...o().dashboardDefinition ?? { name: "" }, ...s }, c = !o().publishedDashboard && !o().lastSentDashboard;
452
+ r({
453
+ dashboardDefinition: m,
454
+ ...c ? { publishedDashboard: m, lastSentDashboard: m } : {}
455
+ }), c || g(), b();
456
+ }, "updateDashboard"),
457
+ loadDashboard: /* @__PURE__ */ a((s) => {
458
+ const u = !!s.jsFileName, m = { ...s };
459
+ d(), r({
460
+ dashboardDefinition: m,
461
+ publishedDashboard: m,
462
+ lastSentDashboard: m,
463
+ dashboardId: s.id ?? null,
464
+ currentSessionId: s.originalSessionId ?? null,
465
+ viewType: u ? "Generated" : "Sketch",
466
+ scriptLoadOnMount: u,
467
+ renderGeneration: o().renderGeneration + 1
468
+ });
469
+ }, "loadDashboard"),
470
+ recordSketchChange: /* @__PURE__ */ a((s, u) => {
471
+ const m = s.trim(), c = u.trim();
472
+ !m || !c || r((p) => {
473
+ const f = p.dashboardDefinition;
474
+ if (!f) return {};
475
+ const _ = f.clientSideChanges ?? {};
476
+ return _[m] === c ? {} : { dashboardDefinition: { ...f, clientSideChanges: { ..._, [m]: c } } };
477
+ });
478
+ }, "recordSketchChange"),
479
+ clearClientSideChanges: /* @__PURE__ */ a(() => {
480
+ r((s) => {
481
+ const u = s.dashboardDefinition, m = u == null ? void 0 : u.clientSideChanges;
482
+ return !u || !m || Object.keys(m).length === 0 ? {} : { dashboardDefinition: { ...u, clientSideChanges: void 0 } };
483
+ });
484
+ }, "clearClientSideChanges"),
485
+ commitForSend: /* @__PURE__ */ a(() => {
486
+ d();
487
+ const s = o().dashboardDefinition;
488
+ r({ publishedDashboard: s, lastSentDashboard: s });
489
+ }, "commitForSend"),
490
+ commitDashboardLayout: /* @__PURE__ */ a(() => {
491
+ d(), r({ publishedDashboard: o().dashboardDefinition });
492
+ }, "commitDashboardLayout"),
493
+ setSketchExpanded: /* @__PURE__ */ a((s) => r((u) => ({ sketchExpanded: typeof s == "function" ? s(u.sketchExpanded) : s })), "setSketchExpanded"),
494
+ setHasCompletedOnce: /* @__PURE__ */ a((s) => r({ hasCompletedOnce: s }), "setHasCompletedOnce"),
495
+ setProducedDashboardId: /* @__PURE__ */ a((s) => r({ producedDashboardId: s }), "setProducedDashboardId"),
496
+ setViewport: /* @__PURE__ */ a((s) => r((u) => u.viewport.width === s.width && u.viewport.height === s.height ? {} : { viewport: s }), "setViewport"),
497
+ highlightComponent: /* @__PURE__ */ a((s, u) => {
498
+ const m = (u == null ? void 0 : u.durationMs) ?? la, { elements: c } = Ze(s);
499
+ return c.length === 0 ? 0 : (c.forEach((p, f) => {
500
+ p.classList.add(Xe), setTimeout(() => p.classList.remove(Xe), m), f === 0 && (u != null && u.scrollIntoView) && typeof p.scrollIntoView == "function" && p.scrollIntoView({ behavior: "smooth", block: "center", inline: "center" });
501
+ }), c.length);
502
+ }, "highlightComponent"),
503
+ cloneComponent: /* @__PURE__ */ a((s, u) => {
504
+ const { selectors: m, elements: c } = Ze(s), p = un(c, (u == null ? void 0 : u.includeHidden) ?? !1);
505
+ if (!p) return null;
506
+ const f = p.getBoundingClientRect(), _ = {
507
+ id: Ie(),
508
+ sourceSelector: m.join(",") || (typeof s == "string" ? s : s.identifier ?? ""),
509
+ html: p.outerHTML.replaceAll("data-env-id", "d-env-id").replaceAll("data-env-key", "d-env-key").replaceAll("data-env-name", "d-env-name").replaceAll("llm-env-target", "").replaceAll("llm-env-dashboard-action", ""),
510
+ width: Math.max(1, Math.round(f.width)),
511
+ height: Math.max(1, Math.round(f.height))
512
+ }, B = {
513
+ cloneId: _.id,
514
+ width: _.width,
515
+ height: _.height,
516
+ sourceSelector: _.sourceSelector,
517
+ html: _.html,
518
+ source: p
519
+ };
520
+ return B.component = /* @__PURE__ */ t(yn, { entry: B, onHover: /* @__PURE__ */ a((G) => o().highlightComponent(G), "onHover") }), B;
521
+ }, "cloneComponent"),
522
+ createDashboardPad: /* @__PURE__ */ a((s) => {
523
+ C(s);
524
+ }, "createDashboardPad"),
525
+ updateDashboardPad: /* @__PURE__ */ a((s) => {
526
+ C(s);
527
+ }, "updateDashboardPad"),
528
+ showGuide: /* @__PURE__ */ a((s, u) => {
529
+ if (!Array.isArray(s) || s.length === 0) {
530
+ console.warn("[@aintela/bi composer] showGuide called with empty or non-array `steps`; tour will not be shown.", { steps: s, guideOptions: u });
531
+ return;
532
+ }
533
+ const m = s.findIndex((f) => !f || f.target === void 0 || f.target === null);
534
+ if (m >= 0) {
535
+ console.warn(`[@aintela/bi composer] showGuide: step ${m} is missing \`target\`; tour will not be shown.`, { steps: s });
536
+ return;
537
+ }
538
+ const c = o()._guideShowTimer;
539
+ c && clearTimeout(c);
540
+ const p = setTimeout(() => {
541
+ r({ guideSteps: s, guideOptions: u ?? null, _guideShowTimer: null });
542
+ }, Cn);
543
+ r({ _guideShowTimer: p });
544
+ }, "showGuide"),
545
+ dismissGuide: /* @__PURE__ */ a(() => {
546
+ var m;
547
+ const s = o()._guideShowTimer;
548
+ s && clearTimeout(s);
549
+ const u = o().guideOptions;
550
+ r({ guideSteps: null, guideOptions: null, _guideShowTimer: null }), (m = u == null ? void 0 : u.onComplete) == null || m.call(u);
551
+ }, "dismissGuide"),
552
+ refreshDashboard: /* @__PURE__ */ a(() => {
553
+ const s = o().dashboardDefinition;
554
+ if (!(s != null && s.id)) return;
555
+ const u = {
556
+ ...s,
557
+ name: s.name || "Untitled",
558
+ jsFileName: s.jsFileName ?? `${s.id}.js`
559
+ };
560
+ d(), r((m) => ({
561
+ dashboardDefinition: u,
562
+ publishedDashboard: u,
563
+ lastSentDashboard: u,
564
+ viewType: "Generated",
565
+ scriptLoadOnMount: !1,
566
+ renderGeneration: m.renderGeneration + 1,
567
+ llmCounter: m.llmCounter + 1
568
+ }));
569
+ }, "refreshDashboard"),
570
+ openComposer: /* @__PURE__ */ a((s) => {
571
+ if (d(), s) {
572
+ const u = !!s.jsFileName, m = { ...s };
573
+ r({
574
+ dashboardDefinition: m,
575
+ publishedDashboard: m,
576
+ lastSentDashboard: m,
577
+ dashboardId: s.id ?? null,
578
+ currentSessionId: s.originalSessionId ?? null,
579
+ viewType: u ? "Generated" : "Sketch",
580
+ scriptLoadOnMount: u,
581
+ renderGeneration: o().renderGeneration + 1,
582
+ turnOpen: !1,
583
+ todosByCardKey: {}
584
+ });
585
+ } else
586
+ r({
587
+ dashboardDefinition: null,
588
+ publishedDashboard: null,
589
+ lastSentDashboard: null,
590
+ dashboardId: null,
591
+ currentSessionId: null,
592
+ viewType: "Sketch",
593
+ scriptLoadOnMount: !1,
594
+ renderGeneration: o().renderGeneration + 1,
595
+ turnOpen: !1,
596
+ todosByCardKey: {}
597
+ });
598
+ }, "openComposer")
599
+ };
600
+ });
601
+ }
602
+ a(wn, "createComposerStore");
603
+ const Pt = qt(null), sa = /* @__PURE__ */ a(({ client: e, store: n, children: i, ...l }) => {
604
+ const r = et(), o = e === void 0 ? r : e, [x] = L(() => n ?? wn({ ...l, client: o }));
605
+ return q(() => {
606
+ x.getState()._client !== o && x.getState().setClient(o);
607
+ }, [x, o]), /* @__PURE__ */ t(Pt.Provider, { value: x, children: i });
608
+ }, "ComposerProvider");
609
+ function me() {
610
+ const e = Qe(Pt);
611
+ if (!e)
612
+ throw new Error("[@aintela/bi] No composer store in scope. Wrap the composer surface in <ComposerProvider>.");
613
+ return e;
614
+ }
615
+ a(me, "useComposerStore");
616
+ function da() {
617
+ return Qe(Pt);
618
+ }
619
+ a(da, "useComposerStoreOptional");
620
+ function N(e) {
621
+ const n = me();
622
+ return Xt(n, e ?? ((i) => i));
623
+ }
624
+ a(N, "useComposer");
625
+ function Tn() {
626
+ const e = me();
627
+ return Xt(
628
+ e,
629
+ ii((n) => ({
630
+ highlightComponent: n.highlightComponent,
631
+ cloneComponent: n.cloneComponent,
632
+ createDashboardPad: n.createDashboardPad,
633
+ updateDashboardPad: n.updateDashboardPad,
634
+ refreshDashboard: n.refreshDashboard,
635
+ showGuide: n.showGuide,
636
+ dismissGuide: n.dismissGuide
637
+ }))
638
+ );
639
+ }
640
+ a(Tn, "useComposerEnvironment");
641
+ function ca(e) {
642
+ const n = e.getState();
643
+ return {
644
+ highlightComponent: n.highlightComponent,
645
+ cloneComponent: n.cloneComponent,
646
+ createDashboardPad: n.createDashboardPad,
647
+ updateDashboardPad: n.updateDashboardPad,
648
+ refreshDashboard: n.refreshDashboard,
649
+ showGuide: n.showGuide,
650
+ dismissGuide: n.dismissGuide
651
+ };
652
+ }
653
+ a(ca, "environmentFromStore");
654
+ const Dn = {
655
+ Generic: wt,
656
+ Métrica: tn,
657
+ Tabela: en,
658
+ Gráfico: ut,
659
+ Mapa: ri,
660
+ Árvore: Qt,
661
+ Medidor: Zt
662
+ }, kn = {
663
+ Generic: "info",
664
+ Métrica: "kpi",
665
+ Tabela: "table",
666
+ Gráfico: "chart",
667
+ Mapa: "map",
668
+ Árvore: "chart",
669
+ Medidor: "chart"
670
+ }, In = {
671
+ Generic: wt,
672
+ MetricComparison: tn,
673
+ TableAuto: en,
674
+ TableBars: wi,
675
+ TableHeatmap: Ci,
676
+ TableLarge: vi,
677
+ ChartAuto: ut,
678
+ ChartLine: Si,
679
+ ChartBarH: bi,
680
+ ChartBarV: ut,
681
+ ChartArea: yi,
682
+ ChartStackedArea: xi,
683
+ ChartStackedBar: gi,
684
+ ChartCombo: fi,
685
+ ChartPie: mi,
686
+ Scatter: ui,
687
+ ChartDonut: pi,
688
+ MapBubbles: hi,
689
+ MapConnections: ci,
690
+ Treemap: Qt,
691
+ Gauge: Zt
692
+ }, zn = {
693
+ Generic: "DashboardOutlined",
694
+ MetricComparison: "TagOutlined",
695
+ TableAuto: "TableChartOutlined",
696
+ TableBars: "ViewColumnOutlined",
697
+ TableHeatmap: "HeatPumpOutlined",
698
+ TableLarge: "TableRowsOutlined",
699
+ ChartAuto: "BarChartOutlined",
700
+ ChartLine: "ShowChartOutlined",
701
+ ChartBarH: "AlignHorizontalLeftOutlined",
702
+ ChartBarV: "BarChartOutlined",
703
+ ChartArea: "AreaChartOutlined",
704
+ ChartStackedArea: "StackedLineChartOutlined",
705
+ ChartStackedBar: "StackedBarChartOutlined",
706
+ ChartCombo: "MultilineChartOutlined",
707
+ ChartPie: "PieChartOutlined",
708
+ Scatter: "ScatterPlotOutlined",
709
+ ChartDonut: "DonutLargeOutlined",
710
+ MapBubbles: "BubbleChartOutlined",
711
+ MapConnections: "TimelineOutlined",
712
+ Treemap: "GridViewOutlined",
713
+ Gauge: "SpeedOutlined"
714
+ }, On = {
715
+ DateRangePicker: di,
716
+ DatePicker: si,
717
+ AutoComplete: li
718
+ }, Pn = {
719
+ category: Dn,
720
+ specificType: In,
721
+ filterType: On
722
+ }, St = qt(Pn), ha = /* @__PURE__ */ a(({ icons: e, children: n }) => {
723
+ const i = Qe(St), l = ze(
724
+ () => ({
725
+ category: { ...i.category, ...e.category ?? {} },
726
+ specificType: { ...i.specificType, ...e.specificType ?? {} },
727
+ filterType: { ...i.filterType, ...e.filterType ?? {} }
728
+ }),
729
+ [i, e]
730
+ );
731
+ return /* @__PURE__ */ t(St.Provider, { value: l, children: n });
732
+ }, "CardTypeIconsProvider");
733
+ function Ae() {
734
+ return Qe(St);
735
+ }
736
+ a(Ae, "useCardTypeIcons");
737
+ const pa = 60, ua = it(ve);
738
+ function ma(e) {
739
+ const [n, i] = L(0);
740
+ return q(() => {
741
+ const l = e.current;
742
+ if (!l) return;
743
+ const r = /* @__PURE__ */ a(() => i(l.getBoundingClientRect().height), "measure");
744
+ if (r(), typeof ResizeObserver > "u") return;
745
+ const o = new ResizeObserver(r);
746
+ return o.observe(l), () => o.disconnect();
747
+ }, [e]), n;
748
+ }
749
+ a(ma, "useElementHeight");
750
+ const Et = /* @__PURE__ */ a((e) => {
751
+ var F;
752
+ const n = Ae(), [i, l] = L(e.cellConfig.name ?? "[Card Name]"), [r, o] = L(e.cellConfig.actionDescription ?? "[Card Description]"), [x, b] = L(!1), [g, d] = L(e.cellConfig), [C, s] = L(!1), [u, m] = L(!1), c = te(null), p = te(null), f = te(null), _ = ma(f), B = e.cellConfig.specificType ?? "Generic", G = e.cellConfig.category ?? "Generic", z = n.specificType[B] ?? n.specificType.Generic;
753
+ q(() => {
754
+ d(e.cellConfig);
755
+ }, [e.cellConfig]), q(() => {
756
+ const w = setTimeout(() => {
757
+ if (!c.current) return;
758
+ let O = c.current.getElementsByTagName("input").item(0);
759
+ O || (O = c.current.getElementsByTagName("textarea").item(0)), O && (O.focus(), O.selectionStart = 0, O.selectionEnd = O.value.length);
760
+ }, 50);
761
+ return () => clearTimeout(w);
762
+ }, [x, C]);
763
+ const R = /* @__PURE__ */ a((w) => {
764
+ (!w.shiftKey && w.key === "Enter" || w.key === "Escape") && (s(!1), b(!1), e.onDataEdit(g));
765
+ }, "handleKeyPress"), P = /* @__PURE__ */ a((w, O) => {
766
+ const k = O.target.value;
767
+ if (w === l && $e(k).length > pa) return;
768
+ w(k);
769
+ const U = { ...e.cellConfig };
770
+ w === l ? U.name = k : U.actionDescription = k, d(U);
771
+ }, "handleChange"), H = /* @__PURE__ */ a((w, O) => {
772
+ m(!1);
773
+ const k = { ...e.cellConfig, category: w, specificType: O };
774
+ k.muiIconName = zn[O], k.color = kn[w];
775
+ const U = Oe[w];
776
+ (!k.name || k.name.startsWith("[Card") || Object.values(Oe).some((J) => {
777
+ var Z;
778
+ return (Z = k.name) == null ? void 0 : Z.match(new RegExp(`^${J}\\d+$`));
779
+ })) && (k.name = U, l(U)), e.onDataEdit(k);
780
+ }, "handleTypeChange"), j = (F = e.todoItem) == null ? void 0 : F.status, E = { onMouseDown: /* @__PURE__ */ a((w) => w.stopPropagation(), "onMouseDown"), onTouchStart: /* @__PURE__ */ a((w) => w.stopPropagation(), "onTouchStart") }, S = e.renderDescription ?? ((w) => /* @__PURE__ */ t("span", { style: { whiteSpace: "pre-wrap" }, children: w }));
781
+ return /* @__PURE__ */ y(
782
+ W,
783
+ {
784
+ className: "llm-env-target llm-env-card llm-env-card-sketch",
785
+ "data-env-id": e.cellConfig.i,
786
+ "data-env-key": e.cellConfig.i,
787
+ "data-env-name": e.cellConfig.name ?? "",
788
+ "data-env-kind": "sketch-card",
789
+ sx: { height: "100%", position: "relative", overflow: "hidden" },
790
+ children: [
791
+ !(e.todoItem && e.turnOpen) && /* @__PURE__ */ t(
792
+ W,
793
+ {
794
+ "aria-hidden": !0,
795
+ sx: {
796
+ position: "absolute",
797
+ inset: 0,
798
+ display: "flex",
799
+ alignItems: "center",
800
+ justifyContent: "center",
801
+ pointerEvents: "none",
802
+ color: "text.primary",
803
+ opacity: 0.06,
804
+ zIndex: 0,
805
+ "& > svg": { width: "70%", height: "70%", maxWidth: "180px", maxHeight: "180px" }
806
+ },
807
+ children: /* @__PURE__ */ t(z, {})
808
+ }
809
+ ),
810
+ /* @__PURE__ */ t(W, { sx: { position: "absolute", top: "15px", right: "-5px", display: "flex", gap: 0, zIndex: 2 }, children: /* @__PURE__ */ t(ce, { ...E, children: /* @__PURE__ */ t(Pe, { size: "small", onClick: /* @__PURE__ */ a(() => {
811
+ var w;
812
+ return (w = e.onDelete) == null ? void 0 : w.call(e, e.cellConfig.i);
813
+ }, "onClick"), "aria-label": "Remover card", children: /* @__PURE__ */ t(nn, { fontSize: "small" }) }) }) }),
814
+ e.todoItem && e.turnOpen && /* @__PURE__ */ y(
815
+ W,
816
+ {
817
+ sx: /* @__PURE__ */ a((w) => ({
818
+ position: "absolute",
819
+ display: "flex",
820
+ alignItems: "center",
821
+ justifyContent: "center",
822
+ minHeight: "calc(100% + 11px)",
823
+ minWidth: "calc(100% + 10px)",
824
+ top: -6,
825
+ left: -7,
826
+ gap: 2,
827
+ py: 0.4,
828
+ borderRadius: "10px",
829
+ backgroundColor: Ce(w.palette.common.black, 0.4),
830
+ opacity: j == "completed" ? 0.6 : 1
831
+ }), "sx"),
832
+ children: [
833
+ /* @__PURE__ */ t(W, { sx: { mt: "1px", flexShrink: 0, color: j == "completed" ? "success.main" : j === "in_progress" ? "primary.main" : "text.disabled" }, children: j == "completed" ? /* @__PURE__ */ t(Ti, { sx: { fontSize: "0.95rem" } }) : j === "in_progress" ? /* @__PURE__ */ t(Di, { sx: { fontSize: "0.95rem" } }) : /* @__PURE__ */ t(ft, { size: 20, sx: { fontSize: "0.95rem" } }) }),
834
+ /* @__PURE__ */ y(W, { sx: { textAlign: "left" }, children: [
835
+ /* @__PURE__ */ t(ae, { variant: "caption", sx: { display: "block", fontSize: "0.78rem", lineHeight: 1.3, textDecoration: j === "completed" ? "line-through" : "none" }, children: e.todoItem.label }),
836
+ e.todoItem.detail && /* @__PURE__ */ t(ae, { variant: "caption", sx: { display: "block", fontSize: "0.7rem", color: "text.secondary", lineHeight: 1.3 }, children: e.todoItem.detail })
837
+ ] })
838
+ ]
839
+ }
840
+ ),
841
+ /* @__PURE__ */ t(We, { open: u, anchorEl: p.current, placement: "bottom-start", transition: !0, sx: { zIndex: 1300 }, children: /* @__PURE__ */ a(({ TransitionProps: w }) => /* @__PURE__ */ t(Ve, { ...w, children: /* @__PURE__ */ t(Re, { elevation: 8, sx: { maxHeight: 380, overflow: "auto", minWidth: 240 }, children: /* @__PURE__ */ t(je, { onClickAway: /* @__PURE__ */ a(() => m(!1), "onClickAway"), children: /* @__PURE__ */ t(gt, { dense: !0, children: Object.entries(ua).map(([O, k], U) => {
842
+ const J = n.category[O];
843
+ return /* @__PURE__ */ y(W, { children: [
844
+ U > 0 && /* @__PURE__ */ t(Ue, {}),
845
+ /* @__PURE__ */ y(ae, { variant: "overline", sx: { px: 2, pt: 1, display: "flex", alignItems: "center", gap: 0.5 }, children: [
846
+ /* @__PURE__ */ t(J, { fontSize: "inherit" }),
847
+ O
848
+ ] }),
849
+ k.map((Z) => {
850
+ const ie = n.specificType[Z.specificType];
851
+ return /* @__PURE__ */ y(Ee, { selected: Z.specificType === B, onClick: /* @__PURE__ */ a(() => H(Z.category, Z.specificType), "onClick"), children: [
852
+ /* @__PURE__ */ t(Ke, { children: /* @__PURE__ */ t(ie, { fontSize: "small" }) }),
853
+ /* @__PURE__ */ t(Ye, { children: Z.label })
854
+ ] }, Z.specificType);
855
+ })
856
+ ] }, O);
857
+ }) }) }) }) }), "children") }),
858
+ /* @__PURE__ */ t(W, { sx: { minHeight: "20%", textAlign: "left", position: "relative", zIndex: 1 }, children: /* @__PURE__ */ y(ce, { direction: "row", children: [
859
+ /* @__PURE__ */ t(
860
+ Pe,
861
+ {
862
+ ...E,
863
+ ref: p,
864
+ size: "small",
865
+ onClick: /* @__PURE__ */ a(() => m((w) => !w), "onClick"),
866
+ title: `Tipo: ${G} / ${B}`,
867
+ sx: { color: "primary.main", mr: 0 },
868
+ children: /* @__PURE__ */ t(z, { fontSize: "small" })
869
+ }
870
+ ),
871
+ !x && /* @__PURE__ */ t(
872
+ W,
873
+ {
874
+ ...E,
875
+ onClick: /* @__PURE__ */ a(() => {
876
+ b(!0), s(!1);
877
+ }, "onClick"),
878
+ sx: { color: "text.primary", minWidth: "50%", maxWidth: "80%", maxHeight: "30px", cursor: "pointer", display: "inline-flex", alignItems: "center", gap: 0.5, overflow: "clip", textWrap: "nowrap" },
879
+ children: i
880
+ }
881
+ ),
882
+ x && /* @__PURE__ */ t(
883
+ Fe,
884
+ {
885
+ size: "small",
886
+ ref: c,
887
+ ...E,
888
+ onChange: /* @__PURE__ */ a((w) => P(l, w), "onChange"),
889
+ onBlur: /* @__PURE__ */ a((w) => P(l, w), "onBlur"),
890
+ onKeyDown: R,
891
+ value: i,
892
+ sx: /* @__PURE__ */ a((w) => ({
893
+ fontSize: "0.75rem",
894
+ width: "82%",
895
+ "& .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline": { border: "0px" },
896
+ "& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline": { border: "0px", pl: 3, p: 0, backgroundColor: Ce(w.palette.text.primary, 0.08) }
897
+ }), "sx"),
898
+ slotProps: {
899
+ root: { style: { padding: "2px 0px 0px 0px", border: "0px" } },
900
+ input: { style: { padding: "2px 0px 0px 0px", border: "0px" } }
901
+ }
902
+ }
903
+ )
904
+ ] }) }),
905
+ /* @__PURE__ */ y(W, { ref: f, sx: { textAlign: "left", position: "relative", zIndex: 1, minHeight: "80%" }, ...E, children: [
906
+ !C && /* @__PURE__ */ t(
907
+ W,
908
+ {
909
+ ...E,
910
+ onClick: /* @__PURE__ */ a(() => {
911
+ s(!0), b(!1);
912
+ }, "onClick"),
913
+ sx: { fontSize: "0.85rem", cursor: "pointer", color: "text.primary", width: "100%", minHeight: "30%", pb: "20px" },
914
+ children: S(r)
915
+ }
916
+ ),
917
+ C && /* @__PURE__ */ t(
918
+ Fe,
919
+ {
920
+ slotProps: {
921
+ root: { style: { padding: "0px", border: "0px" } },
922
+ input: { style: { padding: "0px 0px 5px 0px", border: "0px", height: Math.max(0, _ - 2.5), alignContent: "start", flexWrap: "wrap", fontSize: "0.8rem" } }
923
+ },
924
+ multiline: !0,
925
+ ref: c,
926
+ sx: /* @__PURE__ */ a((w) => ({
927
+ minHeight: "100%",
928
+ alignContent: "start",
929
+ width: "92%",
930
+ "& .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline": { border: "0px" },
931
+ "& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline": { border: "0px", backgroundColor: Ce(w.palette.text.primary, 0.08) }
932
+ }), "sx"),
933
+ onChange: /* @__PURE__ */ a((w) => {
934
+ w.stopPropagation(), P(o, w);
935
+ }, "onChange"),
936
+ onBlur: /* @__PURE__ */ a((w) => P(o, w), "onBlur"),
937
+ onKeyDown: R,
938
+ value: r
939
+ }
940
+ )
941
+ ] })
942
+ ]
943
+ }
944
+ );
945
+ }, "CardSketch"), fa = Et, $t = /* @__PURE__ */ a(({ filter: e, onEdit: n, onDelete: i }) => {
946
+ const [l, r] = L(!1), [o, x] = L(e.name), b = te(null), g = Ae().filterType[e.filterType];
947
+ q(() => {
948
+ l && b.current && (b.current.focus(), b.current.select());
949
+ }, [l]), q(() => {
950
+ x(e.name);
951
+ }, [e.name]);
952
+ const d = /* @__PURE__ */ a(() => {
953
+ const s = o.trim();
954
+ s && s !== e.name ? n({ ...e, name: s }) : x(e.name), r(!1);
955
+ }, "commitName"), C = /* @__PURE__ */ a((s) => {
956
+ s.key === "Enter" && d(), s.key === "Escape" && (x(e.name), r(!1));
957
+ }, "handleKeyDown");
958
+ return /* @__PURE__ */ y(
959
+ W,
960
+ {
961
+ className: "llm-env-target llm-env-filter llm-env-filter-sketch",
962
+ "data-env-id": e.i,
963
+ "data-env-key": e.i,
964
+ "data-env-name": e.name,
965
+ "data-env-kind": "sketch-filter",
966
+ sx: /* @__PURE__ */ a((s) => ({
967
+ display: "inline-flex",
968
+ alignItems: "center",
969
+ gap: 0.5,
970
+ flexWrap: "wrap",
971
+ border: `1px dashed ${s.palette.divider}`,
972
+ borderRadius: "10px",
973
+ maxHeight: "90%",
974
+ px: 1,
975
+ py: 0.5,
976
+ backgroundColor: s.palette.background.default,
977
+ maxWidth: 260
978
+ }), "sx"),
979
+ children: [
980
+ /* @__PURE__ */ t(g, { sx: { fontSize: 16, color: "primary.main", flexShrink: 0 } }),
981
+ l ? /* @__PURE__ */ t(
982
+ Fe,
983
+ {
984
+ inputRef: b,
985
+ value: o,
986
+ onChange: /* @__PURE__ */ a((s) => x(s.target.value), "onChange"),
987
+ onBlur: d,
988
+ onKeyDown: C,
989
+ variant: "standard",
990
+ size: "small",
991
+ slotProps: {
992
+ input: { disableUnderline: !0, sx: { fontSize: "0.75rem", pl: 1, height: 20 } },
993
+ root: { style: { width: "80%" } }
994
+ }
995
+ }
996
+ ) : /* @__PURE__ */ t(
997
+ ae,
998
+ {
999
+ variant: "caption",
1000
+ noWrap: !0,
1001
+ onClick: /* @__PURE__ */ a(() => r(!0), "onClick"),
1002
+ sx: {
1003
+ cursor: "pointer",
1004
+ fontSize: "0.75rem",
1005
+ color: "text.primary",
1006
+ pl: 1,
1007
+ width: "80%",
1008
+ minWidth: "90px",
1009
+ "&:hover": { textDecoration: "underline" }
1010
+ },
1011
+ children: e.name
1012
+ }
1013
+ ),
1014
+ e.filterType !== "AutoComplete" && /* @__PURE__ */ t(ke, { title: e.mandatory ? "Mandatory filter" : "Optional filter", arrow: !0, children: /* @__PURE__ */ y(W, { sx: { display: "inline-flex", alignItems: "center", gap: 0 }, children: [
1015
+ /* @__PURE__ */ t(ae, { variant: "caption", sx: { fontSize: "0.6rem", color: "text.secondary", minWidth: "55px", whiteSpace: "nowrap" }, children: e.mandatory ? "Obrigatório" : "Opcional" }),
1016
+ /* @__PURE__ */ t(
1017
+ xt,
1018
+ {
1019
+ size: "small",
1020
+ checked: e.mandatory,
1021
+ onChange: /* @__PURE__ */ a((s, u) => n({ ...e, mandatory: u }), "onChange"),
1022
+ sx: { transform: "scale(0.7)", ml: -0.5, mr: -1 }
1023
+ }
1024
+ )
1025
+ ] }) }),
1026
+ e.filterType === "AutoComplete" && /* @__PURE__ */ t(ke, { title: e.multipleSelection ? "Multiple selection" : "Single selection", arrow: !0, children: /* @__PURE__ */ y(W, { sx: { display: "inline-flex", alignItems: "center", gap: 0 }, children: [
1027
+ /* @__PURE__ */ t(ae, { variant: "caption", sx: { fontSize: "0.6rem", color: "text.secondary", whiteSpace: "wrap", minWidth: "43px" }, children: e.multipleSelection ? "Multiple" : "Single" }),
1028
+ /* @__PURE__ */ t(
1029
+ xt,
1030
+ {
1031
+ size: "small",
1032
+ checked: e.multipleSelection ?? !1,
1033
+ onChange: /* @__PURE__ */ a((s, u) => n({ ...e, multipleSelection: u }), "onChange"),
1034
+ sx: { transform: "scale(0.7)", ml: -0.5, mr: -1 }
1035
+ }
1036
+ )
1037
+ ] }) }),
1038
+ /* @__PURE__ */ t(Pe, { size: "small", onClick: /* @__PURE__ */ a(() => i(e.i), "onClick"), sx: { p: 0.2, ml: "auto" }, "aria-label": "Remover filtro", children: /* @__PURE__ */ t(nn, { sx: { fontSize: 14 } }) })
1039
+ ]
1040
+ }
1041
+ );
1042
+ }, "FilterSketch"), Ge = /* @__PURE__ */ a((e) => {
1043
+ const [n, i] = L(!1), [l, r] = L(e.text), o = te(null), x = e.fontSize ?? 12;
1044
+ q(() => {
1045
+ n && o.current && (o.current.focus(), o.current.select()), r(e.text);
1046
+ }, [n, e.text]);
1047
+ const b = /* @__PURE__ */ a(() => {
1048
+ const d = (l == null ? void 0 : l.trim()) ?? "";
1049
+ d !== e.text && e.onEdit(d), r(d), i(!1);
1050
+ }, "commit");
1051
+ return /* @__PURE__ */ t(
1052
+ W,
1053
+ {
1054
+ sx: /* @__PURE__ */ a((d) => ({
1055
+ display: "inline-flex",
1056
+ alignItems: "center",
1057
+ gap: 0.5,
1058
+ px: 1,
1059
+ py: 0.5,
1060
+ mb: 0.5,
1061
+ backgroundColor: d.palette.background.paper,
1062
+ width: "100%"
1063
+ }), "sx"),
1064
+ children: n ? /* @__PURE__ */ t(
1065
+ Fe,
1066
+ {
1067
+ inputRef: o,
1068
+ value: l,
1069
+ onChange: /* @__PURE__ */ a((d) => r(d.target.value), "onChange"),
1070
+ onBlur: b,
1071
+ onKeyDown: /* @__PURE__ */ a((d) => {
1072
+ d.key === "Enter" && !(e.multiline && d.shiftKey) && b(), d.key === "Escape" && (r(e.text), i(!1));
1073
+ }, "handleKeyDown"),
1074
+ multiline: e.multiline,
1075
+ variant: "standard",
1076
+ size: "small",
1077
+ sx: { width: "100%", overflow: "hidden" },
1078
+ slotProps: {
1079
+ input: {
1080
+ disableUnderline: !0,
1081
+ sx: /* @__PURE__ */ a((d) => ({ minWidth: "100px", color: d.palette.text.primary, fontSize: x, margin: 0, padding: 0, pl: 1 }), "sx")
1082
+ },
1083
+ root: {
1084
+ sx: {
1085
+ overflow: "hidden",
1086
+ alignContent: "center",
1087
+ padding: "0px",
1088
+ width: e.multiline ? "90%" : "unset",
1089
+ margin: 0,
1090
+ height: e.multiline ? "35px" : "unset"
1091
+ }
1092
+ }
1093
+ }
1094
+ }
1095
+ ) : /* @__PURE__ */ t(
1096
+ W,
1097
+ {
1098
+ onClick: /* @__PURE__ */ a(() => i(!0), "onClick"),
1099
+ sx: /* @__PURE__ */ a((d) => ({
1100
+ cursor: "pointer",
1101
+ fontFamily: d.typography.fontFamily,
1102
+ fontSize: x,
1103
+ color: d.palette.text.primary,
1104
+ pl: 1,
1105
+ minWidth: "100px",
1106
+ height: "100%",
1107
+ minHeight: "20px",
1108
+ overflow: "clip",
1109
+ whiteSpace: e.multiline ? "pre-wrap" : "nowrap",
1110
+ "&:hover": { textDecoration: "underline" }
1111
+ }), "sx"),
1112
+ children: !l || l.length == 0 ? e.placeHolderText : l
1113
+ }
1114
+ )
1115
+ }
1116
+ );
1117
+ }, "TitleSketch"), ga = Ge, xa = Ge, ya = { Large: 4, Desktop: 4, Tablet: 4, Mobile: 4 }, ba = { Large: 12, Desktop: 12, Tablet: 12, Mobile: 12 }, ct = 6;
1118
+ function Sa(e, n, i = 0) {
1119
+ const [l, r] = L(i);
1120
+ return q(() => {
1121
+ const o = e.current;
1122
+ if (!o || (r(o.getBoundingClientRect().width), typeof ResizeObserver > "u")) return;
1123
+ const x = new ResizeObserver((b) => {
1124
+ const g = b[0];
1125
+ g && r(g.contentRect.width);
1126
+ });
1127
+ return x.observe(o), () => x.disconnect();
1128
+ }, [e, n]), l;
1129
+ }
1130
+ a(Sa, "useContainerWidth");
1131
+ const va = /* @__PURE__ */ a((e) => {
1132
+ const n = Math.round(Date.now() * Math.pow(10, -6));
1133
+ return `${$e(e)}_${n}`;
1134
+ }, "makeNameUnique"), ot = Ct((e, n) => {
1135
+ const i = me(), l = N((h) => {
1136
+ var I;
1137
+ return (I = h.dashboardDefinition) == null ? void 0 : I.cards;
1138
+ }) ?? Ca, r = N((h) => {
1139
+ var I;
1140
+ return (I = h.dashboardDefinition) == null ? void 0 : I.filters;
1141
+ }) ?? wa, o = N((h) => {
1142
+ var I;
1143
+ return ((I = h.dashboardDefinition) == null ? void 0 : I.name) ?? "";
1144
+ }), x = N((h) => {
1145
+ var I;
1146
+ return ((I = h.dashboardDefinition) == null ? void 0 : I.layoutType) ?? "Boxed";
1147
+ }), b = N((h) => {
1148
+ var I;
1149
+ return (I = h.dashboardDefinition) == null ? void 0 : I.id;
1150
+ }), g = N((h) => h.turnOpen), d = N((h) => h.todosByCardKey), [C, s] = L([]), u = te(null), m = Sa(u, e.renderId), [c, p] = L(null), [f, _] = L(0), B = te({}), G = te(0), z = te(void 0), R = he(), P = e.zoomLevel ?? 0.8, H = Y((h, I) => {
1151
+ I && (i.getState().recordSketchChange("dashboard:layoutType", `Set layout type to ${I}`), i.getState().updateDashboard({ layoutType: I }));
1152
+ }, [i]);
1153
+ q(() => {
1154
+ if (b === z.current || (z.current = b, !b)) return;
1155
+ const h = i.getState().dashboardDefinition, I = (h == null ? void 0 : h.cards) ?? [];
1156
+ B.current = {}, I.forEach((A) => {
1157
+ const M = Oe[A.category ?? "Generic"];
1158
+ B.current[M] = (B.current[M] ?? 0) + 1;
1159
+ }), G.current = ((h == null ? void 0 : h.filters) ?? []).length, s(I);
1160
+ }, [b, i]);
1161
+ const j = Y((h) => {
1162
+ const I = Oe[h], A = (B.current[I] ?? 0) + 1;
1163
+ return B.current[I] = A, va(`${I}${A}`);
1164
+ }, []), E = Y((h, I) => {
1165
+ s(h);
1166
+ }, []), S = Y((h, I, A) => {
1167
+ var pe;
1168
+ if (!I || !A) return;
1169
+ const M = ((pe = i.getState().dashboardDefinition) == null ? void 0 : pe.cards) ?? [];
1170
+ let X = !1;
1171
+ const ne = M.map((xe) => {
1172
+ const ye = h.find((ti) => ti.i === xe.i);
1173
+ return ye && (xe.w !== ye.w || xe.h !== ye.h || xe.x !== ye.x || xe.y !== ye.y) ? (X = !0, { ...xe, w: ye.w, h: ye.h, x: ye.x, y: ye.y }) : xe;
1174
+ });
1175
+ if (!X) return;
1176
+ const D = M.find((xe) => xe.i === A.i), $ = (D == null ? void 0 : D.name) ?? A.i, oe = I.w !== A.w || I.h !== A.h, fe = I.x !== A.x || I.y !== A.y, be = `card:${A.i}:layout`;
1177
+ oe && fe ? i.getState().recordSketchChange(be, `Resized and moved card '${$}' to (w:${A.w}, h:${A.h}, x:${A.x}, y:${A.y})`) : oe ? i.getState().recordSketchChange(be, `Resized card '${$}' to (w:${A.w}, h:${A.h})`) : fe && i.getState().recordSketchChange(be, `Moved card '${$}' to (x:${A.x}, y:${A.y})`), i.getState().updateDashboard({ cards: ne });
1178
+ }, [i]), F = Y((h) => {
1179
+ var M;
1180
+ const I = ((M = i.getState().dashboardDefinition) == null ? void 0 : M.cards) ?? [], A = I.find((X) => X.i === h);
1181
+ i.getState().recordSketchChange(`card:${h}:delete`, `Deleted card '${(A == null ? void 0 : A.name) ?? h}'`), i.getState().updateDashboard({ cards: I.filter((X) => X.i !== h) });
1182
+ }, [i]), w = Y((h = "Generic", I = "Generic") => {
1183
+ const A = j(h);
1184
+ return {
1185
+ i: $e(A),
1186
+ h: ct,
1187
+ w: f,
1188
+ y: 1 / 0,
1189
+ x: 0,
1190
+ isDraggable: void 0,
1191
+ isResizable: !0,
1192
+ category: h,
1193
+ specificType: I,
1194
+ name: A
1195
+ };
1196
+ }, [f, j]), O = Y((h) => {
1197
+ const I = h.length === 0 ? "Untitled Dashboard" : h;
1198
+ i.getState().recordSketchChange("dashboard:name", `Renamed dashboard to '${I}'`), i.getState().updateDashboard({ name: I });
1199
+ }, [i]), k = Y((h) => {
1200
+ var D;
1201
+ const I = ((D = i.getState().dashboardDefinition) == null ? void 0 : D.cards) ?? [], A = C.find(($) => $.i === h.i), M = I.find(($) => $.i === h.i), X = I.map(($) => $.i !== h.i ? $ : {
1202
+ ...$,
1203
+ ...A ? { w: A.w, h: A.h, x: A.x, y: A.y } : {},
1204
+ name: h.name,
1205
+ actionDescription: h.actionDescription,
1206
+ category: h.category,
1207
+ specificType: h.specificType,
1208
+ muiIconName: h.muiIconName
1209
+ }), ne = [];
1210
+ M && (M.name !== h.name && ne.push(`name → '${h.name}'`), M.actionDescription !== h.actionDescription && ne.push("description"), M.category !== h.category && ne.push(`category → '${h.category}'`), M.specificType !== h.specificType && ne.push(`type → '${h.specificType}'`), M.muiIconName !== h.muiIconName && ne.push("icon")), ne.length > 0 && i.getState().recordSketchChange(`card:${h.i}:edit`, `Edited card '${(M == null ? void 0 : M.name) ?? h.name}' (${ne.join(", ")})`), i.getState().updateDashboard({ cards: X });
1211
+ }, [C, i]), U = Y(() => {
1212
+ const h = c ? ba[c] : 10, I = C.length > 0 ? C[C.length - 1] : null;
1213
+ let A = 0, M = 0;
1214
+ return I && (M = I.y, I.x + I.w > h - f ? (M += 1, A = 0) : A = I.x + I.w), { x: A, y: M };
1215
+ }, [c, C, f]), J = Y((h, I) => {
1216
+ var M;
1217
+ const A = ((M = i.getState().dashboardDefinition) == null ? void 0 : M.cards) ?? [];
1218
+ i.getState().recordSketchChange(`card:${h.i}:add`, I), i.getState().updateDashboard({ cards: [...A, h] });
1219
+ }, [i]), Z = Y((h, I) => {
1220
+ const A = (h == null ? void 0 : h.category) ?? "Generic", M = (h == null ? void 0 : h.specificType) ?? "Generic", X = w(A, M);
1221
+ X.actionDescription = h == null ? void 0 : h.description, I && (X.h = ct, X.w = f, X.y = I.y, X.x = I.x), J(X, `Added card '${X.name}' (category: ${A}, type: ${M})`);
1222
+ }, [w, f, J]), ie = Y(() => {
1223
+ if (f === 0) return;
1224
+ const h = w("Generic", "Generic"), I = U();
1225
+ h.x = I.x, h.y = I.y, J(h, `Added card '${h.name}'`);
1226
+ }, [f, w, U, J]), de = Y((h, I, A) => {
1227
+ const M = w(h, I), X = U();
1228
+ M.x = X.x, M.y = X.y, M.w = f, M.h = ct, J(M, `Added card '${M.name}' (category: ${h}, type: ${I})`);
1229
+ }, [f, w, U, J]);
1230
+ q(() => {
1231
+ if (m == 0) return;
1232
+ let h = "Desktop";
1233
+ m >= 920 && (h = "Large"), m < 920 && (h = "Desktop"), m < 750 && (h = "Tablet"), m < 600 && (h = "Mobile"), p(h), _(ya[h]);
1234
+ }, [m]);
1235
+ const V = Y((h) => {
1236
+ var D;
1237
+ G.current += 1;
1238
+ const I = `Filter${G.current}`;
1239
+ let A = !1;
1240
+ h == "DateRangePicker" && (A = !0);
1241
+ const M = Ie(), X = { i: M, name: I, filterType: h, mandatory: A, multipleSelection: !0 }, ne = ((D = i.getState().dashboardDefinition) == null ? void 0 : D.filters) ?? [];
1242
+ i.getState().recordSketchChange(`filter:${M}:add`, `Added filter '${X.name}' (type: ${h})`), i.getState().updateDashboard({ filters: [...ne, X] });
1243
+ }, [i]), Q = Y((h) => {
1244
+ var A;
1245
+ const I = ((A = i.getState().dashboardDefinition) == null ? void 0 : A.filters) ?? [];
1246
+ i.getState().recordSketchChange(
1247
+ `filter:${h.i}:edit`,
1248
+ `Edited filter '${h.name}' - ${h.mandatory ? "Mandatório" : "Opcional"} - ${h.multipleSelection ? "MultipleSelection" : "SingleValue"}`
1249
+ ), i.getState().updateDashboard({ filters: I.map((M) => M.i === h.i ? { ...h } : M) });
1250
+ }, [i]), T = Y((h) => {
1251
+ var M;
1252
+ const I = ((M = i.getState().dashboardDefinition) == null ? void 0 : M.filters) ?? [], A = I.find((X) => X.i === h);
1253
+ i.getState().recordSketchChange(`filter:${h}:delete`, `Deleted filter '${(A == null ? void 0 : A.name) ?? h}'`), i.getState().updateDashboard({ filters: I.filter((X) => X.i !== h) });
1254
+ }, [i]);
1255
+ Jt(n, () => ({ addGenericCell: ie, addTypedCell: de, handleAddFilter: V }), [ie, de, V]);
1256
+ const K = /* @__PURE__ */ a((h) => ({ border: h ? "0px" : `1px solid ${R.palette.divider}`, px: 1, py: 0, gap: 0.5, textTransform: "none" }), "toggleSx"), re = /* @__PURE__ */ a((h) => ({
1257
+ fontSize: "0.75rem",
1258
+ lineHeight: 1,
1259
+ maxWidth: h ? 60 : 0,
1260
+ overflow: "hidden",
1261
+ opacity: h ? 1 : 0,
1262
+ whiteSpace: "nowrap",
1263
+ transition: "max-width 0.25s ease, opacity 0.2s ease"
1264
+ }), "toggleLabelSx");
1265
+ return /* @__PURE__ */ y(ce, { ref: u, className: "bi-dashboard-pad-sketch", sx: { height: "100%", overflow: "hidden" }, children: [
1266
+ !e.hideInternalHeader && /* @__PURE__ */ y(W, { sx: { display: "inline-flex", alignItems: "center", flexWrap: "nowrap", gap: 1, pt: 0.5, pb: 0, pr: 1, pl: 1, borderBottom: `1px solid ${R.palette.divider}` }, children: [
1267
+ /* @__PURE__ */ t(W, { sx: { display: "inline-flex", width: "75%" }, children: /* @__PURE__ */ t(W, { sx: { width: "75%" }, children: /* @__PURE__ */ t(Ge, { placeHolderText: "Untitled Dashboard", onEdit: O, text: o, fontSize: 14.4 }) }) }),
1268
+ /* @__PURE__ */ y(W, { sx: { position: "relative", display: "inline-flex", width: "25%", gap: 1, top: -2, justifyContent: "center", alignItems: "center" }, children: [
1269
+ /* @__PURE__ */ t(ae, { component: "span", sx: { color: "text.secondary" }, children: "Layout:" }),
1270
+ /* @__PURE__ */ y(
1271
+ on,
1272
+ {
1273
+ value: x,
1274
+ exclusive: !0,
1275
+ onChange: H,
1276
+ size: "small",
1277
+ className: "llm-env-target llm-env-layout-toggle",
1278
+ "data-env-id": "dashboard-pad-layout-toggle",
1279
+ sx: { height: 24, border: "0px", "& .Mui-selected": { border: `1px solid ${R.palette.divider}` } },
1280
+ children: [
1281
+ /* @__PURE__ */ y(qe, { value: "Boxed", "data-env-id": "dashboard-pad-layout-boxed", sx: K(x === "Boxed"), children: [
1282
+ /* @__PURE__ */ t(ki, { sx: { fontSize: 18 } }),
1283
+ /* @__PURE__ */ t(ae, { component: "span", sx: re(x === "Boxed"), children: "Boxed" })
1284
+ ] }),
1285
+ /* @__PURE__ */ y(qe, { value: "Naked", "data-env-id": "dashboard-pad-layout-naked", sx: K(x === "Naked"), children: [
1286
+ /* @__PURE__ */ t(Ii, { sx: { fontSize: 18 } }),
1287
+ /* @__PURE__ */ t(ae, { component: "span", sx: re(x === "Naked"), children: "Naked" })
1288
+ ] })
1289
+ ]
1290
+ }
1291
+ ),
1292
+ e.headerExtra
1293
+ ] })
1294
+ ] }),
1295
+ r.length > 0 && !e.hideFiltersInSketch && /* @__PURE__ */ t(W, { sx: { display: "inline-flex", justifyContent: "flex-end", flexWrap: "wrap", gap: 1, pt: 0.5, pb: 0, pr: 1, pl: 1, borderBottom: `1px solid ${R.palette.divider}` }, children: r.map((h) => /* @__PURE__ */ t($t, { filter: h, onEdit: Q, onDelete: T }, h.i)) }),
1296
+ /* @__PURE__ */ y("div", { style: { maxHeight: "100%", height: "100%", overflow: "auto" }, children: [
1297
+ m !== 0 && l.length > 0 && /* @__PURE__ */ t("div", { style: { display: "inline-flex", flex: 1, alignItems: "center", justifyContent: "center", paddingBottom: e.hideInternalHeader ? "50px" : "80px", overflow: "auto", width: "100%" }, children: /* @__PURE__ */ t(
1298
+ Hi,
1299
+ {
1300
+ rowAwareResize: { defaultOn: !0 },
1301
+ onLayoutChange: E,
1302
+ onResizeStop: S,
1303
+ onDragStop: S,
1304
+ onDrop: Z,
1305
+ config: {},
1306
+ cols: { lg: 10, md: 8, sm: 4, xs: 4, xxs: 4 },
1307
+ breakpoints: { lg: 920, md: 600, sm: 400, xs: 400, xxs: 0 },
1308
+ rowHeight: 10,
1309
+ dragLocked: !1,
1310
+ zoomLevel: P,
1311
+ responsive: !1,
1312
+ maxRows: 200,
1313
+ rowMultiplier: 1,
1314
+ manualWidth: m,
1315
+ layouts: l,
1316
+ children: l.map((h) => {
1317
+ var I;
1318
+ return /* @__PURE__ */ t(
1319
+ Wi,
1320
+ {
1321
+ className: "llm-env-target llm-env-card llm-env-card-sketch-wrapper",
1322
+ "data-env-id": h.i,
1323
+ naked: x == "Naked",
1324
+ "data-env-key": h.i,
1325
+ "data-env-name": h.name ?? "",
1326
+ "data-env-kind": "sketch-card-wrapper",
1327
+ children: /* @__PURE__ */ t(
1328
+ Et,
1329
+ {
1330
+ turnOpen: g ?? !1,
1331
+ todoItem: (I = d[h.i]) == null ? void 0 : I.todo,
1332
+ cellConfig: h,
1333
+ onDataEdit: k,
1334
+ onDelete: F,
1335
+ renderDescription: e.renderDescription
1336
+ }
1337
+ )
1338
+ },
1339
+ h.i
1340
+ );
1341
+ })
1342
+ },
1343
+ b
1344
+ ) }),
1345
+ m !== 0 && l.length == 0 && /* @__PURE__ */ t(
1346
+ W,
1347
+ {
1348
+ sx: /* @__PURE__ */ a((h) => ({
1349
+ background: "transparent",
1350
+ border: "none",
1351
+ textAlign: "left",
1352
+ padding: "6px 0",
1353
+ height: "100%",
1354
+ color: h.palette.text.secondary,
1355
+ fontFamily: h.typography.fontFamily,
1356
+ display: "inline-flex",
1357
+ width: "100%",
1358
+ justifyContent: "center",
1359
+ alignItems: "center",
1360
+ "&:hover": { color: h.palette.text.primary }
1361
+ }), "sx"),
1362
+ children: /* @__PURE__ */ y(ce, { direction: "row", gap: 1, sx: { "&:hover": { cursor: "pointer" } }, onClick: /* @__PURE__ */ a(() => {
1363
+ var h;
1364
+ return (h = e.onAddCard) == null ? void 0 : h.call(e);
1365
+ }, "onClick"), children: [
1366
+ /* @__PURE__ */ t(W, { component: "span", sx: /* @__PURE__ */ a((h) => ({ color: h.palette.text.disabled }), "sx"), children: "↗" }),
1367
+ /* @__PURE__ */ t(ae, { sx: /* @__PURE__ */ a((h) => ({ fontSize: 20, fontWeight: 600, color: h.palette.text.primary, margin: 0, lineHeight: 1.2, letterSpacing: -0.4 }), "sx"), children: "Clique aqui para adicionar um novo card" })
1368
+ ] })
1369
+ }
1370
+ )
1371
+ ] })
1372
+ ] });
1373
+ });
1374
+ ot.displayName = "DashboardPadSketch";
1375
+ const Ca = [], wa = [], Te = /* @__PURE__ */ a((e) => {
1376
+ const n = he(), i = e.maxWidth ?? 30;
1377
+ return /* @__PURE__ */ t(
1378
+ W,
1379
+ {
1380
+ sx: {
1381
+ "& .action-btn": {
1382
+ display: "inline-flex",
1383
+ alignItems: "center",
1384
+ height: 28,
1385
+ borderRadius: 1,
1386
+ px: 0.75,
1387
+ cursor: "pointer",
1388
+ overflow: "hidden",
1389
+ transition: "background-color 0.2s",
1390
+ "&:hover": { borderRadius: 1, px: 1.5, backgroundColor: n.palette.action.hover },
1391
+ "&:hover .action-label": { maxWidth: i, opacity: 1, ml: 0.5 }
1392
+ },
1393
+ "& .action-btn-fixed": {
1394
+ display: "inline-flex",
1395
+ alignItems: "center",
1396
+ height: 28,
1397
+ borderRadius: 1,
1398
+ px: 0.75,
1399
+ cursor: "pointer",
1400
+ "&:hover": { bgcolor: n.palette.success.light }
1401
+ },
1402
+ "& .action-label": {
1403
+ maxWidth: 0,
1404
+ overflow: "hidden",
1405
+ whiteSpace: "nowrap",
1406
+ opacity: 0,
1407
+ ml: 0,
1408
+ transition: "max-width 0.3s ease, opacity 0.15s ease 0.1s, margin 0.3s ease",
1409
+ fontSize: "0.7rem",
1410
+ lineHeight: 1
1411
+ },
1412
+ "& .action-label-fixed": {
1413
+ overflow: "hidden",
1414
+ whiteSpace: "nowrap",
1415
+ ml: 0,
1416
+ fontSize: "0.7rem",
1417
+ lineHeight: 1,
1418
+ marginRight: 1
1419
+ }
1420
+ },
1421
+ children: /* @__PURE__ */ y(W, { className: e.fixed ? "action-btn-fixed" : "action-btn", onClick: /* @__PURE__ */ a((l) => {
1422
+ var r;
1423
+ return (r = e.onClick) == null ? void 0 : r.call(e, l);
1424
+ }, "onClick"), sx: { color: "text.secondary" }, children: [
1425
+ typeof e.icon == "function" ? e.icon() : e.icon,
1426
+ /* @__PURE__ */ t(ae, { className: e.fixed ? "action-label-fixed" : "action-label", component: "span", children: e.label })
1427
+ ] })
1428
+ }
1429
+ );
1430
+ }, "HoverButton"), Ta = it(ve);
1431
+ function Da(e, n, i) {
1432
+ const l = document.createElement("div");
1433
+ return l.style.cssText = [
1434
+ "display:flex",
1435
+ "align-items:center",
1436
+ "gap:6px",
1437
+ "padding:6px 12px",
1438
+ `border:2px dashed ${e.palette.secondary.main}`,
1439
+ "border-radius:6px",
1440
+ `background-color:${e.palette.background.paper}`,
1441
+ `color:${e.palette.secondary.main}`,
1442
+ `font-family:${e.typography.fontFamily ?? "inherit"}`,
1443
+ "font-size:13px",
1444
+ "font-weight:500",
1445
+ "white-space:nowrap",
1446
+ "position:fixed",
1447
+ "top:-200px",
1448
+ "left:-200px",
1449
+ "z-index:99999",
1450
+ "pointer-events:none"
1451
+ ].join(";"), l.innerHTML = `${n}<span>${i}</span>`, document.body.appendChild(l), l;
1452
+ }
1453
+ a(Da, "createDragPreview");
1454
+ const En = /* @__PURE__ */ a(({ onAddGeneric: e, onAddTyped: n, onAddFilter: i }) => {
1455
+ const l = he(), r = Ae(), [o, x] = L(!1), [b, g] = L(!1), d = te(null), C = te(null), s = te(null);
1456
+ q(() => () => {
1457
+ var p;
1458
+ return (p = s.current) == null ? void 0 : p.remove();
1459
+ }, []);
1460
+ const u = Y(() => {
1461
+ var p;
1462
+ (p = s.current) == null || p.remove(), s.current = null;
1463
+ }, []), m = /* @__PURE__ */ a((p, f) => {
1464
+ const _ = f ? { category: f.category, specificType: f.specificType, label: f.label } : { category: "Generic", specificType: "Generic", label: "Generic" };
1465
+ p.dataTransfer.setData("text/json", JSON.stringify(_)), p.dataTransfer.effectAllowed = "copy", u();
1466
+ const B = p.currentTarget.querySelector("svg"), G = B ? B.outerHTML.replace(/width="[^"]*"/, 'width="18"').replace(/height="[^"]*"/, 'height="18"') : "", z = Da(l, G, (f == null ? void 0 : f.label) ?? "Generic");
1467
+ s.current = z, p.dataTransfer.setDragImage(z, 0, 0);
1468
+ }, "handleDragStart"), c = /* @__PURE__ */ a((p) => {
1469
+ n(p.category, p.specificType, p.label), x(!1);
1470
+ }, "handleMenuItemClick");
1471
+ return /* @__PURE__ */ y(W, { sx: { display: "inline-flex", gap: 0.5, alignItems: "center" }, children: [
1472
+ /* @__PURE__ */ t(ke, { title: "Drag to add card", children: /* @__PURE__ */ t(
1473
+ W,
1474
+ {
1475
+ className: "action-btn llm-env-target llm-env-dashboard-action",
1476
+ "data-env-id": "dashboardpad-drag-to-add-card",
1477
+ draggable: !0,
1478
+ onDragStart: /* @__PURE__ */ a((p) => m(p), "onDragStart"),
1479
+ onDragEnd: u,
1480
+ sx: {
1481
+ display: "flex",
1482
+ alignItems: "center",
1483
+ justifyContent: "center",
1484
+ width: 28,
1485
+ height: 28,
1486
+ border: "1.5px dashed",
1487
+ borderColor: "secondary.main",
1488
+ borderRadius: 0.5,
1489
+ cursor: "grab",
1490
+ "&:hover": { bgcolor: "action.hover" },
1491
+ "&:active": { cursor: "grabbing" }
1492
+ },
1493
+ children: /* @__PURE__ */ t(zi, { sx: { fontSize: 16 }, color: "secondary" })
1494
+ }
1495
+ ) }),
1496
+ /* @__PURE__ */ y(W, { sx: { position: "relative", display: "inline-flex", alignItems: "center" }, children: [
1497
+ /* @__PURE__ */ t(ke, { title: "Add card", children: /* @__PURE__ */ t(
1498
+ _t,
1499
+ {
1500
+ className: "action-btn llm-env-target llm-env-dashboard-action",
1501
+ "data-env-id": "dashboardpad-add-card",
1502
+ variant: "outlined",
1503
+ size: "small",
1504
+ color: "secondary",
1505
+ startIcon: /* @__PURE__ */ t(Oi, { sx: { m: 0.2, p: 0 } }),
1506
+ onClick: e,
1507
+ sx: { height: 28, fontSize: "0.7rem", pr: 1, gap: 0, minWidth: "80px", textTransform: "none", justifyContent: "left" },
1508
+ children: "Card"
1509
+ }
1510
+ ) }),
1511
+ /* @__PURE__ */ t(
1512
+ Pe,
1513
+ {
1514
+ className: "action-btn llm-env-target llm-env-dashboard-action",
1515
+ "data-env-id": "dashboardpad-add-card-dropdown",
1516
+ ref: d,
1517
+ size: "small",
1518
+ onClick: /* @__PURE__ */ a(() => x((p) => !p), "onClick"),
1519
+ sx: { position: "absolute", right: 0, height: 28, width: 20 },
1520
+ "aria-label": "Tipos de card",
1521
+ children: /* @__PURE__ */ t(mt, { color: "secondary", sx: { fontSize: 18, mr: 0.5 } })
1522
+ }
1523
+ )
1524
+ ] }),
1525
+ /* @__PURE__ */ t(We, { open: o, anchorEl: d.current, placement: "bottom-start", transition: !0, sx: { zIndex: 1300 }, children: /* @__PURE__ */ a(({ TransitionProps: p }) => /* @__PURE__ */ t(Ve, { ...p, children: /* @__PURE__ */ t(Re, { elevation: 8, sx: { maxHeight: 420, overflow: "auto", minWidth: 260 }, children: /* @__PURE__ */ t(je, { onClickAway: /* @__PURE__ */ a(() => x(!1), "onClickAway"), children: /* @__PURE__ */ t(gt, { dense: !0, children: Object.entries(Ta).map(([f, _], B) => {
1526
+ const G = r.category[f];
1527
+ return /* @__PURE__ */ y(W, { children: [
1528
+ B > 0 && /* @__PURE__ */ t(Ue, {}),
1529
+ /* @__PURE__ */ y(W, { component: "span", sx: { px: 2, pt: 1, display: "flex", alignItems: "center", gap: 0.5, typography: "overline" }, children: [
1530
+ /* @__PURE__ */ t(G, { fontSize: "inherit" }),
1531
+ f
1532
+ ] }),
1533
+ _.map((z) => {
1534
+ const R = r.specificType[z.specificType];
1535
+ return /* @__PURE__ */ y(Ee, { onClick: /* @__PURE__ */ a(() => c(z), "onClick"), draggable: !0, onDragStart: /* @__PURE__ */ a((P) => m(P, z), "onDragStart"), onDragEnd: u, children: [
1536
+ /* @__PURE__ */ t(Ke, { children: /* @__PURE__ */ t(R, { fontSize: "small" }) }),
1537
+ /* @__PURE__ */ t(Ye, { children: z.label })
1538
+ ] }, z.specificType);
1539
+ })
1540
+ ] }, f);
1541
+ }) }) }) }) }), "children") }),
1542
+ i && /* @__PURE__ */ y(we, { children: [
1543
+ /* @__PURE__ */ t(ke, { title: "Add filter", children: /* @__PURE__ */ t(
1544
+ _t,
1545
+ {
1546
+ className: "action-btn llm-env-target llm-env-dashboard-action",
1547
+ "data-env-id": "dashboardpad-add-filter",
1548
+ ref: C,
1549
+ variant: "outlined",
1550
+ size: "small",
1551
+ color: "secondary",
1552
+ startIcon: /* @__PURE__ */ t(Pi, {}),
1553
+ endIcon: /* @__PURE__ */ t(mt, {}),
1554
+ onClick: /* @__PURE__ */ a(() => g((p) => !p), "onClick"),
1555
+ sx: { height: 28, fontSize: "0.7rem", minWidth: 0, textTransform: "none" },
1556
+ children: "Filtro"
1557
+ }
1558
+ ) }),
1559
+ /* @__PURE__ */ t(We, { open: b, anchorEl: C.current, placement: "bottom-start", transition: !0, sx: { zIndex: 1300 }, children: /* @__PURE__ */ a(({ TransitionProps: p }) => /* @__PURE__ */ t(Ve, { ...p, children: /* @__PURE__ */ t(Re, { elevation: 8, sx: { minWidth: 220 }, children: /* @__PURE__ */ t(je, { onClickAway: /* @__PURE__ */ a(() => g(!1), "onClickAway"), children: /* @__PURE__ */ t(gt, { dense: !0, children: kt.map((f) => {
1560
+ const _ = r.filterType[f.filterType];
1561
+ return /* @__PURE__ */ y(
1562
+ Ee,
1563
+ {
1564
+ onClick: /* @__PURE__ */ a(() => {
1565
+ i(f.filterType), g(!1);
1566
+ }, "onClick"),
1567
+ children: [
1568
+ /* @__PURE__ */ t(Ke, { children: /* @__PURE__ */ t(_, { fontSize: "small" }) }),
1569
+ /* @__PURE__ */ t(Ye, { children: f.label })
1570
+ ]
1571
+ },
1572
+ f.filterType
1573
+ );
1574
+ }) }) }) }) }), "children") })
1575
+ ] })
1576
+ ] });
1577
+ }, "ToolBox"), $n = /* @__PURE__ */ a((e) => {
1578
+ const n = et(), i = me(), l = N((T) => T.dashboardDefinition), r = N((T) => T.publishedDashboard), o = N((T) => T.viewType), x = N((T) => T.renderGeneration), b = N((T) => T.llmCounter), g = (l == null ? void 0 : l.id) ?? null, [d, C] = L(null), [s, u] = L(), [m, c] = L(!1), [p, f] = L(!1), [_, B] = L(null), [G, z] = L(!1), R = te(null), P = te(null), H = te(null), j = te(null), E = he(), S = ze(() => `pad-${Math.random().toString(36).slice(2)}`, []);
1579
+ q(() => {
1580
+ var K;
1581
+ if (e.turnOpen) return;
1582
+ const T = i.getState().dashboardDefinition;
1583
+ (K = T == null ? void 0 : T.cards) != null && K.some((re) => re.todoItem) && i.getState().updateDashboard({ cards: T.cards.map((re) => ({ ...re, todoItem: void 0 })) });
1584
+ }, [e.turnOpen, i]);
1585
+ const F = Y(() => {
1586
+ const T = i.getState().dashboardDefinition;
1587
+ if (!T || !e.onCompose) return;
1588
+ const K = bt(T);
1589
+ if (K) {
1590
+ u(K), setTimeout(() => u(void 0), 2e3);
1591
+ return;
1592
+ }
1593
+ e.onCompose(T);
1594
+ }, [e.onCompose, i]), w = Y((T) => {
1595
+ var K;
1596
+ j.current = T.id ?? null, bt(T), i.getState().updateDashboard(T), (K = e.onChange) == null || K.call(e, T);
1597
+ }, [e.onChange, i]), O = Y(async () => {
1598
+ var K;
1599
+ const T = i.getState().dashboardDefinition;
1600
+ if (!(!(T != null && T.id) || !n)) {
1601
+ c(!0);
1602
+ try {
1603
+ await at(n, T), (K = e.onChange) == null || K.call(e, T);
1604
+ } catch (re) {
1605
+ console.error("[@aintela/bi composer] Error saving dashboard:", re);
1606
+ } finally {
1607
+ c(!1);
1608
+ }
1609
+ }
1610
+ }, [n, e.onChange, i]);
1611
+ q(() => {
1612
+ if (!n || !e.dashboardId || H.current || j.current === e.dashboardId) return;
1613
+ C(null), i.getState().updateDashboard(void 0);
1614
+ const T = n.getDashboard(e.dashboardId);
1615
+ H.current = T, T.then((K) => w(Ne(K))).catch((K) => C(String(K))).finally(() => {
1616
+ H.current = null;
1617
+ });
1618
+ }, [w, n, e.dashboardId, i]);
1619
+ const k = Y(async () => {
1620
+ if (n)
1621
+ try {
1622
+ w(await Ot(n, e.sessionId));
1623
+ } catch (T) {
1624
+ console.error("[@aintela/bi composer] Error creating new dashboard:", T);
1625
+ }
1626
+ }, [w, n, e.sessionId]), U = Y(() => {
1627
+ i.getState().refreshDashboard();
1628
+ }, [i]), J = Y(async () => {
1629
+ const T = !p;
1630
+ if (f(T), T && n) {
1631
+ z(!0);
1632
+ try {
1633
+ B(await n.getDashboardHierarchy());
1634
+ } catch (K) {
1635
+ console.error("[@aintela/bi composer] Error fetching hierarchy:", K);
1636
+ } finally {
1637
+ z(!1);
1638
+ }
1639
+ }
1640
+ }, [n, p]), Z = Y(async (T) => {
1641
+ if (!(!T.id || !n)) {
1642
+ f(!1);
1643
+ try {
1644
+ w(Ne(await n.getDashboard(T.id)));
1645
+ } catch (K) {
1646
+ console.error("[@aintela/bi composer] Error loading dashboard:", K);
1647
+ }
1648
+ }
1649
+ }, [w, n]), ie = e.renderDashboardPicker, de = /* @__PURE__ */ a((T, K) => Be.cloneElement(K, { className: "llm-env-target llm-env-dashboard-action", "data-env-id": T, sx: { fontSize: 18 } }), "envIcon"), V = /* @__PURE__ */ a((T) => ({ border: T ? "0px" : `1px solid ${E.palette.divider}`, px: 1, py: 0, gap: 0.5, textTransform: "none" }), "viewToggleSx"), Q = /* @__PURE__ */ a((T, K) => ({ fontSize: "0.7rem", lineHeight: 1, maxWidth: T ? K : 0, overflow: "hidden", opacity: T ? 1 : 0, whiteSpace: "nowrap", transition: "max-width 0.25s ease, opacity 0.2s ease" }), "viewLabelSx");
1650
+ return /* @__PURE__ */ y(ce, { className: "bi-dashboard-pad", sx: { height: "100%", minHeight: 0 }, children: [
1651
+ /* @__PURE__ */ t(W, { sx: { display: "flex", py: 0.5, backgroundColor: E.palette.background.paper, borderBottom: `1px solid ${E.palette.divider}`, px: 1 }, children: /* @__PURE__ */ y(ce, { direction: "row", gap: 0.5, sx: { alignItems: "center", width: "100%", px: 1 }, children: [
1652
+ !l && !d && /* @__PURE__ */ y(ce, { direction: "row", gap: 1, alignItems: "center", children: [
1653
+ /* @__PURE__ */ t(ft, { size: 16 }),
1654
+ /* @__PURE__ */ t(ae, { color: "text.secondary", children: "Carregando dashboard" })
1655
+ ] }),
1656
+ d && /* @__PURE__ */ y(ae, { color: "error", children: [
1657
+ "Error creating dashboard: ",
1658
+ d
1659
+ ] }),
1660
+ l && /* @__PURE__ */ y(we, { children: [
1661
+ e.onBack && /* @__PURE__ */ t(Te, { onClick: e.onBack, icon: de("dashboard-pad-back", /* @__PURE__ */ t(Ai, {})), label: "Voltar" }),
1662
+ /* @__PURE__ */ y(
1663
+ on,
1664
+ {
1665
+ value: o,
1666
+ exclusive: !0,
1667
+ onChange: /* @__PURE__ */ a((T, K) => K && i.getState().setViewType(K), "onChange"),
1668
+ size: "small",
1669
+ className: "llm-env-target llm-env-view-toggle",
1670
+ "data-env-id": "dashboard-pad-view-toggle",
1671
+ sx: { height: 24, border: "0px", "& .Mui-selected": { border: `1px solid ${E.palette.divider}` } },
1672
+ children: [
1673
+ /* @__PURE__ */ y(qe, { value: "Sketch", className: "llm-env-target llm-env-action-sketch", "data-env-id": "dashboard-pad-view-sketch", sx: V(o == "Sketch"), children: [
1674
+ /* @__PURE__ */ t(wt, { sx: { fontSize: 18 } }),
1675
+ /* @__PURE__ */ t(ae, { component: "span", sx: Q(o === "Sketch", 50), children: "Sketch" })
1676
+ ] }),
1677
+ /* @__PURE__ */ y(qe, { value: "Generated", className: "llm-env-target llm-env-action-generated", "data-env-id": "dashboard-pad-view-generated", sx: V(o == "Generated"), children: [
1678
+ /* @__PURE__ */ t(Ei, { sx: { fontSize: 18 } }),
1679
+ /* @__PURE__ */ t(ae, { component: "span", sx: Q(o === "Generated", 70), children: "Dashboard" })
1680
+ ] })
1681
+ ]
1682
+ }
1683
+ ),
1684
+ /* @__PURE__ */ t(Ue, { orientation: "vertical", flexItem: !0, sx: { mx: 1 } }),
1685
+ /* @__PURE__ */ t(W, { sx: { flex: 1, display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ t(
1686
+ En,
1687
+ {
1688
+ onAddGeneric: /* @__PURE__ */ a(() => {
1689
+ var T;
1690
+ return (T = P.current) == null ? void 0 : T.addGenericCell();
1691
+ }, "onAddGeneric"),
1692
+ onAddTyped: /* @__PURE__ */ a((T, K, re) => {
1693
+ var h;
1694
+ return (h = P.current) == null ? void 0 : h.addTypedCell(T, K, re);
1695
+ }, "onAddTyped"),
1696
+ onAddFilter: /* @__PURE__ */ a((T) => {
1697
+ var K;
1698
+ return (K = P.current) == null ? void 0 : K.handleAddFilter(T);
1699
+ }, "onAddFilter")
1700
+ }
1701
+ ) }),
1702
+ /* @__PURE__ */ t(Ue, { orientation: "vertical", flexItem: !0, sx: { mx: 1 } }),
1703
+ /* @__PURE__ */ y(ce, { direction: "row", gap: 0.25, alignItems: "center", children: [
1704
+ n && /* @__PURE__ */ t(Te, { onClick: k, icon: de("dashboard-pad-new", /* @__PURE__ */ t(Mi, {})), label: "Novo" }),
1705
+ n && /* @__PURE__ */ t(
1706
+ Te,
1707
+ {
1708
+ onClick: m ? void 0 : O,
1709
+ icon: /* @__PURE__ */ a(() => m ? /* @__PURE__ */ t(ft, { size: 14 }) : de("dashboard-pad-save", /* @__PURE__ */ t(_i, {})), "icon"),
1710
+ label: "Salvar"
1711
+ }
1712
+ ),
1713
+ /* @__PURE__ */ t(Te, { onClick: U, icon: de("dashboard-pad-refresh", /* @__PURE__ */ t(an, {})), label: "Atualizar" }),
1714
+ n && ie && /* @__PURE__ */ t("div", { ref: R, children: /* @__PURE__ */ t(
1715
+ Te,
1716
+ {
1717
+ onClick: J,
1718
+ icon: /* @__PURE__ */ y(ce, { direction: "row", alignItems: "center", "data-env-id": "dashboard-pad-load", className: "llm-env-target llm-env-dashboard-action", children: [
1719
+ /* @__PURE__ */ t($i, { sx: { fontSize: 18 } }),
1720
+ /* @__PURE__ */ t(mt, { sx: { fontSize: 14, ml: -0.25 } })
1721
+ ] }),
1722
+ label: "Abrir"
1723
+ }
1724
+ ) }),
1725
+ /* @__PURE__ */ t(ke, { open: !!s, title: s ?? "", placement: "bottom", slotProps: { tooltip: { sx: { backgroundColor: "error.dark" } } }, children: /* @__PURE__ */ y(
1726
+ W,
1727
+ {
1728
+ className: "action-btn-fixed",
1729
+ onClick: F,
1730
+ sx: {
1731
+ display: "inline-flex",
1732
+ alignItems: "center",
1733
+ height: 28,
1734
+ borderRadius: 1,
1735
+ px: 0.75,
1736
+ cursor: "pointer",
1737
+ color: E.palette.success.contrastText,
1738
+ backgroundColor: E.palette.success.main,
1739
+ "&:hover": { bgcolor: E.palette.success.light }
1740
+ },
1741
+ children: [
1742
+ /* @__PURE__ */ t(ae, { component: "span", sx: { whiteSpace: "nowrap", fontSize: "0.7rem", lineHeight: 1, mr: 1 }, children: "Compose" }),
1743
+ de("dashboard-pad-compose", /* @__PURE__ */ t(Ri, {}))
1744
+ ]
1745
+ }
1746
+ ) })
1747
+ ] })
1748
+ ] })
1749
+ ] }) }),
1750
+ ie && /* @__PURE__ */ t(We, { open: p, anchorEl: R.current, placement: "bottom-end", transition: !0, sx: { zIndex: 1300 }, children: /* @__PURE__ */ a(({ TransitionProps: T }) => /* @__PURE__ */ t(Ve, { ...T, children: /* @__PURE__ */ t(Re, { elevation: 8, sx: { overflow: "hidden", minWidth: 320, maxWidth: 380 }, children: /* @__PURE__ */ t(je, { onClickAway: /* @__PURE__ */ a(() => f(!1), "onClickAway"), children: /* @__PURE__ */ t(W, { sx: { width: 360, maxWidth: "100%", height: 420 }, children: ie({ hierarchy: _, loading: G, selectedDashboardId: g, onSelect: /* @__PURE__ */ a((K) => void Z(K), "onSelect") }) }) }) }) }), "children") }),
1751
+ o == "Sketch" && /* @__PURE__ */ y(ce, { sx: { flex: 1, minHeight: 0 }, children: [
1752
+ e.showDebug && /* @__PURE__ */ t(Re, { variant: "outlined", sx: { maxHeight: 200, p: 1, overflow: "auto", "& pre": { bgcolor: "background.default", p: 1, borderRadius: 1, overflow: "auto", fontSize: 11, m: 0 } }, children: /* @__PURE__ */ t("pre", { children: JSON.stringify(l, void 0, 2) }) }),
1753
+ /* @__PURE__ */ t("div", { style: { minHeight: "300px", flex: 1 }, children: /* @__PURE__ */ t(ot, { ref: P, renderId: S, headerExtra: e.headerExtra, renderDescription: e.renderDescription }) })
1754
+ ] }),
1755
+ o == "Generated" && (r == null ? void 0 : r.id) && /* @__PURE__ */ t(W, { sx: { flex: 1, minHeight: 0, overflow: "auto" }, children: /* @__PURE__ */ t(_e, { dashboard: r, codeGeneration: x, llmRenderCount: b, dragLocked: !1, editable: !0, onLayoutCommit: /* @__PURE__ */ a(() => i.getState().commitDashboardLayout(), "onLayoutCommit") }, r.id) })
1756
+ ] });
1757
+ }, "DashboardPad");
1758
+ $n.displayName = "DashboardPad";
1759
+ const ht = 40, ka = 100, Ia = 150, An = Ct((e, n) => {
1760
+ const i = e.defaultContentType ?? "default", l = te(0), r = Y(() => (l.current += 1, `Untitled-${l.current}`), []), [o, x] = L(() => e.tabs ?? [{ name: r(), contentType: i, id: Ie() }]), [b, g] = L(() => o[0].name), [d, C] = L(null), [s, u] = L(""), [m, c] = L(null), p = te(null), f = o.find((S) => S.name === b) ?? o[0] ?? null, _ = Y((S, F) => {
1761
+ let w = S, O = 1;
1762
+ for (; o.some((k) => k.name === w && k.name !== F); )
1763
+ O += 1, w = `${S} (${O})`;
1764
+ return w;
1765
+ }, [o]), B = Y((S) => {
1766
+ o.some((F) => F.name === S) && g(S);
1767
+ }, [o]), G = Y((S, F) => {
1768
+ var k;
1769
+ const w = _(F ?? r()), O = { id: Ie(), name: w, contentType: S ?? i };
1770
+ return x((U) => [...U, O]), g(w), (k = e.onTabCreate) == null || k.call(e, O), w;
1771
+ }, [i, _, e.onTabCreate, r]), z = Y((S) => {
1772
+ x((F) => {
1773
+ var U, J;
1774
+ const w = F.findIndex((Z) => Z.name === S);
1775
+ if (w === -1) return F;
1776
+ const O = F[w], k = F.filter((Z) => Z.name !== S);
1777
+ if (k.length === 0) {
1778
+ const Z = { name: r(), contentType: i, id: Ie() };
1779
+ return g(Z.name), (U = e.onTabClose) == null || U.call(e, O), [Z];
1780
+ }
1781
+ return b === S && g(k[Math.min(w, k.length - 1)].name), (J = e.onTabClose) == null || J.call(e, O), k;
1782
+ });
1783
+ }, [b, i, e.onTabClose, r]);
1784
+ Jt(n, () => ({ focusTab: B, createTab: G, closeTab: z, getActiveTab: /* @__PURE__ */ a(() => f, "getActiveTab"), getTabs: /* @__PURE__ */ a(() => o, "getTabs") }), [B, G, z, f, o]), q(() => {
1785
+ var S;
1786
+ f && ((S = e.onTabChange) == null || S.call(e, f));
1787
+ }, [b]);
1788
+ const R = /* @__PURE__ */ a((S) => {
1789
+ C(S.name), u(S.name);
1790
+ }, "startRename"), P = /* @__PURE__ */ a(() => {
1791
+ var F;
1792
+ if (!d) return;
1793
+ const S = s.trim();
1794
+ if (S && S !== d) {
1795
+ const w = _(S, d), O = d;
1796
+ x((U) => U.map((J) => J.name === d ? { ...J, name: w } : J)), b === d && g(w);
1797
+ const k = o.find((U) => U.name === d);
1798
+ k && ((F = e.onTabRename) == null || F.call(e, { ...k, name: w }, O));
1799
+ }
1800
+ C(null);
1801
+ }, "commitRename"), H = /* @__PURE__ */ a((S) => {
1802
+ S.key === "Enter" ? P() : S.key === "Escape" && C(null);
1803
+ }, "handleRenameKeyDown");
1804
+ q(() => {
1805
+ d && p.current && (p.current.focus(), p.current.select());
1806
+ }, [d]);
1807
+ const j = /* @__PURE__ */ a((S) => {
1808
+ var F;
1809
+ (F = e.addMenuItems) != null && F.length ? c(S.currentTarget) : G();
1810
+ }, "handleAddMenuOpen"), E = /* @__PURE__ */ t(Bi, { sx: { fontSize: 15, color: "text.secondary", flexShrink: 0 } });
1811
+ return /* @__PURE__ */ y(W, { sx: { display: "flex", flexDirection: "column", height: "100%", overflow: "hidden" }, children: [
1812
+ /* @__PURE__ */ y(W, { sx: { display: "flex", alignItems: "center", borderBottom: "1px solid", borderColor: "divider", backgroundColor: "background.paper", minHeight: ht, maxHeight: ht, overflow: "hidden" }, children: [
1813
+ /* @__PURE__ */ t(W, { sx: { display: "flex", alignItems: "center", flex: 1, overflow: "auto", backgroundColor: "background.default", "&::-webkit-scrollbar": { height: 0 } }, children: o.map((S) => {
1814
+ var O;
1815
+ const F = S.name === b, w = S.name === d;
1816
+ return /* @__PURE__ */ y(
1817
+ W,
1818
+ {
1819
+ onClick: /* @__PURE__ */ a(() => {
1820
+ w || g(S.name);
1821
+ }, "onClick"),
1822
+ onDoubleClick: /* @__PURE__ */ a(() => R(S), "onDoubleClick"),
1823
+ sx: /* @__PURE__ */ a((k) => ({
1824
+ display: "flex",
1825
+ alignItems: "center",
1826
+ gap: 0.5,
1827
+ minWidth: ka,
1828
+ maxWidth: Ia,
1829
+ height: ht,
1830
+ px: 1.5,
1831
+ cursor: "pointer",
1832
+ userSelect: "none",
1833
+ borderBottom: "2px solid",
1834
+ borderColor: F ? "primary.main" : "transparent",
1835
+ backgroundColor: F ? k.palette.action.selected : k.palette.background.paper,
1836
+ "&:hover": { backgroundColor: F ? k.palette.action.selected : k.palette.action.hover },
1837
+ transition: "background-color 0.15s, border-color 0.15s"
1838
+ }), "sx"),
1839
+ children: [
1840
+ ((O = e.renderTabIcon) == null ? void 0 : O.call(e, S)) ?? E,
1841
+ w ? /* @__PURE__ */ t(
1842
+ Fe,
1843
+ {
1844
+ inputRef: p,
1845
+ value: s,
1846
+ onChange: /* @__PURE__ */ a((k) => u(k.target.value), "onChange"),
1847
+ onBlur: P,
1848
+ onKeyDown: H,
1849
+ variant: "standard",
1850
+ size: "small",
1851
+ slotProps: {
1852
+ input: { disableUnderline: !0, style: { fontSize: "0.75rem", fontWeight: 500, padding: "0px", height: 20, border: "0px" } },
1853
+ root: { style: { padding: "2px 0px 0px 0px", border: "0px" } }
1854
+ },
1855
+ sx: { minWidth: "30px", maxWidth: "80%" },
1856
+ onClick: /* @__PURE__ */ a((k) => k.stopPropagation(), "onClick")
1857
+ }
1858
+ ) : /* @__PURE__ */ t(ae, { variant: "caption", noWrap: !0, sx: { minWidth: "60px", fontWeight: F ? 600 : 400, color: F ? "text.primary" : "text.secondary", fontSize: "0.75rem" }, children: S.name }),
1859
+ /* @__PURE__ */ t(
1860
+ Pe,
1861
+ {
1862
+ size: "small",
1863
+ onClick: /* @__PURE__ */ a((k) => {
1864
+ k.stopPropagation(), z(S.name);
1865
+ }, "onClick"),
1866
+ sx: { p: 0.2, opacity: F ? 0.7 : 0, "&:hover": { opacity: 1 }, transition: "opacity 0.15s" },
1867
+ "aria-label": "Fechar aba",
1868
+ children: /* @__PURE__ */ t(Fi, { sx: { fontSize: 14 } })
1869
+ }
1870
+ )
1871
+ ]
1872
+ },
1873
+ S.name
1874
+ );
1875
+ }) }),
1876
+ /* @__PURE__ */ t(Pe, { size: "small", onClick: j, sx: { mx: 0.5, flexShrink: 0 }, title: "Adicionar aba", children: /* @__PURE__ */ t(Ni, { sx: { fontSize: 18 } }) }),
1877
+ e.addMenuItems && /* @__PURE__ */ t(Gi, { anchorEl: m, open: !!m, onClose: /* @__PURE__ */ a(() => c(null), "onClose"), anchorOrigin: { vertical: "bottom", horizontal: "left" }, transformOrigin: { vertical: "top", horizontal: "left" }, children: e.addMenuItems.map((S, F) => [
1878
+ S.dividerBefore && /* @__PURE__ */ t(W, { component: "li", sx: { borderTop: "1px solid", borderColor: "divider" } }, `div-${F}`),
1879
+ /* @__PURE__ */ y(
1880
+ Ee,
1881
+ {
1882
+ onClick: /* @__PURE__ */ a(() => {
1883
+ G(S.contentType), c(null);
1884
+ }, "onClick"),
1885
+ disabled: S.disabled,
1886
+ children: [
1887
+ S.icon && /* @__PURE__ */ t(Ke, { children: S.icon }),
1888
+ /* @__PURE__ */ t(Ye, { children: S.label })
1889
+ ]
1890
+ },
1891
+ S.label
1892
+ )
1893
+ ]) })
1894
+ ] }),
1895
+ o.map((S) => /* @__PURE__ */ t(W, { sx: { flex: 1, overflow: "auto", pr: 0, display: S.name === b ? "flex" : "none", flexDirection: "column" }, children: e.renderContent(S) }, S.id))
1896
+ ] });
1897
+ });
1898
+ An.displayName = "DashboardPadEditor";
1899
+ const za = /* @__PURE__ */ a(({
1900
+ orientation: e = "row",
1901
+ datasets: n,
1902
+ defaultTemplateDataset: i = "BI_TemplateModel",
1903
+ agents: l,
1904
+ agentId: r,
1905
+ recommendedAgentId: o,
1906
+ onAgentChange: x
1907
+ }) => {
1908
+ const b = he(), g = me(), d = N((c) => {
1909
+ var p;
1910
+ return ((p = c.dashboardDefinition) == null ? void 0 : p.isDatasetParameterized) ?? !1;
1911
+ }), C = N((c) => {
1912
+ var p;
1913
+ return (p = c.dashboardDefinition) == null ? void 0 : p.defaultDatasetName;
1914
+ }), s = /* @__PURE__ */ a((c, p) => {
1915
+ g.getState().updateDashboard({
1916
+ isDatasetParameterized: p,
1917
+ defaultDatasetName: p ? C ?? i : void 0
1918
+ });
1919
+ }, "handleToggle"), u = r ?? (o == null ? void 0 : o(d)) ?? "", m = e === "column";
1920
+ return /* @__PURE__ */ y(
1921
+ ce,
1922
+ {
1923
+ direction: m ? "column" : "row",
1924
+ alignItems: m ? "stretch" : "center",
1925
+ gap: m ? 0.75 : 1,
1926
+ sx: m ? {} : { px: 1, py: 0.25, borderLeft: `1px solid ${b.palette.divider}` },
1927
+ children: [
1928
+ /* @__PURE__ */ y(ce, { direction: "row", alignItems: "center", gap: 0.5, children: [
1929
+ /* @__PURE__ */ t(xt, { size: "small", checked: d, onChange: s, "data-env-id": "dashboard-pad-dataset-parameterized" }),
1930
+ /* @__PURE__ */ t(ae, { variant: "body2", sx: { color: "text.secondary", whiteSpace: "nowrap", fontSize: m ? 11.5 : void 0 }, children: "DataSet Dinâmico" })
1931
+ ] }),
1932
+ d && /* @__PURE__ */ t(
1933
+ Rt,
1934
+ {
1935
+ size: "small",
1936
+ value: C ?? "",
1937
+ onChange: /* @__PURE__ */ a((c) => g.getState().updateDashboard({ defaultDatasetName: c.target.value }), "onChange"),
1938
+ displayEmpty: !0,
1939
+ fullWidth: m,
1940
+ sx: { minWidth: m ? void 0 : 160, fontSize: "0.8rem", "& .MuiSelect-select": { py: 0.5 } },
1941
+ renderValue: /* @__PURE__ */ a((c) => {
1942
+ var p;
1943
+ return c ? ((p = n.find((f) => f.dataSetId === c)) == null ? void 0 : p.name) ?? c : "Default…";
1944
+ }, "renderValue"),
1945
+ children: n.map((c) => /* @__PURE__ */ t(Ee, { value: c.dataSetId, sx: { fontSize: "0.8rem" }, children: /* @__PURE__ */ y(W, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
1946
+ /* @__PURE__ */ t("span", { children: c.name }),
1947
+ c.isTemplate && /* @__PURE__ */ t(ae, { variant: "caption", sx: { color: "text.disabled" }, children: "(template)" })
1948
+ ] }) }, c.dataSetId))
1949
+ }
1950
+ ),
1951
+ l && /* @__PURE__ */ t(W, { sx: m ? {} : { borderLeft: `1px solid ${b.palette.divider}`, pl: 1 }, children: /* @__PURE__ */ t(
1952
+ Rt,
1953
+ {
1954
+ size: "small",
1955
+ value: u,
1956
+ onChange: /* @__PURE__ */ a((c) => {
1957
+ const p = l.find((f) => f.id === c.target.value);
1958
+ p && (x == null || x(p));
1959
+ }, "onChange"),
1960
+ displayEmpty: !0,
1961
+ fullWidth: m,
1962
+ sx: { minWidth: m ? void 0 : 180, fontSize: "0.8rem", "& .MuiSelect-select": { py: 0.5 } },
1963
+ renderValue: /* @__PURE__ */ a((c) => {
1964
+ var p;
1965
+ return ((p = l.find((f) => f.id === c)) == null ? void 0 : p.name) ?? "Agent…";
1966
+ }, "renderValue"),
1967
+ "data-env-id": "dashboard-pad-agent-picker",
1968
+ children: l.map((c) => /* @__PURE__ */ t(Ee, { value: c.id, sx: { fontSize: "0.8rem" }, children: c.name }, c.id))
1969
+ }
1970
+ ) })
1971
+ ]
1972
+ }
1973
+ );
1974
+ }, "DatasetParameterizationControls"), Oa = /* @__PURE__ */ a(({ backgroundColor: e, zoom: n = 0.7, width: i = "80%", title: l, config: r }) => /* @__PURE__ */ t(W, { sx: /* @__PURE__ */ a((o) => ({ display: "inline-flex", justifyContent: "left", width: "100%", border: `1px solid ${o.palette.divider}`, borderRadius: "10px", p: 2, maxHeight: "500px", overflow: "auto" }), "sx"), children: /* @__PURE__ */ y(ce, { gap: 2, sx: /* @__PURE__ */ a((o) => ({ p: 1, borderRadius: 2, backgroundColor: e ?? o.palette.background.paper, width: i, zoom: n }), "sx"), children: [
1975
+ l && /* @__PURE__ */ t(ae, { variant: "body1", children: l }),
1976
+ /* @__PURE__ */ t(Je, { container: !0, spacing: 1, children: r.map((o, x) => /* @__PURE__ */ t(Je, { size: o.size, maxHeight: 300, children: /* @__PURE__ */ t(W, { sx: { width: "100%", height: o.specificType == "Gauge" || o.specificType == "MetricComparison" ? "100px" : `${Math.max(o.height ?? 0, nt)}px` }, children: o.card }) }, `example-pad-card-${x}`)) })
1977
+ ] }) }), "ExamplePad"), rt = /* @__PURE__ */ a((e) => {
1978
+ const n = Ae(), i = e.specificType ?? "Generic", l = n.specificType[i] ?? n.specificType.Generic;
1979
+ return /* @__PURE__ */ y(W, { sx: { ...e.sx, width: "100%", height: "100%", p: 1, gap: 0.2, textAlign: "justify" }, className: "react-grid-placeholder-example", children: [
1980
+ /* @__PURE__ */ t(l, { fontSize: "small", sx: { float: "left", shapeOutside: "margin-box", mr: 0.5 } }),
1981
+ /* @__PURE__ */ t(ae, { sx: { fontSize: "14px" }, children: `[${e.name}] - ${e.description}` })
1982
+ ] });
1983
+ }, "ExampleCardSketch"), Pa = rt, Ea = rt, $a = /* @__PURE__ */ a(({ backgroundColor: e, zoom: n = 0.8, width: i = "100%", title: l, config: r }) => /* @__PURE__ */ y(ce, { gap: 2, sx: /* @__PURE__ */ a((o) => ({ p: 1, borderRadius: 2, backgroundColor: e ?? o.palette.background.paper, width: i, maxHeight: "1400px" }), "sx"), children: [
1984
+ l && /* @__PURE__ */ t(ae, { variant: "body1", children: l }),
1985
+ /* @__PURE__ */ t(Je, { container: !0, spacing: 1, sx: { zoom: n }, children: r.map((o, x) => /* @__PURE__ */ t(Je, { size: o.size, children: /* @__PURE__ */ t(W, { sx: { width: "100%", height: o.height ?? nt, "& > *": { width: "100%", maxHeight: "500px" } }, children: o.card }) }, `prototype-pad-card-${x}`)) })
1986
+ ] }), "PrototypePad");
1987
+ function Aa(e, n, i, l, r) {
1988
+ if (l === void 0) return { size: e, height: n, card: i };
1989
+ const o = i;
1990
+ return r !== void 0 && typeof r != "string" ? { size: e, height: n, name: o, specificType: l, card: r } : {
1991
+ size: e,
1992
+ height: n,
1993
+ name: o,
1994
+ specificType: l,
1995
+ description: r,
1996
+ card: /* @__PURE__ */ t(rt, { name: o, specificType: l, description: r })
1997
+ };
1998
+ }
1999
+ a(Aa, "c");
2000
+ const Ma = /* @__PURE__ */ a((e, n) => ({
2001
+ i: e,
2002
+ name: n,
2003
+ filterType: "DateRangePicker",
2004
+ mandatory: !0,
2005
+ parametersNames: [`${n}_inicio`, `${n}_fim`]
2006
+ }), "dateRange"), _a = /* @__PURE__ */ a((e, n, i = !1) => ({
2007
+ i: e,
2008
+ name: n,
2009
+ filterType: "DatePicker",
2010
+ mandatory: i,
2011
+ parametersNames: [n]
2012
+ }), "datePicker"), Ra = /* @__PURE__ */ a((e, n, i = !0, l = !1) => ({
2013
+ i: e,
2014
+ name: n,
2015
+ filterType: "AutoComplete",
2016
+ mandatory: l,
2017
+ multipleSelection: i,
2018
+ parametersNames: [n]
2019
+ }), "autoComplete");
2020
+ function Fa(e, n) {
2021
+ const i = rn();
2022
+ q(() => {
2023
+ var l, r;
2024
+ n == "update" ? (l = i.updateDashboardPad) == null || l.call(i, e) : (r = i.createDashboardPad) == null || r.call(i, e);
2025
+ }, []);
2026
+ }
2027
+ a(Fa, "useDashboardPad");
2028
+ const Mn = {
2029
+ visible: { opacity: 1, y: 0, transition: { duration: 0.18, ease: "easeOut" } },
2030
+ hidden: { opacity: 0, y: -12, transition: { duration: 0.18, ease: "easeOut" } }
2031
+ }, _n = {
2032
+ hidden: { opacity: 0, x: 16, transition: { duration: 0.1, ease: "easeOut" } },
2033
+ visible: { opacity: 1, x: 0, transition: { duration: 0.32, ease: "easeOut", delay: 0.22 } }
2034
+ }, Rn = { duration: 0.28, ease: "easeOut" }, Fn = {
2035
+ visible: { opacity: 1, transition: { duration: 0.15 } },
2036
+ hidden: { opacity: 0, transition: { duration: 0.15 } }
2037
+ }, Nn = {
2038
+ hidden: { opacity: 0, transition: { duration: 0.15 } },
2039
+ visible: { opacity: 1, transition: { duration: 0.15 } }
2040
+ }, Bn = { duration: 0.15, ease: "linear" }, Ln = {
2041
+ kpi: { category: "Métrica", specificType: "MetricComparison" },
2042
+ line: { category: "Gráfico", specificType: "ChartLine" },
2043
+ bars: { category: "Gráfico", specificType: "ChartBarV" },
2044
+ table: { category: "Tabela", specificType: "TableAuto" },
2045
+ donut: { category: "Gráfico", specificType: "ChartDonut" },
2046
+ heatmap: { category: "Tabela", specificType: "TableHeatmap" }
2047
+ };
2048
+ function Gn(e) {
2049
+ return e.cells.map((n) => n.kind);
2050
+ }
2051
+ a(Gn, "templateKinds");
2052
+ function Hn(e, n) {
2053
+ const i = n ?? `${e.id}-${Date.now()}`;
2054
+ return e.cells.map((l, r) => {
2055
+ const o = Ln[l.kind];
2056
+ return {
2057
+ i: `${i}-${r}`,
2058
+ x: l.x,
2059
+ y: l.y,
2060
+ w: l.w,
2061
+ h: l.h,
2062
+ isResizable: !0,
2063
+ category: o.category,
2064
+ specificType: o.specificType,
2065
+ name: l.name,
2066
+ actionDescription: l.description
2067
+ };
2068
+ });
2069
+ }
2070
+ a(Hn, "seedFromTemplate");
2071
+ const At = [
2072
+ {
2073
+ id: "t1",
2074
+ name: "Visão executiva",
2075
+ desc: "KPIs principais + tendência mensal",
2076
+ recommended: !0,
2077
+ cells: [
2078
+ { name: "Receita Total", kind: "kpi", description: "Receita acumulada no período vs. período anterior", x: 0, y: 0, w: 4, h: 4 },
2079
+ { name: "Ticket Médio", kind: "kpi", description: "Valor médio por pedido", x: 4, y: 0, w: 4, h: 4 },
2080
+ { name: "Conversão", kind: "kpi", description: "% de leads que viraram clientes", x: 8, y: 0, w: 4, h: 4 },
2081
+ { name: "Tendência Mensal", kind: "line", description: "Evolução de receita mês a mês", x: 0, y: 4, w: 12, h: 7 },
2082
+ { name: "Top 10 Clientes", kind: "table", description: "Ranking dos clientes com maior receita", x: 0, y: 11, w: 7, h: 7 },
2083
+ { name: "Receita por Canal", kind: "donut", description: "Distribuição percentual da receita por canal de venda", x: 7, y: 11, w: 5, h: 7 }
2084
+ ]
2085
+ },
2086
+ {
2087
+ id: "t2",
2088
+ name: "Análise comercial",
2089
+ desc: "Funil de vendas + receita por canal",
2090
+ cells: [
2091
+ { name: "Pipeline", kind: "kpi", description: "Valor total do pipeline aberto", x: 0, y: 0, w: 6, h: 4 },
2092
+ { name: "Win Rate", kind: "kpi", description: "% de oportunidades fechadas vs. perdidas", x: 6, y: 0, w: 6, h: 4 },
2093
+ { name: "Receita Semanal", kind: "line", description: "Receita semanal nos últimos 90 dias", x: 0, y: 4, w: 7, h: 6 },
2094
+ { name: "Vendas por Vendedor", kind: "bars", description: "Volume de vendas por representante comercial", x: 7, y: 4, w: 5, h: 6 },
2095
+ { name: "Funil de Vendas", kind: "line", description: "Conversão por estágio do funil", x: 0, y: 10, w: 5, h: 6 },
2096
+ { name: "Top Oportunidades", kind: "table", description: "Maiores oportunidades em aberto, ordenadas por valor", x: 5, y: 10, w: 7, h: 6 },
2097
+ { name: "Receita por Canal", kind: "donut", description: "Distribuição da receita por canal de venda", x: 0, y: 16, w: 5, h: 6 },
2098
+ { name: "Atividade da Equipe", kind: "heatmap", description: "Heatmap de atividade por vendedor por dia", x: 5, y: 16, w: 7, h: 6 }
2099
+ ]
2100
+ },
2101
+ {
2102
+ id: "t3",
2103
+ name: "Operação",
2104
+ desc: "Volume, ocupação e cancelamentos",
2105
+ cells: [
2106
+ { name: "Volume Diário", kind: "kpi", description: "Total de operações no dia atual", x: 0, y: 0, w: 4, h: 4 },
2107
+ { name: "Ocupação", kind: "kpi", description: "% de capacidade utilizada", x: 4, y: 0, w: 4, h: 4 },
2108
+ { name: "Cancelamentos", kind: "kpi", description: "% de operações canceladas no período", x: 8, y: 0, w: 4, h: 4 },
2109
+ { name: "Volume por Origem", kind: "bars", description: "Top origens por volume de operações", x: 0, y: 4, w: 7, h: 6 },
2110
+ { name: "SLA", kind: "line", description: "Tempo médio de processamento ao longo do dia", x: 7, y: 4, w: 5, h: 6 },
2111
+ { name: "Pendências", kind: "table", description: "Operações pendentes ordenadas por SLA", x: 0, y: 10, w: 7, h: 6 },
2112
+ { name: "Status", kind: "donut", description: "Distribuição percentual dos status (Aberto, Em andamento, Concluído)", x: 7, y: 10, w: 5, h: 6 }
2113
+ ]
2114
+ },
2115
+ {
2116
+ id: "t4",
2117
+ name: "Em branco",
2118
+ desc: "Comece do zero — adicione cards conforme pensa",
2119
+ cells: []
2120
+ }
2121
+ ], Na = At;
2122
+ function ge(e) {
2123
+ var l, r, o;
2124
+ const n = e.palette, i = e.typography.fontFamilyMono;
2125
+ return {
2126
+ raised: ((l = n.surface) == null ? void 0 : l.raised) ?? n.background.paper,
2127
+ hover: ((r = n.surface) == null ? void 0 : r.hover) ?? n.action.hover,
2128
+ borderSoft: ((o = n.border) == null ? void 0 : o.soft) ?? n.divider,
2129
+ fontFamilyMono: i ?? "ui-monospace, SFMono-Regular, Menlo, monospace"
2130
+ };
2131
+ }
2132
+ a(ge, "resolveComposerSurfaces");
2133
+ function Ba() {
2134
+ const e = /* @__PURE__ */ a(() => typeof window > "u" ? { width: 0, height: 0 } : { width: window.innerWidth, height: window.innerHeight }, "read"), [n, i] = L(e);
2135
+ return q(() => {
2136
+ if (typeof window > "u") return;
2137
+ const l = /* @__PURE__ */ a(() => i(e()), "onResize");
2138
+ return window.addEventListener("resize", l), () => window.removeEventListener("resize", l);
2139
+ }, []), n;
2140
+ }
2141
+ a(Ba, "useWindowSize");
2142
+ const Wt = /* @__PURE__ */ a((e) => e.toString().padStart(2, "0"), "pad2"), pt = /* @__PURE__ */ a((e) => `${e.getFullYear()}-${Wt(e.getMonth() + 1)}-${Wt(e.getDate())}`, "isoDate"), Wn = /* @__PURE__ */ a((e) => {
2143
+ const n = he(), i = ge(n), l = me(), r = N((O) => {
2144
+ var k;
2145
+ return ((k = O.publishedDashboard) == null ? void 0 : k.jsFileName) ?? null;
2146
+ }), o = N((O) => O.publishedDashboard), x = N((O) => O.llmCounter), b = N((O) => O.renderGeneration), g = N((O) => {
2147
+ var k;
2148
+ return ((k = O.publishedDashboard) == null ? void 0 : k.id) ?? null;
2149
+ }), d = N((O) => {
2150
+ var k;
2151
+ return ((k = O.publishedDashboard) == null ? void 0 : k.name) || "Dashboard";
2152
+ }), C = N((O) => {
2153
+ var k, U;
2154
+ return ((U = (k = O.publishedDashboard) == null ? void 0 : k.cards) == null ? void 0 : U.length) ?? 0;
2155
+ }), [s, u] = L(0), [m, c] = L(!1), [p, f] = L(e.defaultCollapsed ?? !1), [_, B] = L({});
2156
+ q(() => {
2157
+ if (!o) return;
2158
+ const O = {}, k = /* @__PURE__ */ new Date(), U = new Date(k.getTime() - 1e3 * 3600 * 24 * 30);
2159
+ for (const J of o.filters ?? [])
2160
+ J.mandatory && (J.filterType == "DateRangePicker" ? (O[`${J.name}_inicio`] = pt(U), O[`${J.name}_fim`] = pt(k)) : J.filterType == "DatePicker" && (O[J.name] = pt(k)));
2161
+ B(O);
2162
+ }, [o == null ? void 0 : o.filters, o]);
2163
+ const G = /* @__PURE__ */ a((O) => {
2164
+ var k;
2165
+ (k = e.onCollapseChange) == null || k.call(e, O), f(O);
2166
+ }, "changeCollapse");
2167
+ q(() => {
2168
+ G(e.defaultCollapsed ?? !1);
2169
+ }, [e.defaultCollapsed]);
2170
+ const z = p ? "25%" : e.width, { width: R, height: P } = Ba(), H = R > P ? 1.7 : 1, j = P > R ? 1.7 : 1, E = Math.min(R, P) * H, S = Math.min(R, P) * j, F = !!r, w = { color: n.palette.text.secondary, p: 0.5, "&:hover": { color: n.palette.text.primary, backgroundColor: i.hover } };
2171
+ return /* @__PURE__ */ t(tt, { initial: !1, children: F && o && /* @__PURE__ */ y(
2172
+ se.aside,
2173
+ {
2174
+ initial: { width: 0, opacity: 0 },
2175
+ animate: { width: z, opacity: 1 },
2176
+ exit: { width: 0, opacity: 0 },
2177
+ transition: { duration: 0.32, ease: [0.22, 0.8, 0.32, 1] },
2178
+ style: { overflow: "hidden", display: "inline-flex", flexDirection: "column", borderLeft: `1px solid ${n.palette.divider}`, backgroundColor: n.palette.background.default, minHeight: 0 },
2179
+ children: [
2180
+ /* @__PURE__ */ y(se.div, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.28, delay: 0.08, ease: "easeOut" }, style: { display: "inline-flex", flexDirection: "column", minHeight: 0, position: "relative", height: "100%" }, children: [
2181
+ /* @__PURE__ */ y(v, { sx: { display: "inline-flex", alignItems: "center", width: "100%", gap: 1, px: 1.75, py: 1.25, borderBottom: `1px solid ${n.palette.divider}`, backgroundColor: n.palette.background.paper }, children: [
2182
+ /* @__PURE__ */ t(v, { sx: { color: n.palette.primary.main, display: "inline-flex" }, children: /* @__PURE__ */ t(De, { size: 15 }) }),
2183
+ /* @__PURE__ */ t(ee, { sx: { color: n.palette.text.primary, fontWeight: 500, fontSize: 12.5, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: d }),
2184
+ !p && /* @__PURE__ */ y(we, { children: [
2185
+ /* @__PURE__ */ t(ee, { sx: { color: n.palette.text.disabled, fontSize: 11, flexShrink: 0 }, children: "·" }),
2186
+ /* @__PURE__ */ y(ee, { sx: { fontFamily: i.fontFamilyMono, color: n.palette.text.secondary, fontSize: 11, flexShrink: 0 }, children: [
2187
+ C,
2188
+ " ",
2189
+ C === 1 ? "card" : "cards"
2190
+ ] })
2191
+ ] }),
2192
+ /* @__PURE__ */ t(v, { sx: { flex: 1 } }),
2193
+ /* @__PURE__ */ t(ue, { title: "Atualizar dados (ignora cache)", placement: "top", children: /* @__PURE__ */ t(Se, { size: "small", onClick: /* @__PURE__ */ a(() => u((O) => O + 1), "onClick"), sx: w, "aria-label": "Atualizar dados", children: /* @__PURE__ */ t(an, { sx: { fontSize: 18 } }) }) }),
2194
+ /* @__PURE__ */ t(ue, { title: p ? "Expandir" : "Diminuir", placement: "top", children: /* @__PURE__ */ t(Se, { size: "small", onClick: /* @__PURE__ */ a(() => G(!p), "onClick"), sx: w, "aria-label": p ? "Expandir" : "Diminuir", children: /* @__PURE__ */ t(Le, { size: 14 }) }) }),
2195
+ /* @__PURE__ */ t(ue, { title: "Tela cheia", placement: "top", children: /* @__PURE__ */ t(Se, { size: "small", onClick: /* @__PURE__ */ a(() => c(!0), "onClick"), sx: w, "aria-label": "Abrir em tela cheia", children: /* @__PURE__ */ t(Li, { sx: { fontSize: "18px" } }) }) })
2196
+ ] }),
2197
+ /* @__PURE__ */ y(v, { sx: { display: "inline-flex", height: "100%", width: "100%", minHeight: 0, overflow: "auto", backgroundColor: n.palette.background.default }, children: [
2198
+ g && !p && /* @__PURE__ */ t(
2199
+ _e,
2200
+ {
2201
+ dragLocked: !1,
2202
+ llmRenderCount: x + s,
2203
+ codeGeneration: b,
2204
+ dashboard: o,
2205
+ editable: !0,
2206
+ onLayoutCommit: /* @__PURE__ */ a(() => l.getState().commitDashboardLayout(), "onLayoutCommit"),
2207
+ onFiltersChanged: /* @__PURE__ */ a((O) => B(O), "onFiltersChanged")
2208
+ },
2209
+ g
2210
+ ),
2211
+ g && p && /* @__PURE__ */ t(oi, { llmRenderCount: x + s, codeGeneration: b, dashboard: o, parameters: _ }, g)
2212
+ ] })
2213
+ ] }),
2214
+ /* @__PURE__ */ y(ln, { open: m, onClose: /* @__PURE__ */ a(() => c(!1), "onClose"), maxWidth: !1, fullScreen: !0, slotProps: { paper: { sx: { backgroundColor: n.palette.background.default, backgroundImage: "none", color: n.palette.text.primary } } }, children: [
2215
+ /* @__PURE__ */ y(v, { sx: { display: "flex", alignItems: "center", gap: 1, px: 2, py: 1.25, borderBottom: `1px solid ${n.palette.divider}`, backgroundColor: n.palette.background.paper, flexShrink: 0 }, children: [
2216
+ /* @__PURE__ */ t(v, { sx: { color: n.palette.primary.main, display: "inline-flex" }, children: /* @__PURE__ */ t(De, { size: 16 }) }),
2217
+ /* @__PURE__ */ t(ee, { sx: { color: n.palette.text.primary, fontWeight: 500, fontSize: 13.5 }, children: d }),
2218
+ /* @__PURE__ */ t(ee, { sx: { color: n.palette.text.disabled, fontSize: 12 }, children: "·" }),
2219
+ /* @__PURE__ */ y(ee, { sx: { fontFamily: i.fontFamilyMono, color: n.palette.text.secondary, fontSize: 12 }, children: [
2220
+ C,
2221
+ " ",
2222
+ C === 1 ? "card" : "cards"
2223
+ ] }),
2224
+ /* @__PURE__ */ t(v, { sx: { flex: 1 } }),
2225
+ /* @__PURE__ */ t(ue, { title: "Fechar", placement: "left", children: /* @__PURE__ */ t(Se, { size: "small", onClick: /* @__PURE__ */ a(() => c(!1), "onClick"), sx: { ...w, p: 0.75 }, "aria-label": "Fechar", children: /* @__PURE__ */ t(Tt, { size: 14 }) }) })
2226
+ ] }),
2227
+ /* @__PURE__ */ t(v, { sx: { width: "100%", justifyContent: "center", display: "inline-flex" }, children: /* @__PURE__ */ t(v, { sx: { minHeight: 0, overflow: "hidden", width: E, height: S, backgroundColor: n.palette.background.default }, children: g && /* @__PURE__ */ t(_e, { dragLocked: !1, llmRenderCount: x, codeGeneration: b, dashboard: o }, g) }) })
2228
+ ] })
2229
+ ]
2230
+ },
2231
+ "dashboard-side-panel"
2232
+ ) });
2233
+ }, "DashboardSidePanelInner");
2234
+ Wn.displayName = "DashboardSidePanel";
2235
+ const Vn = Be.memo(Wn), La = it(ve), Ga = [], He = /* @__PURE__ */ a(({ children: e }) => /* @__PURE__ */ t(ee, { sx: /* @__PURE__ */ a((n) => ({ fontSize: 9.5, color: n.palette.text.disabled, textTransform: "uppercase", letterSpacing: 0.6, fontWeight: 500, lineHeight: 1.6 }), "sx"), children: e }), "RailSectionLabel");
2236
+ function Vt(e, n) {
2237
+ const i = new Map(e.map((b) => [b.i, b])), l = new Map(n.map((b) => [b.i, b]));
2238
+ let r = 0, o = 0, x = 0;
2239
+ for (const [b, g] of i) {
2240
+ const d = l.get(b);
2241
+ d ? JSON.stringify(g) !== JSON.stringify(d) && x++ : r++;
2242
+ }
2243
+ for (const b of l.keys()) i.has(b) || o++;
2244
+ return { added: r, removed: o, modified: x };
2245
+ }
2246
+ a(Vt, "diffById");
2247
+ function jt(e, n, i) {
2248
+ return {
2249
+ background: n.raised,
2250
+ border: `1px solid ${e.palette.divider}`,
2251
+ color: e.palette.text.primary,
2252
+ fontFamily: e.typography.fontFamily,
2253
+ fontSize: 11,
2254
+ fontWeight: 500,
2255
+ px: 1,
2256
+ py: 0.625,
2257
+ borderRadius: 1,
2258
+ cursor: i ? "not-allowed" : "pointer",
2259
+ opacity: i ? 0.45 : 1,
2260
+ display: "inline-flex",
2261
+ alignItems: "center",
2262
+ justifyContent: "flex-start",
2263
+ gap: 0.625,
2264
+ transition: "filter .12s, background-color .12s, border-color .12s, color .12s",
2265
+ "&:hover": i ? void 0 : { backgroundColor: n.hover }
2266
+ };
2267
+ }
2268
+ a(jt, "railActionPill");
2269
+ const Ha = /* @__PURE__ */ a(({ locked: e, name: n, onNameChange: i, layoutType: l, onLayoutTypeChange: r, onAddGenericCard: o, onAddTypedCard: x, onAddFilter: b, cardsOpened: g, filters: d, onEditFilter: C, onDeleteFilter: s, datasetControls: u }) => {
2270
+ const m = he(), c = ge(m), p = Ae(), [f, _] = L(null), [B, G] = L(null), z = te(null), [R, P] = L(!1);
2271
+ q(() => {
2272
+ z.current && g && z.current.click();
2273
+ }, [g]);
2274
+ const H = { display: "flex", flexDirection: "column", gap: 0.5, px: 1, pt: 1, pb: 0.875, borderBottom: `1px solid ${c.borderSoft}` }, j = { fontSize: 12, color: m.palette.text.primary, "&:hover": { backgroundColor: c.hover } }, E = { backgroundColor: c.raised, border: `1px solid ${m.palette.divider}`, ml: 0.5, minWidth: 260, maxHeight: 420, overflow: "auto" };
2275
+ return /* @__PURE__ */ y(
2276
+ se.aside,
2277
+ {
2278
+ animate: { width: R ? 44 : "12vw" },
2279
+ transition: { duration: 0.22, ease: [0.22, 0.8, 0.32, 1] },
2280
+ style: { flexShrink: 0, display: "flex", flexDirection: "column", borderRight: `1px solid ${c.borderSoft}`, backgroundColor: m.palette.background.paper, overflow: "hidden", minHeight: 0 },
2281
+ children: [
2282
+ /* @__PURE__ */ y(v, { sx: { flexShrink: 0, display: "flex", alignItems: "center", gap: 0.625, pl: 1, pr: 1, py: 1.5, borderBottom: `1px solid ${c.borderSoft}` }, children: [
2283
+ /* @__PURE__ */ t(ue, { title: R ? "Expandir painel" : "Recolher painel", placement: "right", children: /* @__PURE__ */ t(Se, { size: "small", onClick: /* @__PURE__ */ a(() => P((S) => !S), "onClick"), sx: { color: m.palette.text.primary, p: 0.5, flexShrink: 0, "&:hover": { color: m.palette.primary.main } }, "aria-label": R ? "Expandir painel" : "Recolher painel", children: /* @__PURE__ */ t(Le, { size: 13 }) }) }),
2284
+ !R && /* @__PURE__ */ t(ee, { sx: { color: m.palette.text.primary, fontWeight: 500, fontSize: 11.5, lineHeight: 1.2, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: "Desenhe seu prompt" })
2285
+ ] }),
2286
+ !R && /* @__PURE__ */ y(v, { sx: { flex: 1, minHeight: 0, overflowY: "auto", display: "flex", flexDirection: "column" }, children: [
2287
+ /* @__PURE__ */ y(v, { sx: { ...H, gap: 0.25 }, children: [
2288
+ /* @__PURE__ */ t(He, { children: "Nome" }),
2289
+ /* @__PURE__ */ t(v, { sx: { color: m.palette.text.primary, fontFamily: m.typography.fontFamily, fontSize: 12 }, children: /* @__PURE__ */ t(Ge, { placeHolderText: "novo dashboard", onEdit: i, text: n, fontSize: 12 }) })
2290
+ ] }),
2291
+ /* @__PURE__ */ y(v, { sx: { ...H, p: 1 }, children: [
2292
+ /* @__PURE__ */ y(
2293
+ v,
2294
+ {
2295
+ ref: z,
2296
+ component: "button",
2297
+ onClick: /* @__PURE__ */ a((S) => _(S.currentTarget), "onClick"),
2298
+ disabled: e,
2299
+ "data-env-id": "dashboardpad-add-card",
2300
+ "data-env-key": "dashboardpad-add-card-dropdown",
2301
+ className: "llm-env-target llm-env-dashboard-action",
2302
+ sx: jt(m, c, e),
2303
+ children: [
2304
+ /* @__PURE__ */ t(yt, { size: 11 }),
2305
+ /* @__PURE__ */ t(v, { component: "span", children: "Card" })
2306
+ ]
2307
+ }
2308
+ ),
2309
+ /* @__PURE__ */ y(v, { component: "button", onClick: /* @__PURE__ */ a((S) => G(S.currentTarget), "onClick"), disabled: e, "data-env-id": "dashboardpad-add-filter", className: "llm-env-target llm-env-dashboard-action", sx: jt(m, c, e), children: [
2310
+ /* @__PURE__ */ t(ji, { size: 11 }),
2311
+ /* @__PURE__ */ t(v, { component: "span", children: "Filtro" })
2312
+ ] })
2313
+ ] }),
2314
+ d.length > 0 ? /* @__PURE__ */ y(v, { sx: { p: 1, display: "flex", flexDirection: "column", gap: 0.625 }, children: [
2315
+ /* @__PURE__ */ y(He, { children: [
2316
+ "Filtros · ",
2317
+ d.length
2318
+ ] }),
2319
+ d.map((S) => /* @__PURE__ */ t($t, { filter: S, onEdit: C, onDelete: s }, S.i))
2320
+ ] }) : /* @__PURE__ */ t(v, { sx: { p: 1, display: "flex", alignItems: "flex-start" }, children: /* @__PURE__ */ y(ee, { sx: { fontSize: 10, color: m.palette.text.disabled, fontStyle: "italic", lineHeight: 1.4 }, children: [
2321
+ "Nenhum filtro ainda. Use ",
2322
+ /* @__PURE__ */ t("b", { children: "+ Filtro" }),
2323
+ " para adicionar."
2324
+ ] }) }),
2325
+ /* @__PURE__ */ y(v, { sx: { ...H, borderBottom: "none", borderTop: `1px solid ${c.borderSoft}` }, children: [
2326
+ /* @__PURE__ */ t(He, { children: "Layout" }),
2327
+ /* @__PURE__ */ y(
2328
+ Qi,
2329
+ {
2330
+ exclusive: !0,
2331
+ size: "small",
2332
+ value: l,
2333
+ onChange: /* @__PURE__ */ a((S, F) => F && r(F), "onChange"),
2334
+ disabled: e,
2335
+ "data-env-id": "dashboard-pad-layout-toggle",
2336
+ className: "llm-env-target llm-env-layout-toggle",
2337
+ sx: {
2338
+ height: 24,
2339
+ "& .MuiToggleButton-root": {
2340
+ flex: 1,
2341
+ px: 0.875,
2342
+ py: 0,
2343
+ fontSize: 10.5,
2344
+ textTransform: "none",
2345
+ color: m.palette.text.secondary,
2346
+ border: `1px solid ${m.palette.divider}`,
2347
+ "&.Mui-selected": { color: m.palette.text.primary, backgroundColor: c.hover },
2348
+ "&.Mui-selected:hover": { backgroundColor: c.hover }
2349
+ }
2350
+ },
2351
+ children: [
2352
+ /* @__PURE__ */ t(Gt, { value: "Boxed", "data-env-id": "dashboard-pad-layout-boxed", children: "Boxed" }),
2353
+ /* @__PURE__ */ t(Gt, { value: "Naked", "data-env-id": "dashboard-pad-layout-naked", children: "Naked" })
2354
+ ]
2355
+ }
2356
+ )
2357
+ ] }),
2358
+ u && /* @__PURE__ */ y(v, { sx: { ...H, borderBottom: "none", borderTop: `1px solid ${c.borderSoft}` }, children: [
2359
+ /* @__PURE__ */ t(He, { children: "Dataset / Agent" }),
2360
+ u
2361
+ ] })
2362
+ ] }),
2363
+ /* @__PURE__ */ t(Lt, { open: !!f, anchorEl: f, onClose: /* @__PURE__ */ a(() => _(null), "onClose"), anchorOrigin: { vertical: "top", horizontal: "right" }, transformOrigin: { vertical: "top", horizontal: "left" }, slotProps: { paper: { sx: E } }, children: /* @__PURE__ */ y(Bt, { dense: !0, children: [
2364
+ /* @__PURE__ */ y(
2365
+ dt,
2366
+ {
2367
+ onClick: /* @__PURE__ */ a(() => {
2368
+ o(), _(null);
2369
+ }, "onClick"),
2370
+ sx: j,
2371
+ children: [
2372
+ /* @__PURE__ */ t(lt, { sx: { color: m.palette.primary.main, minWidth: 28 }, children: /* @__PURE__ */ t(yt, { size: 14 }) }),
2373
+ /* @__PURE__ */ t(st, { primaryTypographyProps: { fontSize: 12, fontWeight: 500 }, secondaryTypographyProps: { fontSize: 10.5, color: m.palette.text.disabled }, primary: "Genérico", secondary: "Card sem tipo definido — você ou o agente preenche depois" })
2374
+ ]
2375
+ }
2376
+ ),
2377
+ /* @__PURE__ */ t(Nt, { sx: { borderColor: c.borderSoft } }),
2378
+ Object.entries(La).map(([S, F], w) => {
2379
+ const O = p.category[S];
2380
+ return /* @__PURE__ */ y(v, { children: [
2381
+ w > 0 && /* @__PURE__ */ t(Nt, { sx: { borderColor: c.borderSoft } }),
2382
+ /* @__PURE__ */ y(ee, { sx: { px: 2, pt: 1, pb: 0.5, fontSize: 10, textTransform: "uppercase", letterSpacing: 0.6, color: m.palette.text.disabled, display: "flex", alignItems: "center", gap: 0.5 }, children: [
2383
+ /* @__PURE__ */ t(O, { fontSize: "inherit" }),
2384
+ " ",
2385
+ S
2386
+ ] }),
2387
+ F.map((k) => {
2388
+ const U = p.specificType[k.specificType];
2389
+ return /* @__PURE__ */ y(
2390
+ dt,
2391
+ {
2392
+ onClick: /* @__PURE__ */ a(() => {
2393
+ x(k.category, k.specificType), _(null);
2394
+ }, "onClick"),
2395
+ sx: j,
2396
+ children: [
2397
+ /* @__PURE__ */ t(lt, { sx: { color: m.palette.text.secondary, minWidth: 28 }, children: /* @__PURE__ */ t(U, { fontSize: "small" }) }),
2398
+ /* @__PURE__ */ t(st, { primaryTypographyProps: { fontSize: 12 }, children: k.label })
2399
+ ]
2400
+ },
2401
+ k.specificType
2402
+ );
2403
+ })
2404
+ ] }, S);
2405
+ })
2406
+ ] }) }),
2407
+ /* @__PURE__ */ t(Lt, { open: !!B, anchorEl: B, onClose: /* @__PURE__ */ a(() => G(null), "onClose"), anchorOrigin: { vertical: "top", horizontal: "right" }, transformOrigin: { vertical: "top", horizontal: "left" }, slotProps: { paper: { sx: { ...E, minWidth: 220, maxHeight: void 0 } } }, children: /* @__PURE__ */ t(Bt, { dense: !0, children: kt.map((S) => {
2408
+ const F = p.filterType[S.filterType];
2409
+ return /* @__PURE__ */ y(
2410
+ dt,
2411
+ {
2412
+ onClick: /* @__PURE__ */ a(() => {
2413
+ b(S.filterType), G(null);
2414
+ }, "onClick"),
2415
+ sx: j,
2416
+ children: [
2417
+ /* @__PURE__ */ t(lt, { sx: { color: m.palette.text.secondary, minWidth: 28 }, children: /* @__PURE__ */ t(F, { fontSize: "small" }) }),
2418
+ /* @__PURE__ */ t(st, { primaryTypographyProps: { fontSize: 12 }, children: S.label })
2419
+ ]
2420
+ },
2421
+ S.filterType
2422
+ );
2423
+ }) }) })
2424
+ ]
2425
+ }
2426
+ );
2427
+ }, "LeftRail");
2428
+ function jn(e) {
2429
+ const [n, i] = L(!1), l = te(!0);
2430
+ return q(() => {
2431
+ if (l.current) {
2432
+ l.current = !1;
2433
+ return;
2434
+ }
2435
+ i(e > 0);
2436
+ const r = window.setTimeout(() => i(!1), 2500);
2437
+ return () => window.clearTimeout(r);
2438
+ }, [e]), n;
2439
+ }
2440
+ a(jn, "usePulseTooltip");
2441
+ const Un = /* @__PURE__ */ a((e, n, i) => ({
2442
+ initial: i > 0 ? { scale: 1.18, backgroundColor: e.palette.primary.main, borderColor: e.palette.primary.main } : !1,
2443
+ animate: { scale: 1, backgroundColor: n.raised, borderColor: e.palette.divider },
2444
+ transition: { duration: 2, ease: [0.22, 0.8, 0.32, 1] },
2445
+ style: {
2446
+ display: "inline-flex",
2447
+ alignItems: "center",
2448
+ gap: 6,
2449
+ backgroundColor: n.raised,
2450
+ borderStyle: "solid",
2451
+ borderWidth: 1,
2452
+ borderColor: e.palette.divider,
2453
+ borderRadius: 999,
2454
+ paddingLeft: 10,
2455
+ paddingRight: 4,
2456
+ paddingTop: 3,
2457
+ paddingBottom: 3,
2458
+ fontSize: 11,
2459
+ color: e.palette.text.primary,
2460
+ transformOrigin: "center center"
2461
+ }
2462
+ }), "chipMotionProps"), Kn = /* @__PURE__ */ a(({ cardCount: e, surfaces: n }) => /* @__PURE__ */ y(we, { children: [
2463
+ /* @__PURE__ */ t(v, { sx: /* @__PURE__ */ a((i) => ({ color: i.palette.primary.main, display: "inline-flex" }), "sx"), children: /* @__PURE__ */ t(Le, { size: 12 }) }),
2464
+ /* @__PURE__ */ t(v, { component: "span", sx: { fontWeight: 500 }, children: "Sketch" }),
2465
+ /* @__PURE__ */ t(v, { component: "span", sx: /* @__PURE__ */ a((i) => ({ color: i.palette.text.disabled }), "sx"), children: "·" }),
2466
+ /* @__PURE__ */ y(v, { component: "span", sx: /* @__PURE__ */ a((i) => ({ fontFamily: n.fontFamilyMono, color: i.palette.text.secondary }), "sx"), children: [
2467
+ e,
2468
+ " ",
2469
+ e === 1 ? "card" : "cards"
2470
+ ] })
2471
+ ] }), "ChipHead"), Wa = /* @__PURE__ */ a(({ cardCount: e, expanded: n, locked: i, onToggle: l, pulseTick: r = 0 }) => {
2472
+ const o = he(), x = ge(o), b = jn(r);
2473
+ return /* @__PURE__ */ t(
2474
+ ue,
2475
+ {
2476
+ title: "O agente atualizou o sketch — clique em editar para ver",
2477
+ placement: "top-end",
2478
+ arrow: !0,
2479
+ slotProps: { popper: { modifiers: [{ name: "offset", options: { offset: [0, 5] } }] }, tooltip: { sx: { backgroundColor: x.raised, border: `1px solid ${o.palette.primary.dark}`, color: o.palette.primary.dark } } },
2480
+ open: b,
2481
+ disableHoverListener: !0,
2482
+ disableFocusListener: !0,
2483
+ disableTouchListener: !0,
2484
+ children: /* @__PURE__ */ y(se.div, { ...Un(o, x, r), children: [
2485
+ /* @__PURE__ */ t(Kn, { cardCount: e, surfaces: x }),
2486
+ /* @__PURE__ */ t(ue, { title: n ? "Recolher sketch" : "Editar sketch", placement: "top", children: /* @__PURE__ */ t(
2487
+ v,
2488
+ {
2489
+ component: "button",
2490
+ onClick: l,
2491
+ disabled: i,
2492
+ sx: {
2493
+ background: x.raised,
2494
+ border: `1px solid ${o.palette.divider}`,
2495
+ color: o.palette.text.primary,
2496
+ fontFamily: o.typography.fontFamily,
2497
+ fontSize: 11.5,
2498
+ display: "inline-flex",
2499
+ alignItems: "center",
2500
+ gap: 0.625,
2501
+ pl: 1,
2502
+ pr: 1.25,
2503
+ py: 0.625,
2504
+ borderRadius: 999,
2505
+ cursor: i ? "not-allowed" : "pointer",
2506
+ opacity: i ? 0.45 : 1,
2507
+ transition: "background-color 2s, border-color 2s",
2508
+ "&:hover": i ? void 0 : { backgroundColor: x.hover, borderColor: o.palette.primary.main }
2509
+ },
2510
+ children: n ? /* @__PURE__ */ t(Le, { size: 13 }) : /* @__PURE__ */ t(ea, { sx: { fontSize: 14 } })
2511
+ }
2512
+ ) })
2513
+ ] }, r + i.toString())
2514
+ }
2515
+ );
2516
+ }, "SketchChip"), Va = /* @__PURE__ */ a(({ cardCount: e, locked: n, onCreate: i, pulseTick: l = 0 }) => {
2517
+ const r = he(), o = ge(r), x = jn(l), b = n || !i;
2518
+ return /* @__PURE__ */ t(
2519
+ ue,
2520
+ {
2521
+ title: "O agente atualizou o sketch — clique em editar para ver",
2522
+ placement: "top",
2523
+ slotProps: { popper: { modifiers: [{ name: "offset", options: { offset: [0, 5] } }] }, tooltip: { sx: { backgroundColor: o.raised, color: r.palette.primary.main } } },
2524
+ open: x,
2525
+ disableHoverListener: !0,
2526
+ disableFocusListener: !0,
2527
+ disableTouchListener: !0,
2528
+ children: /* @__PURE__ */ y(se.div, { ...Un(r, o, l), children: [
2529
+ /* @__PURE__ */ t(Kn, { cardCount: e, surfaces: o }),
2530
+ /* @__PURE__ */ y(
2531
+ v,
2532
+ {
2533
+ component: "button",
2534
+ onClick: i,
2535
+ disabled: b,
2536
+ "data-env-id": "dashboard-pad-new",
2537
+ className: "llm-env-target llm-env-dashboard-action",
2538
+ sx: {
2539
+ background: o.raised,
2540
+ border: "none",
2541
+ color: r.palette.text.primary,
2542
+ fontFamily: r.typography.fontFamily,
2543
+ fontSize: 11.5,
2544
+ display: "inline-flex",
2545
+ alignItems: "center",
2546
+ gap: 0.625,
2547
+ pl: 1,
2548
+ pr: 1.25,
2549
+ py: 0.625,
2550
+ borderRadius: 999,
2551
+ cursor: b ? "not-allowed" : "pointer",
2552
+ opacity: b ? 0.45 : 1,
2553
+ transition: "background-color .12s, border-color .12s",
2554
+ "&:hover": b ? void 0 : { backgroundColor: o.hover, borderColor: r.palette.primary.main }
2555
+ },
2556
+ children: [
2557
+ /* @__PURE__ */ t(v, { sx: { color: r.palette.primary.main, display: "inline-flex", backgroundColor: r.palette.background.default, borderRadius: 999, p: 0.25, border: `1px solid ${o.borderSoft}` }, children: /* @__PURE__ */ t(yt, { size: 11 }) }),
2558
+ /* @__PURE__ */ t(v, { component: "span", sx: { fontWeight: 500 }, children: "Adicionar sketch" }),
2559
+ /* @__PURE__ */ t(v, { component: "span", sx: { color: r.palette.text.disabled, fontFamily: o.fontFamilyMono, fontSize: 10.5 }, children: "desenhe o layout antes de pedir" })
2560
+ ]
2561
+ }
2562
+ )
2563
+ ] }, l)
2564
+ }
2565
+ );
2566
+ }, "AddSketchChip"), Yn = Ct(({ onCreateSketch: e, onBeforeSend: n, sketchExpanded: i, bottomSlot: l, zoomLevel: r, onSketchExpandedChange: o, seedDraft: x, compact: b, datasetControls: g, renderDescription: d }, C) => {
2567
+ const s = me(), [u, m] = L(x);
2568
+ q(() => {
2569
+ m(x);
2570
+ }, [x]);
2571
+ const c = te(null), p = N((D) => D.agentPulseTick), f = N((D) => {
2572
+ var $;
2573
+ return (($ = D.dashboardDefinition) == null ? void 0 : $.id) ?? null;
2574
+ }), _ = N((D) => {
2575
+ var $;
2576
+ return (($ = D.dashboardDefinition) == null ? void 0 : $.name) ?? "";
2577
+ }), B = N((D) => {
2578
+ var $, oe;
2579
+ return ((oe = ($ = D.dashboardDefinition) == null ? void 0 : $.cards) == null ? void 0 : oe.length) ?? 0;
2580
+ }), G = N((D) => {
2581
+ var $, oe;
2582
+ return ((oe = ($ = D.dashboardDefinition) == null ? void 0 : $.filters) == null ? void 0 : oe.length) ?? 0;
2583
+ }), z = N((D) => D.currentSessionId), R = N((D) => {
2584
+ var $;
2585
+ return ($ = D.dashboardDefinition) == null ? void 0 : $.filters;
2586
+ }) ?? Ga, P = N((D) => {
2587
+ var $;
2588
+ return (($ = D.dashboardDefinition) == null ? void 0 : $.layoutType) ?? "Boxed";
2589
+ }), H = N((D) => D.turnOpen), j = N((D) => {
2590
+ var $;
2591
+ return (($ = D.dashboardDefinition) == null ? void 0 : $.clientSideChanges) ?? null;
2592
+ }), E = N((D) => D.dashboardDefinition), S = N((D) => D.lastSentDashboard), [F, w] = L(!1), O = ze(() => {
2593
+ if (!E && !S) return { hasAny: !1, text: null };
2594
+ if (!E || !S) return { hasAny: !0, text: "Sketch alterado" };
2595
+ const D = Vt(E.cards ?? [], S.cards ?? []), $ = Vt(E.filters ?? [], S.filters ?? []), oe = (E.name ?? "") !== (S.name ?? ""), fe = (E.layoutType ?? "Boxed") !== (S.layoutType ?? "Boxed");
2596
+ if (D.added + D.removed + D.modified + $.added + $.removed + $.modified === 0 && !oe && !fe) return { hasAny: !1, text: null };
2597
+ const pe = [];
2598
+ return D.added && pe.push(`+${D.added} ${D.added === 1 ? "card" : "cards"}`), D.removed && pe.push(`-${D.removed} ${D.removed === 1 ? "card" : "cards"}`), D.modified && pe.push(`${D.modified} ${D.modified === 1 ? "card alterado" : "cards alterados"}`), $.added && pe.push(`+${$.added} ${$.added === 1 ? "filtro" : "filtros"}`), $.removed && pe.push(`-${$.removed} ${$.removed === 1 ? "filtro" : "filtros"}`), $.modified && pe.push(`${$.modified} ${$.modified === 1 ? "filtro alterado" : "filtros alterados"}`), pe.length === 0 && pe.push("Sketch alterado"), { hasAny: !0, text: pe.join(" · ") };
2599
+ }, [E, S]), k = O.hasAny, U = O.text, J = !!f || B > 0 || G > 0, Z = /* @__PURE__ */ a(async (D) => {
2600
+ m(""), s.getState().commitForSend(), n && await n(D);
2601
+ }, "handleOnBefore"), ie = i ?? !1, de = /* @__PURE__ */ a((D) => o == null ? void 0 : o(D), "setSketchExpanded"), V = /* @__PURE__ */ a(() => {
2602
+ w(!0), setTimeout(() => w(!1), 1e3);
2603
+ }, "handleForceOpenCard"), Q = /* @__PURE__ */ a((D) => {
2604
+ const $ = D.length === 0 ? "Untitled Dashboard" : D;
2605
+ s.getState().recordSketchChange("dashboard:name", `Renamed dashboard to '${$}'`), s.getState().updateDashboard({ name: $ });
2606
+ }, "handleNameChange"), T = /* @__PURE__ */ a((D) => {
2607
+ s.getState().recordSketchChange("dashboard:layoutType", `Set layout type to ${D}`), s.getState().updateDashboard({ layoutType: D });
2608
+ }, "handleLayoutTypeChange"), K = /* @__PURE__ */ a(() => {
2609
+ var D;
2610
+ return (D = c.current) == null ? void 0 : D.addGenericCell();
2611
+ }, "handleAddGenericCard"), re = /* @__PURE__ */ a((D, $) => {
2612
+ var oe;
2613
+ return (oe = c.current) == null ? void 0 : oe.addTypedCell(D, $, "");
2614
+ }, "handleAddTypedCard"), h = /* @__PURE__ */ a((D) => {
2615
+ var $;
2616
+ return ($ = c.current) == null ? void 0 : $.handleAddFilter(D);
2617
+ }, "handleAddFilter"), I = /* @__PURE__ */ a((D) => {
2618
+ var oe;
2619
+ const $ = ((oe = s.getState().dashboardDefinition) == null ? void 0 : oe.filters) ?? [];
2620
+ s.getState().recordSketchChange(`filter:${D.i}:edit`, `Edited filter '${D.name}'`), s.getState().updateDashboard({ filters: $.map((fe) => fe.i === D.i ? { ...D } : fe) });
2621
+ }, "handleEditFilter"), A = /* @__PURE__ */ a((D) => {
2622
+ var fe;
2623
+ const $ = ((fe = s.getState().dashboardDefinition) == null ? void 0 : fe.filters) ?? [], oe = $.find((be) => be.i === D);
2624
+ s.getState().recordSketchChange(`filter:${D}:delete`, `Deleted filter '${(oe == null ? void 0 : oe.name) ?? D}'`), s.getState().updateDashboard({ filters: $.filter((be) => be.i !== D) });
2625
+ }, "handleDeleteFilter"), M = /* @__PURE__ */ y(v, { sx: { display: "flex", flexDirection: "column" }, children: [
2626
+ /* @__PURE__ */ y(tt, { mode: "wait", initial: !1, children: [
2627
+ !J && !ie && /* @__PURE__ */ t(se.div, { initial: { opacity: 0, height: 0 }, animate: { opacity: 1, height: "auto" }, exit: { opacity: 0, height: 0 }, transition: { duration: 0.18, ease: "easeOut" }, children: /* @__PURE__ */ t(v, { sx: { px: 1.25, py: 1, display: "flex", alignItems: "center" }, children: /* @__PURE__ */ t(Va, { onCreate: e, locked: H, cardCount: B, pulseTick: p }) }) }, "add-sketch"),
2628
+ ie && /* @__PURE__ */ t(se.div, { style: { overflow: "hidden" }, initial: { opacity: 0, height: 0 }, animate: { opacity: 1, height: "auto" }, exit: { opacity: 0, height: 0 }, transition: { duration: 0.25, ease: "easeOut" }, children: /* @__PURE__ */ y(v, { sx: /* @__PURE__ */ a((D) => ({ flexShrink: 0, height: "min(50vh, 300px)", minHeight: 280, display: "flex", flexDirection: "row", overflow: "auto", background: D.palette.background.default }), "sx"), children: [
2629
+ /* @__PURE__ */ t(
2630
+ Ha,
2631
+ {
2632
+ locked: H,
2633
+ name: _,
2634
+ onNameChange: Q,
2635
+ layoutType: P,
2636
+ onLayoutTypeChange: T,
2637
+ onAddGenericCard: K,
2638
+ onAddTypedCard: re,
2639
+ onAddFilter: h,
2640
+ cardsOpened: F,
2641
+ filters: R,
2642
+ onEditFilter: I,
2643
+ onDeleteFilter: A,
2644
+ datasetControls: g
2645
+ }
2646
+ ),
2647
+ /* @__PURE__ */ t(v, { sx: { flex: 1, pt: 1, minWidth: 0, display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ t(ot, { ref: c, zoomLevel: r, onAddCard: V, renderId: "composer-pad", hideInternalHeader: !0, hideFiltersInSketch: !0, renderDescription: d }) })
2648
+ ] }) }, "sketch-expanded")
2649
+ ] }),
2650
+ J && /* @__PURE__ */ t(
2651
+ se.div,
2652
+ {
2653
+ initial: { opacity: ie ? 0 : 1, height: 0, display: ie ? "flex" : "none" },
2654
+ animate: { opacity: ie ? 0 : 1, height: "auto", display: ie ? "none" : "flex" },
2655
+ exit: { opacity: J ? 1 : 0, height: 0, display: "flex" },
2656
+ transition: { duration: 0.5, ease: "easeInOut" },
2657
+ children: /* @__PURE__ */ y(v, { sx: { display: "flex", alignItems: "center", gap: 1, px: 1.25, py: 0.875 }, children: [
2658
+ /* @__PURE__ */ t(Wa, { cardCount: B, expanded: ie, locked: H, onToggle: /* @__PURE__ */ a(() => de(!ie), "onToggle"), pulseTick: p }),
2659
+ /* @__PURE__ */ t(ee, { sx: /* @__PURE__ */ a((D) => ({ color: D.palette.text.primary, fontWeight: 500, fontSize: 11.5, lineHeight: 1.2, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }), "sx"), children: _ })
2660
+ ] })
2661
+ },
2662
+ "filled-sketch"
2663
+ )
2664
+ ] }), X = ze(() => {
2665
+ const D = "Será enviado junto com a mensagem", $ = Dt(j ?? void 0);
2666
+ return $ ? `${D}:
2667
+
2668
+ ${$}` : D;
2669
+ }, [j]);
2670
+ return /* @__PURE__ */ t(
2671
+ Vi,
2672
+ {
2673
+ ref: C,
2674
+ seedDraft: u,
2675
+ showLastPrompts: !1,
2676
+ topSlot: M,
2677
+ topSlotCollapsible: J || ie,
2678
+ topSlotExpanded: ie,
2679
+ onTopSlotExpandedChange: de,
2680
+ onBeforeSend: Z,
2681
+ sendButtonProps: { "data-env-id": "dashboard-pad-compose", className: "llm-env-target llm-env-dashboard-action" },
2682
+ allowEmptyDraft: k,
2683
+ submitAdornment: U ? /* @__PURE__ */ t(ue, { placement: "top", title: X, slotProps: { tooltip: { sx: { whiteSpace: "pre-line", maxWidth: 360, fontSize: 11.5, lineHeight: 1.4, fontFamily: /* @__PURE__ */ a((D) => D.typography.fontFamily, "fontFamily") } } }, children: /* @__PURE__ */ t(v, { sx: /* @__PURE__ */ a((D) => ({ display: "inline-flex", alignItems: "center", gap: 0.5, px: 0.875, py: 0.25, mr: 0.75, borderRadius: 999, border: `1px solid ${D.palette.primary.dark}`, color: D.palette.primary.main, fontFamily: D.typography.fontFamily, fontSize: 10.5, lineHeight: 1.2, whiteSpace: "nowrap", pointerEvents: "auto" }), "sx"), children: U }) }) : null,
2684
+ inputMinHeight: ie || b ? 40 : 120
2685
+ },
2686
+ z ?? "no-session"
2687
+ );
2688
+ });
2689
+ Yn.displayName = "DrawablePrompt";
2690
+ const qn = Be.memo(Yn), Jn = [
2691
+ {
2692
+ label: "Compare vendas e reservas por semana, focando em rotas internacionais",
2693
+ prompt: "Crie uma sugestão de dashboard de vendas e reservas por semana, focando em rotas nacionais. Envie um rascunho pronto para carregar na minha interface."
2694
+ },
2695
+ {
2696
+ label: "Me ajude a entender como o Dashboard Composer funciona",
2697
+ prompt: "Me ajude a entender como o Dashboard Composer funciona. Apresente os tipos de gráficos e depois envie um guia ao vivo, do passo a passo da interface"
2698
+ }
2699
+ ];
2700
+ function ja({ kinds: e, accent: n }) {
2701
+ const i = he(), l = ge(i), r = n ? i.palette.primary.main : i.palette.text.disabled;
2702
+ return e.length === 0 ? /* @__PURE__ */ t(v, { sx: { width: "100%", height: 56, display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 0.375 }, children: Array.from({ length: 6 }).map((o, x) => /* @__PURE__ */ t(v, { sx: { background: i.palette.background.default, border: `1px dashed ${l.borderSoft}`, borderRadius: 0.5 } }, x)) }) : /* @__PURE__ */ t(v, { sx: { width: "100%", height: 56, display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 0.375 }, children: e.slice(0, 6).map((o, x) => /* @__PURE__ */ y(
2703
+ v,
2704
+ {
2705
+ sx: {
2706
+ background: i.palette.background.default,
2707
+ border: `1px solid ${n ? i.palette.primary.main : l.borderSoft}`,
2708
+ borderRadius: 0.5,
2709
+ p: 0.5,
2710
+ display: "flex",
2711
+ alignItems: "center",
2712
+ justifyContent: "center",
2713
+ color: r
2714
+ },
2715
+ children: [
2716
+ o === "kpi" && /* @__PURE__ */ t(v, { sx: { fontSize: 8, fontWeight: 600 }, children: "R$ ··" }),
2717
+ o === "line" && /* @__PURE__ */ t("svg", { width: "100%", height: "14", viewBox: "0 0 40 14", preserveAspectRatio: "none", children: /* @__PURE__ */ t("path", { d: "M0 11 L8 7 L16 9 L24 4 L32 6 L40 2", stroke: r, strokeWidth: "1", fill: "none" }) }),
2718
+ o === "bars" && /* @__PURE__ */ t("svg", { width: "100%", height: "14", viewBox: "0 0 40 14", preserveAspectRatio: "none", children: [3, 7, 5, 9, 6, 11, 8, 12].map((b, g) => /* @__PURE__ */ t("rect", { x: g * 5 + 0.5, y: 14 - b, width: 3.5, height: b, fill: r }, g)) }),
2719
+ o === "table" && /* @__PURE__ */ t(v, { sx: { width: "90%", display: "flex", flexDirection: "column", gap: "1px" }, children: [0, 1, 2].map((b) => /* @__PURE__ */ t(v, { sx: { height: 1.5, background: r, borderRadius: "0.5px" } }, b)) }),
2720
+ o === "donut" && /* @__PURE__ */ t("svg", { width: "14", height: "14", viewBox: "0 0 14 14", children: /* @__PURE__ */ t("circle", { cx: "7", cy: "7", r: "5", stroke: r, strokeWidth: "2", fill: "none", strokeDasharray: "20 30" }) }),
2721
+ o === "heatmap" && /* @__PURE__ */ t(v, { sx: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: "0.5px", width: "70%" }, children: Array.from({ length: 8 }).map((b, g) => /* @__PURE__ */ t(v, { sx: { aspectRatio: "1", background: r, opacity: 0.2 + g / 8 * 0.7 } }, g)) })
2722
+ ]
2723
+ },
2724
+ `Template${x}`
2725
+ )) });
2726
+ }
2727
+ a(ja, "TemplatePreview");
2728
+ function Ua(e) {
2729
+ if (!e) return "";
2730
+ const n = Date.now() - e, i = 6e4, l = 60 * i, r = 24 * l;
2731
+ return n < i ? "agora" : n < l ? `${Math.floor(n / i)}m` : n < r ? `${Math.floor(n / l)}h` : n < 7 * r ? `${Math.floor(n / r)}d` : `${Math.floor(n / (7 * r))}sem`;
2732
+ }
2733
+ a(Ua, "formatRelativeTime");
2734
+ const Mt = /* @__PURE__ */ a(({
2735
+ onDraftPromptChange: e,
2736
+ onApplyTemplate: n,
2737
+ composerSlot: i,
2738
+ ambientWrapper: l,
2739
+ recentSessions: r,
2740
+ onSelectSession: o,
2741
+ onSearchAllSessions: x,
2742
+ suggestions: b = Jn,
2743
+ templates: g = At
2744
+ }) => {
2745
+ const d = he(), C = ge(d), s = l ?? ((c) => c), u = {
2746
+ background: "transparent",
2747
+ border: "none",
2748
+ textAlign: "left",
2749
+ padding: "6px 0",
2750
+ color: d.palette.text.secondary,
2751
+ fontFamily: d.typography.fontFamily,
2752
+ fontSize: 13,
2753
+ cursor: "pointer",
2754
+ display: "flex",
2755
+ alignItems: "center",
2756
+ gap: 1,
2757
+ "&:hover": { color: d.palette.text.primary }
2758
+ }, m = { fontSize: 11, color: d.palette.text.disabled, textTransform: "uppercase", letterSpacing: 0.5, mb: 1 };
2759
+ return /* @__PURE__ */ y(v, { sx: { flex: 1, minHeight: 0, overflow: "auto", display: "flex", flexDirection: "column", gap: 3.5, padding: { xs: 3, md: "40px 56px" }, background: d.palette.background.default }, children: [
2760
+ s(
2761
+ /* @__PURE__ */ y(v, { children: [
2762
+ /* @__PURE__ */ t(ee, { sx: { fontSize: 11, color: d.palette.primary.main, textTransform: "uppercase", letterSpacing: 0.8, mb: 1, fontWeight: 500 }, children: "Novo dashboard" }),
2763
+ /* @__PURE__ */ y(ee, { component: "h1", sx: { fontSize: 30, fontWeight: 600, color: d.palette.text.primary, margin: 0, lineHeight: 1.2, letterSpacing: -0.4 }, children: [
2764
+ "Descreva o que você quer, peça ajuda",
2765
+ " ",
2766
+ /* @__PURE__ */ t(v, { component: "span", sx: { color: d.palette.text.disabled }, children: "ou comece de um template." })
2767
+ ] })
2768
+ ] }),
2769
+ "hero"
2770
+ ),
2771
+ i,
2772
+ s(
2773
+ /* @__PURE__ */ y(v, { sx: { display: "grid", gridTemplateColumns: { xs: "1fr", md: "1fr 1fr" }, gap: { xs: 3, md: 5 } }, children: [
2774
+ /* @__PURE__ */ y(v, { children: [
2775
+ /* @__PURE__ */ t(ee, { sx: m, children: "Sugestões" }),
2776
+ /* @__PURE__ */ t(v, { sx: { display: "flex", flexDirection: "column", gap: 0.25 }, children: b.map((c) => /* @__PURE__ */ y(v, { component: "button", onClick: /* @__PURE__ */ a(() => e(c.prompt), "onClick"), sx: u, children: [
2777
+ /* @__PURE__ */ t(v, { component: "span", sx: { color: d.palette.text.disabled }, children: "↗" }),
2778
+ /* @__PURE__ */ t("span", { children: c.label })
2779
+ ] }, c.label)) })
2780
+ ] }),
2781
+ /* @__PURE__ */ y(v, { children: [
2782
+ /* @__PURE__ */ t(ee, { sx: m, children: "Sessões recentes" }),
2783
+ !r || r.length === 0 ? /* @__PURE__ */ t(ee, { sx: { fontSize: 12, color: d.palette.text.disabled, fontStyle: "italic", py: 0.5 }, children: "Você ainda não tem sessões salvas. Crie um novo dashboard acima." }) : /* @__PURE__ */ y(v, { sx: { display: "flex", flexDirection: "column", gap: 0.25 }, children: [
2784
+ r.map((c, p) => /* @__PURE__ */ y(
2785
+ v,
2786
+ {
2787
+ component: "button",
2788
+ onClick: /* @__PURE__ */ a(() => o == null ? void 0 : o(c.sessionId), "onClick"),
2789
+ disabled: !o,
2790
+ sx: { ...u, minWidth: 0, cursor: o ? "pointer" : "default", "&:hover": o ? u["&:hover"] : void 0 },
2791
+ children: [
2792
+ /* @__PURE__ */ t(v, { component: "span", sx: { color: d.palette.text.disabled, flexShrink: 0 }, children: "↺" }),
2793
+ /* @__PURE__ */ t(v, { component: "span", sx: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: c.name }),
2794
+ /* @__PURE__ */ y(v, { component: "span", sx: { color: d.palette.text.disabled, fontFamily: C.fontFamilyMono, fontSize: 11, flexShrink: 0 }, children: [
2795
+ c.cardCount,
2796
+ " ",
2797
+ c.cardCount === 1 ? "card" : "cards",
2798
+ c.updatedAt ? ` · ${Ua(c.updatedAt)}` : ""
2799
+ ] })
2800
+ ]
2801
+ },
2802
+ c.sessionId + p
2803
+ )),
2804
+ x && /* @__PURE__ */ y(v, { component: "button", onClick: x, sx: { ...u, color: d.palette.primary.main, fontSize: 12.5, mt: 0.5, "&:hover": { filter: "brightness(1.1)" } }, children: [
2805
+ /* @__PURE__ */ t(v, { component: "span", sx: { color: d.palette.text.disabled }, children: "⌕" }),
2806
+ /* @__PURE__ */ t("span", { children: "Buscar todas as sessões" })
2807
+ ] })
2808
+ ] })
2809
+ ] })
2810
+ ] }),
2811
+ "suggestions"
2812
+ ),
2813
+ s(
2814
+ /* @__PURE__ */ y(v, { children: [
2815
+ /* @__PURE__ */ y(v, { sx: { display: "flex", alignItems: "center", gap: 1, mb: 1.25, fontSize: 11, color: d.palette.text.disabled, textTransform: "uppercase", letterSpacing: 0.5 }, children: [
2816
+ /* @__PURE__ */ t("span", { children: "ou comece de um template" }),
2817
+ /* @__PURE__ */ t(v, { sx: { flex: 1, height: "1px", background: C.borderSoft } })
2818
+ ] }),
2819
+ /* @__PURE__ */ t(v, { sx: { display: "grid", gridTemplateColumns: { xs: "1fr 1fr", md: "repeat(4, 1fr)" }, gap: 1.25 }, children: g.map((c) => /* @__PURE__ */ y(
2820
+ v,
2821
+ {
2822
+ component: "button",
2823
+ onClick: /* @__PURE__ */ a(() => n(c), "onClick"),
2824
+ sx: {
2825
+ background: d.palette.background.paper,
2826
+ border: `1px solid ${d.palette.divider}`,
2827
+ borderRadius: 1.25,
2828
+ padding: 1.5,
2829
+ cursor: "pointer",
2830
+ textAlign: "left",
2831
+ fontFamily: d.typography.fontFamily,
2832
+ display: "flex",
2833
+ flexDirection: "column",
2834
+ gap: 1,
2835
+ transition: "border-color .15s, transform .15s",
2836
+ "&:hover": { borderColor: d.palette.primary.main, transform: "translateY(-1px)" }
2837
+ },
2838
+ children: [
2839
+ /* @__PURE__ */ t(ja, { kinds: Gn(c), accent: c.recommended }),
2840
+ /* @__PURE__ */ y(v, { children: [
2841
+ /* @__PURE__ */ t(ee, { sx: { fontSize: 12.5, color: d.palette.text.primary, fontWeight: 500 }, children: c.name }),
2842
+ /* @__PURE__ */ t(ee, { sx: { fontSize: 10.5, color: d.palette.text.secondary, mt: 0.25, lineHeight: 1.4 }, children: c.desc }),
2843
+ /* @__PURE__ */ t(ee, { sx: { fontSize: 10, color: d.palette.text.disabled, fontFamily: C.fontFamilyMono, mt: 0.5 }, children: c.cells.length === 0 ? "em branco" : `${c.cells.length} cards` })
2844
+ ] })
2845
+ ]
2846
+ },
2847
+ c.id
2848
+ )) })
2849
+ ] }),
2850
+ "templates"
2851
+ )
2852
+ ] });
2853
+ }, "EntryEmptyState");
2854
+ Mt.displayName = "EntryEmptyState";
2855
+ const le = 6, Me = 12, Ut = 320, Ka = 220, Kt = 150, Yt = 3e3;
2856
+ function Ya(e, n, i, l) {
2857
+ const r = window.innerWidth, o = window.innerHeight, x = e && e !== "auto" ? [e] : ["bottom", "top", "right", "left"];
2858
+ for (const b of x) {
2859
+ let g = 0, d = 0;
2860
+ switch (b) {
2861
+ case "bottom":
2862
+ g = n.top + n.height + le + Me, d = n.left + n.width / 2 - i / 2;
2863
+ break;
2864
+ case "top":
2865
+ g = n.top - le - Me - l, d = n.left + n.width / 2 - i / 2;
2866
+ break;
2867
+ case "right":
2868
+ g = n.top + n.height / 2 - l / 2, d = n.left + n.width + le + Me;
2869
+ break;
2870
+ case "left":
2871
+ g = n.top + n.height / 2 - l / 2, d = n.left - le - Me - i;
2872
+ break;
2873
+ }
2874
+ if (d = Math.max(8, Math.min(d, r - i - 8)), g = Math.max(8, Math.min(g, o - l - 8)), g >= 0 && g + l <= o && d >= 0 && d + i <= r || b === x[x.length - 1]) return { top: g, left: d, resolvedPlacement: b };
2875
+ }
2876
+ return { top: n.top + n.height + Me, left: n.left, resolvedPlacement: "bottom" };
2877
+ }
2878
+ a(Ya, "computePlacement");
2879
+ const Xn = /* @__PURE__ */ a(({ steps: e, overlayOpacity: n = 0.6, allowInteraction: i = !1, onComplete: l, onDismiss: r, resolveElement: o = zt }) => {
2880
+ const x = he(), b = ge(x), [g, d] = L(0), [C, s] = L(null), [u, m] = L({ width: Ut, height: 120 }), c = te(null), p = te(0), f = e[g], _ = g === 0, B = g === e.length - 1, G = Y(() => {
2881
+ var S;
2882
+ if (!f) return;
2883
+ const E = o(f.target);
2884
+ if (E) {
2885
+ const F = E.getBoundingClientRect();
2886
+ s({ top: F.top, left: F.left, width: F.width, height: F.height }), (S = E.scrollIntoView) == null || S.call(E, { behavior: "smooth", block: "nearest", inline: "nearest" });
2887
+ } else
2888
+ s(null);
2889
+ }, [f, o]);
2890
+ q(() => {
2891
+ if (!f) return;
2892
+ let E = !1, S = 0, F;
2893
+ const w = /* @__PURE__ */ a(() => {
2894
+ console.warn(`[@aintela/bi SpotlightOverlay] Step ${g + 1}/${e.length} could not resolve its target within ${Yt} ms; skipping.`, { target: f.target, title: f.title }), g < e.length - 1 ? d((U) => U + 1) : (console.warn("[@aintela/bi SpotlightOverlay] All steps failed to resolve; dismissing tour."), r());
2895
+ }, "giveUpOnStep"), O = /* @__PURE__ */ a(() => {
2896
+ var J;
2897
+ if (E) return;
2898
+ const U = o(f.target);
2899
+ if (U) {
2900
+ const Z = U.getBoundingClientRect();
2901
+ if (Z.width > 0 && Z.height > 0) {
2902
+ s({ top: Z.top, left: Z.left, width: Z.width, height: Z.height }), (J = U.scrollIntoView) == null || J.call(U, { behavior: "smooth", block: "nearest", inline: "nearest" });
2903
+ return;
2904
+ }
2905
+ }
2906
+ if (S += Kt, S >= Yt) {
2907
+ w();
2908
+ return;
2909
+ }
2910
+ F = window.setTimeout(O, Kt);
2911
+ }, "attempt");
2912
+ O();
2913
+ const k = /* @__PURE__ */ a(() => {
2914
+ cancelAnimationFrame(p.current), p.current = requestAnimationFrame(G);
2915
+ }, "onScroll");
2916
+ return window.addEventListener("scroll", k, !0), window.addEventListener("resize", k), () => {
2917
+ E = !0, F !== void 0 && window.clearTimeout(F), window.removeEventListener("scroll", k, !0), window.removeEventListener("resize", k), cancelAnimationFrame(p.current);
2918
+ };
2919
+ }, [f, o, r, G, g, e.length]), q(() => {
2920
+ if (c.current) {
2921
+ const { offsetWidth: E, offsetHeight: S } = c.current;
2922
+ m({ width: E, height: S });
2923
+ }
2924
+ }, [g, C]);
2925
+ const z = Y(() => {
2926
+ B ? (l == null || l(), r()) : d((E) => E + 1);
2927
+ }, [B, l, r]), R = Y(() => {
2928
+ _ || d((E) => E - 1);
2929
+ }, [_]);
2930
+ if (q(() => {
2931
+ const E = /* @__PURE__ */ a((S) => {
2932
+ S.key === "Escape" ? r() : S.key === "ArrowRight" || S.key === "Enter" ? z() : S.key === "ArrowLeft" && R();
2933
+ }, "onKey");
2934
+ return window.addEventListener("keydown", E), () => window.removeEventListener("keydown", E);
2935
+ }, [r, z, R]), !f || typeof document > "u") return null;
2936
+ const P = C ? `polygon(
2937
+ 0% 0%, 0% 100%, 100% 100%, 100% 0%, 0% 0%,
2938
+ ${C.left - le}px ${C.top - le}px,
2939
+ ${C.left + C.width + le}px ${C.top - le}px,
2940
+ ${C.left + C.width + le}px ${C.top + C.height + le}px,
2941
+ ${C.left - le}px ${C.top + C.height + le}px,
2942
+ ${C.left - le}px ${C.top - le}px
2943
+ )` : void 0, H = C ? Ya(f.placement, C, u.width, u.height) : null, j = {
2944
+ fontFamily: x.typography.fontFamily,
2945
+ fontSize: 11.5,
2946
+ fontWeight: 500,
2947
+ px: 1.25,
2948
+ py: 0.625,
2949
+ borderRadius: 1,
2950
+ cursor: "pointer",
2951
+ transition: "filter .12s, background-color .12s, border-color .12s",
2952
+ border: "1px solid transparent"
2953
+ };
2954
+ return ta(
2955
+ /* @__PURE__ */ y(v, { className: "llm-guide-overlay-root", sx: { position: "fixed", inset: 0, zIndex: 9999 }, children: [
2956
+ C && /* @__PURE__ */ t(
2957
+ v,
2958
+ {
2959
+ onClick: i ? r : void 0,
2960
+ sx: {
2961
+ position: "absolute",
2962
+ inset: 0,
2963
+ backgroundColor: Ce(x.palette.common.black, n),
2964
+ clipPath: P,
2965
+ transition: "clip-path 0.3s ease",
2966
+ pointerEvents: i ? "none" : "auto"
2967
+ }
2968
+ }
2969
+ ),
2970
+ C && /* @__PURE__ */ t(
2971
+ v,
2972
+ {
2973
+ className: "llm-guide-spotlight-ring",
2974
+ sx: {
2975
+ position: "absolute",
2976
+ top: C.top - le,
2977
+ left: C.left - le,
2978
+ width: C.width + le * 2,
2979
+ height: C.height + le * 2,
2980
+ borderRadius: "6px",
2981
+ border: `2px solid ${x.palette.primary.main}`,
2982
+ boxShadow: `0 0 0 4px ${Ce(x.palette.primary.main, 0.2)}, 0 8px 24px ${Ce(x.palette.primary.main, 0.13)}`,
2983
+ transition: "all 0.3s ease",
2984
+ pointerEvents: "none"
2985
+ }
2986
+ }
2987
+ ),
2988
+ H && /* @__PURE__ */ y(
2989
+ v,
2990
+ {
2991
+ ref: c,
2992
+ sx: {
2993
+ position: "absolute",
2994
+ top: H.top,
2995
+ left: H.left,
2996
+ maxWidth: Ut,
2997
+ minWidth: Ka,
2998
+ p: 2,
2999
+ borderRadius: 1.5,
3000
+ backgroundColor: x.palette.background.paper,
3001
+ border: `1px solid ${x.palette.divider}`,
3002
+ boxShadow: x.shadows[8],
3003
+ transition: "top 0.3s ease, left 0.3s ease",
3004
+ pointerEvents: "auto",
3005
+ display: "flex",
3006
+ flexDirection: "column",
3007
+ gap: 1.25,
3008
+ fontFamily: x.typography.fontFamily
3009
+ },
3010
+ children: [
3011
+ /* @__PURE__ */ y(v, { sx: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", gap: 1 }, children: [
3012
+ /* @__PURE__ */ y(v, { sx: { flex: 1, minWidth: 0 }, children: [
3013
+ /* @__PURE__ */ y(ee, { sx: { fontSize: 10, color: x.palette.primary.main, textTransform: "uppercase", letterSpacing: 0.6, fontWeight: 500, mb: f.title ? 0.5 : 0 }, children: [
3014
+ "Guia · ",
3015
+ g + 1,
3016
+ " / ",
3017
+ e.length
3018
+ ] }),
3019
+ f.title && /* @__PURE__ */ t(ee, { sx: { fontSize: 13.5, fontWeight: 600, color: x.palette.text.primary, lineHeight: 1.3, mb: 0.5 }, children: f.title }),
3020
+ /* @__PURE__ */ t(ee, { sx: { fontSize: 12.5, color: x.palette.text.secondary, lineHeight: 1.5 }, children: f.description })
3021
+ ] }),
3022
+ /* @__PURE__ */ t(v, { component: "button", onClick: r, "aria-label": "Fechar guia", sx: { ...j, background: "transparent", border: "none", color: x.palette.text.disabled, p: 0.5, display: "inline-flex", "&:hover": { color: x.palette.text.primary } }, children: /* @__PURE__ */ t(Tt, { size: 12 }) })
3023
+ ] }),
3024
+ /* @__PURE__ */ y(v, { sx: { display: "flex", justifyContent: "flex-end", alignItems: "center", gap: 0.75 }, children: [
3025
+ !_ && /* @__PURE__ */ t(v, { component: "button", onClick: R, sx: { ...j, background: "transparent", color: x.palette.text.secondary, "&:hover": { color: x.palette.text.primary, backgroundColor: b.raised } }, children: "Anterior" }),
3026
+ /* @__PURE__ */ t(v, { component: "button", onClick: z, sx: { ...j, background: x.palette.primary.main, color: x.palette.primary.contrastText, fontWeight: 600, "&:hover": { filter: "brightness(1.05)" } }, children: B ? "Concluir" : "Próximo" })
3027
+ ] })
3028
+ ]
3029
+ }
3030
+ )
3031
+ ] }),
3032
+ document.body
3033
+ );
3034
+ }, "SpotlightOverlay"), qa = "aintela-bi-composer", Ja = 2, Xa = /* @__PURE__ */ a((e) => {
3035
+ var de;
3036
+ const { sessionId: n = null, routeSessionId: i, composerMode: l, onForceExecutionMode: r, recentSessionsResolved: o } = e, x = he(), b = ge(x), g = me(), d = et(), C = N((V) => {
3037
+ var Q;
3038
+ return ((Q = V.dashboardDefinition) == null ? void 0 : Q.jsFileName) ?? null;
3039
+ }), s = N((V) => {
3040
+ var Q;
3041
+ return ((Q = V.dashboardDefinition) == null ? void 0 : Q.name) ?? null;
3042
+ }), u = N((V) => V.turnOpen), m = N((V) => V.sketchExpanded), c = Y((V) => g.getState().setSketchExpanded(V), [g]), [p, f] = L(""), [_, B] = L(void 0), [G, z] = L(!1), [R, P] = L(!1), H = C !== null, j = te(null);
3043
+ q(() => {
3044
+ var Q;
3045
+ const V = s == null ? void 0 : s.trim();
3046
+ return (Q = e.onDashboardNameChange) == null || Q.call(e, V || null), () => {
3047
+ var T;
3048
+ return (T = e.onDashboardNameChange) == null ? void 0 : T.call(e, null);
3049
+ };
3050
+ }, [s]), q(() => {
3051
+ g.getState().currentSessionId !== n && g.getState().setCurrentSessionId(n);
3052
+ }, [n, g]), q(() => {
3053
+ u && P(!1);
3054
+ }, [u]), q(() => {
3055
+ (C || void 0) !== _ && P(!0), B(C ?? void 0);
3056
+ }, [C]), q(() => {
3057
+ var K;
3058
+ const V = g.getState().dashboardDefinition, Q = (V == null ? void 0 : V.originalSessionId) ?? null;
3059
+ if (Q && Q !== (i ?? null) && (g.getState().updateDashboard(void 0), j.current = null), !i && Q && (g.getState().updateDashboard(void 0), j.current = null), !i || !d || j.current === i) return;
3060
+ if ((K = g.getState().dashboardDefinition) != null && K.id) {
3061
+ j.current = i;
3062
+ return;
3063
+ }
3064
+ let T = !1;
3065
+ return (async () => {
3066
+ var re;
3067
+ try {
3068
+ const h = await d.getDashboardBySession(i);
3069
+ if (T) return;
3070
+ if ((re = g.getState().dashboardDefinition) != null && re.id) {
3071
+ j.current = i;
3072
+ return;
3073
+ }
3074
+ if (!h) {
3075
+ console.warn("[@aintela/bi composer] no dashboard found for session", i), j.current = i;
3076
+ return;
3077
+ }
3078
+ g.getState().loadDashboard(Ne(h)), j.current = i;
3079
+ } catch (h) {
3080
+ console.error("[@aintela/bi composer] failed to load dashboard for session", h);
3081
+ }
3082
+ })(), () => {
3083
+ T = !0;
3084
+ };
3085
+ }, [i, d, g]);
3086
+ const E = Y(
3087
+ async (V) => {
3088
+ var K, re, h, I;
3089
+ const Q = n;
3090
+ let T = g.getState().dashboardDefinition;
3091
+ if (T != null && T.id && T.originalSessionId && T.originalSessionId !== Q && T.originalSessionId !== i && (g.getState().updateDashboard(void 0), T = g.getState().dashboardDefinition), T != null && T.id) {
3092
+ V && g.getState().updateDashboard({
3093
+ originalSessionId: i !== g.getState().currentSessionId ? g.getState().currentSessionId : T.originalSessionId,
3094
+ ...V.name !== void 0 && { name: V.name },
3095
+ ...V.cards !== void 0 && { cards: V.cards },
3096
+ ...V.filters !== void 0 && { filters: V.filters }
3097
+ });
3098
+ return;
3099
+ }
3100
+ if (!Q || !d) {
3101
+ V ? (g.getState().updateDashboard({ name: V.name ?? "Untitled Dashboard", cards: V.cards ?? [], filters: V.filters ?? [] }), c(!0)) : (g.getState().updateDashboard({ name: "Untitled Dashboard", cards: [], filters: [] }), c(!0));
3102
+ return;
3103
+ }
3104
+ try {
3105
+ const A = !V && T && ((((K = T.cards) == null ? void 0 : K.length) ?? 0) > 0 || (((re = T.filters) == null ? void 0 : re.length) ?? 0) > 0) ? { name: T.name, cards: T.cards, filters: T.filters, layoutType: T.layoutType } : void 0, M = V ?? A;
3106
+ M && !M.layoutType && (M.layoutType = "Naked");
3107
+ const X = await Ot(d, Q, M), ne = g.getState().dashboardDefinition;
3108
+ g.getState().updateDashboard({
3109
+ ...X,
3110
+ name: (M == null ? void 0 : M.name) ?? (ne == null ? void 0 : ne.name) ?? X.name,
3111
+ cards: (M == null ? void 0 : M.cards) ?? ((h = ne == null ? void 0 : ne.cards) != null && h.length ? ne.cards : X.cards),
3112
+ filters: (M == null ? void 0 : M.filters) ?? ((I = ne == null ? void 0 : ne.filters) != null && I.length ? ne.filters : X.filters)
3113
+ }), c(!0);
3114
+ } catch (A) {
3115
+ console.error("[@aintela/bi composer] createDraft failed", A);
3116
+ }
3117
+ },
3118
+ [d, n, i, c, g]
3119
+ ), S = Y(() => {
3120
+ c(!0), E();
3121
+ }, [E, c]), F = Y(async (V) => {
3122
+ var Q;
3123
+ await E(), await ((Q = e.onBeforeSend) == null ? void 0 : Q.call(e, V));
3124
+ }, [E, e.onBeforeSend]), w = Y((V) => {
3125
+ if (V.cells.length === 0) {
3126
+ r();
3127
+ return;
3128
+ }
3129
+ E({ name: V.name, cards: Hn(V), filters: [] });
3130
+ }, [E, r]), O = Zi(), k = O ? Fn : Mn, U = O ? Nn : _n, J = O ? Bn : Rn, Z = Y(
3131
+ (V, Q) => /* @__PURE__ */ t(se.div, { variants: k, initial: "hidden", animate: "visible", exit: "hidden", children: V }, Q),
3132
+ [k]
3133
+ ), ie = /* @__PURE__ */ a(() => /* @__PURE__ */ t(se.div, { layoutId: qa, transition: J, style: { display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ t(
3134
+ qn,
3135
+ {
3136
+ onCreateSketch: S,
3137
+ onBeforeSend: F,
3138
+ sketchExpanded: m,
3139
+ onSketchExpandedChange: c,
3140
+ seedDraft: p,
3141
+ zoomLevel: H ? 0.8 : 0.95,
3142
+ compact: l !== "empty",
3143
+ bottomSlot: l === "empty" ? e.progressStrip : void 0,
3144
+ datasetControls: e.datasetControls,
3145
+ renderDescription: e.renderDescription
3146
+ }
3147
+ ) }), "renderPromptForBranch");
3148
+ return /* @__PURE__ */ t(tt, { mode: "popLayout", initial: !1, children: l === "empty" ? /* @__PURE__ */ t(se.div, { initial: { opacity: 1 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { flex: 1, minHeight: 0, display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ t(
3149
+ Mt,
3150
+ {
3151
+ onDraftPromptChange: f,
3152
+ onApplyTemplate: w,
3153
+ composerSlot: ie(),
3154
+ ambientWrapper: Z,
3155
+ recentSessions: o,
3156
+ onSelectSession: e.onSelectSession,
3157
+ onSearchAllSessions: e.onSearchAllSessions,
3158
+ suggestions: e.suggestions,
3159
+ templates: e.templates
3160
+ }
3161
+ ) }, "empty-layout") : /* @__PURE__ */ t(se.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { minHeight: 0, width: "100%", height: "100%", display: "flex", background: x.palette.background.default }, children: /* @__PURE__ */ y(Ft, { direction: "row", sx: { display: "inline-flex", width: "100%", height: "100%", flexWrap: "nowrap" }, children: [
3162
+ /* @__PURE__ */ y(
3163
+ Ft,
3164
+ {
3165
+ sx: {
3166
+ minWidth: "20%",
3167
+ width: H ? e.chatColumnWidthWithDashboard ?? "80%" : "100%",
3168
+ minHeight: 0,
3169
+ height: "100%",
3170
+ display: "flex",
3171
+ flexDirection: "column",
3172
+ overflow: "hidden",
3173
+ '& [data-message-role="user"]': { backgroundColor: `${b.hover} !important`, border: `1px solid ${b.borderSoft} !important`, borderRadius: "12px !important" },
3174
+ '& [data-message-role="user"], & [data-message-role="user"] span, & [data-message-role="user"] p': { fontSize: "12.5px", lineHeight: 1.55 }
3175
+ },
3176
+ children: [
3177
+ /* @__PURE__ */ t(v, { className: "bi-composer-chat-pane", sx: { minHeight: 0, width: "100%", flex: 5, overflow: "hidden", display: "flex", flexDirection: "column" }, children: e.chatPane }),
3178
+ /* @__PURE__ */ t(se.div, { variants: U, initial: "hidden", animate: "visible", exit: "hidden", style: { width: "100%", flex: 1 }, children: /* @__PURE__ */ t(v, { sx: { backgroundColor: x.palette.background.default, flex: 1 }, children: ie() }) })
3179
+ ]
3180
+ }
3181
+ ),
3182
+ /* @__PURE__ */ t(Vn, { width: e.sidePanelWidth ?? "70%", defaultCollapsed: !R, onCollapseChange: z }),
3183
+ (de = e.renderProgressPanel) == null ? void 0 : de.call(e, { hasDashboard: H, dashboardCollapsed: G, turnOpen: u })
3184
+ ] }) }, "execution-layout") });
3185
+ }, "ComposerInner"), Zn = /* @__PURE__ */ a((e) => {
3186
+ const n = me(), i = et(), l = te(null);
3187
+ q(() => {
3188
+ const z = l.current;
3189
+ if (!z || typeof ResizeObserver > "u") return;
3190
+ const R = /* @__PURE__ */ a(() => {
3191
+ const H = z.getBoundingClientRect();
3192
+ n.getState().setViewport({ width: H.width, height: H.height });
3193
+ }, "publish");
3194
+ R();
3195
+ const P = new ResizeObserver(R);
3196
+ return P.observe(z), () => P.disconnect();
3197
+ }, [n]);
3198
+ const [r, o] = L([]);
3199
+ q(() => {
3200
+ if (e.recentSessions || !i) return;
3201
+ let z = !1;
3202
+ return (async () => {
3203
+ try {
3204
+ const R = await i.listDashboards();
3205
+ if (z) return;
3206
+ const P = R.filter((H) => !!H.originalSessionId).map((H) => {
3207
+ var E;
3208
+ const j = H.updatedAt ? H.updatedAt instanceof Date ? H.updatedAt.getTime() : Date.parse(String(H.updatedAt)) : 0;
3209
+ return { sessionId: H.originalSessionId, name: H.name || "Dashboard", cardCount: ((E = H.cards) == null ? void 0 : E.length) ?? 0, updatedAt: Number.isFinite(j) ? j : 0 };
3210
+ });
3211
+ P.sort((H, j) => (j.updatedAt ?? 0) - (H.updatedAt ?? 0)), o(P.slice(0, Ja));
3212
+ } catch (R) {
3213
+ console.error("[@aintela/bi composer] failed to list dashboards", R);
3214
+ }
3215
+ })(), () => {
3216
+ z = !0;
3217
+ };
3218
+ }, [i, e.recentSessions, e.routeSessionId]);
3219
+ const x = e.recentSessions ?? r, b = N((z) => z.turnOpen), g = N((z) => z.hasCompletedOnce), d = N((z) => z.producedDashboardId), C = N((z) => {
3220
+ var R;
3221
+ return !!((R = z.dashboardDefinition) != null && R.jsFileName);
3222
+ }), s = N((z) => {
3223
+ var R;
3224
+ return ((R = z.dashboardDefinition) == null ? void 0 : R.id) ?? null;
3225
+ }), u = N((z) => {
3226
+ var R, P;
3227
+ return ((P = (R = z.dashboardDefinition) == null ? void 0 : R.cards) == null ? void 0 : P.length) ?? 0;
3228
+ }), m = N((z) => {
3229
+ var R, P;
3230
+ return ((P = (R = z.dashboardDefinition) == null ? void 0 : R.filters) == null ? void 0 : P.length) ?? 0;
3231
+ }), c = te({ id: s, cards: u, filters: m, firstTime: !0 });
3232
+ q(() => {
3233
+ if (b) return;
3234
+ const z = c.current, R = !z.id && !!s, P = z.cards === 0 && u > 0, H = z.filters === 0 && m > 0, j = z.firstTime;
3235
+ c.current = { id: s, cards: u, filters: m, firstTime: !1 }, !j && (R || P || H) && n.getState().setSketchExpanded(!0);
3236
+ }, [s, u, m, b, n]);
3237
+ const p = N((z) => z.guideSteps), f = N((z) => z.guideOptions), _ = N((z) => z.dismissGuide);
3238
+ q(() => {
3239
+ p && p.length > 0 && xn(p) && n.getState().setSketchExpanded(!0);
3240
+ }, [p, n]);
3241
+ const B = ze(() => b ? "generating" : !g && !e.routeSessionId ? "empty" : d || C ? "done-dashboard" : "done-text", [b, g, d, C, e.routeSessionId]), G = Y(() => {
3242
+ n.getState().setHasCompletedOnce(!0), n.getState().setSketchExpanded(!1);
3243
+ }, [n]);
3244
+ return /* @__PURE__ */ y(we, { children: [
3245
+ /* @__PURE__ */ t("div", { className: "bi-composer-root", ref: l, style: { display: "inherit", height: "100%" }, children: /* @__PURE__ */ t(Xa, { ...e, composerMode: B, onForceExecutionMode: G, recentSessionsResolved: x }) }),
3246
+ p && p.length > 0 && /* @__PURE__ */ t(Xn, { steps: p, overlayOpacity: f == null ? void 0 : f.overlayOpacity, allowInteraction: f == null ? void 0 : f.allowInteraction, onComplete: f == null ? void 0 : f.onComplete, onDismiss: _, resolveElement: e.resolveGuideElement ?? zt })
3247
+ ] });
3248
+ }, "ComposerView");
3249
+ Zn.displayName = "ComposerView";
3250
+ const vt = 20, Za = 60;
3251
+ function Qa(e) {
3252
+ for (const n of e.artifactData ?? [])
3253
+ if ((n == null ? void 0 : n.type) === "Dashboard" && n.id) return n.id;
3254
+ return null;
3255
+ }
3256
+ a(Qa, "detectProducedDashboardId");
3257
+ function Qn() {
3258
+ const e = me(), n = Tn(), i = Y((b) => {
3259
+ var B, G, z, R;
3260
+ const { viewport: g, dashboardDefinition: d } = e.getState(), C = Math.round(g.height), s = g.width === 0 ? 0 : Math.round(g.width / 2 - Za), u = s, m = Math.round(1080 * 0.9), c = Math.round(m / 12), p = ((d == null ? void 0 : d.cards) ?? []).map((P) => ({
3261
+ ...P,
3262
+ widthPx: typeof P.w == "number" && c > 0 ? Math.round(c * P.w * 0.95) : void 0,
3263
+ heightPx: typeof P.h == "number" ? Math.round(P.h * vt * 0.95) : void 0
3264
+ }));
3265
+ let f;
3266
+ try {
3267
+ const P = JSON.parse(b), H = (((G = (B = P == null ? void 0 : P.userPrompt) == null ? void 0 : B.trim()) == null ? void 0 : G.length) ?? 0) > 0 ? P.userPrompt : void 0, j = ((z = P == null ? void 0 : P.cards) == null ? void 0 : z.length) ?? 0, E = ((R = P == null ? void 0 : P.filters) == null ? void 0 : R.length) ?? 0, S = j > 0 ? `${j} card(s) ` : "", F = E > 0 ? ` - ${E} filter(s) ` : "";
3268
+ f = H ?? `${S}${F}(${(P == null ? void 0 : P.layoutType) ?? ""})`;
3269
+ } catch {
3270
+ f = void 0;
3271
+ }
3272
+ const _ = {
3273
+ id: (d == null ? void 0 : d.id) ?? "",
3274
+ name: (d == null ? void 0 : d.name) ?? "",
3275
+ cards: p,
3276
+ filters: (d == null ? void 0 : d.filters) ?? [],
3277
+ layoutType: (d == null ? void 0 : d.layoutType) ?? "Boxed",
3278
+ remarks: d == null ? void 0 : d.remarks,
3279
+ userPrompt: b,
3280
+ screenData: {
3281
+ chatBox: { heightPx: C, widthPx: u },
3282
+ dashboardPreviewBox: { heightPx: C, widthPx: s },
3283
+ dashboardVisualizationBox: { heightPx: C, widthPx: m },
3284
+ gridRowHeightPixelsPerUnit: vt,
3285
+ gridColumnWidthPixelsPerUnit: c,
3286
+ gridColumnWidthPixelsPerUnitFullView: c
3287
+ },
3288
+ isDatasetParameterized: (d == null ? void 0 : d.isDatasetParameterized) ?? !1,
3289
+ defaultDatasetName: d == null ? void 0 : d.defaultDatasetName,
3290
+ clientSideChanges: Dt(d == null ? void 0 : d.clientSideChanges)
3291
+ };
3292
+ return d != null && d.clientSideChanges && Object.keys(d.clientSideChanges).length > 0 && e.getState().clearClientSideChanges(), { promptAsString: f ?? "", json: JSON.stringify(_) };
3293
+ }, [e]), l = Y(() => {
3294
+ const b = e.getState();
3295
+ b.setTurnOpen(!0), b.dismissGuide(), b.setHasCompletedOnce(!1), b.setProducedDashboardId(null), b.setSketchExpanded(!1);
3296
+ }, [e]), r = Y((b) => {
3297
+ const g = e.getState();
3298
+ g.setProducedDashboardId(Qa(b)), g.setHasCompletedOnce(!0), g.setTurnOpen(!1);
3299
+ }, [e]), o = Y((b, g) => e.getState().ingestToolEvent(b, g), [e]), x = Y((b) => {
3300
+ e.getState().currentSessionId !== b && e.getState().setCurrentSessionId(b);
3301
+ }, [e]);
3302
+ return ze(() => ({ onRenderPrompt: i, onTurnOpen: l, onTurnComplete: r, ingestToolEvent: o, setSessionId: x, environment: n }), [i, l, r, o, x, n]);
3303
+ }
3304
+ a(Qn, "useComposerChatBridge");
3305
+ const eo = /* @__PURE__ */ a(() => {
3306
+ const e = Qn(), n = Ui((l) => {
3307
+ var r;
3308
+ return ((r = l.session) == null ? void 0 : r.id) ?? null;
3309
+ }), { eventBusService: i } = Ki();
3310
+ return q(() => {
3311
+ e.setSessionId(n);
3312
+ }, [n, e]), q(() => {
3313
+ const l = i;
3314
+ if (!(l != null && l.gatewayOnToolEvent)) return;
3315
+ const r = /* @__PURE__ */ a((o, x) => e.ingestToolEvent(o, x), "handler");
3316
+ return l.gatewayOnToolEvent(r), () => {
3317
+ var o;
3318
+ return (o = l.gatewayOffToolEvent) == null ? void 0 : o.call(l, r);
3319
+ };
3320
+ }, [i, e]), null;
3321
+ }, "ComposerChatBinding"), to = "0 0 40%", ei = /* @__PURE__ */ a(() => {
3322
+ const e = he(), n = ge(e), i = N((p) => {
3323
+ var f;
3324
+ return ((f = p.dashboardDefinition) == null ? void 0 : f.jsFileName) ?? null;
3325
+ }), l = N((p) => {
3326
+ var f;
3327
+ return ((f = p.dashboardDefinition) == null ? void 0 : f.id) ?? null;
3328
+ }), r = N((p) => {
3329
+ var f;
3330
+ return ((f = p.dashboardDefinition) == null ? void 0 : f.name) || "Dashboard";
3331
+ }), o = N((p) => {
3332
+ var f, _;
3333
+ return ((_ = (f = p.dashboardDefinition) == null ? void 0 : f.cards) == null ? void 0 : _.length) ?? 0;
3334
+ }), [x, b] = L("expanded"), [g, d] = L(!1), C = !!i && !!l, [s, u] = L(!1);
3335
+ if (q(() => {
3336
+ if (!C) {
3337
+ u(!1);
3338
+ return;
3339
+ }
3340
+ u(!0);
3341
+ const p = window.setTimeout(() => u(!1), 2500);
3342
+ return () => window.clearTimeout(p);
3343
+ }, [C]), !C || !l) return null;
3344
+ const m = { color: e.palette.text.secondary, p: 0.5, "&:hover": { color: e.palette.text.primary, backgroundColor: n.hover } }, c = /* @__PURE__ */ y(we, { children: [
3345
+ /* @__PURE__ */ t(ee, { sx: { color: e.palette.text.disabled, fontSize: 11 }, children: "·" }),
3346
+ /* @__PURE__ */ y(ee, { sx: { fontFamily: n.fontFamilyMono, color: e.palette.text.secondary, fontSize: 11 }, children: [
3347
+ o,
3348
+ " ",
3349
+ o === 1 ? "card" : "cards"
3350
+ ] })
3351
+ ] });
3352
+ return x === "minimized" ? /* @__PURE__ */ t(v, { sx: { flexShrink: 0, px: 1.5, py: 1, borderBottom: `1px solid ${n.borderSoft}`, backgroundColor: e.palette.background.paper }, children: /* @__PURE__ */ y(
3353
+ v,
3354
+ {
3355
+ role: "button",
3356
+ tabIndex: 0,
3357
+ onClick: /* @__PURE__ */ a(() => b("expanded"), "onClick"),
3358
+ onKeyDown: /* @__PURE__ */ a((p) => {
3359
+ p.key === "Enter" && b("expanded");
3360
+ }, "onKeyDown"),
3361
+ sx: {
3362
+ display: "inline-flex",
3363
+ alignItems: "center",
3364
+ gap: 0.75,
3365
+ px: 1.25,
3366
+ py: 0.5,
3367
+ borderRadius: 999,
3368
+ cursor: "pointer",
3369
+ backgroundColor: n.raised,
3370
+ border: `1px solid ${e.palette.divider}`,
3371
+ color: e.palette.text.primary,
3372
+ fontFamily: e.typography.fontFamily,
3373
+ fontSize: 11.5,
3374
+ transition: "background-color .12s, border-color .12s",
3375
+ "&:hover": { backgroundColor: n.hover, borderColor: e.palette.primary.main }
3376
+ },
3377
+ children: [
3378
+ /* @__PURE__ */ t(v, { sx: { color: e.palette.primary.main, display: "inline-flex" }, children: /* @__PURE__ */ t(De, { size: 13 }) }),
3379
+ /* @__PURE__ */ t(v, { component: "span", sx: { fontWeight: 500 }, children: r }),
3380
+ c,
3381
+ /* @__PURE__ */ t(v, { component: "span", sx: { color: e.palette.text.disabled, mx: 0.25 }, children: "|" }),
3382
+ /* @__PURE__ */ t(v, { component: "span", sx: { color: e.palette.primary.main, fontWeight: 500 }, children: "expandir" })
3383
+ ]
3384
+ }
3385
+ ) }) : /* @__PURE__ */ y(we, { children: [
3386
+ /* @__PURE__ */ t(se.div, { initial: { opacity: 0, y: -8, scaleY: 0.96 }, animate: { opacity: 1, y: 0, scaleY: 1 }, transition: { duration: 0.32, ease: [0.22, 0.8, 0.32, 1] }, style: { transformOrigin: "top center", flex: to, minHeight: 200, display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ y(v, { sx: { flex: 1, minHeight: 0, display: "flex", flexDirection: "column", borderBottom: `1px solid ${n.borderSoft}`, backgroundColor: e.palette.background.default, overflow: "hidden", position: "relative" }, children: [
3387
+ /* @__PURE__ */ y(v, { sx: { display: "flex", alignItems: "center", gap: 1, px: 1.5, py: 0.875, borderBottom: `1px solid ${n.borderSoft}`, backgroundColor: e.palette.background.paper, flexShrink: 0 }, children: [
3388
+ /* @__PURE__ */ t(v, { sx: { color: e.palette.primary.main, display: "inline-flex" }, children: /* @__PURE__ */ t(De, { size: 14 }) }),
3389
+ /* @__PURE__ */ t(ee, { sx: { color: e.palette.text.primary, fontWeight: 500, fontSize: 12 }, children: r }),
3390
+ c,
3391
+ /* @__PURE__ */ t(v, { sx: { flex: 1 } }),
3392
+ /* @__PURE__ */ t(ue, { title: "Tela cheia", placement: "top", children: /* @__PURE__ */ t(Se, { size: "small", onClick: /* @__PURE__ */ a(() => d(!0), "onClick"), sx: m, "aria-label": "Abrir em tela cheia", children: /* @__PURE__ */ t(Le, { size: 13 }) }) }),
3393
+ /* @__PURE__ */ t(ue, { title: "Minimizar", placement: "top", children: /* @__PURE__ */ t(Se, { size: "small", onClick: /* @__PURE__ */ a(() => b("minimized"), "onClick"), sx: { ...m, transform: "rotate(180deg)" }, "aria-label": "Minimizar", children: /* @__PURE__ */ t(Yi, { size: 13 }) }) })
3394
+ ] }),
3395
+ /* @__PURE__ */ t(tt, { children: s && /* @__PURE__ */ y(
3396
+ se.div,
3397
+ {
3398
+ initial: { opacity: 0, y: -6 },
3399
+ animate: { opacity: 1, y: 0 },
3400
+ exit: { opacity: 0, y: -4 },
3401
+ transition: { duration: 0.25, ease: "easeOut" },
3402
+ style: {
3403
+ position: "absolute",
3404
+ top: 8,
3405
+ right: 12,
3406
+ zIndex: 2,
3407
+ pointerEvents: "none",
3408
+ display: "inline-flex",
3409
+ alignItems: "center",
3410
+ gap: 6,
3411
+ background: e.palette.primary.main,
3412
+ color: e.palette.primary.contrastText,
3413
+ fontFamily: e.typography.fontFamily,
3414
+ fontSize: 11,
3415
+ fontWeight: 600,
3416
+ padding: "4px 10px 4px 8px",
3417
+ borderRadius: 999,
3418
+ boxShadow: `0 4px 14px ${Ce(e.palette.primary.main, 0.35)}`
3419
+ },
3420
+ children: [
3421
+ /* @__PURE__ */ t(De, { size: 11 }),
3422
+ "Dashboard pronto"
3423
+ ]
3424
+ }
3425
+ ) }),
3426
+ /* @__PURE__ */ t(v, { sx: { flex: 1, minHeight: 0, overflow: "auto" }, children: /* @__PURE__ */ t(_e, { dashboardId: l }) })
3427
+ ] }) }),
3428
+ /* @__PURE__ */ y(ln, { open: g, onClose: /* @__PURE__ */ a(() => d(!1), "onClose"), maxWidth: !1, fullScreen: !0, slotProps: { paper: { sx: { backgroundColor: e.palette.background.default, backgroundImage: "none", color: e.palette.text.primary } } }, children: [
3429
+ /* @__PURE__ */ y(v, { sx: { display: "flex", alignItems: "center", gap: 1, px: 2, py: 1.25, borderBottom: `1px solid ${e.palette.divider}`, backgroundColor: e.palette.background.paper, flexShrink: 0 }, children: [
3430
+ /* @__PURE__ */ t(v, { sx: { color: e.palette.primary.main, display: "inline-flex" }, children: /* @__PURE__ */ t(De, { size: 16 }) }),
3431
+ /* @__PURE__ */ t(ee, { sx: { color: e.palette.text.primary, fontWeight: 500, fontSize: 13.5 }, children: r }),
3432
+ c,
3433
+ /* @__PURE__ */ t(v, { sx: { flex: 1 } }),
3434
+ /* @__PURE__ */ t(ue, { title: "Fechar", placement: "left", children: /* @__PURE__ */ t(Se, { size: "small", onClick: /* @__PURE__ */ a(() => d(!1), "onClick"), sx: { ...m, p: 0.75 }, "aria-label": "Fechar", children: /* @__PURE__ */ t(Tt, { size: 14 }) }) })
3435
+ ] }),
3436
+ /* @__PURE__ */ t(v, { sx: { flex: 1, minHeight: 0, overflow: "auto" }, children: /* @__PURE__ */ t(_e, { dashboardId: l }) })
3437
+ ] })
3438
+ ] });
3439
+ }, "DashboardPinInner");
3440
+ ei.displayName = "DashboardPin";
3441
+ const no = Be.memo(ei), Ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3442
+ __proto__: null,
3443
+ CARD_TYPE_CATALOG: ve,
3444
+ CATEGORY_ICONS: Dn,
3445
+ COLOR_MAP: kn,
3446
+ CardScketch: fa,
3447
+ CardSketch: Et,
3448
+ CardTypeIconsProvider: ha,
3449
+ ClonedComponent: yn,
3450
+ ComposerChatBinding: eo,
3451
+ ComposerProvider: sa,
3452
+ ComposerView: Zn,
3453
+ DEFAULT_PAD_HEIGHT_PX: nt,
3454
+ DRAFT_SAVE_DEBOUNCE_MS: vn,
3455
+ DashboardPad: $n,
3456
+ DashboardPadEditor: An,
3457
+ DashboardPadSketch: ot,
3458
+ DashboardPin: no,
3459
+ DashboardSidePanel: Vn,
3460
+ DatasetParameterizationControls: za,
3461
+ DrawablePrompt: qn,
3462
+ ENV_HIGHLIGHT_CLASS: Xe,
3463
+ EntryEmptyState: Mt,
3464
+ EnvironmentProvider: qi,
3465
+ ExampleCardSkath: Ea,
3466
+ ExampleCardSketch: rt,
3467
+ ExampleCardSketh: Pa,
3468
+ ExamplePad: Oa,
3469
+ FILTER_TYPE_CATALOG: kt,
3470
+ FILTER_TYPE_ICONS: On,
3471
+ FilterSketch: $t,
3472
+ GRID_ROW_HEIGHT_PX: vt,
3473
+ GUIDE_SHOW_DELAY_MS: Cn,
3474
+ HoverButton: Te,
3475
+ InertEnvironmentProvider: Ji,
3476
+ PAD_INTERNAL_CLASSES: fn,
3477
+ PAD_INTERNAL_IDS: mn,
3478
+ PrototypePad: $a,
3479
+ SPECIFIC_TYPE_ICONS: In,
3480
+ SPECIFIC_TYPE_ICON_NAMES: zn,
3481
+ STARTER_TEMPLATES: Na,
3482
+ SpotlightOverlay: Xn,
3483
+ TEMPLATE_KIND_TO_SKETCH: Ln,
3484
+ TextSketh: ga,
3485
+ TitleSkath: xa,
3486
+ TitleSketch: Ge,
3487
+ ToolBox: En,
3488
+ VIEWER_COMMIT_DEBOUNCE_MS: Sn,
3489
+ activityPanelVariants: _n,
3490
+ activityPanelVariantsReduced: Nn,
3491
+ ambientVariants: Mn,
3492
+ ambientVariantsReduced: Fn,
3493
+ autoComplete: Ra,
3494
+ c: Aa,
3495
+ categoryPrefix: oa,
3496
+ composerLayoutTransition: Rn,
3497
+ composerLayoutTransitionReduced: Bn,
3498
+ createComposerStore: wn,
3499
+ createDashboardDraft: Ot,
3500
+ datePicker: _a,
3501
+ dateRange: Ma,
3502
+ defaultCardTypeIcons: Pn,
3503
+ defaultComposerSuggestions: Jn,
3504
+ defaultComposerTemplates: At,
3505
+ environmentFromStore: ca,
3506
+ fromUpsertResponse: Ne,
3507
+ groupCardCatalog: it,
3508
+ guideStepsRequireSketch: xn,
3509
+ isElementVisible: It,
3510
+ isSimplePadDefinition: dn,
3511
+ joinClientSideChanges: Dt,
3512
+ padConfigToDashboard: sn,
3513
+ pickBestElement: un,
3514
+ randomId: Ie,
3515
+ resolveComposerSurfaces: ge,
3516
+ resolveEnvironmentElements: Ze,
3517
+ resolveGuideElement: zt,
3518
+ sanitizeToJsVariable: $e,
3519
+ seedFromTemplate: Hn,
3520
+ sketchCardItemComparer: na,
3521
+ sketchFilterComparer: ia,
3522
+ targetSuggestsPadInternal: gn,
3523
+ templateKinds: Gn,
3524
+ toDraftPayload: bn,
3525
+ toSelectorList: pn,
3526
+ upsertDashboardDraft: at,
3527
+ useCardTypeIcons: Ae,
3528
+ useComposer: N,
3529
+ useComposerChatBridge: Qn,
3530
+ useComposerEnvironment: Tn,
3531
+ useComposerStore: me,
3532
+ useComposerStoreOptional: da,
3533
+ useDashboardPad: Fa,
3534
+ useEnvironment: rn,
3535
+ useEnvironmentOptional: Xi,
3536
+ validateSketch: bt
3537
+ }, Symbol.toStringTag, { value: "Module" }));
3538
+ export {
3539
+ wn as $,
3540
+ $a as A,
3541
+ zn as B,
3542
+ ve as C,
3543
+ nt as D,
3544
+ Xe as E,
3545
+ kt as F,
3546
+ vt as G,
3547
+ Te as H,
3548
+ Na as I,
3549
+ Xn as J,
3550
+ ga as K,
3551
+ xa as L,
3552
+ Ge as M,
3553
+ En as N,
3554
+ _n as O,
3555
+ fn as P,
3556
+ Nn as Q,
3557
+ Mn as R,
3558
+ In as S,
3559
+ Ln as T,
3560
+ Fn as U,
3561
+ Sn as V,
3562
+ Ra as W,
3563
+ Aa as X,
3564
+ oa as Y,
3565
+ Rn as Z,
3566
+ Bn as _,
3567
+ Dn as a,
3568
+ Ot as a0,
3569
+ _a as a1,
3570
+ Ma as a2,
3571
+ Pn as a3,
3572
+ Jn as a4,
3573
+ At as a5,
3574
+ ca as a6,
3575
+ Ne as a7,
3576
+ it as a8,
3577
+ xn as a9,
3578
+ Ro as aA,
3579
+ It as aa,
3580
+ dn as ab,
3581
+ Dt as ac,
3582
+ sn as ad,
3583
+ un as ae,
3584
+ Ie as af,
3585
+ ge as ag,
3586
+ Ze as ah,
3587
+ zt as ai,
3588
+ $e as aj,
3589
+ Hn as ak,
3590
+ na as al,
3591
+ ia as am,
3592
+ gn as an,
3593
+ Gn as ao,
3594
+ bn as ap,
3595
+ pn as aq,
3596
+ at as ar,
3597
+ Ae as as,
3598
+ N as at,
3599
+ Qn as au,
3600
+ Tn as av,
3601
+ me as aw,
3602
+ da as ax,
3603
+ Fa as ay,
3604
+ bt as az,
3605
+ kn as b,
3606
+ fa as c,
3607
+ Et as d,
3608
+ ha as e,
3609
+ yn as f,
3610
+ eo as g,
3611
+ sa as h,
3612
+ Zn as i,
3613
+ vn as j,
3614
+ $n as k,
3615
+ An as l,
3616
+ ot as m,
3617
+ no as n,
3618
+ Vn as o,
3619
+ za as p,
3620
+ qn as q,
3621
+ Mt as r,
3622
+ Ea as s,
3623
+ rt as t,
3624
+ Pa as u,
3625
+ Oa as v,
3626
+ On as w,
3627
+ $t as x,
3628
+ Cn as y,
3629
+ mn as z
3630
+ };
3631
+ //# sourceMappingURL=index-7p-ogAPK.js.map