@aintela/bi 0.2.0 → 0.2.2

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