@actionexec/dashboards 0.16.1 → 0.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { jsxs as p, jsx as r, Fragment as de } from "react/jsx-runtime";
2
- import { useState as T, useRef as $, useEffect as D, useCallback as E, useMemo as ue } from "react";
3
- import { M as V, f as Re, a as $e, c as Q, b as Z, d as Ce, e as me, i as J, g as z, p as Ae, h as q, j as he, k as fe, l as G, m as xe, r as Fe, D as ee, n as Me, o as Te, S as ge, C as Ee, q as Le, s as _e, t as Oe, u as Ie, v as Pe, G as De, w as te, x as We, y as ze, z as He, A as je, B as Ge } from "./ColorPaletteSelector-nBO_fbbj.js";
4
- import { E as lr } from "./ColorPaletteSelector-nBO_fbbj.js";
5
- import { LineChart as Ye, Line as Ve, AreaChart as Ke, Area as Ue, BarChart as pe, Bar as K, CartesianGrid as be, XAxis as ve, YAxis as we, Tooltip as U, Legend as qe, Cell as re, PieChart as Xe, Pie as Be } from "recharts";
6
- function W(e, t = {}) {
1
+ import { jsxs as b, jsx as r, Fragment as he } from "react/jsx-runtime";
2
+ import { useState as M, useRef as $, useEffect as W, useCallback as E, useMemo as Y, memo as Ae } from "react";
3
+ import { M as V, f as Fe, a as Te, c as J, b as ee, d as Me, e as fe, i as te, g as z, p as xe, h as q, j as ge, k as _e, l as j, m as Ee, r as Le, D as re, n as Oe, o as Pe, S as pe, C as Ie, q as We, s as be, t as De, u as ze, v as He, G as je, w as ne, x as Ge, y as Ye, z as Ve, A as Ke, B as Ue } from "./ColorPaletteSelector-nBO_fbbj.js";
4
+ import { E as ur } from "./ColorPaletteSelector-nBO_fbbj.js";
5
+ import { LineChart as qe, Line as Be, AreaChart as Xe, Area as Qe, BarChart as ve, Bar as K, CartesianGrid as we, XAxis as ye, YAxis as Ne, Tooltip as U, Legend as Ze, Cell as ae, PieChart as Je, Pie as et } from "recharts";
6
+ function D(e, t = {}) {
7
7
  const n = {};
8
8
  for (const [a, l] of Object.entries(e))
9
9
  if (l.includes("|")) {
@@ -18,11 +18,11 @@ function W(e, t = {}) {
18
18
  function H(e) {
19
19
  return Object.keys(e).sort().map((t) => `${t}=${e[t]}`).join("&");
20
20
  }
21
- function ye(e, t) {
21
+ function Se(e, t) {
22
22
  const n = Object.keys(e);
23
23
  return n.length !== Object.keys(t).length ? !1 : n.every((a) => e[a] === t[a]);
24
24
  }
25
- function Ne(e) {
25
+ function ke(e) {
26
26
  const t = {};
27
27
  for (const [n, a] of Object.entries(e))
28
28
  if (a && typeof a == "object" && "start" in a) {
@@ -31,46 +31,46 @@ function Ne(e) {
31
31
  } else Array.isArray(a) ? t[n] = a.join(V) : typeof a == "string" && (t[n] = a);
32
32
  return t;
33
33
  }
34
- const Qe = 300;
35
- function Ze(e) {
36
- const [t, n] = T(null), [a, l] = T(null), [s, c] = T({}), [i, u] = T({}), [o, m] = T(null), [d, h] = T(!0), [_, v] = T(null), S = $(), R = $(!1), A = $(null), N = $(!1);
37
- D(() => {
38
- let f = !1;
39
- return R.current = !1, A.current = null, N.current = !1, Re(e).then((g) => {
40
- f || n(g);
41
- }).catch((g) => {
42
- f || v(g.message);
34
+ const tt = 300;
35
+ function rt(e) {
36
+ const [t, n] = M(null), [a, l] = M(null), [s, c] = M({}), [i, m] = M({}), [o, h] = M(null), [d, f] = M(!0), [p, v] = M(null), S = $(), k = $(!1), A = $(null), y = $(!1);
37
+ W(() => {
38
+ let _ = !1;
39
+ return k.current = !1, A.current = null, y.current = !1, Fe(e).then((u) => {
40
+ _ || n(u);
41
+ }).catch((u) => {
42
+ _ || v(u.message);
43
43
  }), () => {
44
- f = !0;
44
+ _ = !0;
45
45
  };
46
- }, [e]), D(() => {
46
+ }, [e]), W(() => {
47
47
  if (!t) return;
48
48
  if (t.widgets.length === 0) {
49
- h(!1);
49
+ f(!1);
50
50
  return;
51
51
  }
52
- const f = W(s, i), g = H(f);
53
- if (g === A.current) return;
52
+ const _ = D(s, i), u = H(_);
53
+ if (u === A.current) return;
54
54
  S.current && clearTimeout(S.current);
55
- const C = N.current ? Qe : 0;
55
+ const R = y.current ? tt : 0;
56
56
  return S.current = setTimeout(() => {
57
- h(!0), $e(e, f).then((M) => {
58
- A.current = g, N.current = !0, l(M), !R.current && M.applied && (R.current = !0, c((b) => {
59
- const w = { ...Ne(M.applied), ...b };
60
- return ye(w, b) ? b : (A.current = H(W(w, i)), w);
57
+ f(!0), Te(e, _).then((C) => {
58
+ A.current = u, y.current = !0, l(C), !k.current && C.applied && (k.current = !0, c((F) => {
59
+ const g = { ...ke(C.applied), ...F };
60
+ return Se(g, F) ? F : (A.current = H(D(g, i)), g);
61
61
  })), v(null);
62
- }).catch((M) => v(M.message)).finally(() => h(!1));
63
- }, C), () => {
62
+ }).catch((C) => v(C.message)).finally(() => f(!1));
63
+ }, R), () => {
64
64
  S.current && clearTimeout(S.current);
65
65
  };
66
66
  }, [e, t, s, i]);
67
- const y = E((f, g) => {
68
- c((C) => ({ ...C, [f]: g }));
69
- }, []), k = E((f, g) => {
70
- u((C) => ({ ...C, [f]: g }));
71
- }, []), F = E((f) => {
72
- m(f);
73
- }, []), x = ue(
67
+ const w = E((_, u) => {
68
+ c((R) => ({ ...R, [_]: u }));
69
+ }, []), N = E((_, u) => {
70
+ m((R) => ({ ...R, [_]: u }));
71
+ }, []), T = E((_) => {
72
+ h(_);
73
+ }, []), x = Y(
74
74
  () => o ?? (t == null ? void 0 : t.palette) ?? [],
75
75
  [o, t]
76
76
  );
@@ -78,26 +78,26 @@ function Ze(e) {
78
78
  layout: t,
79
79
  renderData: a,
80
80
  loading: d,
81
- error: _,
81
+ error: p,
82
82
  filters: s,
83
83
  variables: i,
84
84
  palette: x,
85
- setFilter: y,
86
- setVariable: k,
87
- setPalette: F
85
+ setFilter: w,
86
+ setVariable: N,
87
+ setPalette: T
88
88
  };
89
89
  }
90
- const Je = (e) => {
90
+ const nt = (e) => {
91
91
  var t, n;
92
92
  return ((n = (t = e.borderBoxSize) == null ? void 0 : t[0]) == null ? void 0 : n.inlineSize) ?? e.target.offsetWidth;
93
- }, et = (e) => {
93
+ }, at = (e) => {
94
94
  var t, n;
95
95
  return ((n = (t = e.borderBoxSize) == null ? void 0 : t[0]) == null ? void 0 : n.blockSize) ?? e.target.offsetHeight;
96
96
  };
97
- function tt(e, t, n) {
98
- return e === void 0 ? 0 : e === "auto" ? Ce(t, n) : Math.max(0, e);
97
+ function lt(e, t, n) {
98
+ return e === void 0 ? 0 : e === "auto" ? Me(t, n) : Math.max(0, e);
99
99
  }
100
- function rt(e) {
100
+ function st(e) {
101
101
  let t = e.parentElement;
102
102
  for (; t && t !== document.body && t !== document.documentElement; ) {
103
103
  const { overflowY: n } = getComputedStyle(t);
@@ -107,94 +107,94 @@ function rt(e) {
107
107
  }
108
108
  return null;
109
109
  }
110
- function nt(e) {
110
+ function it(e) {
111
111
  const t = $(e);
112
112
  t.current = e;
113
- const n = $(null), a = $(null), l = $(null), s = $(null), c = $(null), i = $(0), u = $(0), o = $(!1), m = $(!1), d = $(-1), [h, _] = T(!1), v = E((f) => {
114
- const g = a.current;
115
- if (m.current || t.current.silenceWarnings || !g) return;
116
- const C = rt(g);
117
- !C || C.clientHeight >= f.gridHeight || (m.current = !0, console.warn(
118
- `[@actionexec/dashboards] O dashboard esta sendo cortado: o container precisa de ${Math.ceil(f.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.`
113
+ const n = $(null), a = $(null), l = $(null), s = $(null), c = $(null), i = $(0), m = $(0), o = $(!1), h = $(!1), d = $(-1), [f, p] = M(!1), v = E((_) => {
114
+ const u = a.current;
115
+ if (h.current || t.current.silenceWarnings || !u) return;
116
+ const R = st(u);
117
+ !R || R.clientHeight >= _.gridHeight || (h.current = !0, console.warn(
118
+ `[@actionexec/dashboards] O dashboard esta sendo cortado: o container precisa de ${Math.ceil(_.gridHeight)}px de altura, mas o ancestral com overflow oculto tem ${R.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.`
119
119
  ));
120
120
  }, []), S = E(() => {
121
- var P, O;
121
+ var L, O;
122
122
  if (!n.current) return;
123
- const { columns: f, cellAspect: g } = t.current, C = i.current, M = Z(C, f), b = {
124
- containerWidth: C,
125
- cellWidth: M,
126
- cellHeight: Q(M, g),
127
- gridHeight: u.current,
123
+ const { columns: _, cellAspect: u } = t.current, R = i.current, C = ee(R, _), F = {
124
+ containerWidth: R,
125
+ cellWidth: C,
126
+ cellHeight: J(C, u),
127
+ gridHeight: m.current,
128
128
  stacked: o.current
129
- }, w = c.current;
130
- w && w.containerWidth === b.containerWidth && w.cellWidth === b.cellWidth && w.cellHeight === b.cellHeight && w.gridHeight === b.gridHeight && w.stacked === b.stacked || (c.current = b, (O = (P = t.current).onGeometryChange) == null || O.call(P, b), v(b));
131
- }, [v]), R = E((f = !1) => {
132
- const g = n.current;
133
- if (!g) return;
134
- const C = i.current;
135
- if (!f && C === d.current) return;
136
- d.current = C;
137
- const { columns: M, cellAspect: b, stackBelow: w } = t.current, L = Z(C, M);
138
- g.style.setProperty("--dash-cell-h", `${Q(L, b)}px`);
139
- const P = tt(w, M, b), O = P > 0 && C > 0 && C < P;
140
- O !== o.current && (o.current = O, _(O));
129
+ }, g = c.current;
130
+ g && g.containerWidth === F.containerWidth && g.cellWidth === F.cellWidth && g.cellHeight === F.cellHeight && g.gridHeight === F.gridHeight && g.stacked === F.stacked || (c.current = F, (O = (L = t.current).onGeometryChange) == null || O.call(L, F), v(F));
131
+ }, [v]), k = E((_ = !1) => {
132
+ const u = n.current;
133
+ if (!u) return;
134
+ const R = i.current;
135
+ if (!_ && R === d.current) return;
136
+ d.current = R;
137
+ const { columns: C, cellAspect: F, stackBelow: g } = t.current, I = ee(R, C);
138
+ u.style.setProperty("--dash-cell-h", `${J(I, F)}px`);
139
+ const L = lt(g, C, F), O = L > 0 && R > 0 && R < L;
140
+ O !== o.current && (o.current = O, p(O));
141
141
  }, []), A = E(() => {
142
142
  s.current !== null && (cancelAnimationFrame(s.current), s.current = null);
143
- }, []), N = E(() => {
143
+ }, []), y = E(() => {
144
144
  s.current === null && (s.current = requestAnimationFrame(() => {
145
- s.current = null, R(), S();
145
+ s.current = null, k(), S();
146
146
  }));
147
- }, [R, S]), y = E((f) => {
148
- for (const g of f)
149
- g.target === n.current ? i.current = Math.round(Je(g)) : g.target === a.current && (u.current = et(g));
150
- N();
151
- }, [N]), k = E(() => l.current ? l.current : typeof ResizeObserver > "u" ? null : (l.current = new ResizeObserver(y), l.current), [y]), F = E((f) => {
152
- const g = k();
153
- n.current && (g == null || g.unobserve(n.current)), n.current = f, f && (g == null || g.observe(f), i.current = Math.round(f.getBoundingClientRect().width), R(!0), N());
154
- }, [R, k, N]), x = E((f) => {
155
- const g = k();
156
- if (a.current && (g == null || g.unobserve(a.current)), a.current = f, !f) {
157
- u.current = 0;
147
+ }, [k, S]), w = E((_) => {
148
+ for (const u of _)
149
+ u.target === n.current ? i.current = Math.round(nt(u)) : u.target === a.current && (m.current = at(u));
150
+ y();
151
+ }, [y]), N = E(() => l.current ? l.current : typeof ResizeObserver > "u" ? null : (l.current = new ResizeObserver(w), l.current), [w]), T = E((_) => {
152
+ const u = N();
153
+ n.current && (u == null || u.unobserve(n.current)), n.current = _, _ && (u == null || u.observe(_), i.current = Math.round(_.getBoundingClientRect().width), k(!0), y());
154
+ }, [k, N, y]), x = E((_) => {
155
+ const u = N();
156
+ if (a.current && (u == null || u.unobserve(a.current)), a.current = _, !_) {
157
+ m.current = 0;
158
158
  return;
159
159
  }
160
- g == null || g.observe(f), u.current = f.getBoundingClientRect().height, N();
161
- }, [k, N]);
162
- return D(() => {
163
- const f = k();
164
- return n.current && (f == null || f.observe(n.current)), a.current && (f == null || f.observe(a.current)), () => {
165
- var g;
166
- (g = l.current) == null || g.disconnect(), l.current = null, A();
160
+ u == null || u.observe(_), m.current = _.getBoundingClientRect().height, y();
161
+ }, [N, y]);
162
+ return W(() => {
163
+ const _ = N();
164
+ return n.current && (_ == null || _.observe(n.current)), a.current && (_ == null || _.observe(a.current)), () => {
165
+ var u;
166
+ (u = l.current) == null || u.disconnect(), l.current = null, A();
167
167
  };
168
- }, [k, A]), D(() => {
169
- n.current && (R(!0), N());
170
- }, [e.columns, e.cellAspect, e.stackBelow, R, N]), { rootRef: F, gridRef: x, stacked: h };
168
+ }, [N, A]), W(() => {
169
+ n.current && (k(!0), y());
170
+ }, [e.columns, e.cellAspect, e.stackBelow, k, y]), { rootRef: T, gridRef: x, stacked: f };
171
171
  }
172
- const at = {
172
+ const ot = {
173
173
  empty: "Sem dados",
174
174
  error: "Não foi possível carregar",
175
175
  loading: "Carregando...",
176
176
  unconfigured: "Widget não configurado"
177
177
  };
178
- function X({ kind: e, message: t }) {
179
- return /* @__PURE__ */ r("div", { className: `widget__state widget__state--${e}`, role: e === "error" ? "alert" : void 0, children: t || at[e] });
178
+ function B({ kind: e, message: t }) {
179
+ return /* @__PURE__ */ r("div", { className: `widget__state widget__state--${e}`, role: e === "error" ? "alert" : void 0, children: t || ot[e] });
180
180
  }
181
- function I({ name: e, title: t, state: n, stateMessage: a, toolbar: l, children: s }) {
182
- return /* @__PURE__ */ p("div", { className: `widget widget-${e}`, children: [
181
+ function P({ name: e, title: t, state: n, stateMessage: a, toolbar: l, children: s }) {
182
+ return /* @__PURE__ */ b("div", { className: `widget widget-${e}`, children: [
183
183
  t && /* @__PURE__ */ r("span", { className: "widget__title", children: t }),
184
184
  l,
185
- n ? /* @__PURE__ */ r(X, { kind: n, message: a }) : s
185
+ n ? /* @__PURE__ */ r(B, { kind: n, message: a }) : s
186
186
  ] });
187
187
  }
188
- const lt = { up: "↑", down: "↓" };
189
- function Se(e) {
188
+ const ct = { up: "↑", down: "↓" };
189
+ function Re(e) {
190
190
  return Array.isArray(e) ? e.filter(
191
191
  (t) => t && t.status === "ok" && t.formatted && t.formatted !== "-"
192
192
  ) : [];
193
193
  }
194
- function st({ comparison: e, primary: t }) {
195
- const n = e.sentiment ?? "neutral", a = lt[e.trend ?? ""] ?? "";
196
- return /* @__PURE__ */ p("div", { className: `widget-kpi__trend widget-kpi__trend--${n}${t ? "" : " widget-kpi__trend--muted"}`, children: [
197
- /* @__PURE__ */ p("span", { className: "widget-kpi__variance", children: [
194
+ function dt({ comparison: e, primary: t }) {
195
+ const n = e.sentiment ?? "neutral", a = ct[e.trend ?? ""] ?? "";
196
+ return /* @__PURE__ */ b("div", { className: `widget-kpi__trend widget-kpi__trend--${n}${t ? "" : " widget-kpi__trend--muted"}`, children: [
197
+ /* @__PURE__ */ b("span", { className: "widget-kpi__variance", children: [
198
198
  a,
199
199
  " ",
200
200
  e.formatted
@@ -202,159 +202,159 @@ function st({ comparison: e, primary: t }) {
202
202
  e.label && /* @__PURE__ */ r("span", { className: "widget-kpi__trend-label", children: e.label })
203
203
  ] });
204
204
  }
205
- function it({ data: e, label: t }) {
206
- const n = t || String(e.label || ""), a = String(e.formatted || "-"), l = Se(e.comparisons);
207
- return /* @__PURE__ */ p(I, { name: "kpi", title: n, children: [
205
+ function ut({ data: e, label: t }) {
206
+ const n = t || String(e.label || ""), a = String(e.formatted || "-"), l = Re(e.comparisons);
207
+ return /* @__PURE__ */ b(P, { name: "kpi", title: n, children: [
208
208
  /* @__PURE__ */ r("span", { className: "widget-kpi__value", children: a }),
209
- l.map((s, c) => /* @__PURE__ */ r(st, { comparison: s, primary: c === 0 }, s.id || c))
209
+ l.map((s, c) => /* @__PURE__ */ r(dt, { comparison: s, primary: c === 0 }, s.id || c))
210
210
  ] });
211
211
  }
212
- const ot = "var(--bg-elevated)", ct = [
212
+ const mt = "var(--bg-elevated)", ht = [
213
213
  [1, "var(--color-success)"],
214
214
  [0.7, ""],
215
215
  // vazio = cor da serie 1 (destaque do dashboard)
216
216
  [0.4, "var(--color-warning)"],
217
217
  [0, "var(--color-error)"]
218
218
  ];
219
- function ne(e, t, n, a) {
219
+ function le(e, t, n, a) {
220
220
  if (a <= 0) return "";
221
221
  if (a >= 1)
222
222
  return `M ${e - n} ${t} A ${n} ${n} 0 0 1 ${e} ${t - n} A ${n} ${n} 0 0 1 ${e + n} ${t}`;
223
223
  const l = a * Math.PI;
224
224
  return `M ${e - n} ${t} A ${n} ${n} 0 0 1 ${e - n * Math.cos(l)} ${t - n * Math.sin(l)}`;
225
225
  }
226
- function dt({ data: e, palette: t, label: n }) {
227
- const a = n || String(e.label || ""), l = typeof e.ratio == "number" ? e.ratio : 0, s = typeof e.format == "string" ? e.format : void 0, c = String(e.value_formatted || me(e.value, s)), i = String(e.formatted || "-"), u = Se(e.comparisons), [o, ...m] = u, d = String((o == null ? void 0 : o.baseline_formatted) || "-"), h = (o == null ? void 0 : o.label) ?? null, _ = l >= 1, v = Math.min(Math.max(l, 0), 1), S = ct.find(([F]) => l >= F), R = (S == null ? void 0 : S[1]) || t[0] || "var(--color-info)", A = 50, N = 50, y = 44, k = 10;
228
- return /* @__PURE__ */ r(I, { name: "gauge", title: a, children: /* @__PURE__ */ p("div", { className: "widget-gauge__chart", children: [
229
- /* @__PURE__ */ p("svg", { viewBox: "0 0 100 56", preserveAspectRatio: "xMidYMax meet", role: "img", "aria-label": `${i} da meta`, children: [
230
- /* @__PURE__ */ r("path", { d: ne(A, N, y, 1), fill: "none", stroke: ot, strokeWidth: k, strokeLinecap: "butt" }),
231
- v > 0 && /* @__PURE__ */ r("path", { d: ne(A, N, y, v), fill: "none", stroke: R, strokeWidth: k, strokeLinecap: "butt" })
226
+ function ft({ data: e, palette: t, label: n }) {
227
+ const a = n || String(e.label || ""), l = typeof e.ratio == "number" ? e.ratio : 0, s = typeof e.format == "string" ? e.format : void 0, c = String(e.value_formatted || fe(e.value, s)), i = String(e.formatted || "-"), m = Re(e.comparisons), [o, ...h] = m, d = String((o == null ? void 0 : o.baseline_formatted) || "-"), f = (o == null ? void 0 : o.label) ?? null, p = l >= 1, v = Math.min(Math.max(l, 0), 1), S = ht.find(([T]) => l >= T), k = (S == null ? void 0 : S[1]) || t[0] || "var(--color-info)", A = 50, y = 50, w = 44, N = 10;
228
+ return /* @__PURE__ */ r(P, { name: "gauge", title: a, children: /* @__PURE__ */ b("div", { className: "widget-gauge__chart", children: [
229
+ /* @__PURE__ */ b("svg", { viewBox: "0 0 100 56", preserveAspectRatio: "xMidYMax meet", role: "img", "aria-label": `${i} da meta`, children: [
230
+ /* @__PURE__ */ r("path", { d: le(A, y, w, 1), fill: "none", stroke: mt, strokeWidth: N, strokeLinecap: "butt" }),
231
+ v > 0 && /* @__PURE__ */ r("path", { d: le(A, y, w, v), fill: "none", stroke: k, strokeWidth: N, strokeLinecap: "butt" })
232
232
  ] }),
233
- /* @__PURE__ */ p("div", { className: "widget-gauge__center", children: [
233
+ /* @__PURE__ */ b("div", { className: "widget-gauge__center", children: [
234
234
  /* @__PURE__ */ r("span", { className: "widget-gauge__percent", children: i }),
235
- /* @__PURE__ */ p("span", { className: "widget-gauge__comparison", children: [
235
+ /* @__PURE__ */ b("span", { className: "widget-gauge__comparison", children: [
236
236
  c,
237
237
  " / ",
238
238
  d
239
239
  ] }),
240
- _ && /* @__PURE__ */ r("span", { className: "widget-gauge__badge", children: h || "Meta batida" }),
241
- !_ && h && /* @__PURE__ */ r("span", { className: "widget-gauge__comparison", children: h }),
242
- m.map((F, x) => /* @__PURE__ */ p("span", { className: "widget-gauge__comparison", children: [
243
- F.formatted,
240
+ p && /* @__PURE__ */ r("span", { className: "widget-gauge__badge", children: f || "Meta batida" }),
241
+ !p && f && /* @__PURE__ */ r("span", { className: "widget-gauge__comparison", children: f }),
242
+ h.map((T, x) => /* @__PURE__ */ b("span", { className: "widget-gauge__comparison", children: [
243
+ T.formatted,
244
244
  " ",
245
- F.label
246
- ] }, F.id || x))
245
+ T.label
246
+ ] }, T.id || x))
247
247
  ] })
248
248
  ] }) });
249
249
  }
250
- function B(e) {
251
- const [t, n] = T({ width: 0, height: 0 });
252
- return D(() => {
250
+ function X(e) {
251
+ const [t, n] = M({ width: 0, height: 0 });
252
+ return W(() => {
253
253
  const a = e.current;
254
254
  if (!a) return;
255
255
  const l = new ResizeObserver(([s]) => {
256
256
  const { width: c, height: i } = s.contentRect;
257
257
  n(
258
- (u) => u.width !== Math.floor(c) || u.height !== Math.floor(i) ? { width: Math.floor(c), height: Math.floor(i) } : u
258
+ (m) => m.width !== Math.floor(c) || m.height !== Math.floor(i) ? { width: Math.floor(c), height: Math.floor(i) } : m
259
259
  );
260
260
  });
261
261
  return l.observe(a), () => l.disconnect();
262
262
  }, [e]), t;
263
263
  }
264
- const ae = { fontSize: 10, fill: "var(--text-muted)" }, ut = "var(--bg-elevated)", mt = {
264
+ const se = { fontSize: 10, fill: "var(--text-muted)" }, gt = "var(--bg-elevated)", _t = {
265
265
  backgroundColor: "var(--bg-elevated)",
266
266
  border: "1px solid var(--bg-paper)",
267
267
  borderRadius: "6px",
268
268
  color: "var(--text-primary)"
269
- }, ht = {
269
+ }, pt = {
270
270
  color: "var(--text-primary)",
271
271
  fontWeight: 600
272
272
  };
273
- function ft(e, t) {
273
+ function bt(e, t) {
274
274
  var l;
275
275
  const n = Array.isArray(t) ? t[0] : void 0, a = (l = n == null ? void 0 : n.payload) == null ? void 0 : l.tooltipLabel;
276
276
  return typeof a == "string" && a ? a : String(e ?? "");
277
277
  }
278
- function Y({ Chart: e, chartData: t, xKey: n, series: a, palette: l, renderSeries: s, width: c, height: i }) {
279
- return /* @__PURE__ */ p(e, { data: t, width: c, height: i, children: [
280
- /* @__PURE__ */ r(be, { strokeDasharray: "3 3", stroke: ut }),
281
- /* @__PURE__ */ r(ve, { dataKey: n, tick: ae }),
282
- /* @__PURE__ */ r(we, { tick: ae }),
278
+ function G({ Chart: e, chartData: t, xKey: n, series: a, palette: l, renderSeries: s, width: c, height: i }) {
279
+ return /* @__PURE__ */ b(e, { data: t, width: c, height: i, children: [
280
+ /* @__PURE__ */ r(we, { strokeDasharray: "3 3", stroke: gt }),
281
+ /* @__PURE__ */ r(ye, { dataKey: n, tick: se }),
282
+ /* @__PURE__ */ r(Ne, { tick: se }),
283
283
  /* @__PURE__ */ r(
284
284
  U,
285
285
  {
286
- contentStyle: mt,
287
- labelStyle: ht,
288
- labelFormatter: ft,
286
+ contentStyle: _t,
287
+ labelStyle: pt,
288
+ labelFormatter: bt,
289
289
  cursor: { fill: "var(--bg-paper)", opacity: 0.3 }
290
290
  }
291
291
  ),
292
- a.length > 1 && /* @__PURE__ */ r(qe, {}),
293
- a.map((u, o) => s(u, l[o % l.length], o))
292
+ a.length > 1 && /* @__PURE__ */ r(Ze, {}),
293
+ a.map((m, o) => s(m, l[o % l.length], o))
294
294
  ] });
295
295
  }
296
- function gt({ data: e, palette: t, label: n }) {
297
- const a = String(e.chartType || "bar"), l = n || String(e.label || ""), s = String(e.xKey || "label"), c = e.series || [], i = e.data || [], u = $(null), { width: o, height: m } = B(u), d = () => {
298
- if (o <= 0 || m <= 0) return null;
299
- const h = { chartData: i, xKey: s, series: c, palette: t, width: o, height: m };
300
- return a === "line" ? /* @__PURE__ */ r(Y, { ...h, Chart: Ye, renderSeries: (_, v) => /* @__PURE__ */ r(
301
- Ve,
296
+ function vt({ data: e, palette: t, label: n }) {
297
+ const a = String(e.chartType || "bar"), l = n || String(e.label || ""), s = String(e.xKey || "label"), c = e.series || [], i = e.data || [], m = $(null), { width: o, height: h } = X(m), d = () => {
298
+ if (o <= 0 || h <= 0) return null;
299
+ const f = { chartData: i, xKey: s, series: c, palette: t, width: o, height: h };
300
+ return a === "line" ? /* @__PURE__ */ r(G, { ...f, Chart: qe, renderSeries: (p, v) => /* @__PURE__ */ r(
301
+ Be,
302
302
  {
303
303
  type: "monotone",
304
- dataKey: _.key,
305
- name: _.label,
304
+ dataKey: p.key,
305
+ name: p.label,
306
306
  stroke: v,
307
307
  strokeWidth: 2,
308
308
  dot: i.length <= 31
309
309
  },
310
- _.key
311
- ) }) : a === "area" ? /* @__PURE__ */ r(Y, { ...h, Chart: Ke, renderSeries: (_, v) => /* @__PURE__ */ r(
312
- Ue,
310
+ p.key
311
+ ) }) : a === "area" ? /* @__PURE__ */ r(G, { ...f, Chart: Xe, renderSeries: (p, v) => /* @__PURE__ */ r(
312
+ Qe,
313
313
  {
314
314
  type: "monotone",
315
- dataKey: _.key,
316
- name: _.label,
315
+ dataKey: p.key,
316
+ name: p.label,
317
317
  fill: v,
318
318
  stroke: v,
319
319
  fillOpacity: 0.3
320
320
  },
321
- _.key
322
- ) }) : /* @__PURE__ */ r(Y, { ...h, Chart: pe, renderSeries: (_, v) => /* @__PURE__ */ r(
321
+ p.key
322
+ ) }) : /* @__PURE__ */ r(G, { ...f, Chart: ve, renderSeries: (p, v) => /* @__PURE__ */ r(
323
323
  K,
324
324
  {
325
- dataKey: _.key,
326
- name: _.label,
325
+ dataKey: p.key,
326
+ name: p.label,
327
327
  fill: v,
328
328
  radius: [3, 3, 0, 0]
329
329
  },
330
- _.key
330
+ p.key
331
331
  ) });
332
332
  };
333
- return /* @__PURE__ */ r(I, { name: "chart", title: l, children: /* @__PURE__ */ r("div", { ref: u, className: "widget-chart__container", children: i.length === 0 ? /* @__PURE__ */ r(X, { kind: "empty" }) : d() }) });
333
+ return /* @__PURE__ */ r(P, { name: "chart", title: l, children: /* @__PURE__ */ r("div", { ref: m, className: "widget-chart__container", children: i.length === 0 ? /* @__PURE__ */ r(B, { kind: "empty" }) : d() }) });
334
334
  }
335
- const le = { fontSize: 10, fill: "var(--text-muted)" }, _t = "var(--bg-elevated)", pt = { fill: "var(--bg-paper)", opacity: 0.3 };
336
- function bt(e) {
335
+ const ie = { fontSize: 10, fill: "var(--text-muted)" }, wt = "var(--bg-elevated)", yt = { fill: "var(--bg-paper)", opacity: 0.3 };
336
+ function Nt(e) {
337
337
  return e.kind === "anchor" ? "var(--color-accent)" : e.kind === "residual" ? "var(--color-warning)" : e.value < 0 ? "var(--color-error)" : "var(--color-success)";
338
338
  }
339
- function se({ active: e, payload: t }) {
339
+ function oe({ active: e, payload: t }) {
340
340
  var a;
341
341
  const n = e ? (a = t == null ? void 0 : t[0]) == null ? void 0 : a.payload : void 0;
342
- return n ? /* @__PURE__ */ p("div", { className: "widget-composition__tooltip", children: [
342
+ return n ? /* @__PURE__ */ b("div", { className: "widget-composition__tooltip", children: [
343
343
  /* @__PURE__ */ r("span", { className: "widget-composition__tooltip-label", children: n.label }),
344
344
  /* @__PURE__ */ r("span", { className: "widget-composition__tooltip-value", children: n.formatted })
345
345
  ] }) : null;
346
346
  }
347
- function vt({ data: e, palette: t, label: n }) {
348
- const a = n || String(e.label || ""), l = String(e.display || "pie"), s = e.data || [], c = typeof e.format == "string" ? e.format : void 0, i = $(null), { width: u, height: o } = B(i), m = () => /* @__PURE__ */ p(pe, { data: s, width: u, height: o, children: [
349
- /* @__PURE__ */ r(be, { strokeDasharray: "3 3", stroke: _t }),
350
- /* @__PURE__ */ r(ve, { dataKey: "label", tick: le, interval: 0 }),
351
- /* @__PURE__ */ r(we, { tick: le, tickFormatter: (h) => me(h, c) }),
352
- /* @__PURE__ */ r(U, { content: /* @__PURE__ */ r(se, {}), cursor: pt }),
347
+ function St({ data: e, palette: t, label: n }) {
348
+ const a = n || String(e.label || ""), l = String(e.display || "pie"), s = e.data || [], c = typeof e.format == "string" ? e.format : void 0, i = $(null), { width: m, height: o } = X(i), h = () => /* @__PURE__ */ b(ve, { data: s, width: m, height: o, children: [
349
+ /* @__PURE__ */ r(we, { strokeDasharray: "3 3", stroke: wt }),
350
+ /* @__PURE__ */ r(ye, { dataKey: "label", tick: ie, interval: 0 }),
351
+ /* @__PURE__ */ r(Ne, { tick: ie, tickFormatter: (f) => fe(f, c) }),
352
+ /* @__PURE__ */ r(U, { content: /* @__PURE__ */ r(oe, {}), cursor: yt }),
353
353
  /* @__PURE__ */ r(K, { dataKey: "base", stackId: "bridge", fill: "none", fillOpacity: 0, isAnimationActive: !1 }),
354
- /* @__PURE__ */ r(K, { dataKey: "span", stackId: "bridge", radius: [3, 3, 0, 0], children: s.map((h, _) => /* @__PURE__ */ r(re, { fill: bt(h) }, _)) })
355
- ] }), d = () => /* @__PURE__ */ p(Xe, { width: u, height: o, children: [
354
+ /* @__PURE__ */ r(K, { dataKey: "span", stackId: "bridge", radius: [3, 3, 0, 0], children: s.map((f, p) => /* @__PURE__ */ r(ae, { fill: Nt(f) }, p)) })
355
+ ] }), d = () => /* @__PURE__ */ b(Je, { width: m, height: o, children: [
356
356
  /* @__PURE__ */ r(
357
- Be,
357
+ et,
358
358
  {
359
359
  data: s,
360
360
  dataKey: "value",
@@ -362,61 +362,61 @@ function vt({ data: e, palette: t, label: n }) {
362
362
  cx: "50%",
363
363
  cy: "50%",
364
364
  outerRadius: "75%",
365
- label: ({ name: h, percent: _ }) => `${h}: ${(_ * 100).toFixed(0)}%`,
365
+ label: ({ name: f, percent: p }) => `${f}: ${(p * 100).toFixed(0)}%`,
366
366
  labelLine: !1,
367
- children: s.map((h, _) => /* @__PURE__ */ r(re, { fill: t[_ % t.length] }, _))
367
+ children: s.map((f, p) => /* @__PURE__ */ r(ae, { fill: t[p % t.length] }, p))
368
368
  }
369
369
  ),
370
- /* @__PURE__ */ r(U, { content: /* @__PURE__ */ r(se, {}) })
370
+ /* @__PURE__ */ r(U, { content: /* @__PURE__ */ r(oe, {}) })
371
371
  ] });
372
- return /* @__PURE__ */ r(I, { name: "composition", title: a, children: /* @__PURE__ */ r("div", { ref: i, className: "widget-composition__container", children: s.length === 0 || u <= 0 || o <= 0 ? /* @__PURE__ */ r(X, { kind: "empty" }) : l === "bridge" ? m() : d() }) });
372
+ return /* @__PURE__ */ r(P, { name: "composition", title: a, children: /* @__PURE__ */ r("div", { ref: i, className: "widget-composition__container", children: s.length === 0 || m <= 0 || o <= 0 ? /* @__PURE__ */ r(B, { kind: "empty" }) : l === "bridge" ? h() : d() }) });
373
373
  }
374
- function wt(e, t) {
374
+ function kt(e, t) {
375
375
  if (t !== "percentage") return "";
376
376
  const n = Number(e);
377
377
  return Number.isNaN(n) || n === 0 ? "" : n > 0 ? " widget-table__td--up" : " widget-table__td--down";
378
378
  }
379
- function yt(e, t, n, a) {
379
+ function Rt(e, t, n, a) {
380
380
  const l = (a == null ? void 0 : a.offsetHeight) ?? 0;
381
381
  if (e === 0 || t <= 0 || l <= 0) return e;
382
382
  const s = Math.floor((t - ((n == null ? void 0 : n.offsetHeight) ?? 0)) / l);
383
383
  return Math.max(0, Math.min(e, s));
384
384
  }
385
- function Nt({ data: e, label: t }) {
386
- var h;
387
- const n = e.columns || [], a = e.rows || [], l = e.overflow === "clip", s = e.indexColumn === !0, c = t || String(e.label || ""), i = $(null), u = $(null), o = $(null), { height: m } = B(i), d = l ? a.slice(0, yt(
385
+ function $t({ data: e, label: t }) {
386
+ var f;
387
+ const n = e.columns || [], a = e.rows || [], l = e.overflow === "clip", s = e.indexColumn === !0, c = t || String(e.label || ""), i = $(null), m = $(null), o = $(null), { height: h } = X(i), d = l ? a.slice(0, Rt(
388
388
  a.length,
389
- m,
390
- u.current,
391
- ((h = o.current) == null ? void 0 : h.firstElementChild) ?? null
389
+ h,
390
+ m.current,
391
+ ((f = o.current) == null ? void 0 : f.firstElementChild) ?? null
392
392
  )) : a;
393
393
  return n.length === 0 ? /* @__PURE__ */ r(
394
- I,
394
+ P,
395
395
  {
396
396
  name: "table",
397
397
  title: c,
398
398
  state: "unconfigured",
399
399
  stateMessage: "Configure as colunas da tabela."
400
400
  }
401
- ) : /* @__PURE__ */ r(I, { name: "table", title: c, children: /* @__PURE__ */ r(
401
+ ) : /* @__PURE__ */ r(P, { name: "table", title: c, children: /* @__PURE__ */ r(
402
402
  "div",
403
403
  {
404
404
  ref: i,
405
405
  className: `widget-table__scroll${l ? " widget-table__scroll--clip" : ""}`,
406
- children: /* @__PURE__ */ p(
406
+ children: /* @__PURE__ */ b(
407
407
  "table",
408
408
  {
409
409
  className: `widget-table__table${l && d.length < a.length ? "" : " widget-table__table--fill"}`,
410
410
  children: [
411
- /* @__PURE__ */ r("thead", { ref: u, children: /* @__PURE__ */ p("tr", { children: [
411
+ /* @__PURE__ */ r("thead", { ref: m, children: /* @__PURE__ */ b("tr", { children: [
412
412
  s && /* @__PURE__ */ r("th", { className: "widget-table__th widget-table__th--index", children: "#" }),
413
- n.map((_) => /* @__PURE__ */ r(
413
+ n.map((p) => /* @__PURE__ */ r(
414
414
  "th",
415
415
  {
416
- className: `widget-table__th${J(_.format) ? " widget-table__th--num" : ""}`,
417
- children: _.label || _.key
416
+ className: `widget-table__th${te(p.format) ? " widget-table__th--num" : ""}`,
417
+ children: p.label || p.key
418
418
  },
419
- _.key
419
+ p.key
420
420
  ))
421
421
  ] }) }),
422
422
  /* @__PURE__ */ r("tbody", { ref: o, children: d.length === 0 ? /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r(
@@ -426,11 +426,11 @@ function Nt({ data: e, label: t }) {
426
426
  colSpan: n.length + (s ? 1 : 0),
427
427
  children: "Sem dados"
428
428
  }
429
- ) }) : d.map((_, v) => /* @__PURE__ */ p("tr", { children: [
429
+ ) }) : d.map((p, v) => /* @__PURE__ */ b("tr", { children: [
430
430
  s && /* @__PURE__ */ r("td", { className: "widget-table__td widget-table__td--index", children: v + 1 }),
431
431
  n.map((S) => {
432
- const R = _[S.key], A = J(S.format) ? " widget-table__td--num" : "";
433
- return /* @__PURE__ */ r("td", { className: `widget-table__td${A}${wt(R, S.format)}`, children: z(R, S.format) }, S.key);
432
+ const k = p[S.key], A = te(S.format) ? " widget-table__td--num" : "";
433
+ return /* @__PURE__ */ r("td", { className: `widget-table__td${A}${kt(k, S.format)}`, children: z(k, S.format) }, S.key);
434
434
  })
435
435
  ] }, v)) })
436
436
  ]
@@ -439,46 +439,46 @@ function Nt({ data: e, label: t }) {
439
439
  }
440
440
  ) });
441
441
  }
442
- function ke({ mode: e, value: t, dateBounds: n, rangeUnit: a, onChange: l }) {
443
- return e === "yearly" ? /* @__PURE__ */ r(Rt, { value: t, dateBounds: n, onChange: l }) : e === "monthly" ? /* @__PURE__ */ r($t, { value: t, dateBounds: n, onChange: l }) : e === "weekly" ? /* @__PURE__ */ r(Ct, { value: t, dateBounds: n, onChange: l }) : a && a !== "day" ? /* @__PURE__ */ r(
444
- St,
442
+ function $e({ mode: e, value: t, dateBounds: n, rangeUnit: a, onChange: l }) {
443
+ return e === "yearly" ? /* @__PURE__ */ r(Ft, { value: t, dateBounds: n, onChange: l }) : e === "monthly" ? /* @__PURE__ */ r(Tt, { value: t, dateBounds: n, onChange: l }) : e === "weekly" ? /* @__PURE__ */ r(Mt, { value: t, dateBounds: n, onChange: l }) : a && a !== "day" ? /* @__PURE__ */ r(
444
+ Ct,
445
445
  {
446
446
  value: t,
447
447
  dateBounds: n,
448
448
  unit: a,
449
449
  onChange: l
450
450
  }
451
- ) : /* @__PURE__ */ r(kt, { value: t, dateBounds: n, onChange: l });
451
+ ) : /* @__PURE__ */ r(At, { value: t, dateBounds: n, onChange: l });
452
452
  }
453
- function St({ value: e, dateBounds: t, unit: n, onChange: a }) {
454
- const [l, s] = e ? e.split("|") : ["", ""], c = Fe(n, t), i = (o) => {
455
- var m;
456
- return ((m = c.find((d) => o >= d.start && o <= d.end)) == null ? void 0 : m.key) ?? "";
457
- }, u = (o, m) => {
458
- const d = c.find((h) => h.key === m);
453
+ function Ct({ value: e, dateBounds: t, unit: n, onChange: a }) {
454
+ const [l, s] = e ? e.split("|") : ["", ""], c = Le(n, t), i = (o) => {
455
+ var h;
456
+ return ((h = c.find((d) => o >= d.start && o <= d.end)) == null ? void 0 : h.key) ?? "";
457
+ }, m = (o, h) => {
458
+ const d = c.find((f) => f.key === h);
459
459
  d && a(o === "start" ? `${d.start}|${!s || s < d.end ? d.end : s}` : `${!l || l > d.start ? d.start : l}|${d.end}`);
460
460
  };
461
- return /* @__PURE__ */ p("div", { className: "widget-filter__date-range widget-filter__date-range--period", children: [
462
- /* @__PURE__ */ p(
461
+ return /* @__PURE__ */ b("div", { className: "widget-filter__date-range widget-filter__date-range--period", children: [
462
+ /* @__PURE__ */ b(
463
463
  "select",
464
464
  {
465
465
  className: "widget-filter__select",
466
466
  "aria-label": "Período inicial",
467
467
  value: i(l),
468
- onChange: (o) => u("start", o.target.value),
468
+ onChange: (o) => m("start", o.target.value),
469
469
  children: [
470
470
  !i(l) && /* @__PURE__ */ r("option", { value: "", children: "De..." }),
471
471
  c.map((o) => /* @__PURE__ */ r("option", { value: o.key, children: o.label }, o.key))
472
472
  ]
473
473
  }
474
474
  ),
475
- /* @__PURE__ */ p(
475
+ /* @__PURE__ */ b(
476
476
  "select",
477
477
  {
478
478
  className: "widget-filter__select",
479
479
  "aria-label": "Período final",
480
480
  value: i(s),
481
- onChange: (o) => u("end", o.target.value),
481
+ onChange: (o) => m("end", o.target.value),
482
482
  children: [
483
483
  !i(s) && /* @__PURE__ */ r("option", { value: "", children: "Até..." }),
484
484
  c.map((o) => /* @__PURE__ */ r("option", { value: o.key, children: o.label }, o.key))
@@ -487,11 +487,11 @@ function St({ value: e, dateBounds: t, unit: n, onChange: a }) {
487
487
  )
488
488
  ] });
489
489
  }
490
- function kt({ value: e, dateBounds: t, onChange: n }) {
490
+ function At({ value: e, dateBounds: t, onChange: n }) {
491
491
  const [a, l] = e ? e.split("|") : ["", ""];
492
- return /* @__PURE__ */ p("div", { className: "widget-filter__date-range widget-filter__date-range--stacked", children: [
492
+ return /* @__PURE__ */ b("div", { className: "widget-filter__date-range widget-filter__date-range--stacked", children: [
493
493
  /* @__PURE__ */ r(
494
- ee,
494
+ re,
495
495
  {
496
496
  value: a,
497
497
  minIso: t == null ? void 0 : t.min,
@@ -504,7 +504,7 @@ function kt({ value: e, dateBounds: t, onChange: n }) {
504
504
  }
505
505
  ),
506
506
  /* @__PURE__ */ r(
507
- ee,
507
+ re,
508
508
  {
509
509
  value: l,
510
510
  minIso: a || (t == null ? void 0 : t.min),
@@ -518,34 +518,34 @@ function kt({ value: e, dateBounds: t, onChange: n }) {
518
518
  )
519
519
  ] });
520
520
  }
521
- function Rt({ value: e, dateBounds: t, onChange: n }) {
522
- const [a] = e ? e.split("|") : [""], l = Ae(a), s = /* @__PURE__ */ new Date(), c = (l == null ? void 0 : l.year) ?? s.getFullYear(), i = q(t), u = (o) => {
523
- const m = Te(o);
524
- n(`${m.start}|${m.end}`);
521
+ function Ft({ value: e, dateBounds: t, onChange: n }) {
522
+ const [a] = e ? e.split("|") : [""], l = xe(a), s = /* @__PURE__ */ new Date(), c = (l == null ? void 0 : l.year) ?? s.getFullYear(), i = q(t), m = (o) => {
523
+ const h = Pe(o);
524
+ n(`${h.start}|${h.end}`);
525
525
  };
526
526
  return /* @__PURE__ */ r("div", { className: "widget-filter__date-range widget-filter__date-range--year", children: /* @__PURE__ */ r(
527
527
  "select",
528
528
  {
529
529
  className: "widget-filter__select",
530
530
  value: c,
531
- onChange: (o) => u(parseInt(o.target.value)),
531
+ onChange: (o) => m(parseInt(o.target.value)),
532
532
  children: i.map((o) => /* @__PURE__ */ r("option", { value: o, children: o }, o))
533
533
  }
534
534
  ) });
535
535
  }
536
- function $t({ value: e, dateBounds: t, onChange: n }) {
537
- const [a] = e ? e.split("|") : [""], l = he(a), s = /* @__PURE__ */ new Date(), c = (l == null ? void 0 : l.year) ?? s.getFullYear(), i = (l == null ? void 0 : l.month) ?? s.getMonth() + 1, u = q(t), o = (m, d) => {
538
- const h = Me(m, d);
539
- n(`${h.start}|${h.end}`);
536
+ function Tt({ value: e, dateBounds: t, onChange: n }) {
537
+ const [a] = e ? e.split("|") : [""], l = ge(a), s = /* @__PURE__ */ new Date(), c = (l == null ? void 0 : l.year) ?? s.getFullYear(), i = (l == null ? void 0 : l.month) ?? s.getMonth() + 1, m = q(t), o = (h, d) => {
538
+ const f = Oe(h, d);
539
+ n(`${f.start}|${f.end}`);
540
540
  };
541
- return /* @__PURE__ */ p("div", { className: "widget-filter__date-range widget-filter__date-range--month", children: [
541
+ return /* @__PURE__ */ b("div", { className: "widget-filter__date-range widget-filter__date-range--month", children: [
542
542
  /* @__PURE__ */ r(
543
543
  "select",
544
544
  {
545
545
  className: "widget-filter__select",
546
546
  value: i,
547
- onChange: (m) => o(c, parseInt(m.target.value)),
548
- children: fe.map((m, d) => /* @__PURE__ */ r("option", { value: d + 1, children: m }, d + 1))
547
+ onChange: (h) => o(c, parseInt(h.target.value)),
548
+ children: _e.map((h, d) => /* @__PURE__ */ r("option", { value: d + 1, children: h }, d + 1))
549
549
  }
550
550
  ),
551
551
  /* @__PURE__ */ r(
@@ -553,25 +553,25 @@ function $t({ value: e, dateBounds: t, onChange: n }) {
553
553
  {
554
554
  className: "widget-filter__select",
555
555
  value: c,
556
- onChange: (m) => o(parseInt(m.target.value), i),
557
- children: u.map((m) => /* @__PURE__ */ r("option", { value: m, children: m }, m))
556
+ onChange: (h) => o(parseInt(h.target.value), i),
557
+ children: m.map((h) => /* @__PURE__ */ r("option", { value: h, children: h }, h))
558
558
  }
559
559
  )
560
560
  ] });
561
561
  }
562
- function Ct({ value: e, dateBounds: t, onChange: n }) {
563
- const [a] = e ? e.split("|") : [""], l = he(a), s = /* @__PURE__ */ new Date(), c = (l == null ? void 0 : l.year) ?? s.getFullYear(), i = (l == null ? void 0 : l.month) ?? s.getMonth() + 1, u = q(t), o = G(c, i), m = xe(a, c, i) || 1;
564
- return /* @__PURE__ */ p("div", { className: "widget-filter__date-range widget-filter__date-range--week", children: [
562
+ function Mt({ value: e, dateBounds: t, onChange: n }) {
563
+ const [a] = e ? e.split("|") : [""], l = ge(a), s = /* @__PURE__ */ new Date(), c = (l == null ? void 0 : l.year) ?? s.getFullYear(), i = (l == null ? void 0 : l.month) ?? s.getMonth() + 1, m = q(t), o = j(c, i), h = Ee(a, c, i) || 1;
564
+ return /* @__PURE__ */ b("div", { className: "widget-filter__date-range widget-filter__date-range--week", children: [
565
565
  /* @__PURE__ */ r(
566
566
  "select",
567
567
  {
568
568
  className: "widget-filter__select",
569
569
  value: c,
570
570
  onChange: (d) => {
571
- const h = parseInt(d.target.value), v = G(h, i)[0];
571
+ const f = parseInt(d.target.value), v = j(f, i)[0];
572
572
  v && n(`${v.start}|${v.end}`);
573
573
  },
574
- children: u.map((d) => /* @__PURE__ */ r("option", { value: d, children: d }, d))
574
+ children: m.map((d) => /* @__PURE__ */ r("option", { value: d, children: d }, d))
575
575
  }
576
576
  ),
577
577
  /* @__PURE__ */ r(
@@ -580,32 +580,32 @@ function Ct({ value: e, dateBounds: t, onChange: n }) {
580
580
  className: "widget-filter__select",
581
581
  value: i,
582
582
  onChange: (d) => {
583
- const h = parseInt(d.target.value), v = G(c, h)[0];
583
+ const f = parseInt(d.target.value), v = j(c, f)[0];
584
584
  v && n(`${v.start}|${v.end}`);
585
585
  },
586
- children: fe.map((d, h) => /* @__PURE__ */ r("option", { value: h + 1, children: d }, h + 1))
586
+ children: _e.map((d, f) => /* @__PURE__ */ r("option", { value: f + 1, children: d }, f + 1))
587
587
  }
588
588
  ),
589
589
  /* @__PURE__ */ r(
590
590
  "select",
591
591
  {
592
592
  className: "widget-filter__select",
593
- value: m,
593
+ value: h,
594
594
  onChange: (d) => {
595
- const h = o[parseInt(d.target.value) - 1];
596
- h && n(`${h.start}|${h.end}`);
595
+ const f = o[parseInt(d.target.value) - 1];
596
+ f && n(`${f.start}|${f.end}`);
597
597
  },
598
598
  children: o.map((d) => /* @__PURE__ */ r("option", { value: d.index, children: d.label }, d.index))
599
599
  }
600
600
  )
601
601
  ] });
602
602
  }
603
- function At({ config: e, value: t, options: n = [], dateBounds: a, onChange: l }) {
603
+ function xt({ config: e, value: t, options: n = [], dateBounds: a, onChange: l }) {
604
604
  const s = e.filterType || "select", c = e.label || "Filtro", i = e.dateFilterMode || "range";
605
- return /* @__PURE__ */ p("div", { className: "widget-filter", children: [
605
+ return /* @__PURE__ */ b("div", { className: "widget-filter", children: [
606
606
  /* @__PURE__ */ r("label", { className: "widget-filter__label", children: c }),
607
607
  s === "date_range" ? /* @__PURE__ */ r(
608
- ke,
608
+ $e,
609
609
  {
610
610
  mode: i,
611
611
  value: t,
@@ -613,7 +613,7 @@ function At({ config: e, value: t, options: n = [], dateBounds: a, onChange: l }
613
613
  onChange: l
614
614
  }
615
615
  ) : /* @__PURE__ */ r(
616
- xt,
616
+ Et,
617
617
  {
618
618
  value: t,
619
619
  options: n,
@@ -624,10 +624,10 @@ function At({ config: e, value: t, options: n = [], dateBounds: a, onChange: l }
624
624
  )
625
625
  ] });
626
626
  }
627
- function xt({ value: e, options: t, multi: n, searchable: a, onChange: l }) {
627
+ function Et({ value: e, options: t, multi: n, searchable: a, onChange: l }) {
628
628
  if (a)
629
629
  return /* @__PURE__ */ r(
630
- ge,
630
+ pe,
631
631
  {
632
632
  value: e,
633
633
  options: t,
@@ -637,10 +637,10 @@ function xt({ value: e, options: t, multi: n, searchable: a, onChange: l }) {
637
637
  );
638
638
  if (n) {
639
639
  const s = e ? e.split(V) : [], c = (i) => {
640
- const u = s.includes(i) ? s.filter((o) => o !== i) : [...s, i];
641
- l(u.join(V));
640
+ const m = s.includes(i) ? s.filter((o) => o !== i) : [...s, i];
641
+ l(m.join(V));
642
642
  };
643
- return /* @__PURE__ */ p("div", { className: "widget-filter__multi", children: [
643
+ return /* @__PURE__ */ b("div", { className: "widget-filter__multi", children: [
644
644
  s.length > 0 && /* @__PURE__ */ r(
645
645
  "button",
646
646
  {
@@ -650,7 +650,7 @@ function xt({ value: e, options: t, multi: n, searchable: a, onChange: l }) {
650
650
  children: "Limpar filtro"
651
651
  }
652
652
  ),
653
- t.map((i) => /* @__PURE__ */ p("label", { className: "widget-filter__multi-option", children: [
653
+ t.map((i) => /* @__PURE__ */ b("label", { className: "widget-filter__multi-option", children: [
654
654
  /* @__PURE__ */ r(
655
655
  "input",
656
656
  {
@@ -663,7 +663,7 @@ function xt({ value: e, options: t, multi: n, searchable: a, onChange: l }) {
663
663
  ] }, i))
664
664
  ] });
665
665
  }
666
- return /* @__PURE__ */ p(
666
+ return /* @__PURE__ */ b(
667
667
  "select",
668
668
  {
669
669
  className: "widget-filter__select",
@@ -676,15 +676,15 @@ function xt({ value: e, options: t, multi: n, searchable: a, onChange: l }) {
676
676
  }
677
677
  );
678
678
  }
679
- const Ft = {
679
+ const Lt = {
680
680
  currency: "R$",
681
681
  percentage: "%"
682
682
  };
683
- function Mt({ config: e, value: t, onChange: n }) {
684
- const a = e.label || "Variavel", l = e.locked || !1, s = e.variableFormat || "number", c = Ft[s] || "";
685
- return /* @__PURE__ */ p("div", { className: `widget-variable ${l ? "widget-variable--locked" : ""}`, children: [
683
+ function Ot({ config: e, value: t, onChange: n }) {
684
+ const a = e.label || "Variavel", l = e.locked || !1, s = e.variableFormat || "number", c = Lt[s] || "";
685
+ return /* @__PURE__ */ b("div", { className: `widget-variable ${l ? "widget-variable--locked" : ""}`, children: [
686
686
  /* @__PURE__ */ r("label", { className: "widget-variable__label", children: a }),
687
- /* @__PURE__ */ p("div", { className: "widget-variable__input-wrapper", children: [
687
+ /* @__PURE__ */ b("div", { className: "widget-variable__input-wrapper", children: [
688
688
  /* @__PURE__ */ r(
689
689
  "input",
690
690
  {
@@ -701,18 +701,18 @@ function Mt({ config: e, value: t, onChange: n }) {
701
701
  l && /* @__PURE__ */ r("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
702
702
  ] });
703
703
  }
704
- function Tt({ config: e, palette: t, onChange: n }) {
704
+ function Pt({ config: e, palette: t, onChange: n }) {
705
705
  const a = e.label || "Cores", l = e.locked || !1;
706
- return /* @__PURE__ */ p("div", { className: `widget-palette ${l ? "widget-palette--locked" : ""}`, children: [
706
+ return /* @__PURE__ */ b("div", { className: `widget-palette ${l ? "widget-palette--locked" : ""}`, children: [
707
707
  /* @__PURE__ */ r("label", { className: "widget-palette__label", children: a }),
708
- /* @__PURE__ */ r(Ee, { selected: t, onSelect: n, customMode: !0, disabled: l }),
708
+ /* @__PURE__ */ r(Ie, { selected: t, onSelect: n, customMode: !0, disabled: l }),
709
709
  l && /* @__PURE__ */ r("span", { className: "widget-palette__lock-icon", title: "Bloqueado", children: "🔒" })
710
710
  ] });
711
711
  }
712
- const Et = {
712
+ const It = {
713
713
  failed_to_compute: "Não foi possível calcular este widget"
714
714
  };
715
- function Lt({
715
+ function Wt({
716
716
  type: e,
717
717
  computed: t,
718
718
  palette: n,
@@ -721,35 +721,35 @@ function Lt({
721
721
  filterOptions: s,
722
722
  dateBounds: c,
723
723
  onFilterChange: i,
724
- variableValue: u,
724
+ variableValue: m,
725
725
  onVariableChange: o,
726
- onPaletteChange: m
726
+ onPaletteChange: h
727
727
  }) {
728
728
  if (t.error)
729
729
  return /* @__PURE__ */ r(
730
- I,
730
+ P,
731
731
  {
732
732
  name: e.replace("_", "-"),
733
733
  title: a == null ? void 0 : a.label,
734
734
  state: "error",
735
- stateMessage: Et[String(t.error)]
735
+ stateMessage: It[String(t.error)]
736
736
  }
737
737
  );
738
- const d = Le(n);
738
+ const d = We(n);
739
739
  switch (e) {
740
740
  case "kpi_card":
741
- return /* @__PURE__ */ r(it, { data: t, label: a == null ? void 0 : a.label });
741
+ return /* @__PURE__ */ r(ut, { data: t, label: a == null ? void 0 : a.label });
742
742
  case "gauge":
743
- return /* @__PURE__ */ r(dt, { data: t, palette: d, label: a == null ? void 0 : a.label });
743
+ return /* @__PURE__ */ r(ft, { data: t, palette: d, label: a == null ? void 0 : a.label });
744
744
  case "chart":
745
- return /* @__PURE__ */ r(gt, { data: t, palette: d, label: a == null ? void 0 : a.label });
746
- case "composition":
747
745
  return /* @__PURE__ */ r(vt, { data: t, palette: d, label: a == null ? void 0 : a.label });
746
+ case "composition":
747
+ return /* @__PURE__ */ r(St, { data: t, palette: d, label: a == null ? void 0 : a.label });
748
748
  case "table":
749
- return /* @__PURE__ */ r(Nt, { data: t, label: a == null ? void 0 : a.label });
749
+ return /* @__PURE__ */ r($t, { data: t, label: a == null ? void 0 : a.label });
750
750
  case "filter":
751
751
  return a && i ? /* @__PURE__ */ r(
752
- At,
752
+ xt,
753
753
  {
754
754
  config: a,
755
755
  value: l || "",
@@ -759,33 +759,33 @@ function Lt({
759
759
  }
760
760
  ) : null;
761
761
  case "variable": {
762
- const h = a;
763
- return h && o ? /* @__PURE__ */ r(
764
- Mt,
762
+ const f = a;
763
+ return f && o ? /* @__PURE__ */ r(
764
+ Ot,
765
765
  {
766
- config: h,
767
- value: u ?? h.variableValue ?? 0,
766
+ config: f,
767
+ value: m ?? f.variableValue ?? 0,
768
768
  onChange: o
769
769
  }
770
770
  ) : null;
771
771
  }
772
772
  case "color_palette":
773
- return a && m ? /* @__PURE__ */ r(
774
- Tt,
773
+ return a && h ? /* @__PURE__ */ r(
774
+ Pt,
775
775
  {
776
776
  config: a,
777
777
  palette: n,
778
- onChange: m
778
+ onChange: h
779
779
  }
780
780
  ) : null;
781
781
  default:
782
- return /* @__PURE__ */ r(I, { name: "unknown", state: "unconfigured" });
782
+ return /* @__PURE__ */ r(P, { name: "unknown", state: "unconfigured" });
783
783
  }
784
784
  }
785
- const Ot = (e, t) => e.grid.y - t.grid.y || e.grid.x - t.grid.x;
786
- function tr({
785
+ const Dt = Ae(Wt), zt = (e, t) => e.grid.y - t.grid.y || e.grid.x - t.grid.x, Ht = {}, ce = [];
786
+ function ir({
787
787
  token: e,
788
- cellAspect: t = We,
788
+ cellAspect: t = Ge,
789
789
  stackBelow: n,
790
790
  onGeometryChange: a,
791
791
  silenceWarnings: l,
@@ -794,134 +794,143 @@ function tr({
794
794
  const {
795
795
  layout: c,
796
796
  renderData: i,
797
- loading: u,
797
+ loading: m,
798
798
  error: o,
799
- filters: m,
799
+ filters: h,
800
800
  variables: d,
801
- palette: h,
802
- setFilter: _,
801
+ palette: f,
802
+ setFilter: p,
803
803
  setVariable: v,
804
804
  setPalette: S
805
- } = Ze(e), { rootRef: R, gridRef: A, stacked: N } = nt({
805
+ } = rt(e), { rootRef: k, gridRef: A, stacked: y } = it({
806
806
  columns: (c == null ? void 0 : c.gridColumns) ?? 0,
807
807
  cellAspect: t,
808
808
  stackBelow: n,
809
809
  onGeometryChange: a,
810
810
  silenceWarnings: l
811
- }), y = ue(() => {
812
- const f = (c == null ? void 0 : c.widgets) ?? [];
813
- return N ? [...f].sort(Ot) : f;
814
- }, [c == null ? void 0 : c.widgets, N]), k = {
815
- "--dash-gap": `${te}px`,
816
- "--dash-pad": `${De}px`
817
- }, F = ["preview-tab", s].filter(Boolean).join(" ");
818
- let x;
811
+ }), w = Y(() => {
812
+ const u = (c == null ? void 0 : c.widgets) ?? [];
813
+ return y ? [...u].sort(zt) : u;
814
+ }, [c == null ? void 0 : c.widgets, y]), N = Y(() => {
815
+ const u = {};
816
+ for (const R of w)
817
+ u[R.id] = {
818
+ onFilter: (C) => p(R.id, C),
819
+ onVariable: (C) => v(R.id, C)
820
+ };
821
+ return u;
822
+ }, [w, p, v]), T = {
823
+ "--dash-gap": `${ne}px`,
824
+ "--dash-pad": `${je}px`
825
+ }, x = ["preview-tab", s].filter(Boolean).join(" ");
826
+ let _;
819
827
  if (o && !c)
820
- x = /* @__PURE__ */ r("div", { className: "preview-tab__error", children: o });
828
+ _ = /* @__PURE__ */ r("div", { className: "preview-tab__error", children: o });
821
829
  else if (!c)
822
- x = /* @__PURE__ */ r("div", { className: "preview-tab__loading", children: "Carregando dashboard..." });
830
+ _ = /* @__PURE__ */ r("div", { className: "preview-tab__loading", children: "Carregando dashboard..." });
823
831
  else if (c.widgets.length === 0)
824
- x = /* @__PURE__ */ r("div", { className: "preview-tab__empty", children: "Este dashboard nao possui widgets." });
832
+ _ = /* @__PURE__ */ r("div", { className: "preview-tab__empty", children: "Este dashboard nao possui widgets." });
825
833
  else {
826
- const f = (i == null ? void 0 : i.widgets) ?? {}, g = (i == null ? void 0 : i.date_bounds) ?? null, C = {
834
+ const u = (i == null ? void 0 : i.widgets) ?? {}, R = (i == null ? void 0 : i.date_bounds) ?? null, C = {
827
835
  "--dash-cols": c.gridColumns,
828
836
  "--dash-rows": c.gridRows,
829
- ..._e(h)
830
- }, M = ["preview-tab__grid", N && "preview-tab__grid--stacked"].filter(Boolean).join(" ");
831
- x = /* @__PURE__ */ p(de, { children: [
837
+ ...be(f)
838
+ }, F = ["preview-tab__grid", y && "preview-tab__grid--stacked"].filter(Boolean).join(" ");
839
+ _ = /* @__PURE__ */ b(he, { children: [
832
840
  o && !i && /* @__PURE__ */ r("div", { className: "preview-tab__error", children: o }),
833
- i && /* @__PURE__ */ r("div", { className: M, style: C, ref: A, children: y.map((b) => {
834
- const w = Oe.has(b.type), L = f[b.id], P = N ? {
841
+ i && /* @__PURE__ */ r("div", { className: F, style: C, ref: A, children: w.map((g) => {
842
+ var Q, Z;
843
+ const I = De.has(g.type), L = u[g.id], O = y ? {
835
844
  gridColumn: 1,
836
- aspectRatio: `${Pe(b.grid.w, b.grid.h, t)}`,
837
- minHeight: `${Ie(b.grid.h, ze, te, 0)}px`
845
+ aspectRatio: `${He(g.grid.w, g.grid.h, t)}`,
846
+ minHeight: `${ze(g.grid.h, Ye, ne, 0)}px`
838
847
  } : {
839
- gridColumn: `${b.grid.x + 1} / span ${b.grid.w}`,
840
- gridRow: `${b.grid.y + 1} / span ${b.grid.h}`
841
- }, O = b.type === "variable" ? d[b.id] ?? (L == null ? void 0 : L.value) ?? b.config.variableValue ?? 0 : void 0;
848
+ gridColumn: `${g.grid.x + 1} / span ${g.grid.w}`,
849
+ gridRow: `${g.grid.y + 1} / span ${g.grid.h}`
850
+ }, Ce = g.type === "variable" ? d[g.id] ?? (L == null ? void 0 : L.value) ?? g.config.variableValue ?? 0 : void 0;
842
851
  return /* @__PURE__ */ r(
843
852
  "div",
844
853
  {
845
- className: `preview-tab__widget ${w ? "preview-tab__widget--control" : ""}`,
846
- style: P,
847
- children: w || L ? /* @__PURE__ */ r(
848
- Lt,
854
+ className: `preview-tab__widget ${I ? "preview-tab__widget--control" : ""}`,
855
+ style: O,
856
+ children: I || L ? /* @__PURE__ */ r(
857
+ Dt,
849
858
  {
850
- type: b.type,
851
- computed: L || {},
852
- palette: h,
853
- config: b.config,
854
- filterValue: m[b.id] || "",
859
+ type: g.type,
860
+ computed: L || Ht,
861
+ palette: f,
862
+ config: g.config,
863
+ filterValue: h[g.id] || "",
855
864
  filterOptions: (
856
865
  // Estruturais: vem do /layout (cacheavel), nao do /render —
857
866
  // recalcula-los a cada render custaria um DISTINCT por filtro.
858
- b.type === "filter" ? b.config.availableValues ?? [] : []
867
+ g.type === "filter" ? g.config.availableValues ?? ce : ce
859
868
  ),
860
- dateBounds: g,
861
- onFilterChange: (j) => _(b.id, j),
862
- variableValue: O,
863
- onVariableChange: (j) => v(b.id, j),
869
+ dateBounds: R,
870
+ onFilterChange: (Q = N[g.id]) == null ? void 0 : Q.onFilter,
871
+ variableValue: Ce,
872
+ onVariableChange: (Z = N[g.id]) == null ? void 0 : Z.onVariable,
864
873
  onPaletteChange: S
865
874
  }
866
- ) : /* @__PURE__ */ r("div", { className: "preview-tab__widget-loading", children: u ? "Carregando..." : "Sem dados" })
875
+ ) : /* @__PURE__ */ r("div", { className: "preview-tab__widget-loading", children: m ? "Carregando..." : "Sem dados" })
867
876
  },
868
- b.id
877
+ g.id
869
878
  );
870
879
  }) }),
871
- u && i && /* @__PURE__ */ r("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
880
+ m && i && /* @__PURE__ */ r("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
872
881
  ] });
873
882
  }
874
- return /* @__PURE__ */ r("div", { className: F, style: k, ref: R, children: x });
883
+ return /* @__PURE__ */ r("div", { className: x, style: T, ref: k, children: _ });
875
884
  }
876
- function It(e, t) {
885
+ function jt(e, t) {
877
886
  const n = URL.createObjectURL(e), a = document.createElement("a");
878
887
  a.href = n, a.download = t, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(n), 0);
879
888
  }
880
- const Pt = 768, Dt = 879;
881
- function Wt(e) {
889
+ const Gt = 768, Yt = 879;
890
+ function Vt(e) {
882
891
  return Array.from(e.normalize("NFD")).filter((t) => {
883
892
  const n = t.codePointAt(0) ?? 0;
884
- return n < Pt || n > Dt;
893
+ return n < Gt || n > Yt;
885
894
  }).join("");
886
895
  }
887
- function zt(e, t) {
888
- return `${Wt(e).replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() || "documento"}.${t}`;
896
+ function Kt(e, t) {
897
+ return `${Vt(e).replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() || "documento"}.${t}`;
889
898
  }
890
- const Ht = 300;
891
- function jt(e) {
892
- const [t, n] = T(null), [a, l] = T(null), [s, c] = T({}), [i, u] = T(!0), [o, m] = T(null), [d, h] = T(!1), _ = $(), v = $(!1), S = $(null), R = $(!1);
893
- D(() => {
894
- let y = !1;
895
- return v.current = !1, S.current = null, R.current = !1, He(e).then((k) => {
896
- y || n(k);
897
- }).catch((k) => {
898
- y || m(k.message);
899
+ const Ut = 300;
900
+ function qt(e) {
901
+ const [t, n] = M(null), [a, l] = M(null), [s, c] = M({}), [i, m] = M(!0), [o, h] = M(null), [d, f] = M(!1), p = $(), v = $(!1), S = $(null), k = $(!1);
902
+ W(() => {
903
+ let w = !1;
904
+ return v.current = !1, S.current = null, k.current = !1, Ve(e).then((N) => {
905
+ w || n(N);
906
+ }).catch((N) => {
907
+ w || h(N.message);
899
908
  }), () => {
900
- y = !0;
909
+ w = !0;
901
910
  };
902
- }, [e]), D(() => {
911
+ }, [e]), W(() => {
903
912
  if (!t) return;
904
- const y = W(s), k = H(y);
905
- if (k === S.current) return;
906
- _.current && clearTimeout(_.current);
907
- const F = R.current ? Ht : 0;
908
- return _.current = setTimeout(() => {
909
- u(!0), je(e, y).then((x) => {
910
- S.current = k, R.current = !0, l(x), !v.current && x.applied && (v.current = !0, c((f) => {
911
- const g = { ...Ne(x.applied), ...f };
912
- return ye(g, f) ? f : (S.current = H(W(g)), g);
913
- })), m(null);
914
- }).catch((x) => m(x.message)).finally(() => u(!1));
915
- }, F), () => {
916
- _.current && clearTimeout(_.current);
913
+ const w = D(s), N = H(w);
914
+ if (N === S.current) return;
915
+ p.current && clearTimeout(p.current);
916
+ const T = k.current ? Ut : 0;
917
+ return p.current = setTimeout(() => {
918
+ m(!0), Ke(e, w).then((x) => {
919
+ S.current = N, k.current = !0, l(x), !v.current && x.applied && (v.current = !0, c((_) => {
920
+ const u = { ...ke(x.applied), ..._ };
921
+ return Se(u, _) ? _ : (S.current = H(D(u)), u);
922
+ })), h(null);
923
+ }).catch((x) => h(x.message)).finally(() => m(!1));
924
+ }, T), () => {
925
+ p.current && clearTimeout(p.current);
917
926
  };
918
927
  }, [e, t, s]);
919
- const A = E((y, k) => {
920
- c((F) => ({ ...F, [y]: k }));
921
- }, []), N = E(() => {
922
- h(!0), Ge(e, W(s)).then((y) => {
923
- It(y, zt((t == null ? void 0 : t.name) ?? "demonstrativo", "pdf")), m(null);
924
- }).catch((y) => m(y.message)).finally(() => h(!1));
928
+ const A = E((w, N) => {
929
+ c((T) => ({ ...T, [w]: N }));
930
+ }, []), y = E(() => {
931
+ f(!0), Ue(e, D(s)).then((w) => {
932
+ jt(w, Kt((t == null ? void 0 : t.name) ?? "demonstrativo", "pdf")), h(null);
933
+ }).catch((w) => h(w.message)).finally(() => f(!1));
925
934
  }, [e, s, t == null ? void 0 : t.name]);
926
935
  return {
927
936
  layout: t,
@@ -930,22 +939,22 @@ function jt(e) {
930
939
  error: o,
931
940
  filters: s,
932
941
  setFilter: A,
933
- downloadPdf: N,
942
+ downloadPdf: y,
934
943
  downloading: d
935
944
  };
936
945
  }
937
- const Gt = 8, Yt = 14;
938
- function ie(e) {
939
- return { paddingLeft: `${Gt + e * Yt}px` };
946
+ const Bt = 8, Xt = 14;
947
+ function de(e) {
948
+ return { paddingLeft: `${Bt + e * Xt}px` };
940
949
  }
941
- function Vt(e) {
950
+ function Qt(e) {
942
951
  const t = {};
943
952
  return e != null && e.accent && (t["--stmt-accent"] = e.accent), e != null && e.positive && (t["--stmt-positive"] = e.positive), e != null && e.negative && (t["--stmt-negative"] = e.negative), t;
944
953
  }
945
- function oe(e) {
954
+ function ue(e) {
946
955
  return e == null || e === 0 ? "stmt__number" : `stmt__number stmt__number--${e > 0 ? "pos" : "neg"}`;
947
956
  }
948
- const Kt = {
957
+ const Zt = {
949
958
  day: "day",
950
959
  week: "week",
951
960
  month: "month",
@@ -953,13 +962,13 @@ const Kt = {
953
962
  year: "year",
954
963
  total: "month"
955
964
  };
956
- function Ut({ definition: e, value: t, options: n, bounds: a, rangeUnit: l, onChange: s }) {
965
+ function Jt({ definition: e, value: t, options: n, bounds: a, rangeUnit: l, onChange: s }) {
957
966
  if (e.type === "date_range") {
958
967
  const c = e.dateFilterMode ?? "range";
959
- return /* @__PURE__ */ p("div", { className: `stmt__filter stmt__filter--date stmt__filter--${c}`, children: [
968
+ return /* @__PURE__ */ b("div", { className: `stmt__filter stmt__filter--date stmt__filter--${c}`, children: [
960
969
  /* @__PURE__ */ r("span", { className: "stmt__filter-label", children: e.label }),
961
970
  /* @__PURE__ */ r(
962
- ke,
971
+ $e,
963
972
  {
964
973
  mode: c,
965
974
  value: t,
@@ -970,10 +979,10 @@ function Ut({ definition: e, value: t, options: n, bounds: a, rangeUnit: l, onCh
970
979
  )
971
980
  ] });
972
981
  }
973
- return /* @__PURE__ */ p("div", { className: "stmt__filter", children: [
982
+ return /* @__PURE__ */ b("div", { className: "stmt__filter", children: [
974
983
  /* @__PURE__ */ r("span", { className: "stmt__filter-label", children: e.label }),
975
984
  /* @__PURE__ */ r(
976
- ge,
985
+ pe,
977
986
  {
978
987
  value: t,
979
988
  options: n,
@@ -983,7 +992,7 @@ function Ut({ definition: e, value: t, options: n, bounds: a, rangeUnit: l, onCh
983
992
  )
984
993
  ] });
985
994
  }
986
- const qt = 13, ce = {
995
+ const er = 13, me = {
987
996
  day: ["dia", "dias"],
988
997
  week: ["semana", "semanas"],
989
998
  month: ["mês", "meses"],
@@ -991,11 +1000,11 @@ const qt = 13, ce = {
991
1000
  year: ["ano", "anos"],
992
1001
  total: ["período", "períodos"]
993
1002
  };
994
- function Xt(e, t) {
995
- const [n, a] = ce[t] ?? ce.total;
1003
+ function tr(e, t) {
1004
+ const [n, a] = me[t] ?? me.total;
996
1005
  return `Variação sobre ${e} ${e === 1 ? n : a} atrás`;
997
1006
  }
998
- function Bt({
1007
+ function rr({
999
1008
  line: e,
1000
1009
  columnCount: t,
1001
1010
  showTotal: n,
@@ -1006,8 +1015,8 @@ function Bt({
1006
1015
  if (e.type === "separator")
1007
1016
  return /* @__PURE__ */ r("tr", { className: "stmt__row stmt__row--separator", children: /* @__PURE__ */ r("td", { colSpan: t }) });
1008
1017
  if (e.type === "header" && e.formatted.length === 0)
1009
- return /* @__PURE__ */ p("tr", { className: "stmt__row stmt__row--header", children: [
1010
- /* @__PURE__ */ r("th", { scope: "row", style: ie(e.style.indent), children: e.label }),
1018
+ return /* @__PURE__ */ b("tr", { className: "stmt__row stmt__row--header", children: [
1019
+ /* @__PURE__ */ r("th", { scope: "row", style: de(e.style.indent), children: e.label }),
1011
1020
  /* @__PURE__ */ r("td", { colSpan: t - 1 })
1012
1021
  ] });
1013
1022
  const c = [
@@ -1015,14 +1024,14 @@ function Bt({
1015
1024
  `stmt__row--${e.type}`,
1016
1025
  e.style.bold && "stmt__row--bold"
1017
1026
  ].filter(Boolean).join(" ");
1018
- return /* @__PURE__ */ p("tr", { className: c, children: [
1019
- /* @__PURE__ */ r("th", { scope: "row", style: ie(e.style.indent), children: e.label }),
1020
- e.formatted.map((i, u) => {
1027
+ return /* @__PURE__ */ b("tr", { className: c, children: [
1028
+ /* @__PURE__ */ r("th", { scope: "row", style: de(e.style.indent), children: e.label }),
1029
+ e.formatted.map((i, m) => {
1021
1030
  var d;
1022
- const o = e.horizontalAnalysis[u], m = (d = e.comparison) == null ? void 0 : d[u];
1023
- return /* @__PURE__ */ p("td", { className: "stmt__value", children: [
1024
- /* @__PURE__ */ r("span", { className: oe(e.values[u]), children: i }),
1025
- a && e.verticalAnalysis[u] != null && /* @__PURE__ */ r("span", { className: "stmt__aux", title: "Análise vertical", children: z(e.verticalAnalysis[u], "percentage") }),
1031
+ const o = e.horizontalAnalysis[m], h = (d = e.comparison) == null ? void 0 : d[m];
1032
+ return /* @__PURE__ */ b("td", { className: "stmt__value", children: [
1033
+ /* @__PURE__ */ r("span", { className: ue(e.values[m]), children: i }),
1034
+ a && e.verticalAnalysis[m] != null && /* @__PURE__ */ r("span", { className: "stmt__aux", title: "Análise vertical", children: z(e.verticalAnalysis[m], "percentage") }),
1026
1035
  l && o != null && /* @__PURE__ */ r(
1027
1036
  "span",
1028
1037
  {
@@ -1031,59 +1040,59 @@ function Bt({
1031
1040
  children: z(o, "percentage")
1032
1041
  }
1033
1042
  ),
1034
- s && m != null && /* @__PURE__ */ p(
1043
+ s && h != null && /* @__PURE__ */ b(
1035
1044
  "span",
1036
1045
  {
1037
- className: `stmt__aux stmt__aux--${m < 0 ? "down" : "up"}`,
1046
+ className: `stmt__aux stmt__aux--${h < 0 ? "down" : "up"}`,
1038
1047
  title: s,
1039
1048
  children: [
1040
1049
  "vs ",
1041
- z(m, "percentage")
1050
+ z(h, "percentage")
1042
1051
  ]
1043
1052
  }
1044
1053
  )
1045
- ] }, u);
1054
+ ] }, m);
1046
1055
  }),
1047
- n && /* @__PURE__ */ r("td", { className: "stmt__value stmt__value--total", children: /* @__PURE__ */ r("span", { className: oe(e.total), children: e.totalFormatted ?? "-" }) })
1056
+ n && /* @__PURE__ */ r("td", { className: "stmt__value stmt__value--total", children: /* @__PURE__ */ r("span", { className: ue(e.total), children: e.totalFormatted ?? "-" }) })
1048
1057
  ] });
1049
1058
  }
1050
- function rr({ token: e, palette: t, showDownload: n = !0, className: a }) {
1059
+ function or({ token: e, palette: t, showDownload: n = !0, className: a }) {
1051
1060
  const {
1052
1061
  layout: l,
1053
1062
  renderData: s,
1054
1063
  loading: c,
1055
1064
  error: i,
1056
- filters: u,
1065
+ filters: m,
1057
1066
  setFilter: o,
1058
- downloadPdf: m,
1067
+ downloadPdf: h,
1059
1068
  downloading: d
1060
- } = jt(e), [h, _] = T(!1), v = ["stmt", a].filter(Boolean).join(" "), S = {
1061
- ..._e(t),
1062
- ...Vt(l == null ? void 0 : l.colors)
1069
+ } = qt(e), [f, p] = M(!1), v = ["stmt", a].filter(Boolean).join(" "), S = {
1070
+ ...be(t),
1071
+ ...Qt(l == null ? void 0 : l.colors)
1063
1072
  };
1064
- let R;
1073
+ let k;
1065
1074
  if (i && !l)
1066
- R = /* @__PURE__ */ r("div", { className: "stmt__error", children: i });
1075
+ k = /* @__PURE__ */ r("div", { className: "stmt__error", children: i });
1067
1076
  else if (!l)
1068
- R = /* @__PURE__ */ r("div", { className: "stmt__state", children: "Carregando demonstrativo..." });
1077
+ k = /* @__PURE__ */ r("div", { className: "stmt__state", children: "Carregando demonstrativo..." });
1069
1078
  else {
1070
- const A = (s == null ? void 0 : s.dateBounds) ?? l.dateBounds, N = l.periods.showTotal, y = (s == null ? void 0 : s.columns) ?? [], k = (s == null ? void 0 : s.lines) ?? [], F = 1 + y.length + (N ? 1 : 0), x = k.some((w) => w.verticalAnalysis.length > 0), f = k.some((w) => w.horizontalAnalysis.length > 0), g = l.periods.comparisonOffset, C = g ? Xt(g, l.periods.granularity) : void 0, M = qt - (N ? 1 : 0), b = Math.max(0, y.length - M);
1071
- R = /* @__PURE__ */ p(de, { children: [
1072
- /* @__PURE__ */ p("div", { className: "stmt__toolbar", children: [
1073
- l.filters.map((w) => /* @__PURE__ */ r(
1074
- Ut,
1079
+ const A = (s == null ? void 0 : s.dateBounds) ?? l.dateBounds, y = l.periods.showTotal, w = (s == null ? void 0 : s.columns) ?? [], N = (s == null ? void 0 : s.lines) ?? [], T = 1 + w.length + (y ? 1 : 0), x = N.some((g) => g.verticalAnalysis.length > 0), _ = N.some((g) => g.horizontalAnalysis.length > 0), u = l.periods.comparisonOffset, R = u ? tr(u, l.periods.granularity) : void 0, C = er - (y ? 1 : 0), F = Math.max(0, w.length - C);
1080
+ k = /* @__PURE__ */ b(he, { children: [
1081
+ /* @__PURE__ */ b("div", { className: "stmt__toolbar", children: [
1082
+ l.filters.map((g) => /* @__PURE__ */ r(
1083
+ Jt,
1075
1084
  {
1076
- definition: w,
1077
- value: u[w.id] ?? "",
1078
- options: l.filterOptions[w.id] ?? [],
1085
+ definition: g,
1086
+ value: m[g.id] ?? "",
1087
+ options: l.filterOptions[g.id] ?? [],
1079
1088
  bounds: A,
1080
- rangeUnit: Kt[l.periods.granularity] ?? "day",
1081
- onChange: (L) => o(w.id, L)
1089
+ rangeUnit: Zt[l.periods.granularity] ?? "day",
1090
+ onChange: (I) => o(g.id, I)
1082
1091
  },
1083
- w.id
1092
+ g.id
1084
1093
  )),
1085
- /* @__PURE__ */ p("div", { className: "stmt__toolbar-end", children: [
1086
- /* @__PURE__ */ p("span", { className: "stmt__bounds", children: [
1094
+ /* @__PURE__ */ b("div", { className: "stmt__toolbar-end", children: [
1095
+ /* @__PURE__ */ b("span", { className: "stmt__bounds", children: [
1087
1096
  "Base: ",
1088
1097
  A.min,
1089
1098
  " a ",
@@ -1095,11 +1104,11 @@ function rr({ token: e, palette: t, showDownload: n = !0, className: a }) {
1095
1104
  type: "button",
1096
1105
  className: "stmt__download",
1097
1106
  onClick: () => {
1098
- if (b > 0 && !h) {
1099
- _(!0);
1107
+ if (F > 0 && !f) {
1108
+ p(!0);
1100
1109
  return;
1101
1110
  }
1102
- _(!1), m();
1111
+ p(!1), h();
1103
1112
  },
1104
1113
  disabled: d || !s,
1105
1114
  title: "Baixar o documento em PDF",
@@ -1109,49 +1118,49 @@ function rr({ token: e, palette: t, showDownload: n = !0, className: a }) {
1109
1118
  ] })
1110
1119
  ] }),
1111
1120
  i && /* @__PURE__ */ r("div", { className: "stmt__error", children: i }),
1112
- h && b > 0 && /* @__PURE__ */ p("div", { className: "stmt__warning", children: [
1121
+ f && F > 0 && /* @__PURE__ */ b("div", { className: "stmt__warning", children: [
1113
1122
  "O PDF cabe ",
1114
- M,
1123
+ C,
1115
1124
  " períodos e este documento tem ",
1116
- y.length,
1125
+ w.length,
1117
1126
  ": o arquivo sairá com os ",
1118
- M,
1127
+ C,
1119
1128
  " mais recentes",
1120
- N && ", e a coluna de total seguirá cobrindo a janela inteira",
1129
+ y && ", e a coluna de total seguirá cobrindo a janela inteira",
1121
1130
  '. Clique em "Baixar PDF" de novo para gerar assim, ou reduza o período.'
1122
1131
  ] }),
1123
- (s == null ? void 0 : s.truncated) && /* @__PURE__ */ p("div", { className: "stmt__warning", children: [
1132
+ (s == null ? void 0 : s.truncated) && /* @__PURE__ */ b("div", { className: "stmt__warning", children: [
1124
1133
  "A janela pedida excede o limite de colunas: o documento mostra as primeiras ",
1125
- y.length,
1134
+ w.length,
1126
1135
  ". Escolha um período menor ou uma coluna mais larga."
1127
1136
  ] }),
1128
- s ? y.length === 0 ? /* @__PURE__ */ r("div", { className: "stmt__state", children: "Nenhum período na janela selecionada." }) : k.length === 0 ? /* @__PURE__ */ r("div", { className: "stmt__state", children: "Este demonstrativo não possui linhas." }) : /* @__PURE__ */ r("div", { className: "stmt__scroll", children: /* @__PURE__ */ p("table", { className: "stmt__table", children: [
1129
- /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ p("tr", { children: [
1137
+ s ? w.length === 0 ? /* @__PURE__ */ r("div", { className: "stmt__state", children: "Nenhum período na janela selecionada." }) : N.length === 0 ? /* @__PURE__ */ r("div", { className: "stmt__state", children: "Este demonstrativo não possui linhas." }) : /* @__PURE__ */ r("div", { className: "stmt__scroll", children: /* @__PURE__ */ b("table", { className: "stmt__table", children: [
1138
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ b("tr", { children: [
1130
1139
  /* @__PURE__ */ r("th", { className: "stmt__corner", scope: "col", children: s.name }),
1131
- y.map((w) => /* @__PURE__ */ r("th", { scope: "col", title: `${w.start} a ${w.end}`, children: w.label }, w.key)),
1132
- N && /* @__PURE__ */ r("th", { scope: "col", className: "stmt__total-head", children: l.periods.totalLabel })
1140
+ w.map((g) => /* @__PURE__ */ r("th", { scope: "col", title: `${g.start} a ${g.end}`, children: g.label }, g.key)),
1141
+ y && /* @__PURE__ */ r("th", { scope: "col", className: "stmt__total-head", children: l.periods.totalLabel })
1133
1142
  ] }) }),
1134
- /* @__PURE__ */ r("tbody", { children: k.map((w) => /* @__PURE__ */ r(
1135
- Bt,
1143
+ /* @__PURE__ */ r("tbody", { children: N.map((g) => /* @__PURE__ */ r(
1144
+ rr,
1136
1145
  {
1137
- line: w,
1138
- columnCount: F,
1139
- showTotal: N,
1146
+ line: g,
1147
+ columnCount: T,
1148
+ showTotal: y,
1140
1149
  showVertical: x,
1141
- showHorizontal: f,
1142
- comparisonLabel: C
1150
+ showHorizontal: _,
1151
+ comparisonLabel: R
1143
1152
  },
1144
- w.id
1153
+ g.id
1145
1154
  )) })
1146
1155
  ] }) }) : /* @__PURE__ */ r("div", { className: "stmt__state", children: "Calculando..." }),
1147
1156
  c && s && /* @__PURE__ */ r("div", { className: "stmt__recalculating", children: "Atualizando..." })
1148
1157
  ] });
1149
1158
  }
1150
- return /* @__PURE__ */ r("div", { className: v, style: S, children: R });
1159
+ return /* @__PURE__ */ r("div", { className: v, style: S, children: k });
1151
1160
  }
1152
1161
  export {
1153
- lr as ApiError,
1154
- tr as Dashboard,
1155
- rr as Statement
1162
+ ur as ApiError,
1163
+ ir as Dashboard,
1164
+ or as Statement
1156
1165
  };
1157
1166
  //# sourceMappingURL=index.js.map