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