@actionexec/dashboards 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,732 +1,778 @@
1
- import { jsxs as v, jsx as l, Fragment as se } from "react/jsx-runtime";
2
- import { useState as F, useRef as R, useEffect as P, useCallback as $, useMemo as Z } from "react";
3
- import { a7 as ie, a8 as ce, s as G, w as V, x as K, z as oe, J as j, a0 as X, K as de, a5 as ue, $ as z, a2 as B, r as ee, U as H, a3 as he, l as U, v as ge, R as me, O as fe, e as pe, Y as _e, X as be, c as ve, y as we, B as ye, o as Se, G as q, C as ke, p as Ne } from "./ColorPaletteSelector-4eS1vsrU.js";
4
- import { a9 as kt } from "./ColorPaletteSelector-4eS1vsrU.js";
5
- import { PieChart as Ce, Pie as Re, Cell as $e, Tooltip as te, LineChart as xe, Line as Me, AreaChart as Fe, Area as Te, BarChart as Ae, Bar as Ee, CartesianGrid as We, XAxis as Ie, YAxis as Le, Legend as Oe } from "recharts";
6
- const Pe = 300;
7
- function De(t) {
8
- const [e, a] = F(null), [n, r] = F(null), [s, c] = F({}), [i, f] = F({}), [d, g] = F(null), [o, u] = F(!0), [y, h] = F(null), b = R(), N = R(!1);
1
+ import { jsxs as v, jsx as a, Fragment as fe } from "react/jsx-runtime";
2
+ import { useState as M, useRef as N, useEffect as P, useCallback as x, useMemo as le } from "react";
3
+ import { f as pe, a as be, M as G, c as X, b as q, d as _e, e as ie, i as U, g as ve, p as we, h as V, j as se, k as oe, l as H, m as ye, D as Q, S as ke, n as Se, o as Ne, C as Ce, q as Re, r as $e, s as xe, t as Te, u as Me, G as Ae, v as J, w as Ee, x as Fe } from "./ColorPaletteSelector-Ddcuobr5.js";
4
+ import { A as Et } from "./ColorPaletteSelector-Ddcuobr5.js";
5
+ import { LineChart as Le, Line as Ie, AreaChart as We, Area as Oe, BarChart as ce, Bar as z, CartesianGrid as de, XAxis as ue, YAxis as he, Tooltip as K, Legend as Pe, Cell as Z, PieChart as De, Pie as He } from "recharts";
6
+ const Ye = 300;
7
+ function Ge(e) {
8
+ const [t, n] = M(null), [r, l] = M(null), [i, o] = M({}), [s, h] = M({}), [c, g] = M(null), [u, d] = M(!0), [f, _] = M(null), S = N(), R = N(!1);
9
9
  P(() => {
10
- let k = !1;
11
- return ie(t).then((w) => {
12
- k || a(w);
10
+ let y = !1;
11
+ return pe(e).then((w) => {
12
+ y || n(w);
13
13
  }).catch((w) => {
14
- k || h(w.message);
14
+ y || _(w.message);
15
15
  }), () => {
16
- k = !0;
16
+ y = !0;
17
17
  };
18
- }, [t]), P(() => {
19
- if (e)
20
- return b.current && clearTimeout(b.current), b.current = setTimeout(() => {
21
- const k = He(s, i);
22
- u(!0), ce(t, k).then((w) => {
23
- r(w), !N.current && w.applied && (N.current = !0, c((m) => ({ ...Ye(w.applied), ...m }))), h(null);
24
- }).catch((w) => h(w.message)).finally(() => u(!1));
25
- }, Pe), () => {
26
- b.current && clearTimeout(b.current);
18
+ }, [e]), P(() => {
19
+ if (t)
20
+ return S.current && clearTimeout(S.current), S.current = setTimeout(() => {
21
+ const y = ze(i, s);
22
+ d(!0), be(e, y).then((w) => {
23
+ l(w), !R.current && w.applied && (R.current = !0, o((m) => ({ ...Ke(w.applied), ...m }))), _(null);
24
+ }).catch((w) => _(w.message)).finally(() => d(!1));
25
+ }, Ye), () => {
26
+ S.current && clearTimeout(S.current);
27
27
  };
28
- }, [t, e, s, i]);
29
- const T = $((k, w) => {
30
- c((m) => ({ ...m, [k]: w }));
31
- }, []), S = $((k, w) => {
32
- f((m) => ({ ...m, [k]: w }));
33
- }, []), O = $((k) => {
34
- g(k);
35
- }, []), M = Z(
36
- () => d ?? (e == null ? void 0 : e.palette) ?? [],
37
- [d, e]
28
+ }, [e, t, i, s]);
29
+ const A = x((y, w) => {
30
+ o((m) => ({ ...m, [y]: w }));
31
+ }, []), k = x((y, w) => {
32
+ h((m) => ({ ...m, [y]: w }));
33
+ }, []), E = x((y) => {
34
+ g(y);
35
+ }, []), $ = le(
36
+ () => c ?? (t == null ? void 0 : t.palette) ?? [],
37
+ [c, t]
38
38
  );
39
39
  return {
40
- layout: e,
41
- renderData: n,
42
- loading: o,
43
- error: y,
44
- filters: s,
45
- variables: i,
46
- palette: M,
47
- setFilter: T,
48
- setVariable: S,
49
- setPalette: O
40
+ layout: t,
41
+ renderData: r,
42
+ loading: u,
43
+ error: f,
44
+ filters: i,
45
+ variables: s,
46
+ palette: $,
47
+ setFilter: A,
48
+ setVariable: k,
49
+ setPalette: E
50
50
  };
51
51
  }
52
- function He(t, e) {
53
- const a = {};
54
- for (const [n, r] of Object.entries(t))
55
- if (r.includes("|")) {
56
- const [s, c] = r.split("|");
57
- s && (a.f_date_start = s), c && (a.f_date_end = c);
52
+ function ze(e, t) {
53
+ const n = {};
54
+ for (const [r, l] of Object.entries(e))
55
+ if (l.includes("|")) {
56
+ const [i, o] = l.split("|");
57
+ i && (n.f_date_start = i), o && (n.f_date_end = o);
58
58
  } else
59
- a[`f_${n}`] = r;
59
+ n[`f_${r}`] = l;
60
+ for (const [r, l] of Object.entries(t))
61
+ n[`v_${r}`] = String(l);
62
+ return n;
63
+ }
64
+ function Ke(e) {
65
+ const t = {};
60
66
  for (const [n, r] of Object.entries(e))
61
- a[`v_${n}`] = String(r);
62
- return a;
63
- }
64
- function Ye(t) {
65
- const e = {};
66
- for (const [a, n] of Object.entries(t))
67
- if (n && typeof n == "object" && "start" in n) {
68
- const r = n;
69
- e[a] = `${r.start || ""}|${r.end || ""}`;
70
- } else Array.isArray(n) ? e[a] = n.join(G) : typeof n == "string" && (e[a] = n);
71
- return e;
72
- }
73
- const Ge = (t) => {
74
- var e, a;
75
- return ((a = (e = t.borderBoxSize) == null ? void 0 : e[0]) == null ? void 0 : a.inlineSize) ?? t.target.offsetWidth;
76
- }, ze = (t) => {
77
- var e, a;
78
- return ((a = (e = t.borderBoxSize) == null ? void 0 : e[0]) == null ? void 0 : a.blockSize) ?? t.target.offsetHeight;
67
+ if (r && typeof r == "object" && "start" in r) {
68
+ const l = r;
69
+ t[n] = `${l.start || ""}|${l.end || ""}`;
70
+ } else Array.isArray(r) ? t[n] = r.join(G) : typeof r == "string" && (t[n] = r);
71
+ return t;
72
+ }
73
+ const Ve = (e) => {
74
+ var t, n;
75
+ return ((n = (t = e.borderBoxSize) == null ? void 0 : t[0]) == null ? void 0 : n.inlineSize) ?? e.target.offsetWidth;
76
+ }, je = (e) => {
77
+ var t, n;
78
+ return ((n = (t = e.borderBoxSize) == null ? void 0 : t[0]) == null ? void 0 : n.blockSize) ?? e.target.offsetHeight;
79
79
  };
80
- function Ve(t, e, a) {
81
- return t === void 0 ? 0 : t === "auto" ? oe(e, a) : Math.max(0, t);
82
- }
83
- function Ke(t) {
84
- let e = t.parentElement;
85
- for (; e && e !== document.body && e !== document.documentElement; ) {
86
- const { overflowY: a } = getComputedStyle(e);
87
- if (a !== "visible")
88
- return a === "hidden" || a === "clip" ? e : null;
89
- e = e.parentElement;
80
+ function Xe(e, t, n) {
81
+ return e === void 0 ? 0 : e === "auto" ? _e(t, n) : Math.max(0, e);
82
+ }
83
+ function qe(e) {
84
+ let t = e.parentElement;
85
+ for (; t && t !== document.body && t !== document.documentElement; ) {
86
+ const { overflowY: n } = getComputedStyle(t);
87
+ if (n !== "visible")
88
+ return n === "hidden" || n === "clip" ? t : null;
89
+ t = t.parentElement;
90
90
  }
91
91
  return null;
92
92
  }
93
- function je(t) {
94
- const e = R(t);
95
- e.current = t;
96
- const a = R(null), n = R(null), r = R(null), s = R(null), c = R(null), i = R(0), f = R(0), d = R(!1), g = R(!1), o = R(-1), [u, y] = F(!1), h = $((m) => {
97
- const _ = n.current;
98
- if (g.current || e.current.silenceWarnings || !_) return;
99
- const C = Ke(_);
93
+ function Ue(e) {
94
+ const t = N(e);
95
+ t.current = e;
96
+ const n = N(null), r = N(null), l = N(null), i = N(null), o = N(null), s = N(0), h = N(0), c = N(!1), g = N(!1), u = N(-1), [d, f] = M(!1), _ = x((m) => {
97
+ const b = r.current;
98
+ if (g.current || t.current.silenceWarnings || !b) return;
99
+ const C = qe(b);
100
100
  !C || C.clientHeight >= m.gridHeight || (g.current = !0, console.warn(
101
101
  `[@actionexec/dashboards] O dashboard esta sendo cortado: o container precisa de ${Math.ceil(m.gridHeight)}px de altura, mas o ancestral com overflow oculto tem ${C.clientHeight}px. A altura do dashboard varia com a largura — use a prop onGeometryChange para dimensionar o container, ou troque o overflow para auto. Passe silenceWarnings para desligar este aviso.`
102
102
  ));
103
- }, []), b = $(() => {
104
- var I, E;
105
- if (!a.current) return;
106
- const { columns: m, cellAspect: _ } = e.current, C = i.current, W = K(C, m), p = {
103
+ }, []), S = x(() => {
104
+ var O, L;
105
+ if (!n.current) return;
106
+ const { columns: m, cellAspect: b } = t.current, C = s.current, W = q(C, m), p = {
107
107
  containerWidth: C,
108
108
  cellWidth: W,
109
- cellHeight: V(W, _),
110
- gridHeight: f.current,
111
- stacked: d.current
112
- }, x = c.current;
113
- x && x.containerWidth === p.containerWidth && x.cellWidth === p.cellWidth && x.cellHeight === p.cellHeight && x.gridHeight === p.gridHeight && x.stacked === p.stacked || (c.current = p, (E = (I = e.current).onGeometryChange) == null || E.call(I, p), h(p));
114
- }, [h]), N = $((m = !1) => {
115
- const _ = a.current;
116
- if (!_) return;
117
- const C = i.current;
118
- if (!m && C === o.current) return;
119
- o.current = C;
120
- const { columns: W, cellAspect: p, stackBelow: x } = e.current, A = K(C, W);
121
- _.style.setProperty("--dash-cell-h", `${V(A, p)}px`);
122
- const I = Ve(x, W, p), E = I > 0 && C > 0 && C < I;
123
- E !== d.current && (d.current = E, y(E));
124
- }, []), T = $(() => {
125
- s.current !== null && (cancelAnimationFrame(s.current), s.current = null);
126
- }, []), S = $(() => {
127
- s.current === null && (s.current = requestAnimationFrame(() => {
128
- s.current = null, N(), b();
109
+ cellHeight: X(W, b),
110
+ gridHeight: h.current,
111
+ stacked: c.current
112
+ }, T = o.current;
113
+ T && T.containerWidth === p.containerWidth && T.cellWidth === p.cellWidth && T.cellHeight === p.cellHeight && T.gridHeight === p.gridHeight && T.stacked === p.stacked || (o.current = p, (L = (O = t.current).onGeometryChange) == null || L.call(O, p), _(p));
114
+ }, [_]), R = x((m = !1) => {
115
+ const b = n.current;
116
+ if (!b) return;
117
+ const C = s.current;
118
+ if (!m && C === u.current) return;
119
+ u.current = C;
120
+ const { columns: W, cellAspect: p, stackBelow: T } = t.current, F = q(C, W);
121
+ b.style.setProperty("--dash-cell-h", `${X(F, p)}px`);
122
+ const O = Xe(T, W, p), L = O > 0 && C > 0 && C < O;
123
+ L !== c.current && (c.current = L, f(L));
124
+ }, []), A = x(() => {
125
+ i.current !== null && (cancelAnimationFrame(i.current), i.current = null);
126
+ }, []), k = x(() => {
127
+ i.current === null && (i.current = requestAnimationFrame(() => {
128
+ i.current = null, R(), S();
129
129
  }));
130
- }, [N, b]), O = $((m) => {
131
- for (const _ of m)
132
- _.target === a.current ? i.current = Math.round(Ge(_)) : _.target === n.current && (f.current = ze(_));
133
- S();
134
- }, [S]), M = $(() => r.current ? r.current : typeof ResizeObserver > "u" ? null : (r.current = new ResizeObserver(O), r.current), [O]), k = $((m) => {
135
- const _ = M();
136
- a.current && (_ == null || _.unobserve(a.current)), a.current = m, m && (_ == null || _.observe(m), i.current = Math.round(m.getBoundingClientRect().width), N(!0), S());
137
- }, [N, M, S]), w = $((m) => {
138
- const _ = M();
139
- if (n.current && (_ == null || _.unobserve(n.current)), n.current = m, !m) {
140
- f.current = 0;
130
+ }, [R, S]), E = x((m) => {
131
+ for (const b of m)
132
+ b.target === n.current ? s.current = Math.round(Ve(b)) : b.target === r.current && (h.current = je(b));
133
+ k();
134
+ }, [k]), $ = x(() => l.current ? l.current : typeof ResizeObserver > "u" ? null : (l.current = new ResizeObserver(E), l.current), [E]), y = x((m) => {
135
+ const b = $();
136
+ n.current && (b == null || b.unobserve(n.current)), n.current = m, m && (b == null || b.observe(m), s.current = Math.round(m.getBoundingClientRect().width), R(!0), k());
137
+ }, [R, $, k]), w = x((m) => {
138
+ const b = $();
139
+ if (r.current && (b == null || b.unobserve(r.current)), r.current = m, !m) {
140
+ h.current = 0;
141
141
  return;
142
142
  }
143
- _ == null || _.observe(m), f.current = m.getBoundingClientRect().height, S();
144
- }, [M, S]);
143
+ b == null || b.observe(m), h.current = m.getBoundingClientRect().height, k();
144
+ }, [$, k]);
145
145
  return P(() => {
146
- const m = M();
147
- return a.current && (m == null || m.observe(a.current)), n.current && (m == null || m.observe(n.current)), () => {
148
- var _;
149
- (_ = r.current) == null || _.disconnect(), r.current = null, T();
146
+ const m = $();
147
+ return n.current && (m == null || m.observe(n.current)), r.current && (m == null || m.observe(r.current)), () => {
148
+ var b;
149
+ (b = l.current) == null || b.disconnect(), l.current = null, A();
150
150
  };
151
- }, [M, T]), P(() => {
152
- a.current && (N(!0), S());
153
- }, [t.columns, t.cellAspect, t.stackBelow, N, S]), { rootRef: k, gridRef: w, stacked: u };
151
+ }, [$, A]), P(() => {
152
+ n.current && (R(!0), k());
153
+ }, [e.columns, e.cellAspect, e.stackBelow, R, k]), { rootRef: y, gridRef: w, stacked: d };
154
154
  }
155
- const Xe = {
155
+ const Qe = {
156
156
  empty: "Sem dados",
157
157
  error: "Não foi possível carregar",
158
158
  loading: "Carregando...",
159
159
  unconfigured: "Widget não configurado"
160
160
  };
161
- function re({ kind: t, message: e }) {
162
- return /* @__PURE__ */ l("div", { className: `widget__state widget__state--${t}`, role: t === "error" ? "alert" : void 0, children: e || Xe[t] });
163
- }
164
- function L({ name: t, title: e, state: a, stateMessage: n, toolbar: r, children: s }) {
165
- return /* @__PURE__ */ v("div", { className: `widget widget-${t}`, children: [
166
- e && /* @__PURE__ */ l("span", { className: "widget__title", children: e }),
167
- r,
168
- a ? /* @__PURE__ */ l(re, { kind: a, message: n }) : s
161
+ function j({ kind: e, message: t }) {
162
+ return /* @__PURE__ */ a("div", { className: `widget__state widget__state--${e}`, role: e === "error" ? "alert" : void 0, children: t || Qe[e] });
163
+ }
164
+ function I({ name: e, title: t, state: n, stateMessage: r, toolbar: l, children: i }) {
165
+ return /* @__PURE__ */ v("div", { className: `widget widget-${e}`, children: [
166
+ t && /* @__PURE__ */ a("span", { className: "widget__title", children: t }),
167
+ l,
168
+ n ? /* @__PURE__ */ a(j, { kind: n, message: r }) : i
169
169
  ] });
170
170
  }
171
- const Ue = { up: "↑", down: "↓" };
172
- function qe({ data: t, label: e }) {
173
- const a = e || String(t.label || ""), n = String(t.formatted || "-"), r = t.comparison, s = (r == null ? void 0 : r.trend) ?? "", c = s === "up" || s === "down" ? ` widget-kpi__trend--${s}` : "", i = r == null ? void 0 : r.variance_pct;
174
- return /* @__PURE__ */ v(L, { name: "kpi", title: a, children: [
175
- /* @__PURE__ */ l("span", { className: "widget-kpi__value", children: n }),
176
- i != null && /* @__PURE__ */ v("div", { className: `widget-kpi__trend${c}`, children: [
177
- /* @__PURE__ */ v("span", { className: "widget-kpi__variance", children: [
178
- Ue[s] ?? "",
179
- " ",
180
- i > 0 ? "+" : "",
181
- i.toFixed(1),
182
- "%"
183
- ] }),
184
- (r == null ? void 0 : r.label) && /* @__PURE__ */ l("span", { className: "widget-kpi__trend-label", children: r.label })
185
- ] })
171
+ const Je = { up: "↑", down: "↓" };
172
+ function ge(e) {
173
+ return Array.isArray(e) ? e.filter(
174
+ (t) => t && t.status === "ok" && t.formatted && t.formatted !== "-"
175
+ ) : [];
176
+ }
177
+ function Ze({ comparison: e, primary: t }) {
178
+ const n = e.sentiment ?? "neutral", r = Je[e.trend ?? ""] ?? "";
179
+ return /* @__PURE__ */ v("div", { className: `widget-kpi__trend widget-kpi__trend--${n}${t ? "" : " widget-kpi__trend--muted"}`, children: [
180
+ /* @__PURE__ */ v("span", { className: "widget-kpi__variance", children: [
181
+ r,
182
+ " ",
183
+ e.formatted
184
+ ] }),
185
+ e.label && /* @__PURE__ */ a("span", { className: "widget-kpi__trend-label", children: e.label })
186
+ ] });
187
+ }
188
+ function Be({ data: e, label: t }) {
189
+ const n = t || String(e.label || ""), r = String(e.formatted || "-"), l = ge(e.comparisons);
190
+ return /* @__PURE__ */ v(I, { name: "kpi", title: n, children: [
191
+ /* @__PURE__ */ a("span", { className: "widget-kpi__value", children: r }),
192
+ l.map((i, o) => /* @__PURE__ */ a(Ze, { comparison: i, primary: o === 0 }, i.id || o))
186
193
  ] });
187
194
  }
188
- const Je = "var(--bg-elevated)", Qe = [
195
+ const et = "var(--bg-elevated)", tt = [
189
196
  [1, "var(--color-success)"],
190
197
  [0.7, ""],
191
198
  // vazio = cor da serie 1 (destaque do dashboard)
192
199
  [0.4, "var(--color-warning)"],
193
200
  [0, "var(--color-error)"]
194
201
  ];
195
- function J(t, e, a, n) {
196
- if (n <= 0) return "";
197
- if (n >= 1)
198
- return `M ${t - a} ${e} A ${a} ${a} 0 0 1 ${t} ${e - a} A ${a} ${a} 0 0 1 ${t + a} ${e}`;
199
- const r = n * Math.PI;
200
- return `M ${t - a} ${e} A ${a} ${a} 0 0 1 ${t - a * Math.cos(r)} ${e - a * Math.sin(r)}`;
201
- }
202
- function Ze({ data: t, palette: e, label: a }) {
203
- const n = a || String(t.label || ""), r = typeof t.ratio == "number" ? t.ratio : 0, s = typeof t.format == "string" ? t.format : void 0, c = String(t.value_formatted || j(t.value, s)), i = String(t.target_formatted || j(t.target_value, s)), f = String(t.formatted || "-"), d = t.comparison_label, g = r >= 1, o = Math.min(Math.max(r, 0), 1), u = Qe.find(([S]) => r >= S), y = (u == null ? void 0 : u[1]) || e[0] || "var(--color-info)", h = 50, b = 50, N = 44, T = 10;
204
- return /* @__PURE__ */ l(L, { name: "gauge", title: n, children: /* @__PURE__ */ v("div", { className: "widget-gauge__chart", children: [
205
- /* @__PURE__ */ v("svg", { viewBox: "0 0 100 56", preserveAspectRatio: "xMidYMax meet", role: "img", "aria-label": `${f} da meta`, children: [
206
- /* @__PURE__ */ l("path", { d: J(h, b, N, 1), fill: "none", stroke: Je, strokeWidth: T, strokeLinecap: "butt" }),
207
- o > 0 && /* @__PURE__ */ l("path", { d: J(h, b, N, o), fill: "none", stroke: y, strokeWidth: T, strokeLinecap: "butt" })
202
+ function B(e, t, n, r) {
203
+ if (r <= 0) return "";
204
+ if (r >= 1)
205
+ return `M ${e - n} ${t} A ${n} ${n} 0 0 1 ${e} ${t - n} A ${n} ${n} 0 0 1 ${e + n} ${t}`;
206
+ const l = r * Math.PI;
207
+ return `M ${e - n} ${t} A ${n} ${n} 0 0 1 ${e - n * Math.cos(l)} ${t - n * Math.sin(l)}`;
208
+ }
209
+ function rt({ data: e, palette: t, label: n }) {
210
+ const r = n || String(e.label || ""), l = typeof e.ratio == "number" ? e.ratio : 0, i = typeof e.format == "string" ? e.format : void 0, o = String(e.value_formatted || ie(e.value, i)), s = String(e.formatted || "-"), h = ge(e.comparisons), [c, ...g] = h, u = String((c == null ? void 0 : c.baseline_formatted) || "-"), d = (c == null ? void 0 : c.label) ?? null, f = l >= 1, _ = Math.min(Math.max(l, 0), 1), S = tt.find(([y]) => l >= y), R = (S == null ? void 0 : S[1]) || t[0] || "var(--color-info)", A = 50, k = 50, E = 44, $ = 10;
211
+ return /* @__PURE__ */ a(I, { name: "gauge", title: r, children: /* @__PURE__ */ v("div", { className: "widget-gauge__chart", children: [
212
+ /* @__PURE__ */ v("svg", { viewBox: "0 0 100 56", preserveAspectRatio: "xMidYMax meet", role: "img", "aria-label": `${s} da meta`, children: [
213
+ /* @__PURE__ */ a("path", { d: B(A, k, E, 1), fill: "none", stroke: et, strokeWidth: $, strokeLinecap: "butt" }),
214
+ _ > 0 && /* @__PURE__ */ a("path", { d: B(A, k, E, _), fill: "none", stroke: R, strokeWidth: $, strokeLinecap: "butt" })
208
215
  ] }),
209
216
  /* @__PURE__ */ v("div", { className: "widget-gauge__center", children: [
210
- /* @__PURE__ */ l("span", { className: "widget-gauge__percent", children: f }),
217
+ /* @__PURE__ */ a("span", { className: "widget-gauge__percent", children: s }),
211
218
  /* @__PURE__ */ v("span", { className: "widget-gauge__comparison", children: [
212
- c,
219
+ o,
213
220
  " / ",
214
- i
221
+ u
215
222
  ] }),
216
- g && /* @__PURE__ */ l("span", { className: "widget-gauge__badge", children: d || "Meta batida" }),
217
- !g && d && /* @__PURE__ */ l("span", { className: "widget-gauge__comparison", children: d })
223
+ f && /* @__PURE__ */ a("span", { className: "widget-gauge__badge", children: d || "Meta batida" }),
224
+ !f && d && /* @__PURE__ */ a("span", { className: "widget-gauge__comparison", children: d }),
225
+ g.map((y, w) => /* @__PURE__ */ v("span", { className: "widget-gauge__comparison", children: [
226
+ y.formatted,
227
+ " ",
228
+ y.label
229
+ ] }, y.id || w))
218
230
  ] })
219
231
  ] }) });
220
232
  }
221
- const Q = { fontSize: 10, fill: "var(--text-muted)" }, Be = "var(--bg-elevated)", ae = {
233
+ function me(e) {
234
+ const [t, n] = M({ width: 0, height: 0 });
235
+ return P(() => {
236
+ const r = e.current;
237
+ if (!r) return;
238
+ const l = new ResizeObserver(([i]) => {
239
+ const { width: o, height: s } = i.contentRect;
240
+ n(
241
+ (h) => h.width !== Math.floor(o) || h.height !== Math.floor(s) ? { width: Math.floor(o), height: Math.floor(s) } : h
242
+ );
243
+ });
244
+ return l.observe(r), () => l.disconnect();
245
+ }, [e]), t;
246
+ }
247
+ const ee = { fontSize: 10, fill: "var(--text-muted)" }, at = "var(--bg-elevated)", nt = {
222
248
  backgroundColor: "var(--bg-elevated)",
223
249
  border: "1px solid var(--bg-paper)",
224
250
  borderRadius: "6px",
225
251
  color: "var(--text-primary)"
226
- }, ne = {
252
+ }, lt = {
227
253
  color: "var(--text-primary)",
228
254
  fontWeight: 600
229
255
  };
230
- function le(t, e) {
231
- var r;
232
- const a = Array.isArray(e) ? e[0] : void 0, n = (r = a == null ? void 0 : a.payload) == null ? void 0 : r.tooltipLabel;
233
- return typeof n == "string" && n ? n : String(t ?? "");
256
+ function it(e, t) {
257
+ var l;
258
+ const n = Array.isArray(t) ? t[0] : void 0, r = (l = n == null ? void 0 : n.payload) == null ? void 0 : l.tooltipLabel;
259
+ return typeof r == "string" && r ? r : String(e ?? "");
234
260
  }
235
- function et(t) {
236
- const [e, a] = F({ width: 0, height: 0 });
237
- return P(() => {
238
- const n = t.current;
239
- if (!n) return;
240
- const r = new ResizeObserver(([s]) => {
241
- const { width: c, height: i } = s.contentRect;
242
- a(
243
- (f) => f.width !== Math.floor(c) || f.height !== Math.floor(i) ? { width: Math.floor(c), height: Math.floor(i) } : f
244
- );
245
- });
246
- return r.observe(n), () => r.disconnect();
247
- }, [t]), e;
248
- }
249
- function Y({ Chart: t, chartData: e, xKey: a, series: n, palette: r, renderSeries: s, width: c, height: i }) {
250
- return /* @__PURE__ */ v(t, { data: e, width: c, height: i, children: [
251
- /* @__PURE__ */ l(We, { strokeDasharray: "3 3", stroke: Be }),
252
- /* @__PURE__ */ l(Ie, { dataKey: a, tick: Q }),
253
- /* @__PURE__ */ l(Le, { tick: Q }),
254
- /* @__PURE__ */ l(
255
- te,
261
+ function Y({ Chart: e, chartData: t, xKey: n, series: r, palette: l, renderSeries: i, width: o, height: s }) {
262
+ return /* @__PURE__ */ v(e, { data: t, width: o, height: s, children: [
263
+ /* @__PURE__ */ a(de, { strokeDasharray: "3 3", stroke: at }),
264
+ /* @__PURE__ */ a(ue, { dataKey: n, tick: ee }),
265
+ /* @__PURE__ */ a(he, { tick: ee }),
266
+ /* @__PURE__ */ a(
267
+ K,
256
268
  {
257
- contentStyle: ae,
258
- labelStyle: ne,
259
- labelFormatter: le,
269
+ contentStyle: nt,
270
+ labelStyle: lt,
271
+ labelFormatter: it,
260
272
  cursor: { fill: "var(--bg-paper)", opacity: 0.3 }
261
273
  }
262
274
  ),
263
- n.length > 1 && /* @__PURE__ */ l(Oe, {}),
264
- n.map((f, d) => s(f, r[d % r.length], d))
275
+ r.length > 1 && /* @__PURE__ */ a(Pe, {}),
276
+ r.map((h, c) => i(h, l[c % l.length], c))
265
277
  ] });
266
278
  }
267
- function tt({ data: t, palette: e, label: a }) {
268
- const n = String(t.chartType || "bar"), r = a || String(t.label || ""), s = String(t.xKey || "label"), c = t.series || [], i = t.data || [], f = R(null), { width: d, height: g } = et(f), o = () => {
269
- var y;
270
- if (d <= 0 || g <= 0) return null;
271
- if (n === "pie")
272
- return /* @__PURE__ */ v(Ce, { width: d, height: g, children: [
273
- /* @__PURE__ */ l(
274
- Re,
275
- {
276
- data: i,
277
- dataKey: ((y = c[0]) == null ? void 0 : y.key) || "s0",
278
- nameKey: s,
279
- cx: "50%",
280
- cy: "50%",
281
- outerRadius: "75%",
282
- label: ({ name: h, percent: b }) => `${h}: ${(b * 100).toFixed(0)}%`,
283
- labelLine: !1,
284
- children: i.map((h, b) => /* @__PURE__ */ l($e, { fill: e[b % e.length] }, b))
285
- }
286
- ),
287
- /* @__PURE__ */ l(
288
- te,
289
- {
290
- contentStyle: ae,
291
- labelStyle: ne,
292
- labelFormatter: le
293
- }
294
- )
295
- ] });
296
- const u = { chartData: i, xKey: s, series: c, palette: e, width: d, height: g };
297
- return n === "line" ? /* @__PURE__ */ l(Y, { ...u, Chart: xe, renderSeries: (h, b) => /* @__PURE__ */ l(
298
- Me,
279
+ function st({ data: e, palette: t, label: n }) {
280
+ const r = String(e.chartType || "bar"), l = n || String(e.label || ""), i = String(e.xKey || "label"), o = e.series || [], s = e.data || [], h = N(null), { width: c, height: g } = me(h), u = () => {
281
+ if (c <= 0 || g <= 0) return null;
282
+ const d = { chartData: s, xKey: i, series: o, palette: t, width: c, height: g };
283
+ return r === "line" ? /* @__PURE__ */ a(Y, { ...d, Chart: Le, renderSeries: (f, _) => /* @__PURE__ */ a(
284
+ Ie,
299
285
  {
300
286
  type: "monotone",
301
- dataKey: h.key,
302
- name: h.label,
303
- stroke: b,
287
+ dataKey: f.key,
288
+ name: f.label,
289
+ stroke: _,
304
290
  strokeWidth: 2,
305
- dot: i.length <= 31
291
+ dot: s.length <= 31
306
292
  },
307
- h.key
308
- ) }) : n === "area" ? /* @__PURE__ */ l(Y, { ...u, Chart: Fe, renderSeries: (h, b) => /* @__PURE__ */ l(
309
- Te,
293
+ f.key
294
+ ) }) : r === "area" ? /* @__PURE__ */ a(Y, { ...d, Chart: We, renderSeries: (f, _) => /* @__PURE__ */ a(
295
+ Oe,
310
296
  {
311
297
  type: "monotone",
312
- dataKey: h.key,
313
- name: h.label,
314
- fill: b,
315
- stroke: b,
298
+ dataKey: f.key,
299
+ name: f.label,
300
+ fill: _,
301
+ stroke: _,
316
302
  fillOpacity: 0.3
317
303
  },
318
- h.key
319
- ) }) : /* @__PURE__ */ l(Y, { ...u, Chart: Ae, renderSeries: (h, b) => /* @__PURE__ */ l(
320
- Ee,
304
+ f.key
305
+ ) }) : /* @__PURE__ */ a(Y, { ...d, Chart: ce, renderSeries: (f, _) => /* @__PURE__ */ a(
306
+ z,
321
307
  {
322
- dataKey: h.key,
323
- name: h.label,
324
- fill: b,
308
+ dataKey: f.key,
309
+ name: f.label,
310
+ fill: _,
325
311
  radius: [3, 3, 0, 0]
326
312
  },
327
- h.key
313
+ f.key
328
314
  ) });
329
315
  };
330
- return /* @__PURE__ */ l(L, { name: "chart", title: r, children: /* @__PURE__ */ l("div", { ref: f, className: "widget-chart__container", children: i.length === 0 ? /* @__PURE__ */ l(re, { kind: "empty" }) : o() }) });
316
+ return /* @__PURE__ */ a(I, { name: "chart", title: l, children: /* @__PURE__ */ a("div", { ref: h, className: "widget-chart__container", children: s.length === 0 ? /* @__PURE__ */ a(j, { kind: "empty" }) : u() }) });
317
+ }
318
+ const te = { fontSize: 10, fill: "var(--text-muted)" }, ot = "var(--bg-elevated)", re = {
319
+ backgroundColor: "var(--bg-elevated)",
320
+ border: "1px solid var(--bg-paper)",
321
+ borderRadius: "6px",
322
+ color: "var(--text-primary)"
323
+ }, ae = {
324
+ color: "var(--text-primary)",
325
+ fontWeight: 600
326
+ };
327
+ function ct(e) {
328
+ return e.kind === "anchor" ? "var(--color-accent)" : e.kind === "residual" ? "var(--color-warning)" : e.value < 0 ? "var(--color-error)" : "var(--color-success)";
329
+ }
330
+ function ne(e, t, n) {
331
+ const r = n == null ? void 0 : n.payload;
332
+ return [(r == null ? void 0 : r.formatted) ?? "-", (r == null ? void 0 : r.label) ?? ""];
333
+ }
334
+ function dt({ data: e, palette: t, label: n }) {
335
+ const r = n || String(e.label || ""), l = String(e.display || "pie"), i = e.data || [], o = typeof e.format == "string" ? e.format : void 0, s = N(null), { width: h, height: c } = me(s), g = () => /* @__PURE__ */ v(ce, { data: i, width: h, height: c, children: [
336
+ /* @__PURE__ */ a(de, { strokeDasharray: "3 3", stroke: ot }),
337
+ /* @__PURE__ */ a(ue, { dataKey: "label", tick: te, interval: 0 }),
338
+ /* @__PURE__ */ a(he, { tick: te, tickFormatter: (d) => ie(d, o) }),
339
+ /* @__PURE__ */ a(
340
+ K,
341
+ {
342
+ contentStyle: re,
343
+ labelStyle: ae,
344
+ formatter: ne,
345
+ cursor: { fill: "var(--bg-paper)", opacity: 0.3 }
346
+ }
347
+ ),
348
+ /* @__PURE__ */ a(z, { dataKey: "base", stackId: "bridge", fill: "none", fillOpacity: 0, isAnimationActive: !1 }),
349
+ /* @__PURE__ */ a(z, { dataKey: "span", stackId: "bridge", radius: [3, 3, 0, 0], children: i.map((d, f) => /* @__PURE__ */ a(Z, { fill: ct(d) }, f)) })
350
+ ] }), u = () => /* @__PURE__ */ v(De, { width: h, height: c, children: [
351
+ /* @__PURE__ */ a(
352
+ He,
353
+ {
354
+ data: i,
355
+ dataKey: "value",
356
+ nameKey: "label",
357
+ cx: "50%",
358
+ cy: "50%",
359
+ outerRadius: "75%",
360
+ label: ({ name: d, percent: f }) => `${d}: ${(f * 100).toFixed(0)}%`,
361
+ labelLine: !1,
362
+ children: i.map((d, f) => /* @__PURE__ */ a(Z, { fill: t[f % t.length] }, f))
363
+ }
364
+ ),
365
+ /* @__PURE__ */ a(
366
+ K,
367
+ {
368
+ contentStyle: re,
369
+ labelStyle: ae,
370
+ formatter: ne
371
+ }
372
+ )
373
+ ] });
374
+ return /* @__PURE__ */ a(I, { name: "composition", title: r, children: /* @__PURE__ */ a("div", { ref: s, className: "widget-composition__container", children: i.length === 0 || h <= 0 || c <= 0 ? /* @__PURE__ */ a(j, { kind: "empty" }) : l === "bridge" ? g() : u() }) });
331
375
  }
332
- function rt(t, e) {
333
- if (e !== "percentage") return "";
334
- const a = Number(t);
335
- return Number.isNaN(a) || a === 0 ? "" : a > 0 ? " widget-table__td--up" : " widget-table__td--down";
376
+ function ut(e, t) {
377
+ if (t !== "percentage") return "";
378
+ const n = Number(e);
379
+ return Number.isNaN(n) || n === 0 ? "" : n > 0 ? " widget-table__td--up" : " widget-table__td--down";
336
380
  }
337
- function at({ data: t, label: e }) {
381
+ function ht({ data: e, label: t }) {
338
382
  var g;
339
- const [a, n] = F(0), r = t.columns || [], s = t.tabs || [], c = s.length > 0, i = c ? ((g = s[Math.min(a, s.length - 1)]) == null ? void 0 : g.rows) || [] : t.rows || [], f = e || String(t.label || "");
340
- if (r.length === 0)
341
- return /* @__PURE__ */ l(
342
- L,
383
+ const [n, r] = M(0), l = e.columns || [], i = e.tabs || [], o = i.length > 0, s = o ? ((g = i[Math.min(n, i.length - 1)]) == null ? void 0 : g.rows) || [] : e.rows || [], h = t || String(e.label || "");
384
+ if (l.length === 0)
385
+ return /* @__PURE__ */ a(
386
+ I,
343
387
  {
344
388
  name: "table",
345
- title: f,
389
+ title: h,
346
390
  state: "unconfigured",
347
391
  stateMessage: "Configure as colunas da tabela."
348
392
  }
349
393
  );
350
- const d = c ? /* @__PURE__ */ l("div", { className: "widget-table__tabs", role: "tablist", children: s.map((o, u) => /* @__PURE__ */ l(
394
+ const c = o ? /* @__PURE__ */ a("div", { className: "widget-table__tabs", role: "tablist", children: i.map((u, d) => /* @__PURE__ */ a(
351
395
  "button",
352
396
  {
353
397
  type: "button",
354
398
  role: "tab",
355
- "aria-selected": u === a,
356
- className: `widget-table__tab${u === a ? " widget-table__tab--active" : ""}`,
357
- onClick: () => n(u),
358
- children: o.label
399
+ "aria-selected": d === n,
400
+ className: `widget-table__tab${d === n ? " widget-table__tab--active" : ""}`,
401
+ onClick: () => r(d),
402
+ children: u.label
359
403
  },
360
- u
404
+ d
361
405
  )) }) : void 0;
362
- return /* @__PURE__ */ l(L, { name: "table", title: f, toolbar: d, children: /* @__PURE__ */ l("div", { className: "widget-table__scroll", children: /* @__PURE__ */ v("table", { className: "widget-table__table", children: [
363
- /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ l("tr", { children: r.map((o) => /* @__PURE__ */ l(
406
+ return /* @__PURE__ */ a(I, { name: "table", title: h, toolbar: c, children: /* @__PURE__ */ a("div", { className: "widget-table__scroll", children: /* @__PURE__ */ v("table", { className: "widget-table__table", children: [
407
+ /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: l.map((u) => /* @__PURE__ */ a(
364
408
  "th",
365
409
  {
366
- className: `widget-table__th${X(o.format) ? " widget-table__th--num" : ""}`,
367
- children: o.label || o.key
410
+ className: `widget-table__th${U(u.format) ? " widget-table__th--num" : ""}`,
411
+ children: u.label || u.key
368
412
  },
369
- o.key
413
+ u.key
370
414
  )) }) }),
371
- /* @__PURE__ */ l("tbody", { children: i.length === 0 ? /* @__PURE__ */ l("tr", { children: /* @__PURE__ */ l("td", { className: "widget-table__td widget-table__td--placeholder", colSpan: r.length, children: "Sem dados" }) }) : i.map((o, u) => /* @__PURE__ */ l("tr", { children: r.map((y) => {
372
- const h = o[y.key], b = X(y.format) ? " widget-table__td--num" : "";
373
- return /* @__PURE__ */ l("td", { className: `widget-table__td${b}${rt(h, y.format)}`, children: de(h, y.format) }, y.key);
374
- }) }, u)) })
415
+ /* @__PURE__ */ a("tbody", { children: s.length === 0 ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { className: "widget-table__td widget-table__td--placeholder", colSpan: l.length, children: "Sem dados" }) }) : s.map((u, d) => /* @__PURE__ */ a("tr", { children: l.map((f) => {
416
+ const _ = u[f.key], S = U(f.format) ? " widget-table__td--num" : "";
417
+ return /* @__PURE__ */ a("td", { className: `widget-table__td${S}${ut(_, f.format)}`, children: ve(_, f.format) }, f.key);
418
+ }) }, d)) })
375
419
  ] }) }) });
376
420
  }
377
- function nt({ config: t, value: e, options: a = [], dateBounds: n, onChange: r }) {
378
- const s = t.filterType || "select", c = t.label || "Filtro", i = t.dateFilterMode || "range";
421
+ function gt({ config: e, value: t, options: n = [], dateBounds: r, onChange: l }) {
422
+ const i = e.filterType || "select", o = e.label || "Filtro", s = e.dateFilterMode || "range";
379
423
  return /* @__PURE__ */ v("div", { className: "widget-filter", children: [
380
- /* @__PURE__ */ l("label", { className: "widget-filter__label", children: c }),
381
- s === "date_range" ? i === "yearly" ? /* @__PURE__ */ l(st, { value: e, dateBounds: n, onChange: r }) : i === "monthly" ? /* @__PURE__ */ l(it, { value: e, dateBounds: n, onChange: r }) : i === "weekly" ? /* @__PURE__ */ l(ct, { value: e, dateBounds: n, onChange: r }) : /* @__PURE__ */ l(lt, { value: e, dateBounds: n, onChange: r }) : /* @__PURE__ */ l(
382
- ot,
424
+ /* @__PURE__ */ a("label", { className: "widget-filter__label", children: o }),
425
+ i === "date_range" ? s === "yearly" ? /* @__PURE__ */ a(ft, { value: t, dateBounds: r, onChange: l }) : s === "monthly" ? /* @__PURE__ */ a(pt, { value: t, dateBounds: r, onChange: l }) : s === "weekly" ? /* @__PURE__ */ a(bt, { value: t, dateBounds: r, onChange: l }) : /* @__PURE__ */ a(mt, { value: t, dateBounds: r, onChange: l }) : /* @__PURE__ */ a(
426
+ _t,
383
427
  {
384
- value: e,
385
- options: a,
386
- multi: s === "multi_select",
387
- searchable: t.searchable || !1,
388
- onChange: r
428
+ value: t,
429
+ options: n,
430
+ multi: i === "multi_select",
431
+ searchable: e.searchable || !1,
432
+ onChange: l
389
433
  }
390
434
  )
391
435
  ] });
392
436
  }
393
- function lt({ value: t, dateBounds: e, onChange: a }) {
394
- const [n, r] = t ? t.split("|") : ["", ""];
437
+ function mt({ value: e, dateBounds: t, onChange: n }) {
438
+ const [r, l] = e ? e.split("|") : ["", ""];
395
439
  return /* @__PURE__ */ v("div", { className: "widget-filter__date-range widget-filter__date-range--stacked", children: [
396
- /* @__PURE__ */ l(
397
- U,
440
+ /* @__PURE__ */ a(
441
+ Q,
398
442
  {
399
- value: n,
400
- minIso: e == null ? void 0 : e.min,
401
- maxIso: r || (e == null ? void 0 : e.max),
443
+ value: r,
444
+ minIso: t == null ? void 0 : t.min,
445
+ maxIso: l || (t == null ? void 0 : t.max),
402
446
  selectsStart: !0,
403
- startIso: n,
404
- endIso: r,
447
+ startIso: r,
448
+ endIso: l,
405
449
  placeholder: "Data inicial",
406
- onChange: (s) => a(`${s}|${r}`)
450
+ onChange: (i) => n(`${i}|${l}`)
407
451
  }
408
452
  ),
409
- /* @__PURE__ */ l(
410
- U,
453
+ /* @__PURE__ */ a(
454
+ Q,
411
455
  {
412
- value: r,
413
- minIso: n || (e == null ? void 0 : e.min),
414
- maxIso: e == null ? void 0 : e.max,
456
+ value: l,
457
+ minIso: r || (t == null ? void 0 : t.min),
458
+ maxIso: t == null ? void 0 : t.max,
415
459
  selectsEnd: !0,
416
- startIso: n,
417
- endIso: r,
460
+ startIso: r,
461
+ endIso: l,
418
462
  placeholder: "Data final",
419
- onChange: (s) => a(`${n}|${s}`)
463
+ onChange: (i) => n(`${r}|${i}`)
420
464
  }
421
465
  )
422
466
  ] });
423
467
  }
424
- function st({ value: t, dateBounds: e, onChange: a }) {
425
- const [n] = t ? t.split("|") : [""], r = ue(n), s = /* @__PURE__ */ new Date(), c = (r == null ? void 0 : r.year) ?? s.getFullYear(), i = z(e), f = (d) => {
426
- const g = fe(d);
427
- a(`${g.start}|${g.end}`);
468
+ function ft({ value: e, dateBounds: t, onChange: n }) {
469
+ const [r] = e ? e.split("|") : [""], l = we(r), i = /* @__PURE__ */ new Date(), o = (l == null ? void 0 : l.year) ?? i.getFullYear(), s = V(t), h = (c) => {
470
+ const g = Ne(c);
471
+ n(`${g.start}|${g.end}`);
428
472
  };
429
- return /* @__PURE__ */ l("div", { className: "widget-filter__date-range widget-filter__date-range--year", children: /* @__PURE__ */ l(
473
+ return /* @__PURE__ */ a("div", { className: "widget-filter__date-range widget-filter__date-range--year", children: /* @__PURE__ */ a(
430
474
  "select",
431
475
  {
432
476
  className: "widget-filter__select",
433
- value: c,
434
- onChange: (d) => f(parseInt(d.target.value)),
435
- children: i.map((d) => /* @__PURE__ */ l("option", { value: d, children: d }, d))
477
+ value: o,
478
+ onChange: (c) => h(parseInt(c.target.value)),
479
+ children: s.map((c) => /* @__PURE__ */ a("option", { value: c, children: c }, c))
436
480
  }
437
481
  ) });
438
482
  }
439
- function it({ value: t, dateBounds: e, onChange: a }) {
440
- const [n] = t ? t.split("|") : [""], r = B(n), s = /* @__PURE__ */ new Date(), c = (r == null ? void 0 : r.year) ?? s.getFullYear(), i = (r == null ? void 0 : r.month) ?? s.getMonth() + 1, f = z(e), d = (g, o) => {
441
- const u = me(g, o);
442
- a(`${u.start}|${u.end}`);
483
+ function pt({ value: e, dateBounds: t, onChange: n }) {
484
+ const [r] = e ? e.split("|") : [""], l = se(r), i = /* @__PURE__ */ new Date(), o = (l == null ? void 0 : l.year) ?? i.getFullYear(), s = (l == null ? void 0 : l.month) ?? i.getMonth() + 1, h = V(t), c = (g, u) => {
485
+ const d = Se(g, u);
486
+ n(`${d.start}|${d.end}`);
443
487
  };
444
488
  return /* @__PURE__ */ v("div", { className: "widget-filter__date-range widget-filter__date-range--month", children: [
445
- /* @__PURE__ */ l(
489
+ /* @__PURE__ */ a(
446
490
  "select",
447
491
  {
448
492
  className: "widget-filter__select",
449
- value: i,
450
- onChange: (g) => d(c, parseInt(g.target.value)),
451
- children: ee.map((g, o) => /* @__PURE__ */ l("option", { value: o + 1, children: g }, o + 1))
493
+ value: s,
494
+ onChange: (g) => c(o, parseInt(g.target.value)),
495
+ children: oe.map((g, u) => /* @__PURE__ */ a("option", { value: u + 1, children: g }, u + 1))
452
496
  }
453
497
  ),
454
- /* @__PURE__ */ l(
498
+ /* @__PURE__ */ a(
455
499
  "select",
456
500
  {
457
501
  className: "widget-filter__select",
458
- value: c,
459
- onChange: (g) => d(parseInt(g.target.value), i),
460
- children: f.map((g) => /* @__PURE__ */ l("option", { value: g, children: g }, g))
502
+ value: o,
503
+ onChange: (g) => c(parseInt(g.target.value), s),
504
+ children: h.map((g) => /* @__PURE__ */ a("option", { value: g, children: g }, g))
461
505
  }
462
506
  )
463
507
  ] });
464
508
  }
465
- function ct({ value: t, dateBounds: e, onChange: a }) {
466
- const [n] = t ? t.split("|") : [""], r = B(n), s = /* @__PURE__ */ new Date(), c = (r == null ? void 0 : r.year) ?? s.getFullYear(), i = (r == null ? void 0 : r.month) ?? s.getMonth() + 1, f = z(e), d = H(c, i), g = he(n, c, i) || 1;
509
+ function bt({ value: e, dateBounds: t, onChange: n }) {
510
+ const [r] = e ? e.split("|") : [""], l = se(r), i = /* @__PURE__ */ new Date(), o = (l == null ? void 0 : l.year) ?? i.getFullYear(), s = (l == null ? void 0 : l.month) ?? i.getMonth() + 1, h = V(t), c = H(o, s), g = ye(r, o, s) || 1;
467
511
  return /* @__PURE__ */ v("div", { className: "widget-filter__date-range widget-filter__date-range--week", children: [
468
- /* @__PURE__ */ l(
512
+ /* @__PURE__ */ a(
469
513
  "select",
470
514
  {
471
515
  className: "widget-filter__select",
472
- value: c,
473
- onChange: (o) => {
474
- const u = parseInt(o.target.value), h = H(u, i)[0];
475
- h && a(`${h.start}|${h.end}`);
516
+ value: o,
517
+ onChange: (u) => {
518
+ const d = parseInt(u.target.value), _ = H(d, s)[0];
519
+ _ && n(`${_.start}|${_.end}`);
476
520
  },
477
- children: f.map((o) => /* @__PURE__ */ l("option", { value: o, children: o }, o))
521
+ children: h.map((u) => /* @__PURE__ */ a("option", { value: u, children: u }, u))
478
522
  }
479
523
  ),
480
- /* @__PURE__ */ l(
524
+ /* @__PURE__ */ a(
481
525
  "select",
482
526
  {
483
527
  className: "widget-filter__select",
484
- value: i,
485
- onChange: (o) => {
486
- const u = parseInt(o.target.value), h = H(c, u)[0];
487
- h && a(`${h.start}|${h.end}`);
528
+ value: s,
529
+ onChange: (u) => {
530
+ const d = parseInt(u.target.value), _ = H(o, d)[0];
531
+ _ && n(`${_.start}|${_.end}`);
488
532
  },
489
- children: ee.map((o, u) => /* @__PURE__ */ l("option", { value: u + 1, children: o }, u + 1))
533
+ children: oe.map((u, d) => /* @__PURE__ */ a("option", { value: d + 1, children: u }, d + 1))
490
534
  }
491
535
  ),
492
- /* @__PURE__ */ l(
536
+ /* @__PURE__ */ a(
493
537
  "select",
494
538
  {
495
539
  className: "widget-filter__select",
496
540
  value: g,
497
- onChange: (o) => {
498
- const u = d[parseInt(o.target.value) - 1];
499
- u && a(`${u.start}|${u.end}`);
541
+ onChange: (u) => {
542
+ const d = c[parseInt(u.target.value) - 1];
543
+ d && n(`${d.start}|${d.end}`);
500
544
  },
501
- children: d.map((o) => /* @__PURE__ */ l("option", { value: o.index, children: o.label }, o.index))
545
+ children: c.map((u) => /* @__PURE__ */ a("option", { value: u.index, children: u.label }, u.index))
502
546
  }
503
547
  )
504
548
  ] });
505
549
  }
506
- function ot({ value: t, options: e, multi: a, searchable: n, onChange: r }) {
507
- if (n)
508
- return /* @__PURE__ */ l(
509
- ge,
550
+ function _t({ value: e, options: t, multi: n, searchable: r, onChange: l }) {
551
+ if (r)
552
+ return /* @__PURE__ */ a(
553
+ ke,
510
554
  {
511
- value: t,
512
- options: e,
513
- multi: a,
514
- onChange: r
555
+ value: e,
556
+ options: t,
557
+ multi: n,
558
+ onChange: l
515
559
  }
516
560
  );
517
- if (a) {
518
- const s = t ? t.split(G) : [], c = (i) => {
519
- const f = s.includes(i) ? s.filter((d) => d !== i) : [...s, i];
520
- r(f.join(G));
561
+ if (n) {
562
+ const i = e ? e.split(G) : [], o = (s) => {
563
+ const h = i.includes(s) ? i.filter((c) => c !== s) : [...i, s];
564
+ l(h.join(G));
521
565
  };
522
566
  return /* @__PURE__ */ v("div", { className: "widget-filter__multi", children: [
523
- s.length > 0 && /* @__PURE__ */ l(
567
+ i.length > 0 && /* @__PURE__ */ a(
524
568
  "button",
525
569
  {
526
570
  type: "button",
527
571
  className: "widget-filter__multi-clear",
528
- onClick: () => r(""),
572
+ onClick: () => l(""),
529
573
  children: "Limpar filtro"
530
574
  }
531
575
  ),
532
- e.map((i) => /* @__PURE__ */ v("label", { className: "widget-filter__multi-option", children: [
533
- /* @__PURE__ */ l(
576
+ t.map((s) => /* @__PURE__ */ v("label", { className: "widget-filter__multi-option", children: [
577
+ /* @__PURE__ */ a(
534
578
  "input",
535
579
  {
536
580
  type: "checkbox",
537
- checked: s.includes(i),
538
- onChange: () => c(i)
581
+ checked: i.includes(s),
582
+ onChange: () => o(s)
539
583
  }
540
584
  ),
541
- i
542
- ] }, i))
585
+ s
586
+ ] }, s))
543
587
  ] });
544
588
  }
545
589
  return /* @__PURE__ */ v(
546
590
  "select",
547
591
  {
548
592
  className: "widget-filter__select",
549
- value: t,
550
- onChange: (s) => r(s.target.value),
593
+ value: e,
594
+ onChange: (i) => l(i.target.value),
551
595
  children: [
552
- /* @__PURE__ */ l("option", { value: "", children: "Todos" }),
553
- e.map((s) => /* @__PURE__ */ l("option", { value: s, children: s }, s))
596
+ /* @__PURE__ */ a("option", { value: "", children: "Todos" }),
597
+ t.map((i) => /* @__PURE__ */ a("option", { value: i, children: i }, i))
554
598
  ]
555
599
  }
556
600
  );
557
601
  }
558
- const dt = {
602
+ const vt = {
559
603
  currency: "R$",
560
604
  percentage: "%"
561
605
  };
562
- function ut({ config: t, value: e, onChange: a }) {
563
- const n = t.label || "Variavel", r = t.locked || !1, s = t.variableFormat || "number", c = dt[s] || "";
564
- return /* @__PURE__ */ v("div", { className: `widget-variable ${r ? "widget-variable--locked" : ""}`, children: [
565
- /* @__PURE__ */ l("label", { className: "widget-variable__label", children: n }),
606
+ function wt({ config: e, value: t, onChange: n }) {
607
+ const r = e.label || "Variavel", l = e.locked || !1, i = e.variableFormat || "number", o = vt[i] || "";
608
+ return /* @__PURE__ */ v("div", { className: `widget-variable ${l ? "widget-variable--locked" : ""}`, children: [
609
+ /* @__PURE__ */ a("label", { className: "widget-variable__label", children: r }),
566
610
  /* @__PURE__ */ v("div", { className: "widget-variable__input-wrapper", children: [
567
- /* @__PURE__ */ l(
611
+ /* @__PURE__ */ a(
568
612
  "input",
569
613
  {
570
614
  className: "widget-variable__input",
571
615
  type: "number",
572
- value: e,
573
- onChange: (i) => a(parseFloat(i.target.value) || 0),
574
- disabled: r,
575
- step: s === "integer" ? 1 : 0.01
616
+ value: t,
617
+ onChange: (s) => n(parseFloat(s.target.value) || 0),
618
+ disabled: l,
619
+ step: i === "integer" ? 1 : 0.01
576
620
  }
577
621
  ),
578
- c && /* @__PURE__ */ l("span", { className: "widget-variable__suffix", children: c })
622
+ o && /* @__PURE__ */ a("span", { className: "widget-variable__suffix", children: o })
579
623
  ] }),
580
- r && /* @__PURE__ */ l("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
624
+ l && /* @__PURE__ */ a("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
581
625
  ] });
582
626
  }
583
- function ht({ config: t, palette: e, onChange: a }) {
584
- const n = t.label || "Cores", r = t.locked || !1;
585
- return /* @__PURE__ */ v("div", { className: `widget-palette ${r ? "widget-palette--locked" : ""}`, children: [
586
- /* @__PURE__ */ l("label", { className: "widget-palette__label", children: n }),
587
- /* @__PURE__ */ l(pe, { selected: e, onSelect: a, customMode: !0, disabled: r }),
588
- r && /* @__PURE__ */ l("span", { className: "widget-palette__lock-icon", title: "Bloqueado", children: "🔒" })
627
+ function yt({ config: e, palette: t, onChange: n }) {
628
+ const r = e.label || "Cores", l = e.locked || !1;
629
+ return /* @__PURE__ */ v("div", { className: `widget-palette ${l ? "widget-palette--locked" : ""}`, children: [
630
+ /* @__PURE__ */ a("label", { className: "widget-palette__label", children: r }),
631
+ /* @__PURE__ */ a(Ce, { selected: t, onSelect: n, customMode: !0, disabled: l }),
632
+ l && /* @__PURE__ */ a("span", { className: "widget-palette__lock-icon", title: "Bloqueado", children: "🔒" })
589
633
  ] });
590
634
  }
591
- const gt = {
635
+ const kt = {
592
636
  failed_to_compute: "Não foi possível calcular este widget"
593
637
  };
594
- function mt({
595
- type: t,
596
- computed: e,
597
- palette: a,
598
- config: n,
599
- filterValue: r,
600
- filterOptions: s,
601
- dateBounds: c,
602
- onFilterChange: i,
603
- variableValue: f,
604
- onVariableChange: d,
638
+ function St({
639
+ type: e,
640
+ computed: t,
641
+ palette: n,
642
+ config: r,
643
+ filterValue: l,
644
+ filterOptions: i,
645
+ dateBounds: o,
646
+ onFilterChange: s,
647
+ variableValue: h,
648
+ onVariableChange: c,
605
649
  onPaletteChange: g
606
650
  }) {
607
- if (e.error)
608
- return /* @__PURE__ */ l(
609
- L,
651
+ if (t.error)
652
+ return /* @__PURE__ */ a(
653
+ I,
610
654
  {
611
- name: t.replace("_", "-"),
612
- title: n == null ? void 0 : n.label,
655
+ name: e.replace("_", "-"),
656
+ title: r == null ? void 0 : r.label,
613
657
  state: "error",
614
- stateMessage: gt[String(e.error)]
658
+ stateMessage: kt[String(t.error)]
615
659
  }
616
660
  );
617
- const o = _e(a);
618
- switch (t) {
661
+ const u = Re(n);
662
+ switch (e) {
619
663
  case "kpi_card":
620
- return /* @__PURE__ */ l(qe, { data: e, label: n == null ? void 0 : n.label });
664
+ return /* @__PURE__ */ a(Be, { data: t, label: r == null ? void 0 : r.label });
621
665
  case "gauge":
622
- return /* @__PURE__ */ l(Ze, { data: e, palette: o, label: n == null ? void 0 : n.label });
666
+ return /* @__PURE__ */ a(rt, { data: t, palette: u, label: r == null ? void 0 : r.label });
623
667
  case "chart":
624
- return /* @__PURE__ */ l(tt, { data: e, palette: o, label: n == null ? void 0 : n.label });
668
+ return /* @__PURE__ */ a(st, { data: t, palette: u, label: r == null ? void 0 : r.label });
669
+ case "composition":
670
+ return /* @__PURE__ */ a(dt, { data: t, palette: u, label: r == null ? void 0 : r.label });
625
671
  case "table":
626
- return /* @__PURE__ */ l(at, { data: e, label: n == null ? void 0 : n.label });
672
+ return /* @__PURE__ */ a(ht, { data: t, label: r == null ? void 0 : r.label });
627
673
  case "filter":
628
- return n && i ? /* @__PURE__ */ l(
629
- nt,
674
+ return r && s ? /* @__PURE__ */ a(
675
+ gt,
630
676
  {
631
- config: n,
632
- value: r || "",
633
- options: s,
634
- dateBounds: c,
635
- onChange: i
677
+ config: r,
678
+ value: l || "",
679
+ options: i,
680
+ dateBounds: o,
681
+ onChange: s
636
682
  }
637
683
  ) : null;
638
684
  case "variable": {
639
- const u = n;
640
- return u && d ? /* @__PURE__ */ l(
641
- ut,
685
+ const d = r;
686
+ return d && c ? /* @__PURE__ */ a(
687
+ wt,
642
688
  {
643
- config: u,
644
- value: f ?? u.variableValue ?? 0,
645
- onChange: d
689
+ config: d,
690
+ value: h ?? d.variableValue ?? 0,
691
+ onChange: c
646
692
  }
647
693
  ) : null;
648
694
  }
649
695
  case "color_palette":
650
- return n && g ? /* @__PURE__ */ l(
651
- ht,
696
+ return r && g ? /* @__PURE__ */ a(
697
+ yt,
652
698
  {
653
- config: n,
654
- palette: a,
699
+ config: r,
700
+ palette: n,
655
701
  onChange: g
656
702
  }
657
703
  ) : null;
658
704
  default:
659
- return /* @__PURE__ */ l(L, { name: "unknown", state: "unconfigured" });
705
+ return /* @__PURE__ */ a(I, { name: "unknown", state: "unconfigured" });
660
706
  }
661
707
  }
662
- const ft = (t, e) => t.grid.y - e.grid.y || t.grid.x - e.grid.x;
663
- function wt({
664
- token: t,
665
- cellAspect: e = ke,
666
- stackBelow: a,
667
- onGeometryChange: n,
668
- silenceWarnings: r,
669
- className: s
708
+ const Nt = (e, t) => e.grid.y - t.grid.y || e.grid.x - t.grid.x;
709
+ function Tt({
710
+ token: e,
711
+ cellAspect: t = Ee,
712
+ stackBelow: n,
713
+ onGeometryChange: r,
714
+ silenceWarnings: l,
715
+ className: i
670
716
  }) {
671
717
  const {
672
- layout: c,
673
- renderData: i,
674
- loading: f,
675
- error: d,
718
+ layout: o,
719
+ renderData: s,
720
+ loading: h,
721
+ error: c,
676
722
  filters: g,
677
- variables: o,
678
- palette: u,
679
- setFilter: y,
680
- setVariable: h,
681
- setPalette: b
682
- } = De(t), { rootRef: N, gridRef: T, stacked: S } = je({
683
- columns: (c == null ? void 0 : c.gridColumns) ?? 0,
684
- cellAspect: e,
685
- stackBelow: a,
686
- onGeometryChange: n,
687
- silenceWarnings: r
688
- }), O = Z(() => {
689
- const m = (c == null ? void 0 : c.widgets) ?? [];
690
- return S ? [...m].sort(ft) : m;
691
- }, [c == null ? void 0 : c.widgets, S]), M = {
692
- "--dash-gap": `${q}px`,
693
- "--dash-pad": `${Se}px`
694
- }, k = ["preview-tab", s].filter(Boolean).join(" ");
723
+ variables: u,
724
+ palette: d,
725
+ setFilter: f,
726
+ setVariable: _,
727
+ setPalette: S
728
+ } = Ge(e), { rootRef: R, gridRef: A, stacked: k } = Ue({
729
+ columns: (o == null ? void 0 : o.gridColumns) ?? 0,
730
+ cellAspect: t,
731
+ stackBelow: n,
732
+ onGeometryChange: r,
733
+ silenceWarnings: l
734
+ }), E = le(() => {
735
+ const m = (o == null ? void 0 : o.widgets) ?? [];
736
+ return k ? [...m].sort(Nt) : m;
737
+ }, [o == null ? void 0 : o.widgets, k]), $ = {
738
+ "--dash-gap": `${J}px`,
739
+ "--dash-pad": `${Ae}px`
740
+ }, y = ["preview-tab", i].filter(Boolean).join(" ");
695
741
  let w;
696
- if (d && !c)
697
- w = /* @__PURE__ */ l("div", { className: "preview-tab__error", children: d });
698
- else if (!c)
699
- w = /* @__PURE__ */ l("div", { className: "preview-tab__loading", children: "Carregando dashboard..." });
700
- else if (c.widgets.length === 0)
701
- w = /* @__PURE__ */ l("div", { className: "preview-tab__empty", children: "Este dashboard nao possui widgets." });
742
+ if (c && !o)
743
+ w = /* @__PURE__ */ a("div", { className: "preview-tab__error", children: c });
744
+ else if (!o)
745
+ w = /* @__PURE__ */ a("div", { className: "preview-tab__loading", children: "Carregando dashboard..." });
746
+ else if (o.widgets.length === 0)
747
+ w = /* @__PURE__ */ a("div", { className: "preview-tab__empty", children: "Este dashboard nao possui widgets." });
702
748
  else {
703
- const m = (i == null ? void 0 : i.widgets) ?? {}, _ = (i == null ? void 0 : i.date_bounds) ?? null, C = {
704
- "--dash-cols": c.gridColumns,
705
- "--dash-rows": c.gridRows,
706
- ...be(u)
707
- }, W = ["preview-tab__grid", S && "preview-tab__grid--stacked"].filter(Boolean).join(" ");
708
- w = /* @__PURE__ */ v(se, { children: [
709
- d && !i && /* @__PURE__ */ l("div", { className: "preview-tab__error", children: d }),
710
- i && /* @__PURE__ */ l("div", { className: W, style: C, ref: T, children: O.map((p) => {
711
- const x = ve.has(p.type), A = m[p.id], I = S ? {
749
+ const m = (s == null ? void 0 : s.widgets) ?? {}, b = (s == null ? void 0 : s.date_bounds) ?? null, C = {
750
+ "--dash-cols": o.gridColumns,
751
+ "--dash-rows": o.gridRows,
752
+ ...$e(d)
753
+ }, W = ["preview-tab__grid", k && "preview-tab__grid--stacked"].filter(Boolean).join(" ");
754
+ w = /* @__PURE__ */ v(fe, { children: [
755
+ c && !s && /* @__PURE__ */ a("div", { className: "preview-tab__error", children: c }),
756
+ s && /* @__PURE__ */ a("div", { className: W, style: C, ref: A, children: E.map((p) => {
757
+ const T = xe.has(p.type), F = m[p.id], O = k ? {
712
758
  gridColumn: 1,
713
- aspectRatio: `${ye(p.grid.w, p.grid.h, e)}`,
714
- minHeight: `${we(p.grid.h, Ne, q, 0)}px`
759
+ aspectRatio: `${Me(p.grid.w, p.grid.h, t)}`,
760
+ minHeight: `${Te(p.grid.h, Fe, J, 0)}px`
715
761
  } : {
716
762
  gridColumn: `${p.grid.x + 1} / span ${p.grid.w}`,
717
763
  gridRow: `${p.grid.y + 1} / span ${p.grid.h}`
718
- }, E = p.type === "variable" ? o[p.id] ?? (A == null ? void 0 : A.value) ?? p.config.variableValue ?? 0 : void 0;
719
- return /* @__PURE__ */ l(
764
+ }, L = p.type === "variable" ? u[p.id] ?? (F == null ? void 0 : F.value) ?? p.config.variableValue ?? 0 : void 0;
765
+ return /* @__PURE__ */ a(
720
766
  "div",
721
767
  {
722
- className: `preview-tab__widget ${x ? "preview-tab__widget--control" : ""}`,
723
- style: I,
724
- children: x || A ? /* @__PURE__ */ l(
725
- mt,
768
+ className: `preview-tab__widget ${T ? "preview-tab__widget--control" : ""}`,
769
+ style: O,
770
+ children: T || F ? /* @__PURE__ */ a(
771
+ St,
726
772
  {
727
773
  type: p.type,
728
- computed: A || {},
729
- palette: u,
774
+ computed: F || {},
775
+ palette: d,
730
776
  config: p.config,
731
777
  filterValue: g[p.id] || "",
732
778
  filterOptions: (
@@ -734,24 +780,24 @@ function wt({
734
780
  // recalcula-los a cada render custaria um DISTINCT por filtro.
735
781
  p.type === "filter" ? p.config.availableValues ?? [] : []
736
782
  ),
737
- dateBounds: _,
738
- onFilterChange: (D) => y(p.id, D),
739
- variableValue: E,
740
- onVariableChange: (D) => h(p.id, D),
741
- onPaletteChange: b
783
+ dateBounds: b,
784
+ onFilterChange: (D) => f(p.id, D),
785
+ variableValue: L,
786
+ onVariableChange: (D) => _(p.id, D),
787
+ onPaletteChange: S
742
788
  }
743
- ) : /* @__PURE__ */ l("div", { className: "preview-tab__widget-loading", children: f ? "Carregando..." : "Sem dados" })
789
+ ) : /* @__PURE__ */ a("div", { className: "preview-tab__widget-loading", children: h ? "Carregando..." : "Sem dados" })
744
790
  },
745
791
  p.id
746
792
  );
747
793
  }) }),
748
- f && i && /* @__PURE__ */ l("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
794
+ h && s && /* @__PURE__ */ a("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
749
795
  ] });
750
796
  }
751
- return /* @__PURE__ */ l("div", { className: k, style: M, ref: N, children: w });
797
+ return /* @__PURE__ */ a("div", { className: y, style: $, ref: R, children: w });
752
798
  }
753
799
  export {
754
- kt as ApiError,
755
- wt as Dashboard
800
+ Et as ApiError,
801
+ Tt as Dashboard
756
802
  };
757
803
  //# sourceMappingURL=index.js.map